---
title: "Publish the agent draft"
---

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

# Publish the agent draft

Path: CloudRaker Workspace API › Workspace Agents

`POST /agents/{agentRef}/publish`

Publishes the current draft as the agent`s live version and opens a fresh draft at the next version number. Publishing writes the engine-compat shadow playbook document whose id IS the new `agv_` version id, so `POST /spaces/:spaceId/playbook-runs` can start the agent with `playbookId: "<publishedVersionId>"` unchanged. The previous version stops starting runs (its id answers 409 `playbook_not_active`). Authorization: organization administrators only. A `private` agent is visible only to its owner; every other caller gets 404. 409 `agent_archived` when the agent is archived — unarchive it first, publishing must never re-activate a hidden agent. 422 when the draft cannot run: `harness_not_available`, `instructions_too_long_for_native`, `too_many_skills_for_native`, `sandbox_tool_on_native_harness`, `platform_tool_not_available_on_sandbox` (a sandbox version may hold the `files` and `spaces` platform tools only — the rest resolve in the run engine), `tool_grants_nothing_on_sandbox` (a sandbox version may not hold `code`, a connector or delegation — none of them expands to a tool inside a container), `unknown_model_policy`, `space_scope_not_supported_on_native`, or `engine_rejected_version` when the run engine's own validator refuses the version (that one carries `issues[]`, each with the failing `path`). Branch on `error_code`, never on the sentence. Response: `{ data: { agent, draft, published } }` — `agent.publishedVersionId` is the `agv_` id.

## Authentication

- `bearerAuth`, http, header `Authorization`

## Path parameters

- `agentRef` (`publishPaperworkAgent.path.agentRef`; string, required)

## Code samples

### cURL

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

### TypeScript

```typescript
const url = 'https://api.cloudraker.com/agents/<agentRef>/publish';
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/<agentRef>/publish"

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

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

