Skip to main content

Code Sessions

Create and drive a coding assistant in a workspace's terminal. Each session exposes a terminal you can send input to and poll output from, and can be deployed as an application when the project is ready.

All endpoints require authentication via X-API-Key header and the appropriate scope.


Code Session Object​

{
"_id": "cs_abc123",
"userId": "user_456",
"organizationId": "org_xyz",
"workspaceId": "ws_abc123",
"projectId": "proj_abc123",
"managedWorkspace": true,
"assistant": "claude-code",
"status": "ready",
"projectName": "marketing-site",
"projectDescription": "Static marketing landing page with blog",
"outputBuffer": [
{ "seq": 1, "type": "stdout", "content": "Welcome to Claude Code", "timestamp": "2025-02-01T14:24:00Z" }
],
"lastSeq": 1,
"createdAt": "2025-02-01T14:22:00Z",
"updatedAt": "2025-02-01T14:25:00Z"
}
  • status is provisioning, ready, active, completed or error (error then says why). While provisioning, provisioningDetail and provisioningStep describe the current step.
  • managedWorkspace is true when the session created its workspace (ending the session stops it) and false when it runs in a workspace you already had.
  • assistant is the coding assistant the session drives: claude-code or codex.
  • outputBuffer holds the terminal output chunks (seq, type of stdout, stderr or system, content, timestamp); lastSeq is the latest chunk's seq.
  • After a deploy, appId and buildId are set (or deployError if the deploy did not start).

POST /api/v1/code-sessions​

Create a new code session: a workspace with a terminal you drive over the API.

Scope: code-sessions:write

Request Body

{
"projectName": "marketing-site",
"projectDescription": "Static marketing landing page with blog"
}
FieldTypeRequiredDescription
projectNamestringYesName of the project
projectDescriptionstringYesDescription of the project

Response 201 Created

The new code session. When a running session for the same project exists, it is resumed instead: 200 OK with that session.


GET /api/v1/code-sessions​

List your code sessions, most recently updated first. It pages with limit and cursor (Pagination).

Scope: code-sessions:read

Query Parameters

ParameterTypeRequiredDescription
livebooleanNotrue returns only sessions you can resume (provisioning, ready or active). Default: all your sessions

Response 200 OK

{
"data": [
{
"_id": "cs_abc123",
"userId": "user_456",
"organizationId": "org_xyz",
"workspaceId": "ws_abc123",
"projectId": "proj_abc123",
"managedWorkspace": true,
"assistant": "claude-code",
"status": "ready",
"projectDescription": "Static marketing landing page with blog",
"lastSeq": 13,
"createdAt": "2025-02-01T14:22:00Z",
"updatedAt": "2025-02-01T14:25:00Z",
"workspaceName": "marketing-site",
"workspaceStatus": "running",
"projectName": "Marketing"
}
],
"meta": { "total": 1, "limit": 50, "nextCursor": null, "requestId": "req_abc123" }
}

