---
title: "Retitle, relink, invite into, set the work status of or archive a work session"
---

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

# Retitle, relink, invite into, set the work status of or archive a work session

Path: CloudRaker Workspace API › Workspace Sessions

`PATCH /workspace/sessions/{sessionId}`

Changes the title, description, linked spaces, participants or work status, or archives the session. `workStatus` (`active`, `ready_for_review`, `done`) needs only `work_session:comment`, but `done` must come from a person: an org API key, a trigger delivery is 403 `work_status_needs_person`, and so is `archive: true` from any of them, since archiving marks the work `done`. Archiving sets `done`, a reopen `active`, and a new agent turn moves it back to `active`. **Authorization:** `work_session:comment` on the session, OR `space:contribute` on one of its linked spaces; a desk session is writable only by its owner. Any denial is 404. `spaces`, `removeHumans` and `archive` need MORE than that: they are the owner’s (`work_session:manage`, spec §8.1), so a participant or a space contributor gets 403 `forbidden` on those three fields and keeps `title`, `description` and `addHumans`. Every id in `spaces` is re-checked as the caller exactly as `POST /workspace/sessions` checks `spaceIds`: a `me:*` desk the session is not ALREADY on is 400 `cannot_target_desk` (moving a session onto a desk would hide it from its own opener) and a space that does not exist or the caller cannot contribute to is 404, so a relay can never move a session somewhere its owner loses it. Each entry is `{ spaceId, access }` (`access` defaults to `commit`) or a bare id string, and `spaces` replaces the whole set, so it needs at least one entry — a session with no space cannot host a turn, and an empty array left it un-mentionable with no way back. `fileIds` replaces the working set the same way — every id is resolved as the caller (404 for an unknown or unreadable one) and `[]` empties it, so a session whose set carries a file nobody can read is repairable instead of permanently un-mentionable. A relink is checked against the working set it MOVES: every file the session already runs on must live in the new turn space, so a `spaces` patch that would leave the session un-mentionable is 404 — send `fileIds` in the same call (`[]` empties the set) to move and refill at once. The body is STRICT: an unknown key is 400 `validation_failed`, never a 200 that changed nothing. Every id in `addHumans` must be an active member of the caller’s organization: an id from another organization, or one that names nobody, is 404, so the roster never lists a person who could not open the session. `addHumans` also grants each member the `work-session-participant` FGA role, and `removeHumans` revokes it — agents are never FGA subjects (a turn runs as the human who mentioned it). A DESK session cannot be shared: the gate authorizes it by identity alone, so `addHumans` on one is 400 `cannot_share_desk` — relink it to a real space first. (A session opened with no `spaceIds` lands on the desk, so this is the default create path’s sharing story.)

## Authentication

- `bearerAuth`, http, header `Authorization`

## Path parameters

- `sessionId` (`patchWorkspaceSession.path.sessionId`; string, required)

## Request body

_Required._

- `title` (`patchWorkspaceSession.title`; string, optional)
  - minLength 1; maxLength 200
- `description` (`patchWorkspaceSession.description`; string, optional)
  - maxLength 8000
- `spaces` (`patchWorkspaceSession.spaces`; array<WorkspaceSpaceLink>, optional)
  - any of:
    - `string`
    - `object`
      - `spaceId` (`patchWorkspaceSession.spaces.2.spaceId`; string, required)
        - minLength 1; maxLength 128
      - `access` (`patchWorkspaceSession.spaces.2.access`; string, optional)
        - one of `"read"`, `"commit"`; default `"commit"`
- `addHumans` (`patchWorkspaceSession.addHumans`; array<string>, optional)
  - minLength 1; maxLength 128
- `removeHumans` (`patchWorkspaceSession.removeHumans`; array<string>, optional)
  - minLength 1; maxLength 128
- `fileIds` (`patchWorkspaceSession.fileIds`; array<string>, optional) — The session’s working set, replaced wholesale. Every id must exist and be readable by the caller; `[]` empties the set.
  - minLength 1; maxLength 128
- `archive` (`patchWorkspaceSession.archive`; boolean, optional)
- `workStatus` (`patchWorkspaceSession.workStatus`; string, optional) — Whether the WORK is done, which only people decide. `status` stays the derived state of the turns.
  - one of `"active"`, `"ready_for_review"`, `"done"`

