> 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). `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/api/cloud-raker-api/workspace/playbooks/create-playbook-run

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: CloudRaker API
  version: 1.0.0
paths:
  /spaces/{spaceId}/playbook-runs:
    post:
      operationId: create-playbook-run
      summary: Start a playbook run in a space
      description: >-
        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). `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.
      tags:
        - playbooks
      parameters:
        - name: spaceId
          in: path
          required: true
          schema:
            type: string
        - name: Authorization
          in: header
          description: Bearer authentication
          required: true
          schema:
            type: string
      responses:
        '201':
          description: The created playbook run.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlaybookRunEnvelope'
        '404':
          description: Space not found
          content:
            application/json:
              schema:
                description: Any type
      requestBody:
        description: >-
          The space type is resolved from the space record and is not accepted
          here.
        content:
          application/json:
            schema:
              type: object
              properties:
                playbookId:
                  type: string
                fileScope:
                  $ref: >-
                    #/components/schemas/SpacesSpaceIdPlaybookRunsPostRequestBodyContentApplicationJsonSchemaFileScope
              required:
                - playbookId
                - fileScope
servers:
  - url: https://api.cloudraker.com
    description: Production
  - url: https://api.staging.raker.one
    description: Staging
  - url: https://api.dev.raker.one
    description: Development