Each entry is a Code Session object without outputBuffer, plus workspaceName and workspaceStatus (the session's workspace). projectName is the name of the project the session belongs to, and is left out for a session with no project. The list is not paginated.


GET /api/v1/code-sessions/:id​

Get details of a code session including status, workspace info, and metadata.

Scope: code-sessions:read

Path Parameters

ParameterTypeRequiredDescription
idstringYesCode session ID

Response 200 OK

Returns the full Code Session object.

{
"data": {
"_id": "cs_abc123",
"userId": "user_456",
"organizationId": "org_xyz",
"workspaceId": "ws_abc123",
"managedWorkspace": true,
"assistant": "claude-code",
"status": "ready",
"projectName": "marketing-site",
"projectDescription": "Static marketing landing page with blog",
"outputBuffer": [],
"lastSeq": 0,
"createdAt": "2025-02-01T14:22:00Z",
"updatedAt": "2025-02-01T14:25:00Z"
},
"meta": {
"requestId": "req_abc123"
}
}

GET /api/v1/code-sessions/:id/status​

Get the current lifecycle status of a code session. Returns the same record as GET /code-sessions/:id.

Scope: code-sessions:read

Path Parameters

ParameterTypeRequiredDescription
idstringYesCode session ID

Response 200 OK

data is the full Code Session object.

Reading a session also brings its status up to date: a provisioning session moves on to ready once its workspace is up, and a ready or active session whose workspace is no longer running moves to error, with error saying why. The same applies to GET /code-sessions/:id.

Errors

StatusCodeWhen
400validation-errorInvalid session ID
403forbiddenThe session belongs to another user (administrators can read any session)
404not-foundNo session with this ID

POST /api/v1/code-sessions/:id/inputs​

Send text input to the code session's PTY (terminal). Use this to execute commands or provide input to a running prompt.

Scope: code-sessions:write

Path Parameters

ParameterTypeRequiredDescription
idstringYesCode session ID

Request Body

{
"text": "ls -la\n"
}
FieldTypeRequiredDescription
textstringYesText to send to the terminal (include \n to submit)

Response 200 OK: the code session, as GET /code-sessions/:id shows it. Read what the terminal printed with output.


GET /api/v1/code-sessions/:id/output​

Get terminal output from a code session. Use afterSeq to poll for new output since the last read.

Scope: code-sessions:read

Path Parameters

ParameterTypeRequiredDescription
idstringYesCode session ID

Query Parameters

ParameterTypeRequiredDescription
afterSeqintegerNoOnly return output chunks after this sequence number (for polling)

Response 200 OK

{
"data": {
"chunks": [
{ "seq": 12, "content": "total 24\n" },
{ "seq": 13, "content": "drwxr-xr-x 5 root root 160 Feb 1 14:25 .\n" }
],
"lastSeq": 13
},
"meta": {
"requestId": "req_abc123"
}
}

POST /api/v1/code-sessions/:id/login​

Log in to Claude Code in the session's workspace. The platform supplies no Claude credential: you sign in with your own Claude account. This call starts Claude Code in the session's terminal if it is not running yet, starts its login, and returns the sign-in URL. Open the URL, then send the code it shows you to POST /code-sessions/:id/login-codes.

Scope: code-sessions:write

Path Parameters

ParameterTypeRequiredDescription
idstringYesCode session ID

Response 200 OK

{
"data": {
"state": "url",
"authUrl": "https://...",
"message": null
},
"meta": {
"requestId": "req_abc123"
}
}

data is the login: its state, the sign-in authUrl once there is one, and a message saying what to do next.

stateMeaning
urlOpen authUrl to sign in. Calling again while that login is in progress returns the same URL
authenticatedClaude Code in this workspace is already logged in
pendingClaude Code is starting, or login has started but the URL has not appeared yet. Call again in a few seconds
startingThe workspace terminal cannot be reached yet (the workspace is still starting). Wait for the session to be ready, then call again
terminalThe session runs Codex, which this call does not log in. Run codex login in the terminal with input and read the sign-in URL it prints from output

Errors

StatusCodeWhen
400validation-errorInvalid session ID
403forbiddenThe session belongs to another user (administrators can use any session)
404not-foundNo session with this ID

POST /api/v1/code-sessions/:id/login-codes​

Finish logging in to Claude Code: send the code shown after you signed in at the authUrl from POST /code-sessions/:id/login.

Scope: code-sessions:write

Path Parameters

ParameterTypeRequiredDescription
idstringYesCode session ID

Request Body

{
"code": "abc123def456"
}
FieldTypeRequiredDescription
codestringYesThe code shown after signing in

Response 200 OK​

The code session, as GET /code-sessions/:id shows it, once Claude Code confirms the login.

Errors​

StatusWhen
400Claude Code reported the code invalid or the login failed: start the login again for a fresh URL
422The workspace terminal is not reachable yet: wait for the session to be ready and retry
504The login was not confirmed in time: read the session output to see the terminal

Errors

StatusCodeWhen
400validation-errorInvalid session ID, or code is missing
403forbiddenThe session belongs to another user (administrators can use any session)
404not-foundNo session with this ID

POST /api/v1/code-sessions/:id/deploy​

Build the code session's workspace as a new application; the platform deploys it when its build completes.

Scope: code-sessions:deploy

Path Parameters

ParameterTypeRequiredDescription
idstringYesCode session ID

Response 202 Accepted: the new app, as GET /apps/:id shows it, status building. Follow it with GET /apps/:id until it is running.


DELETE /api/v1/code-sessions/:id​

End a code session. Stops the workspace and marks the session as completed.

Scope: code-sessions:write

Path Parameters

ParameterTypeRequiredDescription
idstringYesCode session ID

Response 204 No Content