# POST /ai/generate-whiteboard

**Resource:** [AI](./ai.md)  
**Scopes:** `ai:use`  
**Write operation:** yes

Generate a whiteboard/diagram template with AI -- process flows, org charts, decision trees, customer journeys, system architectures. Produces Excalidraw-compatible shapes with coordinated colour themes. By default (persist=true), creates whiteboard_templates + whiteboard_snapshots rows. Costs credits (ai_tool_generate).

## Parameters

| Name | In | Type | Required | Description |
|------|----|------|----------|-------------|
| `prompt` | body | string | yes | Plain-language description of the diagram to generate. |
| `persist` | body | boolean | no | If true (default), creates the whiteboard template and snapshot. If false, returns only the generated structure. |
| `name` | body | string | no | Override the AI-generated whiteboard name. |

## Response example

```json
{
  "data": {
    "template": {
      "id": "uuid",
      "name": "Sales Pipeline Flow",
      "description": "...",
      "created_at": "2026-04-19T..."
    },
    "element_count": 20,
    "persisted": true
  },
  "meta": {
    "credits_remaining": 9150
  }
}
```

---
Base URL: `https://api.trustpager.com/functions/v1/api/v1` — Auth: `Authorization: Bearer YOUR_API_KEY`