Skip to content
GitmoapAPIBeta
Agentsai-org
POST/ai-agents/{agent_id}/sessions

Start an agent on a subject. The session is queued until the organization can run it.

start_ai_session
  • ai_org:manage
    A token needs the ai_org:manage scope: Configure and operate an AI organization: drafts, pausing, suspending, sessionsGranted by write_api.Every operation this scope unlocks
  • Audited · mutation

    x-gitmoap-audit: {"kind":"audited","arg":"mutation"}

  • Quota · ai sessions per org per day

    x-gitmoap-quota: {"kind":"enforced","arg":"ai_sessions_per_org_per_day"}

Give the agent an instruction and, optionally, the address of what to work on (1 to 255 characters). The session starts when the organization, the agent, its limits and the balance allow. Refused when no revision has been published or the agent is not active, and the number of sessions started per day is capped. Maintainers and above of the organization's top-level group may start one.

Parameters

Path
  • agent_idAgentId (string · uuid)The agent

Request body

application/json
  • instructionSessionInstruction (string)
  • subjectstring or nulloptionalThe address the work is about — acme/api#412 — when there is one.
Request body exampleSynthesized example
{
"instruction": "instruction-0a8d"
}

Responses

201The session, queuedapplication/json
  • cost_microsinteger · int64Settled spend, fee included, in micro-dollars.
  • created_atstring · date-time
  • org_idAiOrgId (string · uuid)
  • root_group_idGroupId (string · uuid)The top-level group whose organization it ran in.
  • session_idAiSessionId (string · uuid)
  • stateAiSessionStatequeuedrunningwaiting_gatewaiting_personcompletedfailedcancelledhalted
  • subjectSessionSubject
    • The SessionSubject schema
    • addressstring or nulloptionalThe address acted on — acme/api#412, acme/api!87 — when the session has one.
    • started_bystring or nulloptionalThe person or account whose action started the session, when one did.
  • trigger_kindAiTriggerKindassignmentreview_requestreview_feedbackmentionchannel_messageritualpipeline_failuretracker_eventgate_decisionhandoffcontinuationproposalmanualprofile_draftWhat started a session.
  • turnsinteger · int32
  • agent_idAgentId (string · uuid) or nulloptional
  • branchstring or nulloptional
  • ended_atstring · date-time or nulloptional
  • instructionSessionInstruction (string) or nulloptional
  • model_idAiModelKey (string) or nulloptional
  • outcomeAiSessionOutcomemerge_request_openedreview_submittedwork_item_updatedmessage_postedproposal_writtenescalatedno_actionbudget_exhaustedrefusederrortaken_overor nulloptional
  • repository_idRepositoryId (string · uuid) or nulloptionalThe repository the session works on, when it works on one.
  • revision_numberinteger · int64 or nulloptionalThe revision it pinned at start; absent only for a platform session started before any revision was published.
  • started_atstring · date-time or nulloptional
  • summarystring or nulloptionalThe agent's own account of the session.
