Create coding

Runs a coding task on a repository: clones it into a sandbox, lets a model read and edit the code, run the tests, and push the work to a branch.

POST /v1/agent/coding

Addresshttps://api.hanzo.ai/v1/agent/coding
MethodPOST
Operationpost_agent_coding
AuthAuthorization: Bearer $HANZO_API_KEY

Runs a coding task on a repository: clones it into a sandbox, lets a model read and edit the code, run the tests, and push the work to a branch. Say the thing you want done — "fix the failing auth test in hanzoai/cloud" — and the run infers the repo, the branch and the plan. No prefix, no ceremony.

Name no repo and the run works in an empty workspace of its own: nothing is cloned and nothing is pushed, and what it makes is kept in its sandbox and as its artifacts. Name a repository the caller can read and not push to — a public one — and it is cloned read-only, the same way.

It answers 202 with the run's handle the moment the run is ADMITTED — not when it finishes. A coding run takes minutes; holding a request open for one would tie a connection to a model loop and give the caller nothing it cannot get better from the session stream.

The handle is a session id, and that is deliberate: the session is already the run's durable record and its live stream (/v1/agent/sessions/stream?root=<id>), so this op does not grow a progress endpoint, a status endpoint or a cancel endpoint of its own. One way to watch a run, whoever started it.

It is also how work CONTINUES. Pass an earlier run's session as after and this one starts from where that one stopped, so "now add tests for it" builds on the branch already pushed instead of a fresh clone. The follow-up still gets its own branch and its own session — one run, one branch, always reviewable on its own.

Request

21 fields, body application/json (required).

FieldInTypeRequiredDescription
afterbodystring—After names a previous run's session, and starts this one from where that one stopped instead of from the repository's default.
agentRefbodystring—AgentRef names a configured agent to run as, which is how an org pins a harness, a model and a prompt to a name.
basebodystring—Base is the branch to start from.
desktopbodyboolean—Desktop asks for a run with a SCREEN — an image carrying an X server — for a task that has to drive a browser or another windowed program.
effortbodystring—Effort is how hard that model reasons: low, medium or high.
issuebodyinteger (int64)—Issue is the number of the issue on Repo this run resolves.
modebodystring—Mode is what the run may do to the repository: build edits, commits and pushes its branch; plan reads the repository and answers with a plan, writing nothing — its sandbox is handed a credential that can only read and no push step runs, and the plan arrives as the run's final status.
modelbodystring—Model is the model the run's agent thinks with, by the id GET /v1/models lists.
projectbodystring—Project scopes the run to one board's work when the org keeps more than one.
promptbodystring—Prompt is the task, in the words you would use with a colleague who has the checkout open.
replybodyagent.Reply—
reply.channelbodystring—Channel is the room inside that workspace, and it is what decides whether there is an address at all.
reply.providerbodystring—Provider is the transport the conversation is on — slack, discord, telegram, teams — and it is what decides who can carry the text at all.
reply.threadbodystring—Thread narrows the address to one thread inside the channel — on Slack the parent message's ts, the same value a reply carries as thread_ts.
reply.turnbodystring—Turn is the turn that renders a run started here: the session whose one message the run's progress and its outcome are shown in.
reply.userbodystring—User is the platform's id for the person the conversation is with — whose run it is.
repobodystring—Repo is what to work on: a repository's name, owner/name in the caller's own org, or the site a repository serves (hanzo.ai), as the person said it.
targetIdbodystring—TargetID routes the run to a registered machine the org has claimed instead of to a sandbox in our cluster.
taskbodystring—Task is Prompt under the name a caller asking for work tends to reach for.
timeoutSecondsbodyinteger (int64)—TimeoutSeconds bounds the whole run.
toolbodystring—Tool is which harness runs the prompt — dev | claude | codex | python | node — and Desktop is whether the run needs a screen.

Response

StatusBodyMeaning
202agent.CodingStartedaccepted
defaultproblem-detailsrefused

202 body — 5 fields.

FieldInTypeAlwaysDescription
branchbodystring—Branch is the ref the run will push its work to, and the ONLY ref it is permitted to write.
repobodystring—Repo is the repository the run was admitted against, echoed back as the engine resolved it.
routedbodyboolean—Routed says the run went to one of the org's own registered machines rather than to a sandbox in our cluster.
sessionIdbodystring—SessionID is the run's handle: its durable record, and the root its live progress streams under at /v1/agent/sessions/stream?root=<sessionId>.
targetIdbodystring—TargetID names that machine when Routed is true, and is empty otherwise.

Failure carries the platform error shape — see Errors.

Examples

hanzo agent coding
import { Configuration, AgentApi } from 'hanzoai';

const api = new AgentApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postAgentCoding({ after: "<after>", agentRef: "<agentRef>" });
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import AgentApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = AgentApi(client).post_agent_coding(after="<after>", agent_ref="<agentRef>")
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.AgentAPI.PostAgentCoding(context.Background()).Execute()
if err != nil {
	return err
}
use hanzo_client::apis::{configuration::Configuration, agent_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = agent_api::post_agent_coding(&cfg, Default::default()).await?;
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.AgentApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new AgentApi(client).postAgentCoding();
curl -X POST https://api.hanzo.ai/v1/agent/coding \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "after": "<after>",
       "agentRef": "<agentRef>"
     }'

MCP reaches agent through the agent tool, which names its 38 operations with its own verbs — this one among them, under a name only MCP declares. describe explains any of them:

curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "describe",
         "arguments": {
           "op": "list_agents"
         }
       }
     }'

Agent API · All Hanzo APIs · Interactive reference

Was this page useful?