Skip to content
NewNexus 2.0 is here, and it’s open source. Read the launch post

API reference

Cloud sandboxes

Cloud sandboxes: a module's throwaway machine at a cloud provider (boat.dev in v1), on Nexus's own provider account, for commands Nexus does not trust. Nexus Review's agent runs its commands in one. Only Nexus Review's module key may use them (cloud.sandboxes.use, product robustness, capability review). A sandbox gets no Nexus token and no files. At most NEXUS_CLOUD_MAX_SANDBOXES live at once; one more is refused, with no queue. Gateway charges a sandbox's running time to the organization as cloud compute (product cloud, capability compute in GET /v1/spend), from its create to its delete, and deletes it at its expiresAt. Without a provider account on the Gateway (BOAT_API_KEY), every route answers 503 cloud_unavailable.

View as Markdown

Create cloud sandbox

post/v1/cloud/sandboxes

Create a throwaway sandbox for untrusted commands. Send ttlSeconds (60 to 7200): Gateway deletes the sandbox then, and the provider's own timer stops it. size is one of NEXUS_CLOUD_SIZES (small when absent). labels are at most 16, keys and values of at most 64 characters; Gateway adds nexus.sandbox and nexus.tenant itself. The sandbox starts from NEXUS_CLOUD_SANDBOX_IMAGE with no Nexus token and no files. Send an Idempotency-Key: the sandbox's id is derived from it, so a resend names the sandbox the first send made. Its running time is charged as cloud compute from the create.

cloud.sandboxes.usemodule keysTry it in the API Explorer

Parameters

  • Idempotency-Keyheader · string

    Send the same key again to retry safely: the request runs once. See Idempotency keys.

Request body · application/json

  • size"small" | "default" | "large" | "xlarge"

    One of NEXUS_CLOUD_SIZES; small when absent.

  • ttlSecondsintegerrequired

    min 60 · max 7200

  • labelsobject

    Keys of 1 to 64 characters, not starting with nexus..

Responses

200The sandbox a send with this key madeapplication/json

  • idstringrequired

    csb_…

  • state"creating" | "starting" | "ready" | "failed" | "gone"required
  • size"small" | "default" | "large" | "xlarge"required
  • labelsobjectrequired

    The labels the create sent.

  • createdAtstring (date-time)required
  • expiresAtstring (date-time)required

    When Gateway deletes the sandbox.

  • errorstring | nullrequired

    Why it failed; null otherwise.

201Created: the sandbox is startingapplication/json

  • idstringrequired

    csb_…

  • state"creating" | "starting" | "ready" | "failed" | "gone"required
  • size"small" | "default" | "large" | "xlarge"required
  • labelsobjectrequired

    The labels the create sent.

  • createdAtstring (date-time)required
  • expiresAtstring (date-time)required

    When Gateway deletes the sandbox.

  • errorstring | nullrequired

    Why it failed; null otherwise.

400The body is not an object, or `size` (`invalid_size`), `ttlSeconds` (`invalid_ttl`) or `labels` (`invalid_labels`) is out of bounds.

402Nothing covers 15 minutes of this sandbox's cloud compute (`budget_exceeded`), or the organization is past due (`payment_past_due`). The refusal is recorded.

403Cloud machines are not turned on for this organization (`cloud_not_enabled`), or the key is not Nexus Review's module key (`role_required`, `module_key`).

422This `Idempotency-Key` names another sandbox (`idempotency_key_reused`); send a new key.

429Gateway runs its most sandboxes (`cloud_capacity`, `NEXUS_CLOUD_MAX_SANDBOXES`), or the provider is busy (`cloud_busy`). There is no queue: try again after `Retry-After`.

502The cloud provider failed or did not answer (`cloud_provider_error`); try again.

503No provider account on this Gateway (`cloud_unavailable`), or the provider has no free machine (`cloud_capacity`); try again later.

Errors

StatusCodeWhen
400invalid_request_errorA field is missing or not valid; the message names it
400The body is not an object, or `size` (`invalid_size`), `ttlSeconds` (`invalid_ttl`) or `labels` (`invalid_labels`) is out of bounds.
401authentication_errorNo key, or a key Gateway does not accept
402budget_exceededNothing covers 15 minutes of this sandbox's cloud compute (`budget_exceeded`), or the organization is past due (`payment_past_due`). The refusal is recorded.
403role_requiredYour role does not have this permission
409idempotency_in_progressA request with the same Idempotency-Key is still running
409idempotency_interruptedThe first request with this Idempotency-Key was cut off and may have run in part
422This `Idempotency-Key` names another sandbox (`idempotency_key_reused`); send a new key.
422idempotency_key_reusedThe Idempotency-Key was used with a different request
429Gateway runs its most sandboxes (`cloud_capacity`, `NEXUS_CLOUD_MAX_SANDBOXES`), or the provider is busy (`cloud_busy`). There is no queue: try again after `Retry-After`.
429rate_limit_errorToo many requests from this key in a minute
502The cloud provider failed or did not answer (`cloud_provider_error`); try again.
503No provider account on this Gateway (`cloud_unavailable`), or the provider has no free machine (`cloud_capacity`); try again later.

