> This page is for Paperwork API.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.cloudraker.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.cloudraker.com/_mcp/server.

# Open a work session

POST https://api.cloudraker.com/v1/work-sessions
Content-Type: application/json

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/overview)

Reference: https://docs.cloudraker.com/paperwork/api/work-sessions/create-work-session

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Body (application/json)

This endpoint expects a CreateWorkSessionBody.

- `description` (string, required)
- `title` (string, optional)
- `agents` (list of string, optional, default: [])
- `spaceIds` (list of string, optional, default: [])
- `fileIds` (list of string, optional, default: [])
- `webhookUrl` (string, optional)
- `apiVisible` (boolean, optional, default: false)
- `metadata` (map from string to any, optional)

## Response

### 201

The opened work session and the turns it started.

- `data` (OpenedWorkSessionData, required)

## Errors

### 400 Bad Request Error

Validation Error

- `success` (boolean, required)
- `error` (list of any, required)
- `data` (any, required)

### 401 Unauthorized Error

Missing or invalid credential.

- `any`

### 403 Forbidden Error

The credential may not use the /v1 API.

- `any`

### 404 Not Found Error

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

- `any`

### 422 Unprocessable Entity Error

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

- `any`

### 429 Too Many Requests Error

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`.

- `code` (enum, required)
  - Allowed values: `rate_limited`
- `message` (string, required)
- `retryable` (boolean, required)
- `requestId` (string, required)
- `docUrl` (string, optional)

### 503 Service Unavailable Error

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

- `any`

## Types

### OpenedWorkSessionData

- `object` ("work_session", required)
- `id` (string, required)
- `status` (enum, required)
  - Allowed values: `open`, `working`, `waiting`, `done`, `archived`
- `title` (string, required)
- `description` (string, required)
- `agents` (list of OpenedWorkSessionDataAgentsItems, required)
- `spaceIds` (list of string, required)
- `fileIds` (list of string, required)
- `counts` (OpenedWorkSessionDataCounts, required)
- `apiVisible` (boolean, required)
- `createdAt` (string, required)
- `lastActivityAt` (string, required)
- `closedAt` (string, required, nullable)
- `entriesUrl` (string, required)
- `streamUrl` (string, required)
- `artifactsUrl` (string, required)
- `startedTurnIds` (list of string, required)
- `failedMentions` (list of string, required)
- `webhookUrl` (string, optional)

### OpenedWorkSessionDataAgentsItems

- `id` (string, required)
- `handle` (string, required)
- `name` (string, required)
- `role` (string, required)

### OpenedWorkSessionDataCounts

- `turns` (integer, required)
- `approvalsPending` (integer, required)
- `tasksPending` (integer, required)

## Examples

**Request**

```json
{
  "description": "string"
}
```

**Response**

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

**SDK Code**

```python
import requests

url = "https://api.cloudraker.com/v1/work-sessions"

payload = { "description": "string" }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.cloudraker.com/v1/work-sessions';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"description":"string"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.cloudraker.com/v1/work-sessions"

	payload := strings.NewReader("{\n  \"description\": \"string\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.cloudraker.com/v1/work-sessions")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"description\": \"string\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.cloudraker.com/v1/work-sessions")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"description\": \"string\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.cloudraker.com/v1/work-sessions', [
  'body' => '{
  "description": "string"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.cloudraker.com/v1/work-sessions");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"description\": \"string\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["description": "string"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.cloudraker.com/v1/work-sessions")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```