> This page is for Workspace app.

> 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/workspace/sessions
Content-Type: application/json

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.

Reference: https://docs.cloudraker.com/workspace/api/workspace-sessions/open-workspace-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 an OpenWorkspaceSessionBody.

- `description` (string, required)
- `title` (string, optional)
- `agentIds` (list of string, optional, default: [])
- `spaceIds` (list of WorkspaceSpaceLink, optional, default: [])
- `fileIds` (list of string, optional, default: []) — 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.

## Response

### 201

The opened work session.

- `data` (WorkspaceSession, required)

## Errors

### 400 Bad Request Error

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

- `any`

### 404 Not Found Error

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

- `any`

### 422 Unprocessable Entity Error

`agent_not_published` — an agent is unpublished or archived.

- `any`

## Types

### WorkspaceSpaceLink

- string
- WorkspaceSpaceLink1

### WorkspaceSession

- `id` (string, required)
- `title` (string, required)
- `description` (string, required)
- `status` (enum, required)
  - Allowed values: `open`, `working`, `waiting`, `done`, `archived`
- `workStatus` (enum, required) — Whether the WORK is done, which only people decide. `status` stays the derived state of the turns.
  - Allowed values: `active`, `ready_for_review`, `done`
- `openedBy` (WorkSessionSender, required)
- `openedVia` (enum, required)
  - Allowed values: `web`, `desktop`, `api`, `email`, `webhook`, `schedule`, `slack`, `assistant`
- `participants` (WorkspaceSessionParticipants, required)
- `spaces` (list of WorkspaceSessionSpacesItems, required)
- `files` (list of WorkspaceSessionFilesItems, required)
- `triggerId` (string, required, nullable)
- `parentSessionId` (string, required, nullable)
- `counts` (WorkspaceSessionCounts, required)
- `lastActivityAt` (datetime, required)
- `createdAt` (datetime, required)
- `closedAt` (string, required, nullable)

### WorkspaceSpaceLink1

- `spaceId` (string, required)
- `access` (enum, optional, default: commit)
  - Allowed values: `read`, `commit`

### WorkSessionSender

- `kind` (enum, required)
  - Allowed values: `user`, `agent`, `api_key`, `trigger`, `external`
- `id` (string, required)
- `name` (string, required)
- `avatarUrl` (string, optional)
- `source` (enum, optional)
  - Allowed values: `web`, `desktop`, `api`, `email`, `webhook`, `schedule`, `slack`, `assistant`, `manual`, `trigger`

### WorkspaceSessionParticipants

- `humans` (list of string, required)
- `agents` (list of WorkspaceSessionParticipantsAgentsItems, required)

### WorkspaceSessionSpacesItems

- `spaceId` (string, required)
- `access` (enum, required)
  - Allowed values: `read`, `commit`

### WorkspaceSessionFilesItems

- `fileId` (string, required)
- `role` (enum, required)
  - Allowed values: `input`, `artifact`

### WorkspaceSessionCounts

- `turns` (double, required)
- `approvalsPending` (double, required)
- `tasksPending` (double, required)
- `unread` (double, required)

### WorkspaceSessionParticipantsAgentsItems

- `agentId` (string, required)
- `versionId` (string, required)
- `handle` (string, required)
- `name` (string, required)
- `role` (string, required)
- `joinedAt` (datetime, required)

## Examples

**Request**

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

**Response**

```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": "2024-01-15T09:30:00Z"
        }
      ]
    },
    "spaces": [
      {
        "spaceId": "string",
        "access": "read"
      }
    ],
    "files": [
      {
        "fileId": "string",
        "role": "input"
      }
    ],
    "triggerId": "string",
    "parentSessionId": "string",
    "counts": {
      "turns": 1.1,
      "approvalsPending": 1.1,
      "tasksPending": 1.1,
      "unread": 1.1
    },
    "lastActivityAt": "2024-01-15T09:30:00Z",
    "createdAt": "2024-01-15T09:30:00Z",
    "closedAt": "string"
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.cloudraker.com/workspace/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/workspace/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/workspace/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/workspace/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/workspace/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/workspace/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/workspace/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/workspace/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()
```