components:
  schemas:
    SpacesSpaceIdPlaybookRunsPostRequestBodyContentApplicationJsonSchemaFileScopeOneOf0Mode:
      type: string
      enum:
        - space
      title: >-
        SpacesSpaceIdPlaybookRunsPostRequestBodyContentApplicationJsonSchemaFileScopeOneOf0Mode
    SpacesSpaceIdPlaybookRunsPostRequestBodyContentApplicationJsonSchemaFileScope0:
      type: object
      properties:
        mode:
          $ref: >-
            #/components/schemas/SpacesSpaceIdPlaybookRunsPostRequestBodyContentApplicationJsonSchemaFileScopeOneOf0Mode
      required:
        - mode
      title: >-
        SpacesSpaceIdPlaybookRunsPostRequestBodyContentApplicationJsonSchemaFileScope0
    SpacesSpaceIdPlaybookRunsPostRequestBodyContentApplicationJsonSchemaFileScopeOneOf1Mode:
      type: string
      enum:
        - picked
      title: >-
        SpacesSpaceIdPlaybookRunsPostRequestBodyContentApplicationJsonSchemaFileScopeOneOf1Mode
    SpacesSpaceIdPlaybookRunsPostRequestBodyContentApplicationJsonSchemaFileScope1:
      type: object
      properties:
        mode:
          $ref: >-
            #/components/schemas/SpacesSpaceIdPlaybookRunsPostRequestBodyContentApplicationJsonSchemaFileScopeOneOf1Mode
        fileIds:
          type: array
          items:
            type: string
      required:
        - mode
        - fileIds
      title: >-
        SpacesSpaceIdPlaybookRunsPostRequestBodyContentApplicationJsonSchemaFileScope1
    SpacesSpaceIdPlaybookRunsPostRequestBodyContentApplicationJsonSchemaFileScope:
      oneOf:
        - $ref: >-
            #/components/schemas/SpacesSpaceIdPlaybookRunsPostRequestBodyContentApplicationJsonSchemaFileScope0
        - $ref: >-
            #/components/schemas/SpacesSpaceIdPlaybookRunsPostRequestBodyContentApplicationJsonSchemaFileScope1
      title: >-
        SpacesSpaceIdPlaybookRunsPostRequestBodyContentApplicationJsonSchemaFileScope
    PlaybookRunDetailStatus:
      type: string
      enum:
        - running
        - waiting_approval
        - waiting_action
        - waiting_user
        - paused
        - completed
        - failed
        - cancelled
      title: PlaybookRunDetailStatus
    PlaybookFileScope0:
      type: object
      properties:
        mode:
          type: string
          enum:
            - space
      required:
        - mode
      title: PlaybookFileScope0
    PlaybookFileScope1:
      type: object
      properties:
        mode:
          type: string
          enum:
            - picked
        fileIds:
          type: array
          items:
            type: string
      required:
        - mode
        - fileIds
      title: PlaybookFileScope1
    PlaybookFileScope:
      oneOf:
        - $ref: '#/components/schemas/PlaybookFileScope0'
        - $ref: '#/components/schemas/PlaybookFileScope1'
      title: PlaybookFileScope
    PlaybookRunDetailTaskProgress:
      type: object
      properties:
        total:
          type: integer
        completed:
          type: integer
      required:
        - total
        - completed
      title: PlaybookRunDetailTaskProgress
    PlaybookRunDetailPendingApprovalKind:
      type: string
      enum:
        - pre
        - post
      title: PlaybookRunDetailPendingApprovalKind
    PlaybookRunDetailPendingApproval:
      type: object
      properties:
        id:
          type: string
        kind:
          $ref: '#/components/schemas/PlaybookRunDetailPendingApprovalKind'
        actionName:
          type: string
        requestedAt:
          type: string
          format: date-time
      required:
        - id
        - kind
        - actionName
        - requestedAt
      title: PlaybookRunDetailPendingApproval
    PlaybookRunDetailSnapshotTasksItemsStatus:
      type: string
      enum:
        - pending
        - completed
      title: PlaybookRunDetailSnapshotTasksItemsStatus
    PlaybookRunDetailSnapshotTasksItems:
      type: object
      properties:
        id:
          type: string
        title:
          type: string
        instructions:
          type:
            - string
            - 'null'
        dependsOn:
          type: array
          items:
            type: string
        status:
          $ref: '#/components/schemas/PlaybookRunDetailSnapshotTasksItemsStatus'
        summary:
          type:
            - string
            - 'null'
        completedAt:
          type:
            - string
            - 'null'
          format: date-time
      required:
        - id
        - title
        - dependsOn
        - status
        - summary
        - completedAt
      title: PlaybookRunDetailSnapshotTasksItems
    PlaybookRunDetailSnapshotActionsItemsTrigger:
      type: string
      enum:
        - agent
        - user
      title: PlaybookRunDetailSnapshotActionsItemsTrigger
    PlaybookRunDetailSnapshotActionsItemsBrowserSessionStatus:
      type: string
      enum:
        - pairing
        - live
        - ended
        - expired
      title: PlaybookRunDetailSnapshotActionsItemsBrowserSessionStatus
    PlaybookRunDetailSnapshotActionsItemsBrowserSession:
      type: object
      properties:
        status:
          $ref: >-
            #/components/schemas/PlaybookRunDetailSnapshotActionsItemsBrowserSessionStatus
        createdAt:
          type: string
          format: date-time
      required:
        - status
        - createdAt
      title: PlaybookRunDetailSnapshotActionsItemsBrowserSession
    PlaybookRunDetailSnapshotActionsItems:
      type: object
      properties:
        installedActionId:
          type: string
        preApproval:
          type: boolean
        postApproval:
          type: boolean
        dependsOn:
          type: array
          items:
            type: string
        actionSlug:
          type: string
        actionName:
          type: string
        trigger:
          $ref: '#/components/schemas/PlaybookRunDetailSnapshotActionsItemsTrigger'
        browserSession:
          oneOf:
            - $ref: >-
                #/components/schemas/PlaybookRunDetailSnapshotActionsItemsBrowserSession
            - type: 'null'
      required:
        - installedActionId
        - preApproval
        - postApproval
        - dependsOn
        - actionSlug
        - actionName
        - trigger
        - browserSession
      title: PlaybookRunDetailSnapshotActionsItems
    PlaybookRunDetailSnapshot:
      type: object
      properties:
        playbookId:
          type: string
        version:
          type: integer
        name:
          type: string
        description:
          type: string
        tasks:
          type: array
          items:
            $ref: '#/components/schemas/PlaybookRunDetailSnapshotTasksItems'
        actions:
          type: array
          items:
            $ref: '#/components/schemas/PlaybookRunDetailSnapshotActionsItems'
        fileScope:
          $ref: '#/components/schemas/PlaybookFileScope'
      required:
        - playbookId
        - version
        - name
        - description
        - tasks
        - actions
        - fileScope
      description: The playbook as captured at launch. Later edits never affect a run.
      title: PlaybookRunDetailSnapshot
    PlaybookRunDetail:
      type: object
      properties:
        id:
          type: string
        spaceId:
          type: string
        playbookId:
          type: string
        playbookVersion:
          type: integer
        playbookName:
          type: string
        status:
          $ref: '#/components/schemas/PlaybookRunDetailStatus'
        fileScope:
          $ref: '#/components/schemas/PlaybookFileScope'
        taskProgress:
          $ref: '#/components/schemas/PlaybookRunDetailTaskProgress'
        pendingApproval:
          oneOf:
            - $ref: '#/components/schemas/PlaybookRunDetailPendingApproval'
            - type: 'null'
        result:
          type:
            - string
            - 'null'
        error:
          type:
            - string
            - 'null'
        startedBy:
          type: string
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
        finishedAt:
          type:
            - string
            - 'null'
          format: date-time
        currentActivity:
          type:
            - string
            - 'null'
        snapshot:
          $ref: '#/components/schemas/PlaybookRunDetailSnapshot'
          description: The playbook as captured at launch. Later edits never affect a run.
      required:
        - id
        - spaceId
        - playbookId
        - playbookVersion
        - playbookName
        - status
        - fileScope
        - taskProgress
        - pendingApproval
        - result
        - error
        - startedBy
        - createdAt
        - updatedAt
        - finishedAt
        - currentActivity
        - snapshot
      title: PlaybookRunDetail
    PlaybookRunEnvelope:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/PlaybookRunDetail'
      required:
        - data
      title: PlaybookRunEnvelope
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

