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

API reference

Cloud sessions

Headless cloud sessions: a cloud session that starts with no desktop app, for the assistant, the CLI, MCP and the apps. Each session runs on its own cloud machine of yours, with the cloud machines' limits and charges. A session is its person's alone: to anyone else it does not exist. Off unless NEXUS_SESSIONS_API is on: every route then answers 404.

View as Markdown

List sessions

get/v1/sessions

Your headless cloud sessions in this organization, newest first (at most 50), each with its cloud machine.

cloud.machines.useEvery memberTry it in the API Explorer

Responses

200OKapplication/json

  • sessionsarray of Sessionrequired
    • idstringrequired

      cs_ and 40 hex characters

    • repostringrequired

      GitHub owner/name, lowercased

    • agentstringrequired

      claude or codex: a cloud session launches only these two agents today.

    • modelstring | nullrequired

      The agent's model name; null for its default.

    • titlestring | nullrequired

      The session's title; null when the start sent none.

    • state"starting" | "running" | "stopped" | "failed"required

      starting: the machine boots or sets the repository up, or the prompt waits for its host. running: the agent started. stopped and failed are final.

    • threadIdstring | nullrequired

      The session's id on its machine once the agent started (t_<uuid>).

    • errorstring | nullrequired

      Why it failed, or why the last message may not have reached it.

    • startedBySessionStartedByrequired

      Who started a session. Absent on a start: you (person).

      • kind"person" | "assistant_conversation" | "room" | "session"required
      • idstringrequired

        A user id (yours, for person), an assistant conversation's id, a room's id, or a session of yours (cs_…).

    • createdAtstring (date-time)required
    • updatedAtstring (date-time)required
    • stoppedAtstring (date-time) | nullrequired

      When it stopped or failed.

    • machineCloudMachine | nullrequired

      Its cloud machine; null once the machine is deleted.

    • fencingTokenintegerrequired

      The session's current fencing token: 0 until a runner first takes it, then raised by one on each take.

      min 0

    • runnerSessionRunner | nullrequired

      The runner that took the session last, and its lease; null until one takes it.

404`NEXUS_SESSIONS_API` is off.

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
404`NEXUS_SESSIONS_API` is off.
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/sessions" \
  -H "Authorization: Bearer $NEXUS_API_KEY"

Create session

post/v1/sessions

Start a headless cloud session: a cloud session with no desktop app. Gateway creates your cloud machine for the session (as POST /v1/cloud/machines does, with its limits and charges), the machine clones repo and runs its .agents/setup at boot with the organization's Nexus GitHub App, and Gateway then starts the agent on the machine with prompt as its first message. The prompt never goes to the provider: Gateway sends it to the machine's host once the host is online. The agent runs on the Nexus route, charged to the organization, in auto permission mode. Send idempotencyKey (or an Idempotency-Key header): the session's id is derived from it, so a resend answers the same session. Read the session (GET) to see it move from starting to running. Off unless NEXUS_SESSIONS_API is on.

cloud.machines.useEvery memberTry it in the API Explorer

Parameters

  • x-nexus-github-tokenheader · string

    Your own GitHub token. Gateway asks GitHub with it whether you may read repo. Used for that check only, never kept, and never sent to the machine. Without it, Gateway uses your own github connection (connect it with POST /v1/connections/github/oauth).

  • x-nexus-github-accountheader · string

    The id of your linked GitHub account when you have more than one.

  • Idempotency-Keyheader · string

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

Request body · application/json

  • repostring

    The GitHub repository, owner/name (a github.com URL also works). Required for now.

  • projectIdstring

    Reserved for projects: refused for now (project_id_unsupported).

  • agentstring

    A coding agent that runs in cloud sessions: claude or codex, and opencode when the Gateway turns it on. Absent, empty or auto: the model picks it (open-weight models run on opencode, Anthropic models on claude, OpenAI models on codex). Another agent is refused with invalid_agent.

  • modelstring

    A catalog model (GET /v1/models) or the agent's own model name; absent for the agent's default. Required when agent is absent. With agent, a catalog model that another agent runs is refused with agent_model_mismatch.

  • promptstringrequired

    The session's first message, 1 to 100000 characters.

  • titlestring

    The session's title, kept on one line, at most 200 characters.

  • idempotencyKeystring

    Names the session: a resend with the same body answers the same session. Else the Idempotency-Key header's.

  • startedBySessionStartedBy

    Who started a session. Absent on a start: you (person).

    • kind"person" | "assistant_conversation" | "room" | "session"required
    • idstringrequired

      A user id (yours, for person), an assistant conversation's id, a room's id, or a session of yours (cs_…).

