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

API reference

Synced sessions

View as Markdown

Get code control

get/v1/threads/{threadId}/control

Read whether your Code session accepts phone control

sessions.controlEvery memberTry it in the API Explorer

Parameters

  • threadIdpath · stringrequired

Responses

200Current control or delivery state.application/json

  • runnerDeviceIdstring | nullrequired
  • enabledbooleanrequired
  • expiresAtinteger | nullrequired
  • serverTimeinteger

    Gateway's clock when it answered, in Unix milliseconds. A device seals a command's expiresAt by this clock. An older Gateway leaves it out.

400Malformed fields, ciphertext or expiry.

403Invalid signature or a caller that is not a person.

404The session, command or device does not belong to the caller.

409A device is untrusted, control is disabled or offline, the organization forbids synced content, or a command state conflicts.

410The session was deleted.

429The bounded command mailbox is full.

Errors

StatusCodeWhen
400Malformed fields, ciphertext or expiry.
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
404The session, command or device does not belong to the caller.
409A device is untrusted, control is disabled or offline, the organization forbids synced content, or a command state conflicts.
410The session was deleted.
429The bounded command mailbox is full.
429rate_limit_errorToo many requests from this key in a minute

Example

curl
curl "$NEXUS_URL/v1/threads/<threadId>/control" \
  -H "Authorization: Bearer $NEXUS_API_KEY"

Set code control

put/v1/threads/{threadId}/control

Renew a signed, locally enabled Code runner lease

sessions.controlEvery memberTry it in the API Explorer

Parameters

  • threadIdpath · stringrequired

Request body · application/json

  • runnerDeviceIdstringrequired
  • enabledbooleanrequired
  • expiresAtintegerrequired
  • signaturestringrequired

Responses

200Current control or delivery state.application/json

  • runnerDeviceIdstring | nullrequired
  • enabledbooleanrequired
  • expiresAtinteger | nullrequired
  • serverTimeinteger

    Gateway's clock when it answered, in Unix milliseconds. A device seals a command's expiresAt by this clock. An older Gateway leaves it out.

400Malformed fields, ciphertext or expiry.

403Invalid signature or a caller that is not a person.

404The session, command or device does not belong to the caller.

409A device is untrusted, control is disabled or offline, the organization forbids synced content, or a command state conflicts.

410The session was deleted.

429The bounded command mailbox is full.

Errors

StatusCodeWhen
400invalid_request_errorA field is missing or not valid; the message names it
400Malformed fields, ciphertext or expiry.
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
404The session, command or device does not belong to the caller.
409A device is untrusted, control is disabled or offline, the organization forbids synced content, or a command state conflicts.
410The session was deleted.
429The bounded command mailbox is full.
429rate_limit_errorToo many requests from this key in a minute

Example

curl
curl -X PUT "$NEXUS_URL/v1/threads/<threadId>/control" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "runnerDeviceId": "<runnerDeviceId>",
    "enabled": false,
    "expiresAt": 1,
    "signature": "<signature>"
  }'

List code commands

get/v1/threads/{threadId}/commands

Read up to 20 queued commands for your trusted runner

sessions.controlEvery memberTry it in the API Explorer

Parameters

  • threadIdpath · stringrequired
  • runnerDeviceIdquery · stringrequired

Responses

200Current control or delivery state.application/json

  • commandsarray of CodeCommandrequired

    at most 20 items

    • idstring (uuid)required
    • senderDeviceIdstringrequired
    • runnerDeviceIdstringrequired
    • expiresAtintegerrequired
    • lockedKeystringrequired

      80 bytes of HPKE ciphertext, base64url without padding.

    • sealedstringrequired

      Encrypted action payload, base64url without padding. At most 65581 decoded bytes.

    • signaturestringrequired

      Ed25519 signature over the domain-separated command and its routing fields, base64url without padding.

    • waitsboolean

      The command may wait for a sleeping computer. Absent means false.

    • threadIdstringrequired
    • state"queued" | "claimed" | "completed" | "rejected" | "expired" | "cancelled"required

400Malformed fields, ciphertext or expiry.

403Invalid signature or a caller that is not a person.

404The session, command or device does not belong to the caller.

409A device is untrusted, control is disabled or offline, the organization forbids synced content, or a command state conflicts.

410The session was deleted.

429The bounded command mailbox is full.

Errors

