Sheaf.us
SheafDocsAPIRun a workflow

Run a workflow

One call creates the case, receives the packet and starts the workflow's run.

POST /workflows/{workflowId}/runs

It does what a person does in the app, with a workflow attached at the gate. Sheaf records the call as consent to spend on the run.

Fields

Send them as multipart/form-data.

FieldRequiredMeaning
filesyes, for a new caseOne or more PDFs, images or text files (HTML, markdown, plain text). Up to 100 files of any type: a PDF or an image up to 100 MB, a text file up to 10 MB. Repeat the field for several files.
applicantyes, for a new caseThe applicant's name.
expectedDocListyes, for a new caseexpectedDocListId for its active version, or expectedDocListId/3 for a specific one.
applicationIdinstead of the two aboveRun on an existing case. Files are optional then.
decidedBynoWho consents to the run. Defaults to the key's name.

Versions

The workflow's active version runs. ?version=2 pins version 2. A missing version returns 404. A draft returns 409. Both fail before anything is written. Publishing a new version changes what callers get, not what they call.

What the run does

The workflow's steps decide. GET /workflows/{workflowId}/{version} returns them.

StepWhat it gives
ParseEvery page's text and layout. Every workflow has it.
ClassifyThe documents, each with a suggested requirement. The workflow matches what the run suggests.
ExtractField values for each matched document, read against its document schema.
IntelOne brief for each template the step names.

A step the workflow does not have does not run. The starter workflow standard-intake has Parse, Classify and Extract; in an organization made before October 2026 it has Parse and Classify.

A step can pin an option, such as the Parse step's engine or its page annotation switch. What it leaves on Default takes the system default, which GET /models/options marks for each stage. The Classify step's Detect sub-documents switch, on by default, finds where a file holds several documents and recommends a split.

The answer

It returns 201 with the case. run.state is previewing when the workflow begins with a preview, and running when it does not. Next, read the results.

The case records its workflow in workflow, for example { "workflowId": "standard-intake", "version": 1 }. A later run without a workflow keeps it.

An existing case

With applicationId, the run reads everything in the case that no run has read yet. Add files to upload more first.

When the last run stopped after its parse, the same call with no new file finishes it: Classify and the steps after it run, and no page is read again.

If nothing is new and nothing is left to finish, it returns 409 and says so.

A run with its own options

The door takes no options: a run follows its workflow. To choose an option for one run, make the three calls the app makes:

  1. POST /applications creates the case.
  2. POST /applications/{id}/files adds the files.
  3. POST /applications/{id}/run/gate starts the run:
{
  "decision": "confirmed",
  "decidedBy": "Jane Doe's agent",
  "mode": "parse",
  "workflow": { "workflowId": "standard-intake", "version": 1 },
  "plan": { "ocr_post_processing_grounding": "grounding-none" },
  "settings": { "pageAnnotation": true }
}
FieldMeaning
decisionconfirmed. A flagged file set is refused with 409, as at the door.
decidedByWho consents to the run.
modeparse starts the run now. A workflow needs it.
workflowThe workflow and the version to run.
planA stage and the option to use for this run, both from GET /models/options, and detectSubDocuments: false to skip sub-document detection. It wins over what the workflow pins.
settingspageAnnotation and figureAnnotation. They win over the workflow's.

It returns the case, as the door does.

Red flags

Pre-flight can flag a file, for example a scan too coarse to read or a duplicated page. Sheaf does not override a flag on your behalf. It returns 409:

{
  "error": "The file set has 1 red flag(s) — use \"bypassed\" (Process anyway) to override them",
  "applicationId": "Xjs0t8SWt_",
  "flags": [ { "fileId": "sf-3kQ9", "page": 1, "code": "low_dpi", "note": "p.1 embedded image ~96 DPI — below 150" } ]
}

The case exists with its files and waits at the gate for a person. Do not send the packet again.

Other refusals

StatusWhen
400No files, a missing applicant or expectedDocList, a file that is not a PDF, an image or a text file, a PDF that needs a password to open, or a file over a limit.
403A sandbox with no email has had its one run. emailRequired is true, and the case waits at the gate with its files.
404Unknown workflow, version, list or case.
409A workflow is already active on the case ("Parse → Classify workflow active"), or there is nothing new to read and nothing left to finish.
502The analyzer could not be reached. The case is put back at the gate with its files, and applicationId is in the answer.

This page as markdown · llms.txt · API contract