Skip to main content
POST
/
public
/
v1
/
task-runs
/
{runId}
/
cancel
Cancel task run
curl --request POST \
  --url https://api.komos.ai/public/v1/task-runs/{runId}/cancel \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "reason": "User requested cancellation"
}'
{
  "run": {
    "id": "9c77d908-7bf4-4e7f-9a20-2c5e7fdf2e94",
    "taskId": "79c6b1aa-24d1-45b3-8c94-9a2e2a2f55bc",
    "status": "PENDING",
    "triggerType": "api",
    "timestamps": {
      "createdAt": "2025-10-14T18:21:52.123Z",
      "startedAt": null,
      "finishedAt": null
    },
    "progress": null,
    "inputs": {
      "url": "https://example.com/orders/48219",
      "runHeadless": true
    },
    "outputs": {},
    "logsUrl": "https://api.komos.ai/public/v1/task-runs/9c77d908-7bf4-4e7f-9a20-2c5e7fdf2e94/logs",
    "error": null,
    "cancelReason": null
  }
}
Submit a cancellation request for a run that is still PENDING or RUNNING. You can optionally include a reason to help with audit trails. The response returns the current run payload; subsequent polling on GET /public/v1/task-runs/{runId} reflects the final status.

Request

Path parameters

  • runId — UUID of the run to cancel.

Body fields

  • reason (string, optional) — Free-form text recorded on the run for auditing.

Example

curl -X POST \
  https://api.komos.ai/public/v1/task-runs/9c77d908-7bf4-4e7f-9a20-2c5e7fdf2e94/cancel \
  -H 'Authorization: Bearer sk_live_example' \
  -H 'Content-Type: application/json' \
  -d '{ "reason": "User cancelled via dashboard" }'

Responses

  • 202 Accepted — Cancellation was accepted. The response includes the run payload reflecting the latest state. Runs that already reached a terminal status are returned unchanged.
  • 400 Bad Request — Invalid run ID.
  • 401 Unauthorized — Missing or malformed API key.
  • 404 Not Found — The run does not belong to the authenticated organization.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

runId
string<uuid>
required

UUID of the run to cancel.

Body

application/json
reason
string

Optional cancellation reason recorded for auditing.

Maximum length: 1024

Response

Cancellation accepted.

run
object
required