StatusCodeWhen
400invalid_request_errorA field is missing or not valid; the message names it
400Malformed fields, ciphertext or expiry.
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
404The session, command or device does not belong to the caller.
409A device is untrusted, control is disabled or offline, the organization forbids synced content, or a command state conflicts.
410The session was deleted.
429The bounded command mailbox is full.
429rate_limit_errorToo many requests from this key in a minute

Example

curl
curl "$NEXUS_URL/v1/threads/<threadId>/commands?runnerDeviceId=%3CrunnerDeviceId%3E" \
  -H "Authorization: Bearer $NEXUS_API_KEY"

Send code command

post/v1/threads/{threadId}/commands

Queue an encrypted command for your own Code session

sessions.controlEvery memberTry it in the API Explorer

Parameters

  • threadIdpath · stringrequired

Request body · application/json

  • idstring (uuid)required
  • senderDeviceIdstringrequired
  • runnerDeviceIdstringrequired
  • expiresAtintegerrequired
  • lockedKeystringrequired

    80 bytes of HPKE ciphertext, base64url without padding.

  • sealedstringrequired

    Encrypted action payload, base64url without padding. At most 65581 decoded bytes.

  • signaturestringrequired

    Ed25519 signature over the domain-separated command and its routing fields, base64url without padding.

  • waitsboolean

    The person lets the command wait for a computer that is asleep or offline. Gateway then queues it without a live lease, and expiresAt may be up to 24 hours ahead (30 seconds more for clock skew). The sender signs nexus-code-command-v2, with true after the expiry line, so a runner that verifies only v1 never runs it. Absent means false.

Responses

200Current control or delivery state.application/json

  • idstring (uuid)required
  • senderDeviceIdstringrequired
  • runnerDeviceIdstringrequired
  • expiresAtintegerrequired
  • lockedKeystringrequired

    80 bytes of HPKE ciphertext, base64url without padding.

  • sealedstringrequired

    Encrypted action payload, base64url without padding. At most 65581 decoded bytes.

  • signaturestringrequired

    Ed25519 signature over the domain-separated command and its routing fields, base64url without padding.

  • waitsboolean

    The command may wait for a sleeping computer. Absent means false.

  • threadIdstringrequired
  • state"queued" | "claimed" | "completed" | "rejected" | "expired" | "cancelled"required

400Malformed fields, ciphertext or expiry.

403Invalid signature or a caller that is not a person.

404The session, command or device does not belong to the caller.

409A device is untrusted, control is disabled or offline, the organization forbids synced content, or a command state conflicts.

410The session was deleted.

429The bounded command mailbox is full.

Errors

StatusCodeWhen
400invalid_request_errorA field is missing or not valid; the message names it
400Malformed fields, ciphertext or expiry.
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
404The session, command or device does not belong to the caller.
409A device is untrusted, control is disabled or offline, the organization forbids synced content, or a command state conflicts.
410The session was deleted.
429The bounded command mailbox is full.
429rate_limit_errorToo many requests from this key in a minute

Example

curl
curl -X POST "$NEXUS_URL/v1/threads/<threadId>/commands" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "id": "<id>",
    "senderDeviceId": "<senderDeviceId>",
    "runnerDeviceId": "<runnerDeviceId>",
    "expiresAt": 1,
    "lockedKey": "<lockedKey>",
    "sealed": "<sealed>",
    "signature": "<signature>"
  }'

Get code command

get/v1/threads/{threadId}/commands/{commandId}

Read the delivery state of your own Code command

sessions.controlEvery memberTry it in the API Explorer

Parameters

  • threadIdpath · stringrequired
  • commandIdpath · string (uuid)required

Responses

200Current control or delivery state.application/json

  • idstring (uuid)required
  • senderDeviceIdstringrequired
  • runnerDeviceIdstringrequired
  • expiresAtintegerrequired
  • lockedKeystringrequired

    80 bytes of HPKE ciphertext, base64url without padding.

  • sealedstringrequired

    Encrypted action payload, base64url without padding. At most 65581 decoded bytes.

  • signaturestringrequired

    Ed25519 signature over the domain-separated command and its routing fields, base64url without padding.

  • waitsboolean

    The command may wait for a sleeping computer. Absent means false.

  • threadIdstringrequired
  • state"queued" | "claimed" | "completed" | "rejected" | "expired" | "cancelled"required

