---
title: "Cancel the active run"
method: POST
path: "/v1/agents/{agent_id}/sessions/{session_id}/cancel"
tags: ["Agents"]
---

# Cancel the active run

`POST /v1/agents/{agent_id}/sessions/{session_id}/cancel`

## Request

- Base URL: `https://api.dexto.ai`
- URL: `https://api.dexto.ai/v1/agents/{agent_id}/sessions/{session_id}/cancel`
- Auth: HTTP bearer

Cancel the session's active run.

## Path parameters

- `agent_id` string, required
- `session_id` string, required

## Response `200`

Successful response.

- object
  - `stop_reason` 'completed' | 'cancelled' | 'spend_limit_reached' | 'insufficient_credits' | 'max_steps' | 'error', nullable, required: Why the run stopped, beside its status: completed, cancelled, a reached spend limit, no credits left, the step limit, or any other failure (error).
  - `usage` object, required
    - `credits` number, required: Credits charged so far for the run's model calls, searches, fetches, Function calls and media: every Cloud charge recorded with its run id. Sandbox compute and file storage are charged to the sandbox and the project, not the run. Charges settle as work finishes, so a later read can be higher.
    - `input_tokens` integer, required: Model input tokens of the run so far, cached reads and writes included.
    - `output_tokens` integer, required: Model output tokens of the run so far.
  - `created_at` string, date-time, required
  - `id` string, uuid, required
  - `object` 'agent_run', required
  - `session_id` string, uuid, required
  - `status` 'queued' | 'running' | 'waiting_approval' | 'completed' | 'failed' | 'cancelled', required
  - `trigger` object, nullable, required: The automation firing that started the run; null for a run a message started, or once the automation is deleted.
    - `automation_id` string, uuid, required
    - `firing_id` string, uuid, required
    - `type` 'automation', required

## Other responses

- `400`: Invalid JSON or request fields.
- `401`: Missing or invalid API key.
- `402`: The account has insufficient credits.
- `403`: The account cannot perform this operation.
- `404`: The requested resource was not found.
- `409`: The request conflicts with existing resource state.
- `429`: The account exceeded this operation's request rate.
- `500`: Unexpected Dexto failure.
- `502`: The upstream model provider failed.
- `503`: A required Dexto service is temporarily unavailable.

---

[API](https://skmtc.dev/dexto/apis/dexto-api.md) - [All operations](https://skmtc.dev/dexto/apis/dexto-api/llms.txt) - [OpenAPI document](https://skmtc.dev/dexto/apis/dexto-api/revisions/47eb880cffa5?raw)
