---
updatedAt: 2026-06-08T00:19:47.000Z
agentTools:
  projectIndex: https://docs.docupipe.ai/llms.txt
---

# Run a Workflow

Run a workflow on one or more documents. This call returns immediately with a `jobId`; poll `GET /job/{job_id}` until the job status is `completed`, then read the results off the job's `outputs` field. For production integrations we recommend [webhooks](https://docs.docupipe.ai/reference/webhooks) instead of polling.

## Providing documents

Each entry in `inputs` supplies exactly one document, in one of two ways:

1. `documentId` - reference a document already uploaded and processed in your workspace.
2. `document` - upload a new file inline (base64 `file` or `url`). The file is parsed first and the workflow runs once parsing completes. The optional parameters `pages`, `dataset`, `metadata`, `parseVersion`, and `processingMethod` apply to inline uploads only and are rejected when combined with `documentId`.

## Matching documents to workflow inputs

A workflow declares one or more named inputs. Each input expects either a **single document** (exactly one) or a **document stack** (one or more). How you label your `inputs` entries depends on how many inputs the workflow has:

- **One input** (whether a single document or a stack): `inputLabel` is optional. Every entry you submit is automatically assigned to that input. To fill a stack, just send multiple entries.
- **Multiple inputs**: every entry **must** set `inputLabel` to the exact label of the workflow input it belongs to. Labels are case-sensitive. Repeat the same label across entries to add several documents to a stack input.

Every workflow input must receive at least one document, and single-document inputs accept exactly one. Requests that omit a required `inputLabel`, use an unknown label, or leave an input empty are rejected with a `400` error that lists the labels the workflow expects.

### Example: workflow with one input

```json
{"inputs": [{"documentId": "abc123"}]}
```

### Example: one stack input, three documents

```json
{"inputs": [
  {"documentId": "abc123"},
  {"documentId": "def456"},
  {"document": {"url": "https://example.com/invoice.pdf"}}
]}
```

### Example: multiple inputs, labels required

```json
{"inputs": [
  {"inputLabel": "contract", "documentId": "abc123"},
  {"inputLabel": "invoices", "documentId": "def456"},
  {"inputLabel": "invoices", "documentId": "ghi789"}
]}
```

## Reading the results

When the job completes, each element of the job's `outputs` is typed by `outputType`. For extraction outputs, `extraction.items` holds one item per document with its `documentId`, `standardizationId`, and inline `data`. When a result is too large to inline, `data` is null; fetch it with `GET /standardization/{standardization_id}`. Redaction outputs use `redaction.items`; each item includes its `redactionId` and authenticated `downloadUrl` for the flattened redacted PDF.

# OpenAPI definition

