---
title: "Cancel Simulation Run"
method: POST
path: "/v1/simulation-runs/{simulation_run_id}/cancel"
---

# Cancel Simulation Run

`POST /v1/simulation-runs/{simulation_run_id}/cancel`

Cancel an in-flight simulation run.

Cascades the cancel down to child test_results:

1. Set simulation_run.status = COMPLETED (the only terminal state after
   the SimulationRunStatus collapse). The fact that the user cancelled
   the run is captured by child test_result rows transitioning to
   CANCELLED, not by a distinct sim_run status.
2. For each child test_result still in PRE_RUNNING_STATUSES, call
   mark_cancelled_async() — guarded so it raises if a status snuck out
   of pre-running between our read and write.
3. Children that already started running (RUNNING / CONVERSATION_ENDED /
   EVALUATING) are LEFT ALONE — they keep their natural terminal status
   so dropped/completed calls still produce meaningful eval data.
4. Bump simulation_run.tests_cancelled by the cascade count.

The endpoint is idempotent for already-terminal sim runs (returns success=False
with a message; doesn't try to re-cancel).

## Path parameters

- `simulation_run_id` integer, required

## Headers

- `X-API-Key` string, required

## Response `200`

Successful Response

- CancelSimulationRunResponse — Response for the cancel-simulation-run endpoint.
  - `success` boolean, required — True if the sim run was marked CANCELLED
  - `simulation_run_id` integer, required — The sim run that was acted upon
  - `cancelled_test_result_ids` integer[] — Pre-running test_results that were cascaded to CANCELLED
  - `left_running_test_result_ids` integer[] — Children in RUNNING / CONVERSATION_ENDED / EVALUATING — left alone so they reach their own natural terminal status instead of being force-cancelled mid-call
  - `message` string, required — Human-readable summary

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/getbluejay/apis/bluejay-api.md) · [All operations](https://skmtc.net/getbluejay/apis/bluejay-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/getbluejay/bluejay-api/versions/f48cef80963f/schema)
