Docs menu

Cancel code run

POST /v1/organisations/{organisation_id}/spaces/{space_id}/runs/{run_id}/cancel

Stops a run: the sandbox is deleted at once and the CPU used so far is billed.

Authentication

Send an API key, or an access token from your organisation’s identity provider, in the Authorization header. How API keys work

Scope the API key needs: code_runs:write

Security schemes in the OpenAPI document: session_cookie (cookie __Host-ivy_session)bearer (bearer)api_key (bearer)

Parameters

  • organisation_id path string required
  • space_id path string required
  • run_id path string required

Responses

  • 202 No content

    Cancellation requested

  • 401 application/json ErrorBody

    unauthenticated

  • 403 application/json ErrorBody

    forbidden: someone else's run; invalid_origin

  • 404 application/json ErrorBody

    No such run in this space

  • 429 application/json ErrorBody

    rate_limited: the API key's requests per minute are used up; retry after Retry-After seconds

  • 503 application/json ErrorBody

    unavailable: the database is briefly unavailable; retry after Retry-After seconds

Error codes

Errors come back as an ErrorBody whose code is one of these.

  • 401 unauthenticated
  • 403 forbiddeninvalid_origin
  • 404 not_found generic code for this status
  • 429 rate_limited
  • 503 unavailable

Examples

curl
curl -X POST "$IVY_API_URL/v1/organisations/$ORGANISATION_ID/spaces/$SPACE_ID/runs/$RUN_ID/cancel" \
  -H "Authorization: Bearer $IVY_API_KEY"
JavaScript SDK
import { client, cancelCodeRun } from "@spacivapp/ivy-sdk";

client.setConfig({
  baseUrl: process.env.IVY_API_URL,
  headers: { Authorization: `Bearer ${process.env.IVY_API_KEY}` },
});

const { data, error, response } = await cancelCodeRun({
  path: { organisation_id: organisationId, space_id: spaceId, run_id: runId },
});