print(response.text)
```

## Responses

### 200

The published agent and its fresh draft.

#### Example

```json
{
  "data": {
    "agent": {
      "id": "string",
      "handle": "string",
      "name": "string",
      "role": "string",
      "avatar": {
        "kind": "initials",
        "color": "string"
      },
      "visibility": "org",
      "ownerUserId": "string",
      "publishedVersionId": "string",
      "documentAgent": true,
      "draftVersionId": "string",
      "emailTriggerId": "string",
      "sourcePlaybookId": "string",
      "createdAt": "2019-08-24T14:15:22Z",
      "updatedAt": "2019-08-24T14:15:22Z",
      "createdBy": "string",
      "archivedAt": "2019-08-24T14:15:22Z"
    },
    "draft": {
      "documentAgent": true,
      "harness": "auto",
      "instructions": "string",
      "model": {
        "policy": "string",
        "maxSteps": 1,
        "budgetCredits": 1
      },
      "memory": {
        "enabled": true
      },
      "skills": [
        "string"
      ],
      "tools": [
        {
          "kind": "action",
          "installedActionId": "string",
          "preApproval": true,
          "postApproval": true
        }
      ],
      "spaces": {
        "mode": "session",
        "spaceIds": [
          "string"
        ],
        "spaceTypes": [
          "string"
        ]
      },
      "network": {
        "policyId": "string"
      },
      "approvals": {
        "defaultForWrite": "ask",
        "sensitive": "ask",
        "approvers": [
          "string"
        ]
      },
      "delegation": {
        "canInvite": [
          "string"
        ]
      },
      "tasks": [
        {
          "id": "string",
          "title": "string",
          "instructions": "string",
          "dependsOn": [
            "string"
          ],
          "executor": "agent",
          "assignee": "string"
        }
      ],
      "id": "string",
      "agentId": "string",
      "version": -9007199254740991,
      "publishedAt": "2019-08-24T14:15:22Z",
      "createdAt": "2019-08-24T14:15:22Z",
      "updatedAt": "2019-08-24T14:15:22Z",
      "createdBy": "string"
    },
    "published": {
      "documentAgent": true,
      "harness": "auto",
      "instructions": "string",
      "model": {
        "policy": "string",
        "maxSteps": 1,
        "budgetCredits": 1
      },
      "memory": {
        "enabled": true
      },
      "skills": [
        "string"
      ],
      "tools": [
        {
          "kind": "action",
          "installedActionId": "string",
          "preApproval": true,
          "postApproval": true
        }
      ],
      "spaces": {
        "mode": "session",
        "spaceIds": [
          "string"
        ],
        "spaceTypes": [
          "string"
        ]
      },
      "network": {
        "policyId": "string"
      },
      "approvals": {
        "defaultForWrite": "ask",
        "sensitive": "ask",
        "approvers": [
          "string"
        ]
      },
      "delegation": {
        "canInvite": [
          "string"
        ]
      },
      "tasks": [
        {
          "id": "string",
          "title": "string",
          "instructions": "string",
          "dependsOn": [
            "string"
          ],
          "executor": "agent",
          "assignee": "string"
        }
      ],
      "id": "string",
      "agentId": "string",
      "version": -9007199254740991,
      "publishedAt": "2019-08-24T14:15:22Z",
      "createdAt": "2019-08-24T14:15:22Z",
      "updatedAt": "2019-08-24T14:15:22Z",
      "createdBy": "string"
    }
  }
}
```

- `data` (`publishPaperworkAgent.response.200.data`; object, required)
  - `agent` (`publishPaperworkAgent.response.200.data.agent`; object, required)
    - `id` (`publishPaperworkAgent.response.200.data.agent.id`; string, required)
    - `handle` (`publishPaperworkAgent.response.200.data.agent.handle`; string, required) — Unique per org, derived from the name when not given (`mike`, `mike-2`, …).
    - `name` (`publishPaperworkAgent.response.200.data.agent.name`; string, required)
    - `role` (`publishPaperworkAgent.response.200.data.agent.role`; string, required)
    - `avatar` (`publishPaperworkAgent.response.200.data.agent.avatar`; object, required)
      - `kind` (`publishPaperworkAgent.response.200.data.agent.avatar.kind`; string, required)
        - one of `"initials"`, `"generated"`
      - `color` (`publishPaperworkAgent.response.200.data.agent.avatar.color`; string, optional)
        - pattern `^#[0-9a-fA-F]{6}$`
    - `visibility` (`publishPaperworkAgent.response.200.data.agent.visibility`; string, required)
      - one of `"org"`, `"private"`
    - `ownerUserId` (`publishPaperworkAgent.response.200.data.agent.ownerUserId`; string, required)
    - `publishedVersionId` (`publishPaperworkAgent.response.200.data.agent.publishedVersionId`; string | null, required) — The `agv_` id a run is started with. Null until the agent is published.
    - `draftVersionId` (`publishPaperworkAgent.response.200.data.agent.draftVersionId`; string, required)
    - `emailTriggerId` (`publishPaperworkAgent.response.200.data.agent.emailTriggerId`; string | null, required)
    - `sourcePlaybookId` (`publishPaperworkAgent.response.200.data.agent.sourcePlaybookId`; string | null, required) — Set on agents created by the playbook migration; null otherwise.
    - `createdAt` (`publishPaperworkAgent.response.200.data.agent.createdAt`; string, required)
      - format `date-time`; pattern `^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$`
    - `updatedAt` (`publishPaperworkAgent.response.200.data.agent.updatedAt`; string, required)
      - format `date-time`; pattern `^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$`
    - `createdBy` (`publishPaperworkAgent.response.200.data.agent.createdBy`; string, required)
    - `archivedAt` (`publishPaperworkAgent.response.200.data.agent.archivedAt`; any of, required)
      - any of: `string`, `null`
    - `documentAgent` (`publishPaperworkAgent.response.200.data.agent.documentAgent`; boolean, optional)
  - `draft` (`publishPaperworkAgent.response.200.data.draft`; object, required)
    - `id` (`publishPaperworkAgent.response.200.data.draft.id`; string, required)
    - `agentId` (`publishPaperworkAgent.response.200.data.draft.agentId`; string, required)
    - `version` (`publishPaperworkAgent.response.200.data.draft.version`; integer, required)
      - min -9007199254740991; max 9007199254740991
    - `publishedAt` (`publishPaperworkAgent.response.200.data.draft.publishedAt`; any of, required)
      - any of: `string`, `null`
    - `createdAt` (`publishPaperworkAgent.response.200.data.draft.createdAt`; string, required)
      - format `date-time`; pattern `^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$`
    - `updatedAt` (`publishPaperworkAgent.response.200.data.draft.updatedAt`; string, required)
      - format `date-time`; pattern `^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$`
    - `createdBy` (`publishPaperworkAgent.response.200.data.draft.createdBy`; string, required)
    - `documentAgent` (`publishPaperworkAgent.response.200.data.draft.documentAgent`; boolean, optional) — Offer this published agent as a document reviewer. Requires file reading and document editing tools.
    - `harness` (`publishPaperworkAgent.response.200.data.draft.harness`; string, optional) — Automatic execution keeps the agent loop in the platform and starts isolated compute only when a tool needs it. Default: `auto`. Legacy `native` and `sandbox` values remain accepted for existing integrations.
      - one of `"auto"`, `"native"`, `"sandbox"`
    - `instructions` (`publishPaperworkAgent.response.200.data.draft.instructions`; string, optional) — The standing instructions the agent runs under. A `native` version must also fit the engine ceiling (8000 chars) to publish.
      - maxLength 32768
    - `model` (`publishPaperworkAgent.response.200.data.draft.model`; object, optional)
      - `policy` (`publishPaperworkAgent.response.200.data.draft.model.policy`; string, optional)
        - minLength 1; maxLength 64
      - `maxSteps` (`publishPaperworkAgent.response.200.data.draft.model.maxSteps`; integer, optional)
        - min 1; max 100
      - `budgetCredits` (`publishPaperworkAgent.response.200.data.draft.model.budgetCredits`; integer, optional)
        - min 1; max 9007199254740991
    - `memory` (`publishPaperworkAgent.response.200.data.draft.memory`; object, optional) — Saved memory the agent reads and updates across sessions. Private agents only: publishing an org agent with memory enabled answers 422 `memory_requires_private`. Default: on for `sandbox`, off otherwise.
      - `enabled` (`publishPaperworkAgent.response.200.data.draft.memory.enabled`; boolean, required)
    - `skills` (`publishPaperworkAgent.response.200.data.draft.skills`; array<string>, optional)
      - minLength 1; maxLength 64
    - `tools` (`publishPaperworkAgent.response.200.data.draft.tools`; array<ToolGrant>, optional)
      - one of:
        - `object`
          - `kind` (`publishPaperworkAgent.response.200.data.draft.tools.1.kind`; string, required)
          - `installedActionId` (`publishPaperworkAgent.response.200.data.draft.tools.1.installedActionId`; string, required)
            - minLength 1; maxLength 128
          - `preApproval` (`publishPaperworkAgent.response.200.data.draft.tools.1.preApproval`; boolean, optional)
          - `postApproval` (`publishPaperworkAgent.response.200.data.draft.tools.1.postApproval`; boolean, optional)
        - `object`
          - `kind` (`publishPaperworkAgent.response.200.data.draft.tools.2.kind`; string, required)
          - `connectionId` (`publishPaperworkAgent.response.200.data.draft.tools.2.connectionId`; string, required)
            - minLength 1; maxLength 128
          - `readOnlyTools` (`publishPaperworkAgent.response.200.data.draft.tools.2.readOnlyTools`; array<string>, optional)
            - minLength 1; maxLength 64
        - `object`
          - `kind` (`publishPaperworkAgent.response.200.data.draft.tools.3.kind`; string, required)
          - `name` (`publishPaperworkAgent.response.200.data.draft.tools.3.name`; string, required)
            - one of `"files"`, `"artifacts"`, `"spaces"`, `"compose"`, `"sign"`, `"search"`, `"objects"`, `"ontology"`, `"markdown"`
        - `object`
          - `kind` (`publishPaperworkAgent.response.200.data.draft.tools.4.kind`; string, required)
          - `name` (`publishPaperworkAgent.response.200.data.draft.tools.4.name`; string, required)
            - one of `"fs"`, `"shell"`, `"browser"`, `"code"`, `"net"`
        - `object`
          - `kind` (`publishPaperworkAgent.response.200.data.draft.tools.5.kind`; string, required)
        - `object`
          - `kind` (`publishPaperworkAgent.response.200.data.draft.tools.6.kind`; string, required)
    - `spaces` (`publishPaperworkAgent.response.200.data.draft.spaces`; object, optional)
      - `mode` (`publishPaperworkAgent.response.200.data.draft.spaces.mode`; string, optional)
        - one of `"session"`, `"fixed"`, `"any"`
      - `spaceIds` (`publishPaperworkAgent.response.200.data.draft.spaces.spaceIds`; array<string>, optional)
        - minLength 1; maxLength 128
      - `spaceTypes` (`publishPaperworkAgent.response.200.data.draft.spaces.spaceTypes`; array<string>, optional)
        - pattern `^[a-z][a-z0-9-]{0,38}[a-z0-9]$`
    - `network` (`publishPaperworkAgent.response.200.data.draft.network`; object, optional)
      - `policyId` (`publishPaperworkAgent.response.200.data.draft.network.policyId`; any of, optional)
        - any of: `string`, `null`
    - `approvals` (`publishPaperworkAgent.response.200.data.draft.approvals`; object, optional)
      - `defaultForWrite` (`publishPaperworkAgent.response.200.data.draft.approvals.defaultForWrite`; string, optional)
        - one of `"ask"`, `"allow"`
      - `sensitive` (`publishPaperworkAgent.response.200.data.draft.approvals.sensitive`; string, optional)
      - `approvers` (`publishPaperworkAgent.response.200.data.draft.approvals.approvers`; array<string>, optional)
        - minLength 1; maxLength 128
    - `delegation` (`publishPaperworkAgent.response.200.data.draft.delegation`; object, optional)
      - `canInvite` (`publishPaperworkAgent.response.200.data.draft.delegation.canInvite`; any of, optional)
        - any of:
          - `array<string>`
          - `string`: one of `"any"`, `"none"`
    - `tasks` (`publishPaperworkAgent.response.200.data.draft.tasks`; array<object>, optional)
      - `id` (`publishPaperworkAgent.response.200.data.draft.tasks.id`; string, required)
        - minLength 1; maxLength 64
      - `title` (`publishPaperworkAgent.response.200.data.draft.tasks.title`; string, required)
        - minLength 1; maxLength 200
      - `instructions` (`publishPaperworkAgent.response.200.data.draft.tasks.instructions`; any of, optional)
        - any of: `string`, `null`
      - `dependsOn` (`publishPaperworkAgent.response.200.data.draft.tasks.dependsOn`; array<string>, optional)
      - `executor` (`publishPaperworkAgent.response.200.data.draft.tasks.executor`; string, optional)
        - one of `"agent"`, `"human"`
      - `assignee` (`publishPaperworkAgent.response.200.data.draft.tasks.assignee`; any of, optional)
        - any of: `string`, `null`
  - `published` (`publishPaperworkAgent.response.200.data.published`; any of, required)
    - any of: `AgentVersion`, `null`

### 404

`not_found` — no such agent in this organization.

### 409

`agent_archived` — unarchive the agent before publishing it.

### 422

The draft cannot run — `error_code` is one of the seven publish codes, or `engine_rejected_version` with per-field `issues[]`.


Source: https://docs.cloudraker.com/workspace/api/workspace-agents/publish-paperwork-agent/index.md
