API REFERENCE
Create Session
On this page
/api/sessionsCreates a new agent session and an initial empty chat in a single transaction. The session is created in the provisioning lifecycle state — a separate orchestration step claims it and starts the sandbox.
Authentication
x-api-key in header
BearerAuth bearer
Request
curl --request POST \
--url 'https://api.recoupable.dev/api/sessions' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"title": "string",
"organizationId": "YOUR_ID",
"artistId": "YOUR_ID"
}'Request body
application/json
titlestringDisplay title for the session. When omitted, the server generates one.
organizationIdstringRecoupable organization id. When provided, the session is created against the org's workspace repo (recoupable/<organizationId>) and the caller must have access to that organization. When omitted, the session is personal and uses the caller's own workspace repo (recoupable/<accountId>).
format: uuid
artistIdstringArtist account id to associate the session with. When provided, the session is created in the context of that artist — used by the chat sidebar to filter chats by artist. Optional; omit for a session with no artist context.
format: uuid
Responses
200Session and initial chat created successfully.+
application/json
sessionobjectrequiredAgent session returned by POST /api/sessions, GET /api/sessions/{sessionId}, and PATCH /api/sessions/{sessionId}. The api serializes every field listed in required on each response, including isNewBranch (boolean, from the non-null sessions.is_new_branch column) and artistId (UUID or null).
Properties for session
idstringrequiredSession id (nanoid).
userIdstringrequiredOwning account id. Named userId here for compatibility with existing clients; on the server side this is the account_id foreign key into the accounts table.
format: uuid
titlestringrequiredstatusstring · enumrequiredValues: "running", "completed", "failed", "archived"
repoOwnerstringnullableGitHub repo owner if the session is bound to a repository.
repoNamestringnullablebranchstringnullablecloneUrlstringnullableClone URL the sandbox should fetch from.
isNewBranchbooleanrequiredAlways present on session responses. True when this session created and pushed a new branch (not committing back to the original); false otherwise.
globalSkillRefsarray<object>requiredSkills attached to the agent at provision time.
Item properties for globalSkillRefs
object
Additional properties
Additional keys are allowed.
sandboxStateobjectnullableSandbox runtime state (Vercel Sandbox).
lifecycleStatestring · enumnullableLifecycle orchestration state for the sandbox.
Values: "provisioning", "active", "hibernating", "hibernated", "restoring", "archived", "failed"
lifecycleVersionintegerrequiredOptimistic concurrency token for lifecycle transitions.
lastActivityAtstringnullableformat: date-time
sandboxExpiresAtstringnullableformat: date-time
hibernateAfterstringnullableformat: date-time
lifecycleRunIdstringnullablelifecycleErrorstringnullablelinesAddedintegernullableLines added across the session's diff. Defaults to 0; null when stats have not been computed.
linesRemovedintegernullableLines removed across the session's diff. Defaults to 0; null when stats have not been computed.
snapshotUrlstringnullablesnapshotCreatedAtstringnullableformat: date-time
snapshotSizeBytesintegernullablecachedDiffobjectnullablecachedDiffUpdatedAtstringnullableformat: date-time
createdAtstringrequiredformat: date-time
updatedAtstringrequiredformat: date-time
artistIdstring | nullrequiredArtist account id this session was created in the context of, or null when no artist was associated. Set via POST /api/sessions { artistId }; surfaces here for clients (e.g. the chat sidebar) that filter sessions/chats by artist.
format: uuid
chatobjectrequiredProperties for chat
idstringrequiredChat id (nanoid).
sessionIdstringrequiredOwning session id.
titlestringrequiredDisplay title for the chat. The initial chat created with a session is titled New chat.
modelIdstringrequiredAI Gateway model identifier the chat is configured to use (e.g. openai/gpt-5.4).
activeStreamIdstringnullableId of an in-flight assistant stream, if one is active.
lastAssistantMessageAtstringnullableTimestamp of the most recent assistant message in this chat.
format: date-time
createdAtstringrequiredformat: date-time
updatedAtstringrequiredformat: date-time
400Invalid request body — either malformed JSON or a field failed validation.+
application/json
statusstring · enumrequiredAlways "error" for error responses.
Values: "error"
errorstringrequiredHuman-readable error message.
401Unauthorized — invalid or missing API key / Bearer token.+
application/json
statusstring · enumrequiredAlways "error" for error responses.
Values: "error"
errorstringrequiredHuman-readable error message.
500Server error — the session could not be persisted.+
application/json
statusstring · enumrequiredAlways "error" for error responses.
Values: "error"
errorstringrequiredHuman-readable error message.
Full specification
Download the OpenAPI file for complete schemas, constraints, and examples.
Download sessions.jsonView operation source
{
"summary": "Create session",
"description": "Creates a new agent session and an initial empty chat in a single transaction. The session is created in the `provisioning` lifecycle state — a separate orchestration step claims it and starts the sandbox.",
"requestBody": {
"required": false,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateSessionRequest"
}
}
}
},
"responses": {
"200": {
"description": "Session and initial chat created successfully.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateSessionResponse"
}
}
}
},
"400": {
"description": "Invalid request body — either malformed JSON or a field failed validation.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "Unauthorized — invalid or missing API key / Bearer token.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"500": {
"description": "Server error — the session could not be persisted.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}