Responses

200The session a start with this key madeapplication/json

  • idstringrequired

    cs_ and 40 hex characters

  • repostringrequired

    GitHub owner/name, lowercased

  • agentstringrequired

    claude or codex: a cloud session launches only these two agents today.

  • modelstring | nullrequired

    The agent's model name; null for its default.

  • titlestring | nullrequired

    The session's title; null when the start sent none.

  • state"starting" | "running" | "stopped" | "failed"required

    starting: the machine boots or sets the repository up, or the prompt waits for its host. running: the agent started. stopped and failed are final.

  • threadIdstring | nullrequired

    The session's id on its machine once the agent started (t_<uuid>).

  • errorstring | nullrequired

    Why it failed, or why the last message may not have reached it.

  • startedBySessionStartedByrequired

    Who started a session. Absent on a start: you (person).

    • kind"person" | "assistant_conversation" | "room" | "session"required
    • idstringrequired

      A user id (yours, for person), an assistant conversation's id, a room's id, or a session of yours (cs_…).

  • createdAtstring (date-time)required
  • updatedAtstring (date-time)required
  • stoppedAtstring (date-time) | nullrequired

    When it stopped or failed.

  • machineCloudMachine | nullrequired

    Its cloud machine; null once the machine is deleted.

  • fencingTokenintegerrequired

    The session's current fencing token: 0 until a runner first takes it, then raised by one on each take.

    min 0

  • runnerSessionRunner | nullrequired

    The runner that took the session last, and its lease; null until one takes it.

201Created: the machine starts, and the prompt waits for its hostapplication/json

  • idstringrequired

    cs_ and 40 hex characters

  • repostringrequired

    GitHub owner/name, lowercased

  • agentstringrequired

    claude or codex: a cloud session launches only these two agents today.

  • modelstring | nullrequired

    The agent's model name; null for its default.

  • titlestring | nullrequired

    The session's title; null when the start sent none.

  • state"starting" | "running" | "stopped" | "failed"required

    starting: the machine boots or sets the repository up, or the prompt waits for its host. running: the agent started. stopped and failed are final.

  • threadIdstring | nullrequired

    The session's id on its machine once the agent started (t_<uuid>).

  • errorstring | nullrequired

    Why it failed, or why the last message may not have reached it.

  • startedBySessionStartedByrequired

    Who started a session. Absent on a start: you (person).

    • kind"person" | "assistant_conversation" | "room" | "session"required
    • idstringrequired

      A user id (yours, for person), an assistant conversation's id, a room's id, or a session of yours (cs_…).

  • createdAtstring (date-time)required
  • updatedAtstring (date-time)required
  • stoppedAtstring (date-time) | nullrequired

    When it stopped or failed.

  • machineCloudMachine | nullrequired

    Its cloud machine; null once the machine is deleted.

  • fencingTokenintegerrequired

    The session's current fencing token: 0 until a runner first takes it, then raised by one on each take.

    min 0

  • runnerSessionRunner | nullrequired

    The runner that took the session last, and its lease; null until one takes it.

400A field is wrong: `invalid_repo` (not GitHub `owner/name`), `invalid_agent` (not an agent this Gateway runs in cloud sessions), `invalid_model`, `model_required` (no agent and no model), `unknown_model`, `model_coming_soon` or `unsupported_cloud_model` (no cloud agent runs the model), `agent_model_mismatch` (the model runs on another agent; `error.nexus` names `agent`, `model` and `modelAgent`), `invalid_prompt`, `invalid_started_by`, `idempotency_key_required`, or `project_id_unsupported` (`projectId` is reserved).

402Nothing covers 15 minutes of the machine's cloud compute (`budget_exceeded`), or the organization is past due (`payment_past_due`).

403Cloud machines are disabled (`cloud_not_enabled`), the organization disallows the GitHub connection (`connector_disabled`), or it needs reconnecting (`connection_expired`).

404`NEXUS_SESSIONS_API` is off.

409No `x-nexus-github-token` header and no `github` connection of your own (`github_connection_required`, with `error.nexus.connect` set to `github`): connect your GitHub account, then start again. Or the machine may not set the repository up (`repo_setup_unavailable`): you cannot read it, or the organization's Nexus GitHub App does not reach it.

