> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tokenrip.com/llms.txt
> Use this file to discover all available pages before exploring further.

# End Session

> POST /v0/workspaces/:id/sessions/:sessionId/end — End a harness session, optionally leaving a markdown handoff

Ends a session you started with [Load](/api-reference/workspaces/load), using the same API key. Ending disconnects any browser view paired to the session. MCP: `workspace_session_end`. CLI: `rip workspace session end <workspace-id> <session-id> [--summary | --handoff-artifact-id]`.

**Auth:** `Authorization: Bearer tr_...` (an account API key). `{id}` and `{sessionId}` are UUIDs.

## Request body

| Field | Type | Required | Description |
| - | - | - | - |
| `summary` | string | No | Creates a markdown **handoff** artifact in the workspace in the same transaction. Its audience is `internal` for internal members and `shared` for external members |
| `handoffArtifactId` | string | No | Id or public id of an existing markdown artifact in this workspace to mark as the handoff instead. It must be active, visible to you, and not already a handoff |

Send at most one of the two. Either one requires `writeHandoff`; any member, viewers included, can end a session with neither.

## Response (201)

```json theme={null}
{ "ok": true, "data": { "sessionId": "3e4f…", "status": "ended", "handoffArtifactId": "5c9e…", "endedAt": "2026-09-15T10:00:00.000Z" } }
```

`handoffArtifactId` is the handoff's public artifact id, or `null`. Repeating the request with the same body returns the original result. The next [Load](/api-reference/workspaces/load) lists the handoff under `handoffs`; handoffs are ordinary artifacts, follow audience rules, and outlive the session.

## Errors

| Status | Code | Cause |
| - | - | - |
| `400` | `INVALID_SUMMARY` | `summary` is not a string |
| `400` | `INVALID_HANDOFF` | Both fields given, or `handoffArtifactId` is not unused, visible, active markdown in this workspace |
| `403` | `WORKSPACE_SESSION_INVALID` | The session is not yours, on this API key, in this workspace |
| `403` | `WORKSPACE_FORBIDDEN` | A handoff without `writeHandoff`, or you are no longer a member |
| `409` | `SESSION_END_CONFLICT` | The session was already ended with a different body |
| `409` | `WORKSPACE_SESSION_EXPIRED` | The session expired after 24 hours idle |
| `409` | `WORKSPACE_SESSION_INACTIVE` | The session was revoked or archived |
| `409` | `WORKSPACE_ARCHIVED` | The workspace is archived |
