---
title: "Process text or preview a saved assistant draft"
description: "The preview_assistant_draft operation is available in every workspace and requires a Bearer session, selected X-Workspace-Id membership, and draft-editor or administrator access. Other operation contracts are unchanged. Preview uses a saved current draft, a reviewed safety baseline, current knowledge and model, and no tools or persistent conversation."
---

> Documentation Index
> Fetch the complete documentation index at: https://developer.channelautomations.com/llms.txt
> Use this file to discover all available pages before exploring further.

Path: Channel Automation API

`POST /api/ai/process-text`

The preview_assistant_draft operation is available in every workspace and requires a Bearer session, selected X-Workspace-Id membership, and draft-editor or administrator access. Other operation contracts are unchanged. Preview uses a saved current draft, a reviewed safety baseline, current knowledge and model, and no tools or persistent conversation.

## Request body

_Required._

- `workspaceId` (`post/api/ai/process-text.workspaceId`; string, required)
- `operation` (`post/api/ai/process-text.operation`; string, required)
- `text` (`post/api/ai/process-text.text`; string, optional)
- `options` (`post/api/ai/process-text.options`; object, optional)
  - `agentId` (`post/api/ai/process-text.options.agentId`; string, optional)
    - format `uuid`
  - `draftToken` (`post/api/ai/process-text.options.draftToken`; integer, optional)
    - min 1
  - `messages` (`post/api/ai/process-text.options.messages`; array<object>, optional)
    - `role` (`post/api/ai/process-text.options.messages.role`; string, optional)
      - one of `"user"`, `"assistant"`
    - `content` (`post/api/ai/process-text.options.messages.content`; string, optional)
      - maxLength 8000
  - `simulatedContact` (`post/api/ai/process-text.options.simulatedContact`; object, optional) — Synthetic display fields only; real contact IDs are ignored.

## Example request

```json
{
  "workspaceId": "string",
  "operation": "string",
  "text": "string",
  "options": {
    "agentId": "bc309ecf-5f66-4057-93c5-6611cc9cb7b2",
    "draftToken": 1,
    "messages": [
      {
        "role": "user",
        "content": "string"
      }
    ],
    "simulatedContact": {}
  }
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url https://api.channelautomation.com/api/ai/process-text \
  --header 'Content-Type: application/json' \
  --data '
{
  "workspaceId": "string",
  "operation": "string",
  "text": "string",
  "options": {
    "agentId": "bc309ecf-5f66-4057-93c5-6611cc9cb7b2",
    "draftToken": 1,
    "messages": [
      {
        "role": "user",
        "content": "string"
      }
    ],
    "simulatedContact": {}
  }
}
'
```

### TypeScript

```typescript
const url = 'https://api.channelautomation.com/api/ai/process-text';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    workspaceId: 'string',
    operation: 'string',
    text: 'string',
    options: {
      agentId: 'bc309ecf-5f66-4057-93c5-6611cc9cb7b2',
      draftToken: 1,
      messages: [{role: 'user', content: 'string'}],
      simulatedContact: {}
    }
  })
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.channelautomation.com/api/ai/process-text"

payload = {
    "workspaceId": "string",
    "operation": "string",
    "text": "string",
    "options": {
        "agentId": "bc309ecf-5f66-4057-93c5-6611cc9cb7b2",
        "draftToken": 1,
        "messages": [
            {
                "role": "user",
                "content": "string"
            }
        ],
        "simulatedContact": {}
    }
}
headers = {"Content-Type": "application/json"}

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

print(response.text)
```

## Responses

### 200

Generated text; preview also returns model and draftToken

### 400

Invalid input

### 401

Preview session required

### 403

Preview access denied

### 409

Saved draft changed

### 503

Preview could not run


Source: https://developer.channelautomations.com/api/post-api-ai-process-text/index.md
