API

AgentRepository

Operations

Every route this entity exposes. Each route links to its own reference on this page.

Method Route SDK operation Returns
GET /api/v1/organizations/{organization_id}/agents/{id}/spark/repositories load Repository grants, editor choices and optimistic version
POST /api/v1/organizations/{organization_id}/agents/{id}/spark/repositories/{repository}/environment update What this call prepared. A build still running at the default branch head is building even while thread sandboxes start from an earlier ready revision, which the repositories read shows. Repeated calls reuse the same revision, running setup run or running branch check
PUT /api/v1/organizations/{organization_id}/agents/{id}/spark/repositories update Repository grants, editor choices and optimistic version

Examples

One example per SDK, generated from the API model. The argument names are the parameters and fields of this entity, and the values are placeholders. The examples are not compiled or executed.

Golang

Construct client as shown in the Golang setup, then call the operations:

agent_repository, err := client.AgentRepository(nil).Load(map[string]any{"agent_id": "example", "organization_id": "example"}, nil)
if err != nil {
    panic(err)
}
fmt.Println(agent_repository)
updated, err := client.AgentRepository(nil).Update(map[string]any{"agent_id": "example", "organization_id": "example"}, nil)
if err != nil {
    panic(err)
}
fmt.Println(updated)

Lua

Construct client as shown in the Lua setup, then call the operations:

local agent_repository, err = client:AgentRepository():load({ agent_id = "example", organization_id = "example" })
local updated, err = client:AgentRepository():update({ agent_id = "example", organization_id = "example" })

PHP

Construct client as shown in the PHP setup, then call the operations:

$agent_repository = $client->AgentRepository()->load(["agent_id" => "example", "organization_id" => "example"]);
$updated = $client->AgentRepository()->update(["agent_id" => "example", "organization_id" => "example"]);

Python

Construct client as shown in the Python setup, then call the operations:

agent_repository = client.AgentRepository().load({"agent_id": "example", "organization_id": "example"})
updated = client.AgentRepository().update({"agent_id": "example", "organization_id": "example"})

Ruby

Construct client as shown in the Ruby setup, then call the operations:

agent_repository = client.AgentRepository.load({ "agent_id" => "example", "organization_id" => "example" })
updated = client.AgentRepository.update({ "agent_id" => "example", "organization_id" => "example" })

TypeScript

Construct client as shown in the TypeScript setup, then call the operations:

const agent_repository = await client.AgentRepository().load({ agent_id: "example", organization_id: "example" })
const updated = await client.AgentRepository().update({ agent_id: "example", organization_id: "example" })

Fields

Field Type Required Description
can_manage boolean Yes Can Manage
environments object Yes Sandbox environment per granted repository ID, shared by every bot granted that repository.
expected_version integer Yes Expected Version
id string No Id
repository_choices array Yes Repository Choices
repository_choices_error one,string,null No GitHub discovery warning.
repository_choices_truncated boolean Yes Repository Choices Truncated
version integer Yes Version
work_repositories array Yes Work Repositories

load

GET /api/v1/organizations/{organization_id}/agents/{id}/spark/repositories

Operation ID: spark_repositories_api_v1_organization_persistent_agent.

Authentication: bearer token (bearerAuth).

Parameters

Parameter In Type Required Description
organization_id path string Yes
id path string Yes
q query string No

Responses

200: Repository grants, editor choices and optimistic version

application/json

Property Type Required Description
can_manage boolean Yes
environments object Yes Sandbox environment per granted repository ID, shared by every bot granted that repository.
repository_choices array of object Yes
repository_choices[].available boolean Yes
repository_choices[].id string Yes
repository_choices[].name string,null Yes
repository_choices[].slug string,null Yes
repository_choices_error string,null No GitHub discovery warning. Saved grants and known local repository choices remain available.
repository_choices_truncated boolean Yes
version integer Yes
work_repositories array of object Yes
work_repositories[].exclude_default_branch boolean No With write permission, exclude the current default branch. Defaults to false.
work_repositories[].permission enum: read, write No Defaults to write when omitted.
work_repositories[].repository_id string Yes
work_repositories[].write_branches array of string No Exact branches allowed for writes. Empty or omitted allows all branches, subject to exclude_default_branch and normal repository protections.
401: Unauthorized
403: Agent management authority required
404: Agent not found or disabled
409: Configuration changed; read current version
422: Invalid repository selection
502: Bad gateway

update

