Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

1.1 KB
Raw Blame
import { createAction, Property } from '@activepieces/pieces-framework';
import { HttpMethod } from '@activepieces/pieces-common';
import { hystructAuth } from '../auth';
import { hystructApiCall } from '../common';

export const createJob = createAction({
  auth: hystructAuth,
  name: 'create_job',
  displayName: 'Create Job',
  description: 'Create and queue a new job to run for a workflow',
  audience: 'both',
  aiMetadata: { description: 'Queues a new job to execute a Hystruct document-structuring/data-extraction workflow, identified by its workflow ID. Use this to kick off a workflow run on demand. Not idempotent: each call enqueues a separate job run.', idempotent: false },
  props: {
    workflowId: Property.ShortText({
      displayName: 'Workflow ID',
      description: 'The ID of the workflow to run',
      required: true,
    }),
  },
  async run(context) {
    const { workflowId } = context.propsValue;

    const response = await hystructApiCall<{ message: string }>({
      apiKey: context.auth.secret_text,
      method: HttpMethod.POST,
      endpoint: `/v1/workflows/${workflowId}/queue`,
    });

    return response;
  },
});