## Example request

```json
{
  "title": "string",
  "description": "string",
  "spaces": [
    "string"
  ],
  "addHumans": [
    "string"
  ],
  "removeHumans": [
    "string"
  ],
  "fileIds": [
    "string"
  ],
  "archive": true,
  "workStatus": "active"
}
```

## Code samples

### cURL

```bash
curl --request PATCH \
  --url 'https://api.cloudraker.com/workspace/sessions/<sessionId>' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "title": "string",
  "description": "string",
  "spaces": [
    "string"
  ],
  "addHumans": [
    "string"
  ],
  "removeHumans": [
    "string"
  ],
  "fileIds": [
    "string"
  ],
  "archive": true,
  "workStatus": "active"
}
'
```

### TypeScript

```typescript
const url = 'https://api.cloudraker.com/workspace/sessions/<sessionId>';
const options = {
  method: 'PATCH',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({
    title: 'string',
    description: 'string',
    spaces: ['string'],
    addHumans: ['string'],
    removeHumans: ['string'],
    fileIds: ['string'],
    archive: true,
    workStatus: 'active'
  })
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.cloudraker.com/workspace/sessions/<sessionId>"

payload = {
    "title": "string",
    "description": "string",
    "spaces": ["string"],
    "addHumans": ["string"],
    "removeHumans": ["string"],
    "fileIds": ["string"],
    "archive": True,
    "workStatus": "active"
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 200

The updated work session.

#### Example

```json
{
  "data": {
    "id": "string",
    "title": "string",
    "description": "string",
    "status": "open",
    "workStatus": "active",
    "openedBy": {
      "kind": "user",
      "id": "string",
      "name": "string",
      "avatarUrl": "string",
      "source": "web"
    },
    "openedVia": "web",
    "participants": {
      "humans": [
        "string"
      ],
      "agents": [
        {
          "agentId": "string",
          "versionId": "string",
          "handle": "string",
          "name": "string",
          "role": "string",
          "joinedAt": "2019-08-24T14:15:22Z"
        }
      ]
    },
    "spaces": [
      {
        "spaceId": "string",
        "access": "read"
      }
    ],
    "files": [
      {
        "fileId": "string",
        "role": "input"
      }
    ],
    "triggerId": "string",
    "parentSessionId": "string",
    "counts": {
      "turns": 0,
      "approvalsPending": 0,
      "tasksPending": 0,
      "unread": 0
    },
    "lastActivityAt": "2019-08-24T14:15:22Z",
    "createdAt": "2019-08-24T14:15:22Z",
    "closedAt": "string"
  }
}
```

- `data` (`patchWorkspaceSession.response.200.data`; object, required)
  - `id` (`patchWorkspaceSession.response.200.data.id`; string, required)
    - minLength 1; maxLength 128
  - `title` (`patchWorkspaceSession.response.200.data.title`; string, required)
    - maxLength 200
  - `description` (`patchWorkspaceSession.response.200.data.description`; string, required)
    - maxLength 8000
  - `status` (`patchWorkspaceSession.response.200.data.status`; string, required)
    - one of `"open"`, `"working"`, `"waiting"`, `"done"`, `"archived"`
  - `workStatus` (`patchWorkspaceSession.response.200.data.workStatus`; string, required) — Whether the WORK is done, which only people decide. `status` stays the derived state of the turns.
    - one of `"active"`, `"ready_for_review"`, `"done"`
  - `openedBy` (`patchWorkspaceSession.response.200.data.openedBy`; object, required)
    - `kind` (`patchWorkspaceSession.response.200.data.openedBy.kind`; string, required)
      - one of `"user"`, `"agent"`, `"api_key"`, `"trigger"`, `"external"`
    - `id` (`patchWorkspaceSession.response.200.data.openedBy.id`; string, required)
      - minLength 1; maxLength 128
    - `name` (`patchWorkspaceSession.response.200.data.openedBy.name`; string, required)
      - minLength 1; maxLength 120
    - `avatarUrl` (`patchWorkspaceSession.response.200.data.openedBy.avatarUrl`; string, optional)
      - maxLength 2048
    - `source` (`patchWorkspaceSession.response.200.data.openedBy.source`; string, optional)
      - one of `"web"`, `"desktop"`, `"api"`, `"email"`, `"webhook"`, `"schedule"`, `"slack"`, `"assistant"`, `"manual"`, `"trigger"`
  - `openedVia` (`patchWorkspaceSession.response.200.data.openedVia`; string, required)
    - one of `"web"`, `"desktop"`, `"api"`, `"email"`, `"webhook"`, `"schedule"`, `"slack"`, `"assistant"`
  - `participants` (`patchWorkspaceSession.response.200.data.participants`; object, required)
    - `humans` (`patchWorkspaceSession.response.200.data.participants.humans`; array<string>, required)
    - `agents` (`patchWorkspaceSession.response.200.data.participants.agents`; array<object>, required)
      - `agentId` (`patchWorkspaceSession.response.200.data.participants.agents.agentId`; string, required)
      - `versionId` (`patchWorkspaceSession.response.200.data.participants.agents.versionId`; string, required)
      - `handle` (`patchWorkspaceSession.response.200.data.participants.agents.handle`; string, required)
      - `name` (`patchWorkspaceSession.response.200.data.participants.agents.name`; string, required)
      - `role` (`patchWorkspaceSession.response.200.data.participants.agents.role`; string, required)
      - `joinedAt` (`patchWorkspaceSession.response.200.data.participants.agents.joinedAt`; string, required)
        - format `date-time`; pattern `^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$`
  - `spaces` (`patchWorkspaceSession.response.200.data.spaces`; array<object>, required)
    - `spaceId` (`patchWorkspaceSession.response.200.data.spaces.spaceId`; string, required)
    - `access` (`patchWorkspaceSession.response.200.data.spaces.access`; string, required)
      - one of `"read"`, `"commit"`
  - `files` (`patchWorkspaceSession.response.200.data.files`; array<object>, required)
    - `fileId` (`patchWorkspaceSession.response.200.data.files.fileId`; string, required)
    - `role` (`patchWorkspaceSession.response.200.data.files.role`; string, required)
      - one of `"input"`, `"artifact"`
  - `triggerId` (`patchWorkspaceSession.response.200.data.triggerId`; string | null, required)
  - `parentSessionId` (`patchWorkspaceSession.response.200.data.parentSessionId`; string | null, required)
  - `counts` (`patchWorkspaceSession.response.200.data.counts`; object, required)
    - `turns` (`patchWorkspaceSession.response.200.data.counts.turns`; number, required)
    - `approvalsPending` (`patchWorkspaceSession.response.200.data.counts.approvalsPending`; number, required)
    - `tasksPending` (`patchWorkspaceSession.response.200.data.counts.tasksPending`; number, required)
    - `unread` (`patchWorkspaceSession.response.200.data.counts.unread`; number, required)
  - `lastActivityAt` (`patchWorkspaceSession.response.200.data.lastActivityAt`; string, required)
    - format `date-time`; pattern `^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$`
  - `createdAt` (`patchWorkspaceSession.response.200.data.createdAt`; string, required)
    - format `date-time`; pattern `^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$`
  - `closedAt` (`patchWorkspaceSession.response.200.data.closedAt`; string | null, required)

### 400

`cannot_target_desk` — a `me:*` id the session is not already linked to; `cannot_share_desk` — `addHumans` on a desk session; `validation_failed` — an unknown key in the body.

### 403

`forbidden` — `spaces`, `removeHumans` or `archive` without `work_session:manage`. `work_status_needs_person` — `workStatus: done` or `archive: true` from anything but a person.

### 404

No such session, the caller may not write it, no such space, a file in the working set that does not exist, the caller cannot read, or that does not live in the turn space this patch leaves the session in, or an `addHumans` id that is not a member of this organization.

### 409

`session_has_live_turn` — a turn is still running, so the session cannot be archived. Cancel it first. `session_archived` — the title, description or work status of archived work cannot change; reopen it (`archive: false`) in the same or an earlier call.


Source: https://docs.cloudraker.com/workspace/api/workspace-sessions/patch-workspace-session/index.md