422This key names another session (`idempotency_key_reused`); send a new key.

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
400A field is wrong: `invalid_repo` (not GitHub `owner/name`), `invalid_agent` (not an agent this Gateway runs in cloud sessions), `invalid_model`, `model_required` (no agent and no model), `unknown_model`, `model_coming_soon` or `unsupported_cloud_model` (no cloud agent runs the model), `agent_model_mismatch` (the model runs on another agent; `error.nexus` names `agent`, `model` and `modelAgent`), `invalid_prompt`, `invalid_started_by`, `idempotency_key_required`, or `project_id_unsupported` (`projectId` is reserved).
401authentication_errorNo key, or a key Gateway does not accept
402budget_exceededNothing covers 15 minutes of the machine's cloud compute (`budget_exceeded`), or the organization is past due (`payment_past_due`).
403role_requiredYour role does not have this permission
404`NEXUS_SESSIONS_API` is off.
409No `x-nexus-github-token` header and no `github` connection of your own (`github_connection_required`, with `error.nexus.connect` set to `github`): connect your GitHub account, then start again. Or the machine may not set the repository up (`repo_setup_unavailable`): you cannot read it, or the organization's Nexus GitHub App does not reach it.
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 key names another session (`idempotency_key_reused`); send a new key.
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/sessions" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "<prompt>"
  }'

Get session

get/v1/sessions/{id}

Your session: its state, its id on the machine once it started, its lineage and its cloud machine.

cloud.machines.useEvery memberTry it in the API Explorer

Parameters

  • idpath · stringrequired

    The session's id (cs_…), as POST /v1/sessions answered it

Responses

200OKapplication/json

  • idstringrequired

    cs_ and 40 hex characters

  • repostringrequired

    GitHub owner/name, lowercased

  • agentstringrequired

    claude or codex: a cloud session launches only these two agents today.

  • modelstring | nullrequired

    The agent's model name; null for its default.

  • titlestring | nullrequired

    The session's title; null when the start sent none.

  • state"starting" | "running" | "stopped" | "failed"required

    starting: the machine boots or sets the repository up, or the prompt waits for its host. running: the agent started. stopped and failed are final.

  • threadIdstring | nullrequired

    The session's id on its machine once the agent started (t_<uuid>).

  • errorstring | nullrequired

    Why it failed, or why the last message may not have reached it.

  • startedBySessionStartedByrequired

    Who started a session. Absent on a start: you (person).

    • kind"person" | "assistant_conversation" | "room" | "session"required
    • idstringrequired

      A user id (yours, for person), an assistant conversation's id, a room's id, or a session of yours (cs_…).

  • createdAtstring (date-time)required
  • updatedAtstring (date-time)required
  • stoppedAtstring (date-time) | nullrequired

    When it stopped or failed.

  • machineCloudMachine | nullrequired

    Its cloud machine; null once the machine is deleted.

  • fencingTokenintegerrequired

    The session's current fencing token: 0 until a runner first takes it, then raised by one on each take.

    min 0

  • runnerSessionRunner | nullrequired

    The runner that took the session last, and its lease; null until one takes it.

404No such session of yours: another person's session and another organization's are as absent as a missing one. Every sessions route answers 404 while `NEXUS_SESSIONS_API` is off.

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 session of yours: another person's session and another organization's are as absent as a missing one. Every sessions route answers 404 while `NEXUS_SESSIONS_API` is off.
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/sessions/<id>" \
  -H "Authorization: Bearer $NEXUS_API_KEY"

Send session message

post/v1/sessions/{id}/messages

