Start and cancel a run
The exact request AMC sends to start a run, what to return, where inputs come from, and how cancel works.
Before you startAn endpoint that serves `POST /runs`. See [Bring your own agent](/developers/byo-overview/).View as Markdown
The start request
POST /runs
{
"orchestratorWorkflowId": "invoices.contoso.com/amc",
"versionId": null,
"inputs": {
"invoiceId": "INV-1042",
"ownerEmail": "sam@contoso.com"
},
"idempotencyKey": null
}| Field | Meaning |
|---|---|
orchestratorWorkflowId | The resource id AMC derived at registration (path segments, or host and path). Use it if one endpoint serves several workflows; otherwise ignore it. |
versionId | A version id when the caller picked one, else null. Triggers always send null. |
inputs | A flat map of string to string. Every value is a string: numbers and booleans arrive as text, and webhook objects or arrays arrive as JSON text. See Declare run parameters. |
idempotencyKey | Set on scheduled fires so a retried fire doesn't start a second run. If you see a key you've already started a run for, return that run instead of starting another. |
The response
200 OK
{
"orchestratorRunId": "run_5f2c0e8a41b94c55",
"orchestratorWorkflowId": "invoices.contoso.com/amc",
"status": "running",
"startedAt": "2026-10-17T09:30:00.120000+00:00",
"finishedAt": null
}- Return as soon as the run is accepted, and do the work in the background. Don't hold the request open for the length of the run.
orchestratorRunIdis the id AMC uses on every later call. Keep it unique for the life of the endpoint.startedAtbecomes the run's start time in AMC.- Any non-terminal
status(running,pending,queued) is stored asrunning, and the first poll corrects it. A terminal status (completed,failed,cancelled) creates the run already finished, and AMC never polls it again, so it records no tokens, cost, outcome or failure reason for that run. Return a non-terminal status and let the first poll report the ending, even for an agent that finishes synchronously. - A non-
2xxresponse, or a body AMC can't parse, fails the start: the caller gets502and no run is created.
Where inputs come from
| Trigger | What arrives in `inputs` |
|---|---|
| Run now | The values the person entered. Blank fields are left out. |
| Webhook, input contract declared | Every top-level field of the JSON body, as text, whether or not you declared it. Only the reserved fields runName and assigneeId are taken by AMC and never forwarded. |
| Webhook, no input contract | One input, payload, holding the raw body. Reserved fields are stripped from it. |
| Schedule | No inputs, unless the workflow has default inputs set. A resource with required parameters can't be scheduled without them. |
Before any of these reaches you, AMC validates the inputs against your input contract. A start that fails validation never calls your endpoint.
Cancel
When someone selects Cancel run, AMC sends POST /runs/{id}/cancel with an empty JSON body ({}) and reads a run back.
| You return | AMC does |
|---|---|
status: "cancelled" (or canceled) | Ends the run as cancelled, reads its final tokens, withdraws any open intervention. |
completed or failed | Treats the cancel as a no-op: the run had already ended, and the next poll records how. |
| A non-terminal status | Records the request and keeps polling until you report the ending. Use this for a cancel that takes time. |
- A run waiting on a person must still be cancellable.
- Return
404for a run id you don't know. cancelledmeans a person asked for it. When your agent stops a run itself, reportfailedwith a reason.
Related
Last updated 2026-10-21