Skip to content

Sessions

End one of your sessions, with an optional reason and result (what it reported when it finished: a subagent's final message, up to 8,000 characters, never a tool's output).

POST/repos/{owner}/{name}/sessions/{id}/end

A session.ended event. Ending one already ended returns it as it is, taking result if it had none. Its subagents still going end with it (parent ended). Its claims are not released: release them, hand the issue off, or let them expire.

Name Type Required Description
owner string Yes The workspace that owns the repository.
name string Yes The repository’s name.
id string Yes The session’s id (ses_…), from start_session or list_sessions.

Send a JSON object. Names are snake_case, as in responses; the camelCase spelling is accepted too.

Name Type Required Description
reason string No Why it ended, in a few words. “ended” if left out.
result string No What it reported when it finished: a subagent’s final message. Kept up to 8,000 characters. Never a tool’s output.
curl -X POST https://api.g1t.sh/repos/flagon-io/hello/sessions/id/end \
-H "Authorization: Bearer $G1T_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"reason": "done"
}'

A successful request answers 200 with:

{
"id": "ses_01m4b2c3d4e5f6g7h8j9k0m1n2",
"repo_id": "rep_01m3m5q6p0e2qaw6mmjahk0qrr",
"issue": 12,
"pull": 14,
"branch": "greet-caller",
"actor": {
"id": "usr_01kkntcg1eeb98j62xjm7eh09p",
"username": "syntaqx"
},
"harness": "claude_code",
"harness_session_id": "5b0c1f9e-3d2a-4e8b-9f61-0c7d2a9e4b13",
"title": "Make the greeting name the caller",
"state": "ended",
"head_commit": "9f2c4e1a7b3d5f60812a4c6e8b0d2f4a6c8e0b13",
"started_at": "2026-10-12T14:02:11.204Z",
"last_seen_at": "2026-10-12T14:40:03.115Z",
"ended_at": "2026-10-12T14:40:03.115Z",
"end_reason": "done"
}

A failed request answers with one of these statuses and a body like {"error": {"code": "not_found", "message": "Repository not found."}}. See errors.

Status Code When
401 unauthenticated A token is required, or the one sent is not valid.
403 forbidden The token is valid but not allowed to do this, such as a member-only change, or a token without the scope it needs.
404 not_found It does not exist, or you cannot see it.
409 conflict The request conflicts with the current state.
422 invalid The input is not valid. message says which field and why.