````json
{
  "openapi": "3.1.0",
  "info": {
    "title": "DocuPipe",
    "version": "1.0"
  },
  "paths": {
    "/v2/workflow/{workflow_id}/run": {
      "post": {
        "summary": "Run a Workflow",
        "operationId": "run_workflow_v2",
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "workflow_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Workflow Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WorkflowV2RunRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowV2RunResponse"
                }
              }
            }
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Bad Request"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Not Found"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal Server Error"
          }
        },
        "description": "Run a workflow on one or more documents. This call returns immediately with a `jobId`; poll `GET /job/{job_id}` until the job status is `completed`, then read the results off the job's `outputs` field. For production integrations we recommend [webhooks](https://docs.docupipe.ai/reference/webhooks) instead of polling.\n\n## Providing documents\n\nEach entry in `inputs` supplies exactly one document, in one of two ways:\n\n1. `documentId` - reference a document already uploaded and processed in your workspace.\n2. `document` - upload a new file inline (base64 `file` or `url`). The file is parsed first and the workflow runs once parsing completes. The optional parameters `pages`, `dataset`, `metadata`, `parseVersion`, and `processingMethod` apply to inline uploads only and are rejected when combined with `documentId`.\n\n## Matching documents to workflow inputs\n\nA workflow declares one or more named inputs. Each input expects either a **single document** (exactly one) or a **document stack** (one or more). How you label your `inputs` entries depends on how many inputs the workflow has:\n\n- **One input** (whether a single document or a stack): `inputLabel` is optional. Every entry you submit is automatically assigned to that input. To fill a stack, just send multiple entries.\n- **Multiple inputs**: every entry **must** set `inputLabel` to the exact label of the workflow input it belongs to. Labels are case-sensitive. Repeat the same label across entries to add several documents to a stack input.\n\nEvery workflow input must receive at least one document, and single-document inputs accept exactly one. Requests that omit a required `inputLabel`, use an unknown label, or leave an input empty are rejected with a `400` error that lists the labels the workflow expects.\n\n### Example: workflow with one input\n\n```json\n{\"inputs\": [{\"documentId\": \"abc123\"}]}\n```\n\n### Example: one stack input, three documents\n\n```json\n{\"inputs\": [\n  {\"documentId\": \"abc123\"},\n  {\"documentId\": \"def456\"},\n  {\"document\": {\"url\": \"https://example.com/invoice.pdf\"}}\n]}\n```\n\n### Example: multiple inputs, labels required\n\n```json\n{\"inputs\": [\n  {\"inputLabel\": \"contract\", \"documentId\": \"abc123\"},\n  {\"inputLabel\": \"invoices\", \"documentId\": \"def456\"},\n  {\"inputLabel\": \"invoices\", \"documentId\": \"ghi789\"}\n]}\n```\n\n## Reading the results\n\nWhen the job completes, each element of the job's `outputs` is typed by `outputType`. For extraction outputs, `extraction.items` holds one item per document with its `documentId`, `standardizationId`, and inline `data`. When a result is too large to inline, `data` is null; fetch it with `GET /standardization/{standardization_id}`. Redaction outputs use `redaction.items`; each item includes its `redactionId` and authenticated `downloadUrl` for the flattened redacted PDF.",
        "tags": [
          "Workflow"
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "ErrorResponse": {
        "properties": {
          "detail": {
            "type": "string",
            "title": "Detail",
            "description": "Details about the error"
          }
        },
        "type": "object",
        "required": [
          "detail"
        ],
        "title": "ErrorResponse"
      },
      "File": {
        "properties": {
          "contents": {
            "type": "string",
            "contentMediaType": "application/octet-stream",
            "title": "File Contents",
            "description": "Binary string representing the content of the file in base64 encoding."
          }
        },
        "type": "object",
        "required": [
          "contents"
        ],
        "title": "File"
      },
      "FileExtension": {
        "type": "string",
        "enum": [
          "pdf",
          "png",
          "jpeg",
          "webp",
          "tiff",
          "jp2",
          "txt",
          "json",
          "xml",
          "html",
          "doc",
          "docx",
          "csv",
          "xlsx",
          "xls",
          "eml"
        ],
        "title": "FileExtension"
      },
      "FileType": {
        "type": "string",
        "enum": [
          "pdf",
          "image",
          "text",
          "json",
          "html",
          "word",
          "table"
        ],
        "title": "FileType"
      },
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
          }
        },
        "type": "object",
        "title": "HTTPValidationError"
      },
      "InputDocument": {
        "properties": {
          "file": {
            "$ref": "#/components/schemas/File",
            "description": "File object containing the input document in base64 encoding."
          },
          "url": {
            "type": "string",
            "maxLength": 2083,
            "minLength": 1,
            "format": "uri",
            "title": "Document URL",
            "description": "URL pointing to the location of the input file.",
            "examples": [
              "https://example.com/document.pdf"
            ]
          },
          "filename": {
            "type": "string",
            "title": "Filename",
            "description": "Name of the file, not including the file extension."
          },
          "fileExtension": {
            "$ref": "#/components/schemas/FileExtension",
            "title": "File Extension",
            "description": "Extension of the file."
          },
          "fileType": {
            "$ref": "#/components/schemas/FileType",
            "title": "File Type",
            "description": "Type of the file. If not provided, it will be determined from the file contents."
          }
        },
        "type": "object",
        "title": "Input Document"
      },
      "ProcessingMethod": {
        "type": "string",
        "enum": [
          "asImage",
          "removeWatermark"
        ],
        "title": "ProcessingMethod"
      },
      "ProcessingStatus": {
        "type": "string",
        "enum": [
          "processing",
          "completed",
          "error"
        ],
        "title": "ProcessingStatus"
      },
      "ValidationError": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "type": "array",
            "title": "Location"
          },
          "msg": {
            "type": "string",
            "title": "Message"
          },
          "type": {
            "type": "string",
            "title": "Error Type"
          },
          "input": {
            "title": "Input"
          },
          "ctx": {
            "type": "object",
            "title": "Context"
          }
        },
        "type": "object",
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError"
      },
      "WorkflowV2RunInput": {
        "properties": {
          "inputLabel": {
            "type": "string",
            "title": "Inputlabel",
            "description": "Label of the workflow input this document belongs to (case-sensitive). Required when the workflow has multiple inputs; optional when it has exactly one (single document or stack), where every entry is assigned to that input. Repeat the same label across entries to add several documents to a stack input."
          },
          "documentId": {
            "type": "string",
            "title": "Documentid",
            "description": "Reference an existing, fully processed workspace document. Provide exactly one of 'documentId' or 'document'."
          },
          "document": {
            "$ref": "#/components/schemas/InputDocument",
            "title": "Document",
            "description": "Or upload a new document inline using url or base64 file; it is parsed before the workflow runs."
          },
          "pages": {
            "items": {
              "type": "integer"
            },
            "type": "array",
            "title": "Pages",
            "description": "Zero-indexed pages. With an inline 'document': the pages to parse. With a 'documentId': the pages of that document the run's Standardize steps read, in place of their page range (other steps still see the whole document). Null/empty means all pages."
          },
          "dataset": {
            "type": "string",
            "title": "Dataset",
            "description": "Inline-upload only. Dataset to assign the uploaded document to."
          },
          "metadata": {
            "additionalProperties": true,
            "type": "object",
            "title": "Metadata",
            "description": "Inline-upload only. Optional metadata to associate with the document."
          },
          "parseVersion": {
            "type": "number",
            "title": "Parseversion",
            "description": "Inline-upload only. Parsing version."
          },
          "processingMethod": {
            "$ref": "#/components/schemas/ProcessingMethod",
            "title": "Processingmethod",
            "description": "Inline-upload only. Processing method."
          }
        },
        "type": "object",
        "title": "WorkflowV2RunInput"
      },
      "WorkflowV2RunInputResult": {
        "properties": {
          "inputLabel": {
            "type": "string",
            "title": "Inputlabel",
            "description": "Input node label this document was bound to."
          },
          "documentId": {
            "type": "string",
            "title": "Documentid",
            "description": "Resolved document id."
          },
          "uploadJobId": {
            "type": "string",
            "title": "Uploadjobid",
            "description": "Parse job id for a fresh upload; null when referencing an existing doc."
          },
          "status": {
            "$ref": "#/components/schemas/ProcessingStatus",
            "description": "Per-input processing status."
          }
        },
        "type": "object",
        "required": [
          "inputLabel",
          "documentId",
          "status"
        ],
        "title": "WorkflowV2RunInputResult"
      },
      "WorkflowV2RunRequest": {
        "properties": {
          "inputs": {
            "items": {
              "$ref": "#/components/schemas/WorkflowV2RunInput"
            },
            "type": "array",
            "title": "Inputs",
            "description": "One entry per document. Every workflow input must receive at least one document; single-document inputs accept exactly one, stack inputs accept one or more (repeat the inputLabel). When the workflow has a single input, inputLabel can be omitted and all entries are assigned to it."
          },
          "timeout": {
            "type": "integer",
            "title": "Timeout",
            "description": "Timeout in seconds for this workflow run."
          }
        },
        "type": "object",
        "required": [
          "inputs"
        ],
        "title": "WorkflowV2RunRequest"
      },
      "WorkflowV2RunResponse": {
        "properties": {
          "workflowId": {
            "type": "string",
            "title": "Workflowid",
            "description": "Workflow that was run."
          },
          "jobId": {
            "type": "string",
            "title": "Jobid",
            "description": "WorkflowV2Job id for this run. Poll GET /job/{job_id}."
          },
          "status": {
            "$ref": "#/components/schemas/ProcessingStatus",
            "description": "Overall run status."
          },
          "inputs": {
            "items": {
              "$ref": "#/components/schemas/WorkflowV2RunInputResult"
            },
            "type": "array",
            "title": "Inputs",
            "description": "Per-input resolution."
          }
        },
        "type": "object",
        "required": [
          "workflowId",
          "jobId",
          "status",
          "inputs"
        ],
        "title": "WorkflowV2RunResponse"
      }
    },
    "securitySchemes": {
      "APIKeyHeader": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      },
      "HTTPBearer": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  },
  "servers": [
    {
      "url": "https://app.docupipe.ai"
    }
  ]
}
````