TaskRuns

Cancel a task run

Changed on

Stop a run that is pending, running, or waiting for input, and cancel the image, audio and video generations it still has in flight (they are billed only when they finish). Stopping is asynchronous, like the agent runtime it asks: a run mid-step finishes that step first. The response is the run with cancel_requested_at set; it settles as cancelled moments later (poll GET /task_runs/{id}, or listen for task_run.cancelled). A run that was not mid-step is cancelled at once. Cancelled runs do not count as failures. Repeating the call returns the run unchanged. 409 run_not_active if the run has already settled.

post/task_runs/{id}/cancel

Request

  • Base URL
    https://api.crevio.co/v1
  • Auth
    API key in header Authorization

Path parameters

id, string required

Task run id (trun_...)

Headers

Idempotency-Key, string

Makes this write safe to retry: a repeat with the same key replays the first response instead of creating a second resource. Scoped to the account, remembered for 24 hours; reusing a key with a different payload is an error.

Response

The cancelled run.

AiTaskRun required
id, string required
object, string required
task_id, string required
task_name, string required
chat_id, string nullable required

The run's own conversation (aichat_...): what it read, called and said. Read it with search_chats.

status, 'pending' | 'running' | 'completed' | 'failed' | 'needs_input' | 'unknown' | 'skipped' | 'cancelled' required
summary, string nullable required
error_message, string nullable required
test_run, boolean required
input_tokens, integer required
output_tokens, integer required
credits_consumed, integer required
cancel_requested_at, string nullable required

When a stop was requested. The run stays running until it reaches its next step, then settles as cancelled.

tool_calls_count, integer required
duration_ms, integer nullable required
started_at, string date-time nullable required
completed_at, string date-time nullable required
created_at, string date-time required
updated_at, string date-time required
skip_reason, 'condition' | 'no_paid_plan_or_credits' | 'no_recent_activity' | 'no_task_activity' | 'no_personal_sources' | 'rate_limited' | 'misfire' | 'task_busy' | 'account_at_capacity' | 'member_credit_cap' | 'agent_archived' | 'null' nullable required
skip_count, integer required
delivery_status, 'delivered' | 'not_delivered' | 'not_requested' | 'unknown' required
completion, 'verified' | 'recorded' | 'recovered' | 'null' nullable required

How the agent closed a completed run: verified (it re-checked the result), recorded (it reported without re-checking), or recovered (it never reported; summary is its last message). Null unless an agent turn completed the run.

trigger_source, 'scheduled' | 'event' | 'manual' required
trigger_event, object nullable required

The event that started this run, {type, data}, exactly as the run received it; data matches the event's webhook payload. Events that waited while the task was busy start one run together as {type, events: [{type, data}, ...]}, oldest first. Null for a run no event started. POST /task_runs/{id}/replay runs the task again on it.

replay_of, string nullable required

The run (trun_...) whose event this run replays. Null unless started by POST /task_runs/{id}/replay.

captured_deliveries, unknown[] required
result, string nullable

The agent's final reply, once the run settled. Present on single-run responses, not in lists.

json, unknown
json_error, string nullable

Why the reply did not parse or validate against response_format.

artifacts, Artifact[]
pending_approval_ids, unknown[] required

Changes

    • warning

      added the new idempotency_error enum value to the error/type response property for the response status

    • warning

      added the new idempotency_error enum value to the error/type response property for the response status

    • warning

      added the new idempotency_error enum value to the error/type response property for the response status

    5 more changes in this revision