Send the session's agent its next message. It waits for the machine's host, after the messages before it, and a sleeping machine wakes for it (with the wake's limits and charges). A message whose answer the host lost is not sent again: the session's error says so.

cloud.machines.useEvery memberTry it in the API Explorer

Parameters

  • idpath · stringrequired

    The session's id (cs_…), as POST /v1/sessions answered it

  • Idempotency-Keyheader · string

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

Request body · application/json

  • textstringrequired

    1 to 100000 characters.

Responses

202Accepted: the message waits for the machine's hostapplication/json

  • idstringrequired

    cs_ and 40 hex characters

  • repostringrequired

    GitHub owner/name, lowercased

  • agentstringrequired

    claude or codex: a cloud session launches only these two agents today.

  • modelstring | nullrequired

    The agent's model name; null for its default.

  • titlestring | nullrequired

    The session's title; null when the start sent none.

  • state"starting" | "running" | "stopped" | "failed"required

    starting: the machine boots or sets the repository up, or the prompt waits for its host. running: the agent started. stopped and failed are final.

  • threadIdstring | nullrequired

    The session's id on its machine once the agent started (t_<uuid>).

  • errorstring | nullrequired

    Why it failed, or why the last message may not have reached it.

  • startedBySessionStartedByrequired

    Who started a session. Absent on a start: you (person).

    • kind"person" | "assistant_conversation" | "room" | "session"required
    • idstringrequired

      A user id (yours, for person), an assistant conversation's id, a room's id, or a session of yours (cs_…).

  • createdAtstring (date-time)required
  • updatedAtstring (date-time)required
  • stoppedAtstring (date-time) | nullrequired

    When it stopped or failed.

  • machineCloudMachine | nullrequired

    Its cloud machine; null once the machine is deleted.

  • fencingTokenintegerrequired

    The session's current fencing token: 0 until a runner first takes it, then raised by one on each take.

    min 0

  • runnerSessionRunner | nullrequired

    The runner that took the session last, and its lease; null until one takes it.

400`text` is blank or longer than 100000 characters (`invalid_text`).

404No such session of yours: another person's session and another organization's are as absent as a missing one. Every sessions route answers 404 while `NEXUS_SESSIONS_API` is off.

409The session stopped or failed (`session_ended`).

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
400invalid_request_errorA field is missing or not valid; the message names it
400`text` is blank or longer than 100000 characters (`invalid_text`).
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 session of yours: another person's session and another organization's are as absent as a missing one. Every sessions route answers 404 while `NEXUS_SESSIONS_API` is off.
409The session stopped or failed (`session_ended`).
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
503No provider account on this Gateway (`cloud_unavailable`); try again later.

Example

curl
curl -X POST "$NEXUS_URL/v1/sessions/<id>/messages" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "<text>"
  }'

Stop session

post/v1/sessions/{id}/stop

Stop the session. Before its agent started, it ends now and its machine goes to sleep. After, Gateway asks the machine's host to stop the agent, and the session ends (stopped) once it did; the machine then sleeps when idle. A stop of an ended session changes nothing.

cloud.machines.useEvery memberTry it in the API Explorer

Parameters

  • idpath · stringrequired

    The session's id (cs_…), as POST /v1/sessions answered it

  • Idempotency-Keyheader · string

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

Responses

200OKapplication/json

  • idstringrequired

    cs_ and 40 hex characters

  • repostringrequired

    GitHub owner/name, lowercased

  • agentstringrequired

    claude or codex: a cloud session launches only these two agents today.

  • modelstring | nullrequired

    The agent's model name; null for its default.

  • titlestring | nullrequired

    The session's title; null when the start sent none.

  • state"starting" | "running" | "stopped" | "failed"required

    starting: the machine boots or sets the repository up, or the prompt waits for its host. running: the agent started. stopped and failed are final.

  • threadIdstring | nullrequired

    The session's id on its machine once the agent started (t_<uuid>).

  • errorstring | nullrequired

    Why it failed, or why the last message may not have reached it.

  • startedBySessionStartedByrequired

    Who started a session. Absent on a start: you (person).

    • kind"person" | "assistant_conversation" | "room" | "session"required
    • idstringrequired

      A user id (yours, for person), an assistant conversation's id, a room's id, or a session of yours (cs_…).

  • createdAtstring (date-time)required
  • updatedAtstring (date-time)required
  • stoppedAtstring (date-time) | nullrequired

    When it stopped or failed.

  • machineCloudMachine | nullrequired

    Its cloud machine; null once the machine is deleted.

  • fencingTokenintegerrequired

    The session's current fencing token: 0 until a runner first takes it, then raised by one on each take.

    min 0

  • runnerSessionRunner | nullrequired

    The runner that took the session last, and its lease; null until one takes it.

404No such session of yours: another person's session and another organization's are as absent as a missing one. Every sessions route answers 404 while `NEXUS_SESSIONS_API` is off.

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 session of yours: another person's session and another organization's are as absent as a missing one. Every sessions route answers 404 while `NEXUS_SESSIONS_API` is off.
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
503No provider account on this Gateway (`cloud_unavailable`); try again later.

Example

curl
curl -X POST "$NEXUS_URL/v1/sessions/<id>/stop" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"

Take session runner

post/v1/sessions/{id}/runner