400Malformed fields, ciphertext or expiry.

403Invalid signature or a caller that is not a person.

404The session, command or device does not belong to the caller.

409A device is untrusted, control is disabled or offline, the organization forbids synced content, or a command state conflicts.

410The session was deleted.

429The bounded command mailbox is full.

Errors

StatusCodeWhen
400Malformed fields, ciphertext or expiry.
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
404The session, command or device does not belong to the caller.
409A device is untrusted, control is disabled or offline, the organization forbids synced content, or a command state conflicts.
410The session was deleted.
429The bounded command mailbox is full.
429rate_limit_errorToo many requests from this key in a minute

Example

curl
curl "$NEXUS_URL/v1/threads/<threadId>/commands/<commandId>" \
  -H "Authorization: Bearer $NEXUS_API_KEY"

Claim code command

post/v1/threads/{threadId}/commands/{commandId}/claim

Claim a Code command once before executing it

sessions.controlEvery memberTry it in the API Explorer

Parameters

  • threadIdpath · stringrequired
  • commandIdpath · string (uuid)required

Request body · application/json

  • runnerDeviceIdstringrequired
  • signaturestringrequired

Responses

200Current control or delivery state.application/json

  • claimedbooleanrequired
  • commandCodeCommandrequired
    • idstring (uuid)required
    • senderDeviceIdstringrequired
    • runnerDeviceIdstringrequired
    • expiresAtintegerrequired
    • lockedKeystringrequired

      80 bytes of HPKE ciphertext, base64url without padding.

    • sealedstringrequired

      Encrypted action payload, base64url without padding. At most 65581 decoded bytes.

    • signaturestringrequired

      Ed25519 signature over the domain-separated command and its routing fields, base64url without padding.

    • waitsboolean

      The command may wait for a sleeping computer. Absent means false.

    • threadIdstringrequired
    • state"queued" | "claimed" | "completed" | "rejected" | "expired" | "cancelled"required

400Malformed fields, ciphertext or expiry.

403Invalid signature or a caller that is not a person.

404The session, command or device does not belong to the caller.

409A device is untrusted, control is disabled or offline, the organization forbids synced content, or a command state conflicts.

410The session was deleted.

429The bounded command mailbox is full.

Errors

StatusCodeWhen
400invalid_request_errorA field is missing or not valid; the message names it
400Malformed fields, ciphertext or expiry.
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
404The session, command or device does not belong to the caller.
409A device is untrusted, control is disabled or offline, the organization forbids synced content, or a command state conflicts.
410The session was deleted.
429The bounded command mailbox is full.
429rate_limit_errorToo many requests from this key in a minute

Example

curl
curl -X POST "$NEXUS_URL/v1/threads/<threadId>/commands/<commandId>/claim" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "runnerDeviceId": "<runnerDeviceId>",
    "signature": "<signature>"
  }'

Finish code command

post/v1/threads/{threadId}/commands/{commandId}/result

Report a claimed Code command completed or rejected

sessions.controlEvery memberTry it in the API Explorer

Parameters

  • threadIdpath · stringrequired
  • commandIdpath · string (uuid)required

Request body · application/json

  • runnerDeviceIdstringrequired
  • state"completed" | "rejected"required
  • signaturestringrequired

Responses

200Current control or delivery state.application/json

  • idstring (uuid)required
  • senderDeviceIdstringrequired
  • runnerDeviceIdstringrequired
  • expiresAtintegerrequired
  • lockedKeystringrequired

    80 bytes of HPKE ciphertext, base64url without padding.

  • sealedstringrequired

    Encrypted action payload, base64url without padding. At most 65581 decoded bytes.

  • signaturestringrequired

    Ed25519 signature over the domain-separated command and its routing fields, base64url without padding.

  • waitsboolean

    The command may wait for a sleeping computer. Absent means false.

  • threadIdstringrequired
  • state"queued" | "claimed" | "completed" | "rejected" | "expired" | "cancelled"required

400Malformed fields, ciphertext or expiry.

403Invalid signature or a caller that is not a person.

404The session, command or device does not belong to the caller.

409A device is untrusted, control is disabled or offline, the organization forbids synced content, or a command state conflicts.

410The session was deleted.

429The bounded command mailbox is full.

Errors