POST /api/v1/organizations/{organization_id}/agents/{id}/spark/repositories/{repository}/environment

Operation ID: post_api_v1_organizations_organization_id_agents_id_spark_repositories_repository_environment.

Authentication: bearer token (bearerAuth).

Parameters

Parameter In Type Required Description
organization_id path string Yes
id path string Yes
repository path string Yes

Request body

application/json

Property Type Required Description
branch string No A branch other than the default one. The bot builds the recipe on it and checks the image on a fresh machine, on a thread it reports in. Nothing is promoted, so thread sandboxes keep their current environment.

Responses

202: What this call prepared. A build still running at the default branch head is building even while thread sandboxes start from an earlier ready revision, which the repositories read shows. Repeated calls reuse the same revision, running setup run or running branch check

application/json

Property Type Required Description
environment object Yes
environment.can_check_branch boolean No Whether this person can check this repository's environment recipe on a branch through Prepare. Needs a bot they manage and only they can use, in an organization with sandbox threads. Only in the repositories read.
environment.can_prepare boolean Yes Whether this person can start preparing the environment now. False while it is preparing, building or ready, unless a ready environment has a failed_update, and for people who cannot manage the bot.
environment.failed_update object No Only when ready. The repository's newest recipe on its default branch failed to build, so threads still start from the ready revision. Prepare builds it again.
environment.failed_update.failure_code string No
environment.failed_update.revision_id string Yes
environment.failure_code string No
environment.revision_id string No
environment.setup object No The latest setup run until a recipe revision exists, only when this bot ran it; other bots see the status alone. Prepare with a branch answers with the branch check it started.
environment.setup.branch string No The branch a check builds and proves. Only in the answer to the Prepare that started the check; the repositories read never shows a check.
environment.setup.conversation_id string No The setup or check thread's conversation, once it started
environment.setup.failed_step string No
environment.setup.failure_reason string No
environment.setup.pull_request_url string No
environment.status enum: none, preparing, building, failed, awaiting_trunk, unsupported, ... Yes none has no recipe build yet; preparing is a setup run writing the recipe; unsupported declares something bots cannot use, such as secrets; ready is the promoted revision thread sandboxes start from.
401: Unauthorized
403: Agent management authority required
404: Agent or granted repository not found
409: The setup thread could not start, for example at the thread sandbox limit
422: The recipe is invalid, setup needs a private bot, write access and a GitHub connection, the branch was not found, or another setup run or branch check holds the repository
429: Too many prepare requests; wait before preparing again
503: The bot's runtime is unavailable; retry after Retry-After

PUT /api/v1/organizations/{organization_id}/agents/{id}/spark/repositories

Operation ID: put_api_v1_organizations_organization_id_agents_id_spark_repositories.

Authentication: bearer token (bearerAuth).

Parameters

Parameter In Type Required Description
organization_id path string Yes
id path string Yes

Request body

application/json

Property Type Required Description
expected_version integer Yes
work_repositories array of object Yes
work_repositories[].exclude_default_branch boolean No With write permission, exclude the current default branch. Defaults to false.
work_repositories[].permission enum: read, write No Defaults to write when omitted.
work_repositories[].repository_id string Yes
work_repositories[].write_branches array of string No Exact branches allowed for writes. Empty or omitted allows all branches, subject to exclude_default_branch and normal repository protections.

Responses

200: Repository grants, editor choices and optimistic version

application/json

Property Type Required Description
can_manage boolean Yes
environments object Yes Sandbox environment per granted repository ID, shared by every bot granted that repository.
repository_choices array of object Yes
repository_choices[].available boolean Yes
repository_choices[].id string Yes
repository_choices[].name string,null Yes
repository_choices[].slug string,null Yes
repository_choices_error string,null No GitHub discovery warning. Saved grants and known local repository choices remain available.
repository_choices_truncated boolean Yes
version integer Yes
work_repositories array of object Yes
work_repositories[].exclude_default_branch boolean No With write permission, exclude the current default branch. Defaults to false.
work_repositories[].permission enum: read, write No Defaults to write when omitted.
work_repositories[].repository_id string Yes
work_repositories[].write_branches array of string No Exact branches allowed for writes. Empty or omitted allows all branches, subject to exclude_default_branch and normal repository protections.
401: Unauthorized
403: Agent management authority required
404: Agent not found or disabled
409: Configuration changed; read current version
422: Invalid repository selection
502: Bad gateway