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

# Start a playbook run in a space

POST https://api.cloudraker.com/spaces/{spaceId}/playbook-runs
Content-Type: application/json

Starts a new durable agentic run of a playbook in this space. Authorization: requires `space:contribute` on the space (org admins bypass); missing permission → 403. Body: `playbookId` (required — the playbook to run) and `fileScope`, which is either `{ mode: "space" }` (the agent may see all files in the space) or `{ mode: "picked", fileIds: [...] }` (1–200 explicit file ids). Optional `prompt` (1–4000 chars) is the request that founds the run: it is frozen into the run’s immutable snapshot and stays part of the agent’s standing instructions for every turn — use `steer` to say anything after launch. `spaceType` is resolved from the space record server-side and is NOT accepted from the caller. Returns 404 when the space does not exist. On success returns 201 `{ data: PlaybookRun }` — the created run with its immutable snapshot of the playbook captured at launch time.

Reference: https://docs.cloudraker.com/workspace/api/playbooks/create-playbook-run

## Authentication

- `Authorization` header (bearer token, required)

## Request

### Path parameters

- `spaceId` (string, required)

### Body (application/json)

- `playbookId` (string, required)
- `fileScope` (object or object, required)
  - object
    - `mode` (enum, required)
      - Allowed values: `space`
  - object
    - `mode` (enum, required)
      - Allowed values: `picked`
    - `fileIds` (list of string, required)
- `prompt` (string, optional) — The request that founds the run, frozen into its immutable snapshot and kept in the agent’s standing instructions. Use steer for anything after launch.

## Response

### 201

The created playbook run.

- `data` (object, required)
  - `id` (string, required)
  - `spaceId` (string, required)
  - `playbookId` (string, required)
  - `playbookVersion` (integer, required)
  - `playbookName` (string, required)
  - `status` (enum, required)
    - Allowed values: `running`, `waiting_approval`, `waiting_action`, `waiting_user`, `paused`, `completed`, `failed`, `cancelled`
  - `fileScope` (object or object, required)
    - object
      - `mode` ("space", required)
    - object
      - `mode` ("picked", required)
      - `fileIds` (list of string, required)
  - `taskProgress` (object, required)
    - `total` (integer, required)
    - `completed` (integer, required)
  - `pendingApproval` (object, required, nullable)
    - `id` (string, required)
    - `kind` (enum, required)
      - Allowed values: `pre`, `post`
    - `actionName` (string, required)
    - `requestedAt` (datetime, required)
  - `result` (string, required, nullable)
  - `error` (string, required, nullable)
  - `startedBy` (string, required)
  - `createdAt` (datetime, required)
  - `updatedAt` (datetime, required)
  - `finishedAt` (datetime, required, nullable)
  - `currentActivity` (string, required, nullable)
  - `snapshot` (object, required) — The playbook as captured at launch. Later edits never affect a run.
    - `playbookId` (string, required)
    - `version` (integer, required)
    - `name` (string, required)
    - `description` (string, required)
    - `tasks` (list of object, required)
      - `id` (string, required)
      - `title` (string, required)
      - `dependsOn` (list of string, required)
      - `status` (enum, required)
        - Allowed values: `pending`, `ready`, `in_progress`, `completed`, `skipped`
      - `summary` (string, required, nullable)
      - `completedAt` (datetime, required, nullable)
      - `instructions` (string, optional, nullable)
      - `executor` (enum, optional)
        - Allowed values: `agent`, `human`
      - `assignee` (string, optional, nullable)
      - `claimedBy` (string, optional, nullable)
      - `completedBy` (string, optional, nullable)
      - `note` (string, optional, nullable)
      - `fileIds` (list of string, optional)
    - `actions` (list of object, required)
      - `installedActionId` (string, required)
      - `preApproval` (boolean, required)
      - `postApproval` (boolean, required)
      - `dependsOn` (list of string, required)
      - `actionSlug` (string, required)
      - `actionName` (string, required)
      - `trigger` (enum, required)
        - Allowed values: `agent`, `user`
      - `browserSession` (object, required, nullable)
        - `status` (enum, required)
          - Allowed values: `pairing`, `live`, `ended`, `expired`
        - `createdAt` (datetime, required)
    - `fileScope` (object or object, required)
      - object
        - `mode` ("space", required)
      - object
        - `mode` ("picked", required)
        - `fileIds` (list of string, required)

## Examples

**Request**

```json
{
  "playbookId": "string",
  "fileScope": {
    "mode": "space"
  }
}
```

**Response**

```json
{
  "data": {
    "id": "string",
    "spaceId": "string",
    "playbookId": "string",
    "playbookVersion": 1,
    "playbookName": "string",
    "status": "running",
    "fileScope": {
      "mode": "string"
    },
    "taskProgress": {
      "total": 1,
      "completed": 1
    },
    "pendingApproval": {
      "id": "string",
      "kind": "pre",
      "actionName": "string",
      "requestedAt": "2024-01-15T09:30:00Z"
    },
    "result": "string",
    "error": "string",
    "startedBy": "string",
    "createdAt": "2024-01-15T09:30:00Z",
    "updatedAt": "2024-01-15T09:30:00Z",
    "finishedAt": "2024-01-15T09:30:00Z",
    "currentActivity": "string",
    "snapshot": {
      "playbookId": "string",
      "version": 1,
      "name": "string",
      "description": "string",
      "tasks": [
        {
          "id": "string",
          "title": "string",
          "dependsOn": [
            "string"
          ],
          "status": "pending",
          "summary": "string",
          "completedAt": "2024-01-15T09:30:00Z",
          "instructions": "string",
          "executor": "agent",
          "assignee": "string",
          "claimedBy": "string",
          "completedBy": "string",
          "note": "string",
          "fileIds": [
            "string"
          ]
        }
      ],
      "actions": [
        {
          "installedActionId": "string",
          "preApproval": true,
          "postApproval": true,
          "dependsOn": [
            "string"
          ],
          "actionSlug": "string",
          "actionName": "string",
          "trigger": "agent",
          "browserSession": {
            "status": "pairing",
            "createdAt": "2024-01-15T09:30:00Z"
          }
        }
      ],
      "fileScope": {
        "mode": "string"
      }
    }
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.cloudraker.com/spaces/spaceId/playbook-runs"

payload = {
    "playbookId": "string",
    "fileScope": { "mode": "space" }
}
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/spaces/spaceId/playbook-runs';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"playbookId":"string","fileScope":{"mode":"space"}}'
};

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/spaces/spaceId/playbook-runs"

	payload := strings.NewReader("{\n  \"playbookId\": \"string\",\n  \"fileScope\": {\n    \"mode\": \"space\"\n  }\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/spaces/spaceId/playbook-runs")

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  \"playbookId\": \"string\",\n  \"fileScope\": {\n    \"mode\": \"space\"\n  }\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/spaces/spaceId/playbook-runs")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"playbookId\": \"string\",\n  \"fileScope\": {\n    \"mode\": \"space\"\n  }\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.cloudraker.com/spaces/spaceId/playbook-runs', [
  'body' => '{
  "playbookId": "string",
  "fileScope": {
    "mode": "space"
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.cloudraker.com/spaces/spaceId/playbook-runs");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"playbookId\": \"string\",\n  \"fileScope\": {\n    \"mode\": \"space\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

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

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.cloudraker.com/spaces/spaceId/playbook-runs")! 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()
```