> ## Documentation Index
> Fetch the complete documentation index at: https://docs.artaios.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Cancel Execution

Cancel the currently running execution for a session. Cancellation is cooperative — the agent checks for a cancel signal between steps and stops at the next checkpoint rather than being killed instantly.

<ParamField path="session_id" type="string" required>
  The session ID whose execution should be cancelled
</ParamField>

No request body is required.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.artaios.ai/api/v1/runtime/session_abc123/cancel/ \
    -H "x-api-key: YOUR_API_KEY"
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      "https://api.artaios.ai/api/v1/runtime/session_abc123/cancel/",
      headers={"x-api-key": "YOUR_API_KEY"},
  )
  result = response.json()
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.artaios.ai/api/v1/runtime/session_abc123/cancel/', {
    method: 'POST',
    headers: {
      'x-api-key': 'YOUR_API_KEY'
    }
  });

  const result = await response.json();
  ```
</CodeGroup>

## Response

`200 OK` on success:

```json theme={null}
{
  "id": "session_abc123",
  "status": "cancelled",
  "message": "Execution cancelled successfully"
}
```

### Error responses

<ResponseField name="400 Bad Request" type="object">
  Returned as `{"error": "no_active_execution", "message": "No active execution found to cancel"}` when the session has nothing running.
</ResponseField>

<ResponseField name="404 Not Found" type="object">
  Returned when the session itself doesn't exist (or isn't owned by the authenticated user).
</ResponseField>

## Cancelling a Human-in-the-Loop pause

A session suspended on an open [Human-in-the-Loop](/documentation/agent_config/human-in-the-loop) approval card has no actively running worker task — the agent graph is parked on a checkpoint, waiting for `hitl_response`. Calling this endpoint while a session is in that state still succeeds: instead of stopping a live task, it **abandons the pending approval**. The backend finalizes the suspended checkpoint with a synthetic "cancelled by user" tool result and frees the session, so the next message is accepted instead of being rejected by the busy-guard that otherwise blocks new input while an approval is outstanding.

<Note>
  Abandoning a HITL pause this way does not "deny" the tool call through the normal approval flow — it ends the turn outright. If you want to formally deny a specific tool call and let the agent continue, respond to the approval card instead; see [Human-in-the-Loop over WebSocket](/documentation/integration/websocket-api#human-in-the-loop-over-websocket).
</Note>

## WebSocket equivalent

The [WebSocket API](/documentation/integration/websocket-api) exposes the same operation as a client message rather than an HTTP call — send a `cancel_execution` message on the socket instead of calling this endpoint:

```json theme={null}
{
  "type": "cancel_execution",
  "client_type": "api",
  "session_id": "sess_abc123xyz"
}
```

Use whichever transport matches how you started the execution; both reach the same cancellation logic server-side.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.