Docs menu

Start code run legacy

POST /v1/organisations/{organisation_id}/workspaces/{workspace_id}/files/{file_id}/runs Deprecated

Runs a code file in a gVisor sandbox as the caller. Output streams from …/runs/{run_id}/events; outputs are saved as new file versions.

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
  • workspace_id path string required
  • file_id path string required

Request body

application/json StartRun required

  • client_run_id string required

    The client's id for this run: repeating it returns the same run.

  • connections string[]

    Connections declared with direct_runs: true the run may call through the gateway; a person's runs only, never a key's.

  • egress string[]

    Hosts of the space allow-list the run may reach; without them it has no network.

  • environment string | null

    The sandbox environment that runs the file; by default the first built-in environment whose run rules match it.

  • files string[]

    Files, folders (Inbox/, Inbox/** with subfolders) and globs (Finance/*.csv) you can read, staged read-only under $IVY_IN/files/ at their current clean versions.

  • input object | null

    A JSON value staged read-only as $IVY_IN/input.json (workflows-design.md §5.2.1).

  • input_file_ids string[]

    Space files copied into the sandbox read-only, beside the code file.

  • Channels of the space you can read, staged as $IVY_IN/messages/<channel>.json.

  • output_folder_id string | null

    Where new output files go; defaults to the code file's folder.

  • save_to string | null

    A folder path or id to save new output files in; the code file's folder by default.

  • tier ComputeTier | null
  • timeout_seconds integer (int32) | null

    10 s up to the installation's maximum (15 min by default); shortened to what the remaining credits cover.

    minimum 0

  • version_id string | null

    Defaults to the version currently served.

Responses

  • 202 application/json RunAccepted

    Queued; repeating client_run_id returns the same run

  • 401 application/json ErrorBody

    unauthenticated

  • 402 application/json ErrorBody

    usage_limit_reached, billing_restricted

  • 403 application/json ErrorBody

    forbidden: editors and admins only; tier_not_available, invalid_origin

  • 404 application/json ErrorBody

    No such file or version in this space; environment_not_found

  • 409 application/json ErrorBody

    run_in_progress, file_scanning; environment_not_ready: the environment is off

  • 413 application/json ErrorBody

    inputs_too_large

  • 422 application/json ErrorBody

    file_not_runnable: no rule of the environment (or of any built-in, when none is named) matches the file (details.patterns); validation_failed; sandbox_tier_unavailable: the installation doesn't offer that size (details.enabled_tiers)

  • 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

    sandbox_unavailable: no gVisor sandbox on this installation (details.reason); or 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
  • 402 usage_limit_reachedbilling_restricted
  • 403 forbiddentier_not_availableinvalid_origin
  • 404 environment_not_found
  • 409 run_in_progressfile_scanningenvironment_not_ready
  • 413 inputs_too_large
  • 422 file_not_runnablevalidation_failedsandbox_tier_unavailable
  • 429 rate_limited
  • 503 sandbox_unavailableunavailable

Examples

curl
curl -X POST "$IVY_API_URL/v1/organisations/$ORGANISATION_ID/workspaces/$WORKSPACE_ID/files/$FILE_ID/runs" \
  -H "Authorization: Bearer $IVY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"client_run_id":"client_run_123"}'
JavaScript SDK
import { client, startCodeRunLegacy } 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 startCodeRunLegacy({
  path: { organisation_id: organisationId, workspace_id: workspaceId, file_id: fileId },
  body: {
    client_run_id: "client_run_123"
  },
});
Example request body
{
  "client_run_id": "client_run_123",
  "connections": [
    "string"
  ],
  "egress": [
    "string"
  ],
  "environment": "string",
  "files": [
    "string"
  ],
  "input": {},
  "input_file_ids": [
    "string"
  ],
  "messages": [
    {
      "channel": "string",
      "since": "string"
    }
  ],
  "output_folder_id": "output_folder_123",
  "save_to": "string",
  "tier": "string",
  "timeout_seconds": 0,
  "version_id": "version_123"
}
Example response (202)
{
  "run_id": "run_123",
  "timeout_seconds": 0
}