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

API reference

Fix runs

Fix runs, for @nexus fix this: Gateway fixes one GitHub issue in a throwaway cloud sandbox on Nexus's provider account and opens the pull request as the person's agent. The run reads the issue and the repository through the GitHub connector, runs the coding agent's turns through Gateway, and runs every command in the sandbox with no network and no credential. It opens the pull request with github/pull_create through the person's agents' writes, so only an agent link starts one. A run is a job: its state and its pull request are read at GET /v1/cloud/runs/{id}. The sandbox is charged as cloud compute. Rust only.

View as Markdown

Create cloud run

post/v1/cloud/runs

Start a fix run for one issue of a GitHub repository, as the calling agent link. Gateway reads the issue and the repository at its default branch through the GitHub connector, runs the coding agent in a cloud sandbox, and opens a pull request that closes the issue with github/pull_create. The organization must have agent writes on with github.pull_create on its allowlist, and the person their own agents' writes on; otherwise the run fails with write_not_granted, chat_writes_off or operation_not_allowed and opens nothing. Send an Idempotency-Key: the run's id is derived from it, so a resend answers the run the first send started.

cloud.runs.useEvery memberTry 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

  • repostringrequired

    https://github.com/<owner>/<name>

  • issueintegerrequired

    The issue's number

    min 1

Responses

200The run a send with this key startedapplication/json

  • idstringrequired

    The run's job id (job_…)

  • state"accepted" | "running" | "done" | "failed" | "cancelled"required
  • repostringrequired
  • issueintegerrequired
  • pullRequestobject | nullrequired

    The pull request the run opened, once it is done

    • numberintegerrequired
    • urlstringrequired
  • errorobject | nullrequired

    Why the run failed, once it failed: write_not_granted, chat_writes_off or operation_not_allowed (the pull request write), no_change, agent_stopped, repo_too_large, link_ended, budget_exceeded and others

    • codestringrequired
    • messagestringrequired
  • createdAtstring (date-time)required
  • updatedAtstring (date-time)required

202Accepted: the run waits for the job workerapplication/json

  • idstringrequired

    The run's job id (job_…)

  • state"accepted" | "running" | "done" | "failed" | "cancelled"required
  • repostringrequired
  • issueintegerrequired
  • pullRequestobject | nullrequired

    The pull request the run opened, once it is done

    • numberintegerrequired
    • urlstringrequired
  • errorobject | nullrequired

    Why the run failed, once it failed: write_not_granted, chat_writes_off or operation_not_allowed (the pull request write), no_change, agent_stopped, repo_too_large, link_ended, budget_exceeded and others

    • codestringrequired
    • messagestringrequired
  • createdAtstring (date-time)required
  • updatedAtstring (date-time)required

400The body is not `{ repo, issue }`, `repo` is not a GitHub repository's URL (`invalid_repo`), `issue` is 0 (`invalid_issue`), or the `Idempotency-Key` is missing.

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

403The credential is not an agent link (`agent_link_required`): a person's own key reads runs but never starts one. Or the link does not hold `cloud.runs.use` (`role_required`), or the organization may not run cloud compute (`cloud_not_enabled`).

422This `Idempotency-Key` named another run (`idempotency_key_reused`).

429The person has two runs going (`fix_runs_busy`); try again after `Retry-After`.

503Fix runs are off on this Gateway (`fix_runs_unavailable`): they need `NEXUS_FIX_RUNS=on`, a provider account (`BOAT_API_KEY`), the job worker (`NEXUS_JOB_WORKER`) and a database. The route still mounts.

Errors

StatusCodeWhen
400invalid_request_errorA field is missing or not valid; the message names it
400The body is not `{ repo, issue }`, `repo` is not a GitHub repository's URL (`invalid_repo`), `issue` is 0 (`invalid_issue`), or the `Idempotency-Key` is missing.
401authentication_errorNo key, or a key Gateway does not accept
402budget_exceededNothing covers 15 minutes of the run's sandbox (`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` named another run (`idempotency_key_reused`).
422idempotency_key_reusedThe Idempotency-Key was used with a different request
429The person has two runs going (`fix_runs_busy`); try again after `Retry-After`.
429rate_limit_errorToo many requests from this key in a minute
503Fix runs are off on this Gateway (`fix_runs_unavailable`): they need `NEXUS_FIX_RUNS=on`, a provider account (`BOAT_API_KEY`), the job worker (`NEXUS_JOB_WORKER`) and a database. The route still mounts.

Example

curl
curl -X POST "$NEXUS_URL/v1/cloud/runs" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "repo": "https://github.com/nexus-demo/hello-factory",
    "issue": 1
  }'

Get cloud run

get/v1/cloud/runs/{id}

A fix run of the caller's person: its state, its pull request once it is done, and why it failed once it failed. Another person's run is a 404, as a missing one is.

cloud.runs.useEvery memberTry it in the API Explorer

Parameters

  • idpath · stringrequired

    The run's id (job_…).

Responses

200The runapplication/json

  • idstringrequired

    The run's job id (job_…)

  • state"accepted" | "running" | "done" | "failed" | "cancelled"required
  • repostringrequired
  • issueintegerrequired
  • pullRequestobject | nullrequired

    The pull request the run opened, once it is done

    • numberintegerrequired
    • urlstringrequired
  • errorobject | nullrequired

    Why the run failed, once it failed: write_not_granted, chat_writes_off or operation_not_allowed (the pull request write), no_change, agent_stopped, repo_too_large, link_ended, budget_exceeded and others

    • codestringrequired
    • messagestringrequired
  • createdAtstring (date-time)required
  • updatedAtstring (date-time)required

404No such run of the caller's person (`not_found`).

503Fix runs are off on this Gateway (`fix_runs_unavailable`): they need `NEXUS_FIX_RUNS=on`, a provider account (`BOAT_API_KEY`), the job worker (`NEXUS_JOB_WORKER`) and a database. The route still mounts.

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 run of the caller's person (`not_found`).
429rate_limit_errorToo many requests from this key in a minute
503Fix runs are off on this Gateway (`fix_runs_unavailable`): they need `NEXUS_FIX_RUNS=on`, a provider account (`BOAT_API_KEY`), the job worker (`NEXUS_JOB_WORKER`) and a database. The route still mounts.

Example

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