---
title: "Cancel session"
method: POST
path: "/sessions/{session_id}/cancel"
tags: ["Sessions"]
---

# Cancel session

`POST /sessions/{session_id}/cancel`

Cancel an in-progress session. If the session is currently `processing` or `queued`, any running stream is aborted and the session is transitioned to `failed`. If the session is already `completed` or `failed`, its current state is returned unchanged.

The response carries a `session` envelope but only `id`, `agent_id`, and `state` are populated.

## Path parameters

- `session_id` string, required

## Response `200`

Session state after the cancel attempt. Only `id`, `agent_id`, and `state` are populated on the session envelope.

- object
  - `session` object
    - `id` string
    - `agent_id` string
    - `messages` object[]
    - `created_at` string, date-time, nullable
    - `state` 'processing' | 'completed' | 'failed' | 'queued' | 'idle', nullable
    - `agent_name` string, nullable
    - `agent_team_id` string, nullable
    - `agent_creator_user_id` string, nullable
    - `agent_icon_url` string, nullable
    - `agent_tools` object[]
    - `participants` object
    - `creator` object, nullable
      - `id` string, nullable
      - `first_name` string, nullable
      - `last_name` string, nullable
      - `email` string, nullable
      - `profile_picture` string, nullable
    - `usage` object — Per-session usage totals. Credit and token counts accumulate as the agent runs and are `null` until the first run records usage.
      - `credit_cost` number, nullable — Total credits consumed by the session, including tool and flow (workflow) credits.
      - `tool_credit_cost` number, nullable — Credits consumed by tool calls.
      - `flow_credit_cost` number, nullable — Credits consumed by workflow (flow) runs invoked by the agent.
      - `input_tokens` integer, nullable — Total input tokens across the session.
      - `output_tokens` integer, nullable — Total output tokens across the session.
  - `queue_position` integer, nullable

## Other responses

- `401` — Unauthorized — missing or invalid API key.
- `403` — Forbidden — the caller does not have update access on the session.
- `404` — Session not found.
- `500` — Internal server error — the abort could not be persisted (`failed_to_abort`).

---

[API](https://skmtc.dev/gumloop/apis/public-api.md) · [All operations](https://skmtc.dev/gumloop/apis/public-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/gumloop/public-api/revisions/115f2d6ce387/schema)