Take the session as its runner: the desktop app, nexus-host or a cloud machine that runs its agent. The runner gets the session's next fencing token and a lease of 60 seconds, which it renews every 20 seconds (POST /v1/sessions/{id}/runner/renew). Without seenToken, the take succeeds only when no runner's lease is live: the first take, or a takeover after the lease passed. With seenToken (the session's fencingToken as you read it), it is a handoff: it takes the session from whoever holds it, while that is still the session's token. Each take raises the token by one, so the runner it replaced gets 409 lost_runner on its next renewal or connector write. Of two takes at once, one wins and the other gets 409 takeover_conflict.

cloud.machines.useEvery memberTry it in the API Explorer

Parameters

  • idpath · stringrequired

    The session's id (cs_…), as POST /v1/sessions answered it

Request body · application/json

  • runnerIdstringrequired

    Who takes the session: a name of the runner's own, such as its device id.

    min length 1 · max length 200

  • seenTokeninteger | null

    The session's fencingToken as you read it: take the session over from its holder (a handoff) while that is still its token.

    min 0

Responses

200OKapplication/json

  • runnerIdstringrequired

    The runner, as it named itself when it took the session.

  • fencingTokenintegerrequired

    The token the runner holds. Its connector writes inside the session send it in x-nexus-fencing-token.

    min 1

  • leaseExpiresAtstring (date-time)required

    When the lease ends unless the runner renews it. After it, another runner may take the session without seenToken.

400`invalid_runner_id` or `invalid_token`.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.

404No such session of yours: another person's session and another organization's are as absent as a missing one. Every sessions route answers 404 while `NEXUS_SESSIONS_API` is off.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.

409`takeover_conflict`: another runner's lease is live and the take named no `seenToken`, or the token you saw is no longer the session's (`error.nexus.currentFencingToken`). `session_ended`: the session stopped or failed.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.

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.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.

Errors

StatusCodeWhen
400invalid_request_errorA field is missing or not valid; the message names it
400`invalid_runner_id` or `invalid_token`.
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 session of yours: another person's session and another organization's are as absent as a missing one. Every sessions route answers 404 while `NEXUS_SESSIONS_API` is off.
409`takeover_conflict`: another runner's lease is live and the take named no `seenToken`, or the token you saw is no longer the session's (`error.nexus.currentFencingToken`). `session_ended`: the session stopped or failed.
409lost_runnerEach take raises the token by one, so the runner it replaced gets 409 `lost_runner` on its next renewal or connector write
409takeover_conflictOf two takes at once, one wins and the other gets 409 `takeover_conflict`
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 -X POST "$NEXUS_URL/v1/sessions/<id>/runner" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "runnerId": "<runnerId>"
  }'

Renew session runner

post/v1/sessions/{id}/runner/renew

Renew the runner's lease for 60 seconds more. Only the holder of the session's current fencing token renews; a lease that passed renews too while no other runner took the session. Send it without Idempotency-Key: a retry has the same effect while the token is current. A key, when sent, is kept and replayed as on any write.

cloud.machines.useEvery memberTry it in the API Explorer

Parameters

  • idpath · stringrequired

    The session's id (cs_…), as POST /v1/sessions answered it

Request body · application/json

  • fencingTokenintegerrequired

    The token the runner got when it took the session.

    min 1

Responses

200OKapplication/json

  • runnerIdstringrequired

    The runner, as it named itself when it took the session.

  • fencingTokenintegerrequired

    The token the runner holds. Its connector writes inside the session send it in x-nexus-fencing-token.

    min 1

  • leaseExpiresAtstring (date-time)required

    When the lease ends unless the runner renews it. After it, another runner may take the session without seenToken.

400The body is not `{ fencingToken }`.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.

404No such session of yours: another person's session and another organization's are as absent as a missing one. Every sessions route answers 404 while `NEXUS_SESSIONS_API` is off.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.

409`lost_runner`: another runner took the session, so stop running it and stop writing for it (`error.nexus.currentFencingToken`). `session_ended`: the session stopped or failed.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.

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.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.

Errors

StatusCodeWhen
400invalid_request_errorA field is missing or not valid; the message names it
400The body is not `{ fencingToken }`.
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 session of yours: another person's session and another organization's are as absent as a missing one. Every sessions route answers 404 while `NEXUS_SESSIONS_API` is off.
409`lost_runner`: another runner took the session, so stop running it and stop writing for it (`error.nexus.currentFencingToken`). `session_ended`: the session stopped or failed.
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 -X POST "$NEXUS_URL/v1/sessions/<id>/runner/renew" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "fencingToken": 1
  }'