StatusCodeWhen
400invalid_request_errorA field is missing or not valid; the message names it
400Malformed fields, ciphertext or expiry.
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
404The session, command or device does not belong to the caller.
409A device is untrusted, control is disabled or offline, the organization forbids synced content, or a command state conflicts.
410The session was deleted.
429The bounded command mailbox is full.
429rate_limit_errorToo many requests from this key in a minute

Example

curl
curl -X POST "$NEXUS_URL/v1/threads/<threadId>/commands/<commandId>/result" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "runnerDeviceId": "<runnerDeviceId>",
    "state": "completed",
    "signature": "<signature>"
  }'

Cancel code command

post/v1/threads/{threadId}/commands/{commandId}/cancel

Cancel your own Code command before a computer receives it

sessions.controlEvery memberTry it in the API Explorer

Parameters

  • threadIdpath · stringrequired
  • commandIdpath · string (uuid)required

Request body · application/json

  • senderDeviceIdstringrequired
  • signaturestringrequired

Responses

200The cancelled command, also when it was already cancelled.application/json

  • idstring (uuid)required
  • senderDeviceIdstringrequired
  • runnerDeviceIdstringrequired
  • expiresAtintegerrequired
  • lockedKeystringrequired

    80 bytes of HPKE ciphertext, base64url without padding.

  • sealedstringrequired

    Encrypted action payload, base64url without padding. At most 65581 decoded bytes.

  • signaturestringrequired

    Ed25519 signature over the domain-separated command and its routing fields, base64url without padding.

  • waitsboolean

    The command may wait for a sleeping computer. Absent means false.

  • threadIdstringrequired
  • state"queued" | "claimed" | "completed" | "rejected" | "expired" | "cancelled"required

400A malformed body.

403An invalid signature, a caller that is not a person, or a device that did not send the command (`code_command_not_sender`).

404The session or command does not belong to the caller, or Gateway has no such command (`code_command_not_found`).

409A computer already claimed the command (`code_command_not_queued`), or the device is untrusted.

410The session was deleted.

Errors

StatusCodeWhen
400invalid_request_errorA field is missing or not valid; the message names it
400A malformed body.
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
404The session or command does not belong to the caller, or Gateway has no such command (`code_command_not_found`).
409A computer already claimed the command (`code_command_not_queued`), or the device is untrusted.
410The session was deleted.
429rate_limit_errorToo many requests from this key in a minute

Example

curl
curl -X POST "$NEXUS_URL/v1/threads/<threadId>/commands/<commandId>/cancel" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "senderDeviceId": "<senderDeviceId>",
    "signature": "<signature>"
  }'

List runner code commands

get/v1/devices/{runnerDeviceId}/code-commands

Read queued encrypted commands across your runner's sessions

sessions.controlEvery memberTry it in the API Explorer

Parameters

  • runnerDeviceIdpath · stringrequired

Responses

200Current control or delivery state.application/json

  • commandsarray of CodeCommandrequired

    at most 20 items

    • idstring (uuid)required
    • senderDeviceIdstringrequired
    • runnerDeviceIdstringrequired
    • expiresAtintegerrequired
    • lockedKeystringrequired

      80 bytes of HPKE ciphertext, base64url without padding.

    • sealedstringrequired

      Encrypted action payload, base64url without padding. At most 65581 decoded bytes.

    • signaturestringrequired

      Ed25519 signature over the domain-separated command and its routing fields, base64url without padding.

    • waitsboolean

      The command may wait for a sleeping computer. Absent means false.

    • threadIdstringrequired
    • state"queued" | "claimed" | "completed" | "rejected" | "expired" | "cancelled"required

400Malformed fields, ciphertext or expiry.

403Invalid signature or a caller that is not a person.

404The session, command or device does not belong to the caller.

409A device is untrusted, control is disabled or offline, the organization forbids synced content, or a command state conflicts.

410The session was deleted.

429The bounded command mailbox is full.

Errors

StatusCodeWhen
400Malformed fields, ciphertext or expiry.
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
404The session, command or device does not belong to the caller.
409A device is untrusted, control is disabled or offline, the organization forbids synced content, or a command state conflicts.
410The session was deleted.
429The bounded command mailbox is full.
429rate_limit_errorToo many requests from this key in a minute

Example

curl
curl "$NEXUS_URL/v1/devices/<runnerDeviceId>/code-commands" \
  -H "Authorization: Bearer $NEXUS_API_KEY"