Example

curl
curl -X POST "$NEXUS_URL/v1/cloud/sandboxes" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "ttlSeconds": 60
  }'

Get cloud sandbox

get/v1/cloud/sandboxes/{id}

Your organization's sandbox, its state read from the provider. A deleted or expired one answers gone.

cloud.sandboxes.usemodule keysTry it in the API Explorer

Parameters

  • idpath · stringrequired

    The sandbox's id (csb_…), as POST /v1/cloud/sandboxes answered it

Responses

200OKapplication/json

  • idstringrequired

    csb_…

  • state"creating" | "starting" | "ready" | "failed" | "gone"required
  • size"small" | "default" | "large" | "xlarge"required
  • labelsobjectrequired

    The labels the create sent.

  • createdAtstring (date-time)required
  • expiresAtstring (date-time)required

    When Gateway deletes the sandbox.

  • errorstring | nullrequired

    Why it failed; null otherwise.

403The key is not Nexus Review's module key (`role_required`), or a person's or another credential's (`module_key`, `role_required`).

404No such sandbox in your organization: another organization's is as absent as a missing one.

429Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap).application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

503No provider account on this Gateway (`cloud_unavailable`); try again later.

Errors

StatusCodeWhen
401authentication_errorNo key, or a key Gateway does not accept
403role_requiredYour role does not have this permission
404not_foundNothing matches the path in your organization
404No such sandbox in your organization: another organization's is as absent as a missing one.
429Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap).
429rate_limit_errorToo many requests from this key in a minute
503No provider account on this Gateway (`cloud_unavailable`); try again later.

Example

curl
curl "$NEXUS_URL/v1/cloud/sandboxes/<id>" \
  -H "Authorization: Bearer $NEXUS_API_KEY"

Delete cloud sandbox

DEL/v1/cloud/sandboxes/{id}

Delete the sandbox at the provider and charge its running time. A sandbox already gone answers the same.

cloud.sandboxes.usemodule keysTry it in the API Explorer

Parameters

  • idpath · stringrequired

    The sandbox's id (csb_…), as POST /v1/cloud/sandboxes answered it

  • Idempotency-Keyheader · string

    Send the same key again to retry safely: the request runs once. See Idempotency keys.

Responses

200OKapplication/json

  • idstringrequired
  • deletedbooleanrequired

403The key is not Nexus Review's module key (`role_required`), or a person's or another credential's (`module_key`, `role_required`).

404No such sandbox in your organization: another organization's is as absent as a missing one.

429Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap).application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

502The cloud provider failed or did not answer (`cloud_provider_error`); try again.

503No provider account on this Gateway (`cloud_unavailable`); try again later.

Errors

StatusCodeWhen
401authentication_errorNo key, or a key Gateway does not accept
403role_requiredYour role does not have this permission
404not_foundNothing matches the path in your organization
404No such sandbox in your organization: another organization's is as absent as a missing one.
409idempotency_in_progressA request with the same Idempotency-Key is still running
409idempotency_interruptedThe first request with this Idempotency-Key was cut off and may have run in part
422idempotency_key_reusedThe Idempotency-Key was used with a different request
429Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap).
429rate_limit_errorToo many requests from this key in a minute
502The cloud provider failed or did not answer (`cloud_provider_error`); try again.
503No provider account on this Gateway (`cloud_unavailable`); try again later.

Example

curl
curl -X DELETE "$NEXUS_URL/v1/cloud/sandboxes/<id>" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"

Exec cloud sandbox

post/v1/cloud/sandboxes/{id}/exec

Run one command in the sandbox with sh -c and wait for it. command is 1 to 16384 bytes and timeoutSeconds 1 to 600: the provider stops the command then and answers timedOut. stdoutTruncated and stderrTruncated say the provider cut that stream. The call waits up to timeoutSeconds plus 30 seconds.

cloud.sandboxes.usemodule keysTry it in the API Explorer

Parameters

  • idpath · stringrequired

    The sandbox's id (csb_…), as POST /v1/cloud/sandboxes answered it

  • Idempotency-Keyheader · string

    Send the same key again to retry safely: the request runs once. See Idempotency keys.

Request body · application/json

  • commandstringrequired

    Run with sh -c; at most 16384 bytes.

    min length 1

  • timeoutSecondsintegerrequired

    min 1 · max 600

Responses

