Cancel a compute plan
POST https://weights.fyi/run/v1/compute/plans/{plan_id}/cancel
Authorization: Bearer <token> scope: submit
Content-Type: application/json- Available since
- 2026-10-29: included in this build; see What is live for deployment status.
- Answer time
- synchronous cancellation commit; does not wait for running work to stop.
Cancels your plan. Every unfinished stage becomes cancelled, its unfinished packs are cancelled, its leases are fenced and its scoped stage tokens are revoked. Completed stages stay completed. The plan settles as cancelled and its capacity demand is released, so no new capacity is requested for it; when no other plan still needs capacity, the pool is marked ready to scale down.
A worker still holding a lease on the plan is refused with 409 stale_compute_lease on its next heartbeat or completion and settles no further work. Accrued cost stays on the receipt.
Request
| Name | Where | Required | Meaning |
|---|---|---|---|
Authorization | header | yes | Bearer token with submit. |
plan_id | path | yes | Identifier of your plan. |
reason | body | no | Non-empty string of at most 4,096 bytes, recorded on each cancelled stage and in the events. Omitted, it is cancelled_by_owner. |
An empty body or {} is accepted. Otherwise send a JSON object of at most 1 MiB containing only reason.
Return value
200 OK with the current plan receipt: state is cancelled, the cancelled stages show cancelled, and readiness.capacity.state is released.
Cancellation is idempotent: cancelling an already cancelled plan returns its receipt unchanged and records no new events. A plan that already completed or failed is not cancelled; the call returns 409.
Each cancelled stage records stage.cancelled with error set to the reason and exit_code null; the plan records plan.cancelled with reason and cancelled_stages.
Errors
| Status | Code | Meaning |
|---|---|---|
400 | invalid_json, invalid_compute_plan | Invalid JSON, identifier, reason, non-object body or extra fields. |
401 | unauthorized, invalid_token, token_revoked, token_expired | Supply a valid token. |
403 | scope_required, account_suspended | Token lacks submit, or the account is suspended. |
404 | compute_plan_not_found | Plan is absent or belongs to another account. |
409 | compute_plan_conflict | Plan already completed or failed. Read its receipt. |
413 | body_too_large | Body exceeds 1 MiB. |
429 | rate_limited | Wait for Retry-After before retrying. |
Examples
curl -s https://weights.fyi/run/v1/compute/plans/PLAN_ID/cancel \
-H "Authorization: Bearer $WEIGHTS_API_KEY" -H "Content-Type: application/json" \
-d '{"reason":"superseded by a new plan"}'Selected response fields:
{"plan_id":"example-plan","state":"cancelled","stages":[{"stage_id":"pages","state":"cancelled","packs_completed":3}],"readiness":{"ready":false,"active_workers":0,"capacity":{"state":"released"}},"last_event_seq":44}History
- 2026-10-29: documented owner cancellation with demand release and fenced leases.