```

## Examples



**Request**

```json
{
  "playbookId": "pb-8f3a2c7d",
  "fileScope": {
    "mode": "space"
  }
}
```

**Response**

```json
{
  "data": {
    "id": "run-4b9d2e1f",
    "spaceId": "space-12345",
    "playbookId": "pb-8f3a2c7d",
    "playbookVersion": 3,
    "playbookName": "Incident Response Workflow",
    "status": "running",
    "fileScope": {
      "mode": "space"
    },
    "taskProgress": {
      "total": 5,
      "completed": 2
    },
    "pendingApproval": {
      "id": "approval-9876",
      "kind": "pre",
      "actionName": "Escalate Incident",
      "requestedAt": "2024-01-15T09:30:00Z"
    },
    "result": "In progress",
    "error": "",
    "startedBy": "user-42",
    "createdAt": "2024-01-15T09:30:00Z",
    "updatedAt": "2024-01-15T10:00:00Z",
    "finishedAt": "2024-01-15T12:00:00Z",
    "currentActivity": "Waiting for escalation approval",
    "snapshot": {
      "playbookId": "pb-8f3a2c7d",
      "version": 3,
      "name": "Incident Response Workflow",
      "description": "A playbook to handle security incidents efficiently.",
      "tasks": [
        {
          "id": "task-001",
          "title": "Identify Incident",
          "dependsOn": [],
          "status": "completed",
          "summary": "Incident identified and logged.",
          "completedAt": "2024-01-15T09:45:00Z",
          "instructions": "Gather all relevant logs and alerts."
        }
      ],
      "actions": [
        {
          "installedActionId": "action-esc-01",
          "preApproval": true,
          "postApproval": false,
          "dependsOn": [
            "task-001"
          ],
          "actionSlug": "escalate-incident",
          "actionName": "Escalate Incident",
          "trigger": "agent",
          "browserSession": {
            "status": "pairing",
            "createdAt": "2024-01-15T09:30:00Z"
          }
        }
      ],
      "fileScope": {
        "mode": "space"
      }
    }
  }
}
```

**SDK Code**

```python
import requests

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

payload = {
    "playbookId": "pb-8f3a2c7d",
    "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":"pb-8f3a2c7d","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\": \"pb-8f3a2c7d\",\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\": \"pb-8f3a2c7d\",\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\": \"pb-8f3a2c7d\",\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": "pb-8f3a2c7d",
  "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\": \"pb-8f3a2c7d\",\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": "pb-8f3a2c7d",
  "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()
```