201 exampleSynthesized example
{
"cost_micros": 46,
"created_at": "2026-10-16T12:38:25Z",
"org_id": "d5e79c56-330e-46e4-9968-176f2823e450",
"root_group_id": "4c1d8e2f-6a3b-4f90-b7c5-1e2d3c4b5a69",
"session_id": "e0873dbf-5edd-4ace-8317-c02e88f73a3c",
"state": "queued",
"subject": {
"address": "address-382d",
"started_by": "c9d8e7f6-a5b4-4c3d-9e2f-1a0b9c8d7e6f"
},
"trigger_kind": "assignment",
"turns": 86,
"agent_id": "d305ae48-1895-4052-9281-ee67b4ab71c2",
"branch": "feature/region-legend",
"ended_at": "2026-10-15T05:15:16Z",
"instruction": "instruction-9ac6",
"model_id": "e6b98120-6c83-4f6c-8974-457113e1aa63",
"outcome": "merge_request_opened",
"repository_id": "5b0e7c2a-9d14-4e8b-a6f1-2c3d4e5f6a70",
"revision_number": 34,
"started_at": "2026-10-11T18:50:34Z",
"summary": "summary-4467"
}
400Bad request — a path parameter is not a well-formed value of its typeapplication/json
Error codes
  • BAD_REQUESTThe request is malformed: a parameter or a body field is not a well-formed value of its type
  • errorErrorBody
    • The ErrorBody schema
    • codestringThe coarse category, tied to the status: NOT_FOUND, CONFLICT, INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all.
    • messagestringWhat went wrong, for a person. Written to be read, not parsed: match on reason or code.
    • fieldstring or nulloptionalOn a 400 that refused one field's value, the field, as its JSON path: email, items[0].name. Put the message under that input. Absent on every other error.
    • reasonstring or nulloptionalThe specific code, when the error has one: LAST_ORGANIZATION_OWNER, BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and on code otherwise.
    • required_scopestring or nulloptionalThe scope the access token was missing, on INSUFFICIENT_SCOPE.
    • violationsanyoptionalPresent on the structured-validation errors (PROVIDER_VALIDATION_FAILED per-node, PIPELINE_VALIDATION_FAILED DAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
400 exampleSynthesized example
{
"error": {
"code": "code-39ee",
"message": "Pin a page's payload to the build that rendered it"
}
}
401Unauthenticated — no credential, or an invalid oneapplication/json
Error codes
  • UNAUTHORIZEDNo credential was sent, or the one sent is invalid, expired or revoked
  • errorErrorBody
    • The ErrorBody schema
    • codestringThe coarse category, tied to the status: NOT_FOUND, CONFLICT, INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all.
    • messagestringWhat went wrong, for a person. Written to be read, not parsed: match on reason or code.
    • fieldstring or nulloptionalOn a 400 that refused one field's value, the field, as its JSON path: email, items[0].name. Put the message under that input. Absent on every other error.
    • reasonstring or nulloptionalThe specific code, when the error has one: LAST_ORGANIZATION_OWNER, BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and on code otherwise.
    • required_scopestring or nulloptionalThe scope the access token was missing, on INSUFFICIENT_SCOPE.
    • violationsanyoptionalPresent on the structured-validation errors (PROVIDER_VALIDATION_FAILED per-node, PIPELINE_VALIDATION_FAILED DAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
401 exampleSynthesized example
{
"error": {
"code": "code-a2be",
"message": "Draw the region map from operation density"
}
}
403Forbidden — the caller's access level or token scope is insufficientapplication/json
Error codes
  • FORBIDDENYou are signed in but may not do this here; reason names the permission or the rule that refused it
  • INSUFFICIENT_SCOPEThe access token lacks the scope this operation needs; required_scope names it
  • PERMISSION_REQUIREDYou need a permission you do not hold here; the message names it
  • errorErrorBody
    • The ErrorBody schema
    • codestringThe coarse category, tied to the status: NOT_FOUND, CONFLICT, INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all.
    • messagestringWhat went wrong, for a person. Written to be read, not parsed: match on reason or code.
    • fieldstring or nulloptionalOn a 400 that refused one field's value, the field, as its JSON path: email, items[0].name. Put the message under that input. Absent on every other error.
    • reasonstring or nulloptionalThe specific code, when the error has one: LAST_ORGANIZATION_OWNER, BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and on code otherwise.
    • required_scopestring or nulloptionalThe scope the access token was missing, on INSUFFICIENT_SCOPE.
    • violationsanyoptionalPresent on the structured-validation errors (PROVIDER_VALIDATION_FAILED per-node, PIPELINE_VALIDATION_FAILED DAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
403 exampleSynthesized example
{
"error": {
"code": "code-12d7",
"message": "Stream pipeline status into the run header"
}
}
404Not found — or found and private, which is masked as absentapplication/json
Error codes
  • NOT_FOUNDThe resource does not exist — or exists and you cannot see it: a private resource you have no access to answers exactly as an absent one does
  • errorErrorBody
    • The ErrorBody schema
    • codestringThe coarse category, tied to the status: NOT_FOUND, CONFLICT, INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all.
    • messagestringWhat went wrong, for a person. Written to be read, not parsed: match on reason or code.
    • fieldstring or nulloptionalOn a 400 that refused one field's value, the field, as its JSON path: email, items[0].name. Put the message under that input. Absent on every other error.
    • reasonstring or nulloptionalThe specific code, when the error has one: LAST_ORGANIZATION_OWNER, BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and on code otherwise.
    • required_scopestring or nulloptionalThe scope the access token was missing, on INSUFFICIENT_SCOPE.
    • violationsanyoptionalPresent on the structured-validation errors (PROVIDER_VALIDATION_FAILED per-node, PIPELINE_VALIDATION_FAILED DAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
404 exampleSynthesized example
{
"error": {
"code": "code-30d6",
"message": "Stream pipeline status into the run header"
}
}
409No revision is published, or the agent takes no new workapplication/json
Error codes
  • CONFLICTThe request conflicts with the resource's current state; reason says how
  • LEGAL_ACCEPTANCE_REQUIREDAccept the current Terms of Service before changing anything; reading stays open
  • errorErrorBody
    • The ErrorBody schema
    • codestringThe coarse category, tied to the status: NOT_FOUND, CONFLICT, INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all.
    • messagestringWhat went wrong, for a person. Written to be read, not parsed: match on reason or code.
    • fieldstring or nulloptionalOn a 400 that refused one field's value, the field, as its JSON path: email, items[0].name. Put the message under that input. Absent on every other error.
    • reasonstring or nulloptionalThe specific code, when the error has one: LAST_ORGANIZATION_OWNER, BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and on code otherwise.
    • required_scopestring or nulloptionalThe scope the access token was missing, on INSUFFICIENT_SCOPE.
    • violationsanyoptionalPresent on the structured-validation errors (PROVIDER_VALIDATION_FAILED per-node, PIPELINE_VALIDATION_FAILED DAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
409 exampleSynthesized example
{
"error": {
"code": "code-2c40",
"message": "Draw the region map from operation density"
}
}
429Session limit reached for todayapplication/json
Error codes
  • TOO_MANY_REQUESTSRetryableA quota, a rate limit or a transfer budget is spent. When the response carries Retry-After, retry after that many seconds
  • errorErrorBody
    • The ErrorBody schema
    • codestringThe coarse category, tied to the status: NOT_FOUND, CONFLICT, INSUFFICIENT_SCOPE. Every error has one; the API reference's error catalogue lists them all.
    • messagestringWhat went wrong, for a person. Written to be read, not parsed: match on reason or code.
    • fieldstring or nulloptionalOn a 400 that refused one field's value, the field, as its JSON path: email, items[0].name. Put the message under that input. Absent on every other error.
    • reasonstring or nulloptionalThe specific code, when the error has one: LAST_ORGANIZATION_OWNER, BRANCH_PROTECTED. The message starts with it too. Match on this when it is present, and on code otherwise.
    • required_scopestring or nulloptionalThe scope the access token was missing, on INSUFFICIENT_SCOPE.
    • violationsanyoptionalPresent on the structured-validation errors (PROVIDER_VALIDATION_FAILED per-node, PIPELINE_VALIDATION_FAILED DAG): a JSON array of the offending elements, so a caller can fix every one in a single round-trip. Absent (omitted) on every other error.
429 exampleSynthesized example
{
"error": {
"code": "code-63d8",
"message": "Draw the region map from operation density"
}
}

CLI

gitmoap ai-org start-ai-session

  • --agent-ididThe agent
  • --instructionstring
  • --subjectstringoptionalThe address the work is about — `acme/api#412` — when there is one.