Skip to content
GitmoapAPIBeta
Agentsai-org
POST/ai-sessions/{session_id}/take-over

Take a session's work over yourself.

take_over_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"}

The session ends at its next step. The agent no longer holds the work, so nothing on its branch wakes it again, and its work item is assigned to you instead of the agent. The branch keeps what the agent pushed; what it had not pushed is lost. Refused when the session has ended. Maintainers and above of the organization's top-level group may take one over.

Parameters

Path
  • session_idAiSessionId (string · uuid)The session

Responses

200The session as it stood, and where its work isapplication/json
  • sessionAiSessionThe session, as it stood when it was taken over. It ends at its next step.
    • The AiSession schema
    • 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.
  • branchstring or nulloptionalThe agent's branch: what it pushed is there; what it had not pushed is lost.
  • repositorystring or nulloptionalThe repository the work is in, as an address.
200 exampleSynthesized example
{
"session": {
"cost_micros": 28,
"created_at": "2026-10-13T01:51:29Z",
"org_id": "c8b54e1c-2472-4b1e-a4d9-19b7fa1d55fc",
"root_group_id": "4c1d8e2f-6a3b-4f90-b7c5-1e2d3c4b5a69",
"session_id": "d9b7ec45-77b9-4d8e-962a-cd686ded1377",
"state": "queued",
"subject": {
"address": "address-6619",
"started_by": "a3f1c2d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d"
},
"trigger_kind": "assignment",
"turns": 25,
"agent_id": "2a893aa4-b100-4880-86f7-2e711361a61c",
"branch": "feature/region-legend",
"ended_at": "2026-10-15T12:16:15Z",
"instruction": "instruction-bd09",
"model_id": "aefd8a05-ea1d-4d3f-946a-f4b0478451d0",
"outcome": "merge_request_opened",
"repository_id": "5b0e7c2a-9d14-4e8b-a6f1-2c3d4e5f6a70",
"revision_number": 65,
"started_at": "2026-10-16T04:52:42Z",
"summary": "summary-d5f5"
},
"branch": "fix/payload-build-pin",
"repository": "repository-467f"
}
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-ff73",
"message": "Draw the region map from operation density"
}
}
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-85ec",
"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-8d25",
"message": "Inline scalar newtypes but keep their brand"
}
}
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-284c",
"message": "Inline scalar newtypes but keep their brand"
}
}
409The session has endedapplication/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-44e6",
"message": "Inline scalar newtypes but keep their brand"
}
}

CLI

gitmoap ai-org take-over-ai-session

  • --session-ididThe session