---
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 Paperwork API › Work Sessions

`POST /v1/work-sessions`

Opens a work session — one durable timeline that humans and named paperwork agents share.

Name the agents in `agents` (a handle such as `mike`, or an `agt_` id); each must have a published version. They are mentioned with your `description` and their turns start before this call returns — `startedTurnIds` names them, and `failedMentions` names any agent whose turn could not be started. Open with an empty `agents` to invite nobody, then post to `/entries` when you are ready.

Give the session its working set in `fileIds`: every turn it runs is scoped to those files, so you never re-send them. With no `spaceIds` the session lives in your organization's API workspace.

Set `webhookUrl` to receive this session's events at one https endpoint, signed exactly like every other delivery. Your saved `/v1/webhooks` subscriptions receive them too.

Access is scoped to the API key that opened the session: another key of the same organization gets `404` on every route here. Set `apiVisible: true` to let every key of your organization read and write it.

**Learn more:** [Work sessions](https://docs.cloudraker.com/paperwork/api)

## Authentication

- `bearerAuth`, http, header `Authorization`

## Request body

_Required._

- `description` (`createWorkSession.description`; string, required)
  - minLength 1; maxLength 8000
- `title` (`createWorkSession.title`; string, optional)
  - maxLength 200
- `agents` (`createWorkSession.agents`; array<string>, optional)
  - minLength 1; maxLength 128; default `[]`
- `spaceIds` (`createWorkSession.spaceIds`; array<string>, optional)
  - minLength 1; maxLength 128; default `[]`
- `fileIds` (`createWorkSession.fileIds`; array<string>, optional)
  - minLength 1; maxLength 128; default `[]`
- `webhookUrl` (`createWorkSession.webhookUrl`; string, optional)
  - format `uri`; maxLength 2048
- `apiVisible` (`createWorkSession.apiVisible`; boolean, optional)
  - default `false`
- `metadata` (`createWorkSession.metadata`; map<unknown>, optional)

## Example request

```json
{
  "description": "string",
  "title": "string",
  "agents": [],
  "spaceIds": [],
  "fileIds": [],
  "webhookUrl": "http://example.com",
  "apiVisible": false,
  "metadata": {
    "property1": null,
    "property2": null
  }
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url https://api.cloudraker.com/v1/work-sessions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "description": "string",
  "title": "string",
  "agents": [],
  "spaceIds": [],
  "fileIds": [],
  "webhookUrl": "http://example.com",
  "apiVisible": false,
  "metadata": {
    "property1": null,
    "property2": null
  }
}
'
```

### TypeScript

```typescript
const url = 'https://api.cloudraker.com/v1/work-sessions';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({
    description: 'string',
    title: 'string',
    agents: [],
    spaceIds: [],
    fileIds: [],
    webhookUrl: 'http://example.com',
    apiVisible: false,
    metadata: {property1: null, property2: null}
  })
};

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/v1/work-sessions"

payload = {
    "description": "string",
    "title": "string",
    "agents": [],
    "spaceIds": [],
    "fileIds": [],
    "webhookUrl": "http://example.com",
    "apiVisible": False,
    "metadata": {
        "property1": None,
        "property2": None
    }
}
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 and the turns it started.

#### Example

```json
{
  "data": {
    "object": "work_session",
    "id": "string",
    "status": "open",
    "title": "string",
    "description": "string",
    "agents": [
      {
        "id": "string",
        "handle": "string",
        "name": "string",
        "role": "string"
      }
    ],
    "spaceIds": [
      "string"
    ],
    "fileIds": [
      "string"
    ],
    "counts": {
      "turns": -9007199254740991,
      "approvalsPending": -9007199254740991,
      "tasksPending": -9007199254740991
    },
    "apiVisible": true,
    "webhookUrl": "string",
    "createdAt": "string",
    "lastActivityAt": "string",
    "closedAt": "string",
    "entriesUrl": "string",
    "streamUrl": "string",
    "artifactsUrl": "string",
    "startedTurnIds": [
      "string"
    ],
    "failedMentions": [
      "string"
    ]
  }
}
```

- `data` (`createWorkSession.response.201.data`; object, required)
  - `object` (`createWorkSession.response.201.data.object`; string, required)
  - `id` (`createWorkSession.response.201.data.id`; string, required)
  - `status` (`createWorkSession.response.201.data.status`; string, required)
    - one of `"open"`, `"working"`, `"waiting"`, `"done"`, `"archived"`
  - `title` (`createWorkSession.response.201.data.title`; string, required)
  - `description` (`createWorkSession.response.201.data.description`; string, required)
  - `agents` (`createWorkSession.response.201.data.agents`; array<object>, required)
    - `id` (`createWorkSession.response.201.data.agents.id`; string, required)
    - `handle` (`createWorkSession.response.201.data.agents.handle`; string, required)
    - `name` (`createWorkSession.response.201.data.agents.name`; string, required)
    - `role` (`createWorkSession.response.201.data.agents.role`; string, required)
  - `spaceIds` (`createWorkSession.response.201.data.spaceIds`; array<string>, required)
  - `fileIds` (`createWorkSession.response.201.data.fileIds`; array<string>, required)
  - `counts` (`createWorkSession.response.201.data.counts`; object, required)
    - `turns` (`createWorkSession.response.201.data.counts.turns`; integer, required)
      - min -9007199254740991; max 9007199254740991
    - `approvalsPending` (`createWorkSession.response.201.data.counts.approvalsPending`; integer, required)
      - min -9007199254740991; max 9007199254740991
    - `tasksPending` (`createWorkSession.response.201.data.counts.tasksPending`; integer, required)
      - min -9007199254740991; max 9007199254740991
  - `apiVisible` (`createWorkSession.response.201.data.apiVisible`; boolean, required)
  - `createdAt` (`createWorkSession.response.201.data.createdAt`; string, required)
  - `lastActivityAt` (`createWorkSession.response.201.data.lastActivityAt`; string, required)
  - `closedAt` (`createWorkSession.response.201.data.closedAt`; string | null, required)
  - `entriesUrl` (`createWorkSession.response.201.data.entriesUrl`; string, required)
  - `streamUrl` (`createWorkSession.response.201.data.streamUrl`; string, required)
  - `artifactsUrl` (`createWorkSession.response.201.data.artifactsUrl`; string, required)
  - `startedTurnIds` (`createWorkSession.response.201.data.startedTurnIds`; array<string>, required)
  - `failedMentions` (`createWorkSession.response.201.data.failedMentions`; array<string>, required)
  - `webhookUrl` (`createWorkSession.response.201.data.webhookUrl`; string, optional)

### 400

Validation Error

#### Example

```json
{
  "success": false,
  "error": [
    null
  ],
  "data": null
}
```

- `success` (`createWorkSession.response.400.success`; boolean, required)
  - one of `false`
- `error` (`createWorkSession.response.400.error`; array<unknown>, required)
- `data` (`createWorkSession.response.400.data`; unknown, required)

### 401

Missing or invalid credential.

### 403

The credential may not use the /v1 API.

### 404

A named space or file does not exist, or you may not use it.

### 422

`agent_not_published` — a named agent has no published version.

### 429

Rate limited. The `/v1` API allows at least **67 requests per minute per organization** (about 1,000 requests per 15 minutes) — a guaranteed floor, enforced per edge location, so a geographically spread caller may get more. Wait for the `Retry-After` interval and retry — the error is `retryable`.

#### Example

```json
{
  "code": "rate_limited",
  "message": "string",
  "retryable": true,
  "requestId": "string",
  "docUrl": "string"
}
```

- `code` (`createWorkSession.response.429.code`; string, required)
  - one of `"rate_limited"`
- `message` (`createWorkSession.response.429.message`; string, required)
- `retryable` (`createWorkSession.response.429.retryable`; boolean, required)
  - one of `true`
- `requestId` (`createWorkSession.response.429.requestId`; string, required)
- `docUrl` (`createWorkSession.response.429.docUrl`; string, optional)

### 503

`turn_start_failed` — no invited agent could be started. Retry.


Source: https://docs.cloudraker.com/paperwork/api/work-sessions/create-work-session/index.md
