> ## Documentation Index
> Fetch the complete documentation index at: https://extend-eb-casing.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Run Workflow

> Once a workflow has been created on the Extend Platform, this endpoint can be used to send file(s) to be run.

### Body

<ParamField body="workflowId" type="string" required>
  The ID of the workflow that files will be run through. This ID can be fetched
  from viewing the workflow on the Extend platform.
</ParamField>

<ResponseField name="files" type="File[]">
  An array of Files. Either files or rawTexts must be provided.

  <ResponseField name="File" type="File">
    <Expandable title="properties" defaultOpen>
      <ResponseField name="fileName" type="string" required>
        The name of the file.
      </ResponseField>

      <ResponseField name="fileUrl" type="string" required>
        A publicly accessible URL for the file.
      </ResponseField>
    </Expandable>
  </ResponseField>
</ResponseField>

<ParamField body="rawTexts" type="string[]">
  An array of raw strings. Can be used in place of files when passing raw data.
  The raw data will be converted to .txt files and run through the workflow. If
  the data follows a specific format, it is recommended to use the files
  parameter instead. Either files or rawTexts must be provided.
</ParamField>

<ParamField body="name" type="string">
  An optional name that can be assigned to a specific WorkflowRun.
</ParamField>

<ParamField body="version" type="string">
  An optional version of the workflow that files will be run through. This
  number can be found when viewing the workflow on the Extend platform. When a
  version number is not supplied, the most recent version of the workflow will
  be used. To run the "draft" version of a workflow, use "draft" as the version.
</ParamField>

<ParamField body="metadata" type="any">
  An optional object that can be passed in to identify the WorkflowRun. It will be returned in the response and webhooks.
</ParamField>

### Response

<ResponseField name="success" type="boolean">
  A true or false value for whether the workflow run was created successfully or not.
</ResponseField>

<ResponseField name="workflowRuns" type="WorkflowRun[]">
  An array of WorkflowRun objects, with each WorkflowRun corresponding to a
  single File that was passed in.

  <ResponseField name="WorkflowRun" type="object">
    <Expandable title="properties" defaultOpen>
      <ResponseField name="object" type="string">
        The type of response, in this case it will always be "workflow\_run".
      </ResponseField>

      <ResponseField name="id" type="string">
        An ID corresponding to a specific File x Workflow combination representing the specific WorkflowRun for a File.
      </ResponseField>

      <ResponseField name="status" type="string">
        The status of a WorkflowRun. This will always be "PENDING" as the WorkflowRun has just started.
      </ResponseField>

      <ResponseField name="metadata" type="any">
        The metadata that was passed in when running the Workflow.
      </ResponseField>

      <ResponseField name="initialRunAt" type="string">
        The time (in UTC) at which the workflow was started.
      </ResponseField>

      <ResponseField name="outputs" type="array">
        An array of outputs that were generated by the WorkflowRun. This will be empty as the WorkflowRun has just started.
      </ResponseField>

      <ResponseField name="workflow" type="object">
        The details about the Workflow that was used in this WorkflowRun.

        <Expandable title="properties" defaultOpen>
          <ResponseField name="id" type="string">
            The Workflow ID that can be fetched from the Extend Platform.
          </ResponseField>

          <ResponseField name="name" type="string">
            The name of the Workflow.
          </ResponseField>

          <ResponseField name="version" type="string">
            The version of the Workflow.
          </ResponseField>
        </Expandable>
      </ResponseField>
    </Expandable>
  </ResponseField>
</ResponseField>

<RequestExample>
  ```bash Example Request
  curl --location --request POST 'https://api-prod.extend.app/v1/workflow_runs' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer <API_TOKEN>' \
  --data '{
      "workflowId": "workflow_1234",
      "version": "1",
      "files": [{
        "fileName":"example_file_name",
        "fileUrl":"https://test.s3.amazonaws.com/example+file+name.pdf"
      }],
      "name": "test_workflow",
      "metadata": {
        "internal_id": "id_1234"
      }
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json Example Response
  {
    "success": true,
    "workflowRuns": [
      {
        "object": "workflow_run",
        "id": "workflow_run_1234",
        "status": "PENDING",
        "metadata": {
          "internal_id": "id_1234"
        },
        "initialRunAt": "2023-01-01T09:41:00.000Z",
        "outputs": [],
        "workflow": {
          "object": "workflow",
          "id": "workflow_1234",
          "name": "test_workflow",
          "version": "1"
        }
      }
    ]
  }
  ```
</ResponseExample>
