Documents API
The Documents API turns a natural-language prompt into a brand-styled, multi-page document — a report, a brief, a white paper — lets you revise it by describing the change, and hands you the finished file as PDF or Word.
Documents are A4 portrait with references in AMA style.
Generate and edit stream: you start the work, then read Server-Sent Events for progress and the result.
Full schemas and per-field documentation live in the interactive API Reference.
Authentication
All endpoints require a Bearer token:
Authorization: Bearer YOUR_API_KEY
See Getting Started → Authentication for details.
Endpoint summary
| Method | Path | Description |
|---|---|---|
POST | /api/v1/documents/generate | Generate a document |
POST | /api/v1/documents/edit | Revise a document |
POST | /api/v1/documents/download | Download the file |
POST | /api/v2/streams/sessions | Get a stream URL for a callback_id |
GET | /api/v1/documents/status | Get a turn's status (polling alternative) |
GET | /api/v1/documents/templates | List available templates |
GET | /api/v1/documents/languages | List supported languages |
GET | /api/v1/documents/skills | List available skills |
POST | /api/v1/documents/feedback | Like or dislike a document |
How the streaming flow works
1. POST /api/v1/documents/generate → { resData: { callback_id } }
2. POST /api/v2/streams/sessions → { data: { stream_url } }
3. open stream_url (SSE) → progress events…
terminal event + download_url
Edit follows the same three steps. Every event has the same shape:
event: status
data: {"status":"inprogress","message":"Writing your document","callback_id":"3f8e7d61-…"}
| Field | Notes |
|---|---|
status | inprogress while working; then one of success, failed, cancelled |
message | Human-readable step — safe to show a user verbatim |
callback_id | The generation or edit turn this event belongs to |
download_url | Only on a success event — the document in its configured export_type |
Reconnection, timeouts, and client code are in Streaming (SSE).
Response envelopes
Errors use the canonical envelope on every endpoint:
{ "success": false, "data": null, "error": { "code": "...", "message": "..." } }
Success shapes differ per endpoint:
| Endpoint | Success shape |
|---|---|
POST /api/v1/documents/generate | { message, resData, error } |
POST /api/v1/documents/edit | { message, resData, error } |
POST /api/v1/documents/download | flat top-level fields |
POST /api/v2/streams/sessions | { success, data } |
GET /api/v1/documents/status | flat { message, status, download_url } |
GET /api/v1/documents/templates | { status, log, data } |
GET /api/v1/documents/languages | { status, log, data } |
GET /api/v1/documents/skills | { status, log, data } |
POST /api/v1/documents/feedback | { message, resData, error } |
POST /api/v1/documents/generate — Generate a document
Starts a generation and returns a callback_id. The document arrives over
the stream.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
prompt | string | yes | What to write, in plain language. |
skill_id | string | no | A skill_id from /api/v1/documents/skills. A skill not available to you is rejected with 422. |
files | array | no | [{ "file_id": "…" }] — files to ground the document in. See File Upload. |
web_links | array | no | URLs for the generator to read. |
text | string | no | A block of text as source material. |
connector_ids | array | no | mcp_id values of connected apps to pull context from. Each must be connected for you, or the request is rejected with 422. |
settings | object | no | Document settings — see below. |
properties | object | no | Document properties — author, version, confidentiality, watermark. See below. |
Unknown fields — at the root, in settings, or in properties — are
rejected with 422 rather than ignored.
Settings
Every key is optional. An omitted key falls back to your API key's configured default, then to the default below.
| Key | Type | Accepted values / default |
|---|---|---|
template_id | string | A template code from /api/v1/documents/templates. Default: your key's template, then your default theme. |
language | string | A locale from /api/v1/documents/languages. Default en. |
page_layout | string | standard, minimal, or summary_first. Default standard. |
export_type | string | pdf or docx. Default pdf. |
websearch | boolean | Let the generator search the web. Default true. |
show_sources | boolean | Include the references section. Default true. |
enable_mcp_context | boolean | Pull context from your connected apps. Default false. Always on when connector_ids is sent. |
Properties
Every key is optional. Empty values are left off the document.
| Key | Type | Accepted values / default |
|---|---|---|
author_name | string | Up to 80 characters. Default: your name. |
version | string | A version number like 1, 1.2, or 1.2.3. |
confidentiality | string | Public, Internal, Confidential, Restricted, or None. Default: your key's setting, then None. |
watermark | string | Watermark text, up to 30 characters, or None. Default: your key's setting, then None. |
client_time_zone | string | An IANA time zone such as Asia/Kolkata, Europe/London, or UTC — the zone the document's date is shown in. Default UTC. |
Example
- cURL
- Python
- Node.js
curl -X POST https://api.prezent.ai/api/v1/documents/generate \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A market overview report on the 2026 cloud security landscape: trends, key players, risks, and recommendations",
"settings": {
"template_id": "your-template-code",
"language": "en",
"page_layout": "summary_first",
"export_type": "pdf"
},
"properties": {
"author_name": "Strategy Team",
"version": "1.0",
"confidentiality": "Internal"
}
}'
import requests
resp = requests.post(
"https://api.prezent.ai/api/v1/documents/generate",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"prompt": "A market overview report on the 2026 cloud security landscape",
"settings": {"page_layout": "summary_first", "export_type": "pdf"},
"properties": {"author_name": "Strategy Team", "version": "1.0"},
},
)
resp.raise_for_status()
callback_id = resp.json()["resData"]["callback_id"]
const res = await fetch('https://api.prezent.ai/api/v1/documents/generate', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
prompt: 'A market overview report on the 2026 cloud security landscape',
settings: { page_layout: 'summary_first', export_type: 'pdf' },
properties: { author_name: 'Strategy Team', version: '1.0' },
}),
});
const { resData } = await res.json();
const callbackId = resData.callback_id;
A grounded request with a skill:
{
"prompt": "An executive brief summarising our Q3 security findings",
"skill_id": "612a9f7d-c2b8-48ba-8f5a-8acdefade314",
"files": [{ "file_id": "0efc0f76-4c51-4564-a671-f0ff0c21d23e" }],
"web_links": ["https://example.com/2026-cloud-security-report"],
"settings": {
"export_type": "docx",
"websearch": false
},
"properties": {
"confidentiality": "Confidential",
"watermark": "DRAFT",
"client_time_zone": "America/New_York"
}
}
Success response (200)
{
"message": "Job submitted successfully",
"resData": {
"callback_id": "3f8e7d61-9a2b-4c5e-b013-7d4a6f2c8e91",
"preview_url": "https://…/documents?…"
},
"error": null
}
The payload is under resData. callback_id is valid for about
3 hours. preview_url opens the document in the Prezent app and is
present only when enabled on your key.
Validation errors (422)
{
"success": false,
"data": null,
"error": {
"code": "INVALID_INPUT",
"message": "The request contains invalid input.",
"details": [
"prompt is required",
"settings.export_type: 'pptx' is not supported (accepted values: pdf, docx)"
]
}
}
POST /api/v1/documents/edit — Revise a document
Applies a natural-language edit to an existing document.
Edits are conversational: pass the callback_id of the most recent
turn, and use the new id you get back for the next edit.
Wait for the previous turn's terminal event before editing. A turn still
in flight is rejected with that reason in error.message.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
callback_id | string | yes | The document to edit — the original generation, or the most recent edit. |
prompt | string | yes | The change to make, in plain language. |
files | array | no | [{ "file_id": "…" }] — context for this edit. |
web_links | array | no | URLs to read as context. |
text | string | no | A block of text as context. |
Settings, properties, the skill, and connected apps chosen at generation carry over unchanged.
Example
curl -X POST https://api.prezent.ai/api/v1/documents/edit \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"callback_id": "3f8e7d61-9a2b-4c5e-b013-7d4a6f2c8e91",
"prompt": "Add a section comparing the top three vendors in a table"
}'
Success response (200)
{
"message": "Edit submitted successfully",
"resData": {
"callback_id": "8c1d4b92-6f37-4e2a-a95c-1b0e7d3f6a48"
},
"error": null
}
This callback_id is new. Stream it to watch the edit, and pass it to
your next edit.
POST /api/v1/documents/download — Download the file
Returns the file for a finished document turn. Downloads are free — a document is billed when it is generated or edited.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
callback_id | string | yes | The document to download. |
export_type | string | no | pdf or docx. Defaults to your key's configured format, then pdf. |
Example
curl -X POST https://api.prezent.ai/api/v1/documents/download \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"callback_id": "3f8e7d61-9a2b-4c5e-b013-7d4a6f2c8e91",
"export_type": "docx"
}'
Success response (200)
The response carries either a download_url or a stream_url:
| Case | Field | What to do |
|---|---|---|
| Already exported in this format | download_url | Fetch it. |
| Needs exporting | stream_url | Open it and read the terminal event for the download_url. |
{
"message": "Document exported successfully",
"status": "success",
"callback_id": "3f8e7d61-9a2b-4c5e-b013-7d4a6f2c8e91",
"export_type": "pdf",
"download_url": "https://assets.prezent.ai/protected/…/document.pdf?token=…",
"expires_at": "2026-08-05T12:34:56.000Z"
}
{
"message": "Connect to stream_url to receive the download URL on the done event",
"status": "success",
"callback_id": "3f8e7d61-9a2b-4c5e-b013-7d4a6f2c8e91",
"export_type": "docx",
"stream_url": "https://stream-api-prod.myprezent.com/v2/streams/a1b2c3?token=…&stream_type=export&export_type=docx",
"expires_at": "2026-08-05T12:34:56.000Z"
}
Both URLs carry their own token — send no Authorization header — and
expire at expires_at (about 5 minutes).
If the turn has no file yet, the response is still 200, with no URL:
status | Meaning |
|---|---|
inprogress | Still generating — retry once it completes. |
failed | The turn produced no document — start a new generation. |
Errors
| Status | error.code | Cause |
|---|---|---|
400 | MISSING_CALLBACK_ID | No callback_id in the body. |
400 | INVALID_DATA_TYPE | callback_id is not a non-empty string, or export_type is unsupported. |
400 | BAD_REQUEST | No active session for this callback_id (expires ~3 hours after generation). |
429 | USAGE_LIMIT_EXCEEDED | The download would exceed your key's limit, counted in documents. |
500 | INTERNAL_SERVER_ERROR | The export could not be started. |
POST /api/v2/streams/sessions — Get a stream URL
Exchanges a callback_id from document generate or edit for an
authenticated SSE URL. Shared across all 2.0 streaming surfaces.
curl -X POST https://api.prezent.ai/api/v2/streams/sessions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "callback_id": "3f8e7d61-9a2b-4c5e-b013-7d4a6f2c8e91" }'
{
"success": true,
"data": {
"callback_id": "3f8e7d61-9a2b-4c5e-b013-7d4a6f2c8e91",
"stream_url": "https://stream-api-prod.myprezent.com/v2/streams/a1b2c3?token=eyJhbGciOi...&turn_id=3f8e7d61",
"expires_at": "2026-08-05T12:34:56.000Z"
}
}
stream_url expires in about 5 minutes; calling again mints a fresh one
that replays from the start of the turn. Full details:
AI Builder → Get a stream URL.
GET /api/v1/documents/status — Get a turn's status
The polling alternative to streaming.
| Parameter | Type | Required | Description |
|---|---|---|---|
callback_id | string | yes | The id from document generate or edit. |
curl -s "https://api.prezent.ai/api/v1/documents/status?callback_id=3f8e7d61-9a2b-4c5e-b013-7d4a6f2c8e91" \
-H "Authorization: Bearer YOUR_API_KEY"
{
"message": "Workflow status polling completed. Your document is ready to download.",
"status": "success",
"download_url": "https://cdn.prezent.ai/exports/a1b2c3/document.pdf?token=..."
}
status | Meaning |
|---|---|
in_progress | Still running. |
success | Finished — download_url is populated. |
failed | Terminal with no file. message carries the reason. |
| Status | error.code | Meaning |
|---|---|---|
400 | MISSING_REQUIRED_FIELD | callback_id absent. |
400 | BAD_REQUEST | callback_id belongs to a presentation, poster, brochure, or diagram — use that surface's status endpoint. |
404 | STREAM_CALLBACK_NOT_FOUND | No document with this id was issued to your key. |
GET /api/v1/documents/templates — List templates
The brand templates available for documents. Pass a template's code as
settings.template_id.
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | no | Filter by template name. |
sort | string | no | <field>:asc or <field>:desc, for example name:asc. |
curl -s "https://api.prezent.ai/api/v1/documents/templates?sort=name:asc" \
-H "Authorization: Bearer YOUR_API_KEY"
{
"status": "success",
"log": "success",
"data": [
{
"code": "CORP26",
"name": "Corporate 2026",
"isDisabled": false
}
]
}
GET /api/v1/documents/languages — List supported languages
Pass a locale from this list as settings.language. The list is static —
cache it.
curl -s https://api.prezent.ai/api/v1/documents/languages \
-H "Authorization: Bearer YOUR_API_KEY"
{
"status": "success",
"log": "Supported languages retrieved successfully",
"data": [
{ "language": "Arabic", "locale": "ar" },
{ "language": "English (UK)", "locale": "en-uk" },
{ "language": "English (US)", "locale": "en" },
{ "language": "French", "locale": "fr" },
{ "language": "German", "locale": "de" }
]
}
GET /api/v1/documents/skills — List skills
The document skills available to you — the values you pass as skill_id
on generate.
| List | Contents |
|---|---|
default_skills | Prezent's skills for your industry, including any you have customized. |
my_skills | Skills you created from scratch. |
shared_skills | Skills other people in your company shared with you. |
curl -s https://api.prezent.ai/api/v1/documents/skills \
-H "Authorization: Bearer YOUR_API_KEY"
{
"status": "success",
"log": "Skills retrieved successfully",
"data": {
"default_skills": [
{
"skill_id": "executive_brief",
"skill_name": "Executive Brief",
"description": "Short, decision-oriented documents for leadership.",
"display_description": "Executive brief",
"instructions": "Open with the recommendation, then the evidence and next steps.",
"industry": "Technology",
"function": null
}
],
"my_skills": [],
"shared_skills": [
{
"skill_id": "5b2e8c1a-7d4f-4a3b-9e6c-2f1d0a8b7c63",
"skill_name": "Quarterly Business Review",
"description": "QBR write-ups in the finance team's format.",
"display_description": null,
"instructions": "Summary first, then KPIs by region, risks, and asks.",
"industry": null,
"function": null
}
]
}
}
POST /api/v1/documents/feedback — Like or dislike a document
Records a like or a dislike on one generation or edit turn. Each call
replaces the turn's previous feedback; send clear to remove it.
Feedback is not metered.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
callback_id | string | yes | The turn to rate — the id from generate, or the new id an edit returned. |
action | string | yes | like, dislike, or clear. |
feedback_text | string | no | A comment about the result, up to 5000 characters. Only with dislike. |
Example
curl -X POST https://api.prezent.ai/api/v1/documents/feedback \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"callback_id": "8c1d4b92-6f37-4e2a-a95c-1b0e7d3f6a48",
"action": "dislike",
"feedback_text": "The recommendations section repeats the summary."
}'
Success response (200)
{
"message": "Feedback recorded successfully",
"resData": {
"callback_id": "8c1d4b92-6f37-4e2a-a95c-1b0e7d3f6a48",
"action": "dislike",
"feedback_text": "The recommendations section repeats the summary.",
"feedback_at": "2026-10-07T10:42:15.123Z"
},
"error": null
}
A callback_id that did not come from document generate or edit is
rejected with 400.
End-to-end example
Generate a document, stream it to completion, then download it as Word.
- Python
- Node.js
import json
import httpx # pip install httpx httpx-sse
from httpx_sse import connect_sse
BASE = "https://api.prezent.ai"
HEADERS = {"Authorization": "Bearer YOUR_API_KEY"}
def read_stream(stream_url):
"""Read a stream to its terminal event and return that event."""
with httpx.Client(timeout=None) as sc:
with connect_sse(sc, "GET", stream_url) as events:
for sse in events.iter_sse():
if not sse.data.strip(): # keep-alive ping
continue
event = json.loads(sse.data)
print(event["status"], "-", event.get("message"))
if event["status"] == "inprogress":
continue
if event["status"] != "success":
raise RuntimeError(f"{event['status']}: {event.get('message')}")
return event
raise RuntimeError("stream closed without a terminal event")
with httpx.Client(base_url=BASE, headers=HEADERS, timeout=30) as c:
# 1. start the generation
gen = c.post("/api/v1/documents/generate", json={
"prompt": "A market overview report on the 2026 cloud security landscape",
"settings": {"export_type": "pdf"},
})
gen.raise_for_status()
callback_id = gen.json()["resData"]["callback_id"]
# 2 + 3. stream to completion (the terminal event carries the PDF)
sess = c.post("/api/v2/streams/sessions", json={"callback_id": callback_id})
sess.raise_for_status()
read_stream(sess.json()["data"]["stream_url"])
# 4. download as Word — inline URL, or a stream that delivers one
dl = c.post("/api/v1/documents/download",
json={"callback_id": callback_id, "export_type": "docx"}).json()
url = dl.get("download_url") or read_stream(dl["stream_url"])["download_url"]
print("document ready:", url)
import { EventSource } from 'eventsource'; // npm install eventsource
const BASE = 'https://api.prezent.ai';
const HEADERS = {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
};
const post = async (path, body) => {
const res = await fetch(`${BASE}${path}`, {
method: 'POST',
headers: HEADERS,
body: JSON.stringify(body),
});
if (!res.ok) throw new Error(`${path} → ${res.status} ${await res.text()}`);
return res.json();
};
// Read a stream to its terminal event and resolve with that event.
const readStream = (streamUrl) =>
new Promise((resolve, reject) => {
const es = new EventSource(streamUrl);
es.onmessage = (e) => {
const event = JSON.parse(e.data);
console.log(event.status, '-', event.message);
if (event.status === 'inprogress') return;
es.close();
if (event.status === 'success') resolve(event);
else reject(new Error(`${event.status}: ${event.message}`));
};
es.onerror = () => { es.close(); reject(new Error('stream failed')); };
});
// 1. start
const { resData } = await post('/api/v1/documents/generate', {
prompt: 'A market overview report on the 2026 cloud security landscape',
settings: { export_type: 'pdf' },
});
const callbackId = resData.callback_id;
// 2 + 3. stream to completion
const { data } = await post('/api/v2/streams/sessions', { callback_id: callbackId });
await readStream(data.stream_url);
// 4. download as Word — inline URL, or a stream that delivers one
const dl = await post('/api/v1/documents/download', {
callback_id: callbackId,
export_type: 'docx',
});
const url = dl.download_url ?? (await readStream(dl.stream_url)).download_url;
console.log('document ready:', url);
Errors
| Status | error.code | Cause |
|---|---|---|
400 | BAD_REQUEST, INVALID_JSON, MISSING_CALLBACK_ID, MISSING_REQUIRED_FIELD, INVALID_DATA_TYPE | Malformed request, or an unknown or expired callback_id. |
401 | UNAUTHORIZED, INVALID_API_KEY, EXPIRED_API_KEY | Missing, invalid, or expired key. |
404 | ENDPOINT_NOT_FOUND, STREAM_CALLBACK_NOT_FOUND | Key not scoped to this path, or expired session. |
422 | INVALID_INPUT | Field validation failed — bad settings or properties value, an unknown template_id, or a skill_id or connector_ids entry not available to you. error.details is an array of messages. |
429 | TOO_MANY_REQUESTS, RATE_LIMIT_EXCEEDED, USAGE_LIMIT_EXCEEDED | Gateway throttle, per-category limit, or quota. |
500 | INTERNAL_SERVER_ERROR | Unexpected server error. |
503 | SERVICE_UNAVAILABLE | connector_ids could not be checked right now — retry. |
Full catalog: Error Reference.
Where to go next
- Streaming (SSE) — reconnection and client patterns.
- File Upload — getting
file_idvalues. - API Reference — every field, interactively.
- Rate Limits — limit tiers and back-off.