---
title: "Import the org playbooks as agents"
---

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

# Import the org playbooks as agents

Path: CloudRaker Workspace API › Workspace Agents

`POST /agents/migrate`

Creates one agent per stored playbook definition (agent-refactor-spec §13): the handle comes from the playbook name, and the published version mirrors the playbook. Idempotent and additive — a playbook that already has an agent comes back in `skipped`, and the source playbook documents are never modified. Every playbook has its own error boundary: a legacy document the current schema refuses lands in `failed` instead of failing the whole import. Authorization: organization administrators only. Response: `{ data: { created: [{ playbookId, agentId, handle }], skipped: string[], failed: [{ playbookId, error }] } }`.

## Authentication

- `bearerAuth`, http, header `Authorization`

## Code samples

### cURL

```bash
curl --request POST \
  --url https://api.cloudraker.com/agents/migrate \
  --header 'Authorization: Bearer <token>'
```

### TypeScript

```typescript
const url = 'https://api.cloudraker.com/agents/migrate';
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

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/agents/migrate"

headers = {"Authorization": "Bearer <token>"}

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

print(response.text)
```

## Responses

### 200

What was created and what was skipped.

#### Example

```json
{
  "data": {
    "created": [
      {
        "playbookId": "string",
        "agentId": "string",
        "handle": "string"
      }
    ],
    "skipped": [
      "string"
    ],
    "failed": [
      {
        "playbookId": "string",
        "error": "string"
      }
    ]
  }
}
```

- `data` (`migratePlaybooksToAgents.response.200.data`; object, required)
  - `created` (`migratePlaybooksToAgents.response.200.data.created`; array<object>, required)
    - `playbookId` (`migratePlaybooksToAgents.response.200.data.created.playbookId`; string, required)
    - `agentId` (`migratePlaybooksToAgents.response.200.data.created.agentId`; string, required)
    - `handle` (`migratePlaybooksToAgents.response.200.data.created.handle`; string, required)
  - `skipped` (`migratePlaybooksToAgents.response.200.data.skipped`; array<string>, required) — Playbook ids that already have an agent — the idempotency answer.
  - `failed` (`migratePlaybooksToAgents.response.200.data.failed`; array<object>, required) — Playbooks the import could not express as an agent (a legacy document the current schema refuses). Each is skipped on its own, the rest of the org still imports.
    - `playbookId` (`migratePlaybooksToAgents.response.200.data.failed.playbookId`; string, required)
    - `error` (`migratePlaybooksToAgents.response.200.data.failed.error`; string, required)


Source: https://docs.cloudraker.com/workspace/api/workspace-agents/migrate-playbooks-to-agents/index.md
