---
title: "Open 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.

# Open a work session

Path: CloudRaker Workspace API › Workspace Sessions

`POST /workspace/sessions`

Opens a work session (`ws_`) with a description, the agents to invite, the spaces it is linked to and its working set of files. **Authorization:** any authenticated member. With no `spaceIds` the session lands on the caller’s own private desk, created on demand — a desk session is private BY IDENTITY and can never be shared, so name a real space (here, or later with `PATCH`) for anything a colleague must see. Every named space must EXIST and is re-checked for `space:contribute` as the caller — either denial is 404, so a space’s existence is never leaked; an explicit `me:*` id is 400 `cannot_target_desk` (a desk is never a named target). An entry in `spaceIds` is a bare id or `{ spaceId, access }`, where `access` is `read` or `commit` (default). Every id in `fileIds` is resolved the same way — it must exist and the caller must hold `space:read` on the space it lives in, otherwise 404. EVERY turn is scoped to this working set, so an id that cannot be read would refuse every later turn. The set is repairable: `PATCH { fileIds }` replaces it. Each agent must be published and not archived — a session pins its `publishedVersionId` — otherwise 422 `agent_not_published`. On success the caller is granted the `work-session-owner` role on the new `work_session` FGA resource.

## Authentication

- `bearerAuth`, http, header `Authorization`

## Request body

_Required._

- `description` (`openWorkspaceSession.description`; string, required)
  - minLength 1; maxLength 8000
- `title` (`openWorkspaceSession.title`; string, optional)
  - maxLength 200
- `agentIds` (`openWorkspaceSession.agentIds`; array<string>, optional)
  - minLength 1; maxLength 128; default `[]`
- `spaceIds` (`openWorkspaceSession.spaceIds`; array<WorkspaceSpaceLink>, optional)
  - default `[]`
  - any of:
    - `string`
    - `object`
      - `spaceId` (`openWorkspaceSession.spaceIds.2.spaceId`; string, required)
        - minLength 1; maxLength 128
      - `access` (`openWorkspaceSession.spaceIds.2.access`; string, optional)
        - one of `"read"`, `"commit"`; default `"commit"`
- `fileIds` (`openWorkspaceSession.fileIds`; array<string>, optional) — The session’s working set. EVERY turn the session runs is scoped to these files, plus whatever the comment that woke it attaches — a caller never has to re-send them.
  - minLength 1; maxLength 128; default `[]`

## Example request

```json
{
  "title": "string",
  "description": "string",
  "agentIds": [],
  "spaceIds": [],
  "fileIds": []
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url https://api.cloudraker.com/workspace/sessions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "title": "string",
  "description": "string",
  "agentIds": [],
  "spaceIds": [],
  "fileIds": []
}
'
```

### TypeScript

```typescript
const url = 'https://api.cloudraker.com/workspace/sessions';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({
    title: 'string',
    description: 'string',
    agentIds: [],
    spaceIds: [],
    fileIds: []
  })
};

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"

payload = {
    "title": "string",
    "description": "string",
    "agentIds": [],
    "spaceIds": [],
    "fileIds": []
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

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

print(response.text)
```

## Responses

### 201

The opened 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` (`openWorkspaceSession.response.201.data`; object, required)
  - `id` (`openWorkspaceSession.response.201.data.id`; string, required)
    - minLength 1; maxLength 128
  - `title` (`openWorkspaceSession.response.201.data.title`; string, required)
    - maxLength 200
  - `description` (`openWorkspaceSession.response.201.data.description`; string, required)
    - maxLength 8000
  - `status` (`openWorkspaceSession.response.201.data.status`; string, required)
    - one of `"open"`, `"working"`, `"waiting"`, `"done"`, `"archived"`
  - `workStatus` (`openWorkspaceSession.response.201.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` (`openWorkspaceSession.response.201.data.openedBy`; object, required)
    - `kind` (`openWorkspaceSession.response.201.data.openedBy.kind`; string, required)
      - one of `"user"`, `"agent"`, `"api_key"`, `"trigger"`, `"external"`
    - `id` (`openWorkspaceSession.response.201.data.openedBy.id`; string, required)
      - minLength 1; maxLength 128
    - `name` (`openWorkspaceSession.response.201.data.openedBy.name`; string, required)
      - minLength 1; maxLength 120
    - `avatarUrl` (`openWorkspaceSession.response.201.data.openedBy.avatarUrl`; string, optional)
      - maxLength 2048
    - `source` (`openWorkspaceSession.response.201.data.openedBy.source`; string, optional)
      - one of `"web"`, `"desktop"`, `"api"`, `"email"`, `"webhook"`, `"schedule"`, `"slack"`, `"assistant"`, `"manual"`, `"trigger"`
  - `openedVia` (`openWorkspaceSession.response.201.data.openedVia`; string, required)
    - one of `"web"`, `"desktop"`, `"api"`, `"email"`, `"webhook"`, `"schedule"`, `"slack"`, `"assistant"`
  - `participants` (`openWorkspaceSession.response.201.data.participants`; object, required)
    - `humans` (`openWorkspaceSession.response.201.data.participants.humans`; array<string>, required)
    - `agents` (`openWorkspaceSession.response.201.data.participants.agents`; array<object>, required)
      - `agentId` (`openWorkspaceSession.response.201.data.participants.agents.agentId`; string, required)
      - `versionId` (`openWorkspaceSession.response.201.data.participants.agents.versionId`; string, required)
      - `handle` (`openWorkspaceSession.response.201.data.participants.agents.handle`; string, required)
      - `name` (`openWorkspaceSession.response.201.data.participants.agents.name`; string, required)
      - `role` (`openWorkspaceSession.response.201.data.participants.agents.role`; string, required)
      - `joinedAt` (`openWorkspaceSession.response.201.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` (`openWorkspaceSession.response.201.data.spaces`; array<object>, required)
    - `spaceId` (`openWorkspaceSession.response.201.data.spaces.spaceId`; string, required)
    - `access` (`openWorkspaceSession.response.201.data.spaces.access`; string, required)
      - one of `"read"`, `"commit"`
  - `files` (`openWorkspaceSession.response.201.data.files`; array<object>, required)
    - `fileId` (`openWorkspaceSession.response.201.data.files.fileId`; string, required)
    - `role` (`openWorkspaceSession.response.201.data.files.role`; string, required)
      - one of `"input"`, `"artifact"`
  - `triggerId` (`openWorkspaceSession.response.201.data.triggerId`; string | null, required)
  - `parentSessionId` (`openWorkspaceSession.response.201.data.parentSessionId`; string | null, required)
  - `counts` (`openWorkspaceSession.response.201.data.counts`; object, required)
    - `turns` (`openWorkspaceSession.response.201.data.counts.turns`; number, required)
    - `approvalsPending` (`openWorkspaceSession.response.201.data.counts.approvalsPending`; number, required)
    - `tasksPending` (`openWorkspaceSession.response.201.data.counts.tasksPending`; number, required)
    - `unread` (`openWorkspaceSession.response.201.data.counts.unread`; number, required)
  - `lastActivityAt` (`openWorkspaceSession.response.201.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` (`openWorkspaceSession.response.201.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` (`openWorkspaceSession.response.201.data.closedAt`; string | null, required)

### 400

`cannot_target_desk` — a `me:*` id was named explicitly.

### 404

A named space the caller cannot contribute to, or a file that does not exist or the caller cannot read.

### 422

`agent_not_published` — an agent is unpublished or archived.


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