Skip to main content
POST
Run and verify the environment's setup script

Authorizations

Authorization
string
header
required

A Recursion API key, created in the console under API keys.

Headers

Idempotency-Key
string
required

Replay-protection key in an organization-wide namespace shared by keyed mutations. It must contain 1 to 256 visible ASCII characters and be sent as exactly one header value. Request identity is the exact HTTP method, escaped path, raw query, and raw body bytes. For the legacy automation-run route only, the historical fingerprint ignores top-level JSON formatting and object-key order and removes the retired top-level idempotency_key field. The same request replays the original successful response; any different request returns 409 idempotency_conflict, and an active matching request returns 409 idempotency_in_progress. Completed receipts are retained for approximately 24 hours, pending claims may be reclaimed after approximately 1 hour, and no deduplication is guaranteed after expiry.

Required string length: 1 - 256
Pattern: ^[!-~]+$

Path Parameters

environment_id
string<uuid>
required

Environment id (UUID) as returned by createEnvironment or listEnvironments.

Response

One execution of an environment's setup script on fresh compute: provision, GPU check, script, profile, image capture, cleanup. Read status until terminal, then hint, failed_line, and stderr_tail; the full log is a separate call.

One execution of an environment's setup script on fresh compute: provision, GPU check, script, profile, image capture, cleanup. Read status until terminal, then hint, failed_line, and stderr_tail; the full log is a separate call.

created_at
string<date-time>
required

When the run was requested.

environment_id
string
required

Environment whose setup ran.

kind
string
required

manual (requested through the API to verify the environment) or session (performed while provisioning a session).

organization_id
string
required

Organization that owns the environment.

setup_run_id
string
required

Server-assigned id of the run.

status
string
required

queued, provisioning, running, succeeded, failed, or cancelled. Poll until one of the last three; getEnvironmentSetupRun accepts wait_seconds to do that server-side.

compute_id
string

Provider id of the compute the run used. Released when the run ends.

compute_profile
object

What the compute turned out to be: vCPUs, memory, GPUs, Docker state, image tools. Recorded after setup passed.

duration_ms
integer<int64>

Wall-clock duration in milliseconds, provisioning included.

exit_code
integer

Exit code of the setup script when it ran. 124 means the timeout elapsed.

failed_command
string

The failing line's command as written, unexpanded.

failed_line
integer<int64>

1-based line in the setup script whose command exited non-zero. 0 when unknown.

failure_code
string

Machine-readable failure class when the run did not succeed: environment_setup_failed, sandbox_capacity_unavailable, sandbox_gpu_not_ready, sandbox_provision_timeout, and so on. Same vocabulary as session failures.

fingerprint
string

Hash of the environment configuration the run executed.

finished_at
string<date-time>

When the run reached a terminal status.

gpu_readiness
object

GPU readiness report for accelerator environments.

hint
string

Likely fix when the failure cause is recognised.

hint_code
string

Stable identifier of the recognised failure cause.

image
string

Runner image the compute booted.

imageCapture
object

Capture failure recorded without changing the setup script verdict.

Example:
imageId
string

Agent Service image id being captured.

log_bytes
integer<int64>

Bytes of log persisted for the run.

log_lines
integer<int64>

Lines of log persisted for the run. The last line's seq equals this; pass it as after to tail.

log_truncated
boolean

True when the script produced more output than the run keeps (4 MiB); the head and the stderr tail are retained.

message
string

One-sentence description of the outcome.

next_action
object

The call that acts on this result: re-run setup after fixing the script, or fetch the log.

Example:
phase
string

Current or final phase: provision, gpu_check, setup, profile, commit, cleanup.

providerEventCursor
integer<int64>

Last Agent Service setup event sequence persisted into this run's log.

providerRunId
string

Durable Agent Service run id executing the setup script.

requested_by_user_id
string

User who requested a manual run.

session_id
string

Session the run provisioned, for kind session.

setupImage
object

Immutable image published by this run when capture succeeded.

Example:
started_at
string<date-time>

When provisioning began.

stderr_tail
string

Last lines of stderr, redacted and bounded to 2 KiB.