200OKapplication/json

  • exitCodeinteger | nullrequired

    Null when the command was killed (a timeout or a signal).

  • stdoutstringrequired
  • stderrstringrequired
  • timedOutbooleanrequired
  • durationMsintegerrequired

    min 0

  • stdoutTruncatedbooleanrequired

    The provider cut stdout: its text is not complete.

  • stderrTruncatedbooleanrequired

    The provider cut stderr: its text is not complete.

400`command` (`invalid_command`) or `timeoutSeconds` (`invalid_timeout`) is out of bounds.

403The key is not Nexus Review's module key (`role_required`), or a person's or another credential's (`module_key`, `role_required`).

404No such sandbox in your organization: another organization's is as absent as a missing one.

409The sandbox is not ready yet, or has ended (`sandbox_not_ready`); read it and try again once it is `ready`.

429Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap).application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

502The cloud provider failed or did not answer (`cloud_provider_error`). The command may still have run: an answer larger than 1 MiB, or one lost on the way, comes after it ran. Do not send it again unless it is safe to run twice.

503No provider account on this Gateway (`cloud_unavailable`); try again later.

Errors

StatusCodeWhen
400invalid_request_errorA field is missing or not valid; the message names it
400`command` (`invalid_command`) or `timeoutSeconds` (`invalid_timeout`) is out of bounds.
401authentication_errorNo key, or a key Gateway does not accept
403role_requiredYour role does not have this permission
404not_foundNothing matches the path in your organization
404No such sandbox in your organization: another organization's is as absent as a missing one.
409The sandbox is not ready yet, or has ended (`sandbox_not_ready`); read it and try again once it is `ready`.
409idempotency_in_progressA request with the same Idempotency-Key is still running
409idempotency_interruptedThe first request with this Idempotency-Key was cut off and may have run in part
422idempotency_key_reusedThe Idempotency-Key was used with a different request
429Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap).
429rate_limit_errorToo many requests from this key in a minute
502The cloud provider failed or did not answer (`cloud_provider_error`). The command may still have run: an answer larger than 1 MiB, or one lost on the way, comes after it ran. Do not send it again unless it is safe to run twice.
503No provider account on this Gateway (`cloud_unavailable`); try again later.

Example

curl
curl -X POST "$NEXUS_URL/v1/cloud/sandboxes/<id>/exec" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "command": "<command>",
    "timeoutSeconds": 1
  }'

Cloud sandbox upload url

post/v1/cloud/sandboxes/{id}/upload-url

A provider link that takes one file for the sandbox. PUT the bytes to url with no auth header; the provider writes them at $HOME/<path> (/home/user). path is relative, with no .., at most 256 characters. The link works for ttlSeconds (60 to 900, 900 when absent).

cloud.sandboxes.usemodule keysTry it in the API Explorer

Parameters

  • idpath · stringrequired

    The sandbox's id (csb_…), as POST /v1/cloud/sandboxes answered it

  • Idempotency-Keyheader · string

    Send the same key again to retry safely: the request runs once. See Idempotency keys.

Request body · application/json

  • pathstringrequired

    Relative to the sandbox's home, with no ...

    min length 1 · max length 256

  • ttlSecondsinteger

    900 when absent.

    min 60 · max 900

Responses

200OKapplication/json

  • urlstring (uri)required

400`path` (`invalid_path`) or `ttlSeconds` (`invalid_ttl`) is out of bounds.

403The key is not Nexus Review's module key (`role_required`), or a person's or another credential's (`module_key`, `role_required`).

404No such sandbox in your organization: another organization's is as absent as a missing one.

409The sandbox is not ready yet, or has ended (`sandbox_not_ready`).

429Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap).application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.

    • codestring

      Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

502The cloud provider failed or did not answer (`cloud_provider_error`); try again.

503No provider account on this Gateway (`cloud_unavailable`); try again later.

Errors

StatusCodeWhen
400invalid_request_errorA field is missing or not valid; the message names it
400`path` (`invalid_path`) or `ttlSeconds` (`invalid_ttl`) is out of bounds.
401authentication_errorNo key, or a key Gateway does not accept
403role_requiredYour role does not have this permission
404not_foundNothing matches the path in your organization
404No such sandbox in your organization: another organization's is as absent as a missing one.
409The sandbox is not ready yet, or has ended (`sandbox_not_ready`).
409idempotency_in_progressA request with the same Idempotency-Key is still running
409idempotency_interruptedThe first request with this Idempotency-Key was cut off and may have run in part
422idempotency_key_reusedThe Idempotency-Key was used with a different request
429Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap).
429rate_limit_errorToo many requests from this key in a minute
502The cloud provider failed or did not answer (`cloud_provider_error`); try again.
503No provider account on this Gateway (`cloud_unavailable`); try again later.

Example

curl
curl -X POST "$NEXUS_URL/v1/cloud/sandboxes/<id>/upload-url" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "path": "<path>"
  }'