AI rewrite a document
POST /documents/{id}/ai-rewrite
apiKey connector:writeAuthorizationBearer <token>ChatPRD API key from Settings → API Keys, sent as Authorization: Bearer <key>. Read-only keys carry the connector:read scope; read/write keys also carry connector:write. Requires a Pro, Team or Enterprise plan.
Scope: connector:write
id*stringDocument ID (UUID), as returned by GET /documents.
uuidapplication/json- body
instructions*stringWhat to change.
1 <= length <= 20000context?stringNotes or requirements the AI should use.
length <= 100000organizationId?stringOrganization the document belongs to, if any.
stream?booleanReturn Server-Sent Events instead of 202.
falseServer-Sent Events stream (when stream: true). Each event's data is JSON.
text/event-stream- response
SSE events, in order: generation (id, kind, threadId, documentId, url) first; document.started (documentId, title) once a new document exists; content.delta (documentId, delta) with Markdown chunks while create/rewrite write the document; message.delta (delta) for the AI's short summary; then document.completed (generationId, summary, document) or error (generationId, code, message); finally done. Comment lines (: keep-alive) are sent every 15s.
event*string"generation""document.started""content.delta""message.delta""document.completed""error""done"data*curl -X POST 'https://app.chatprd.ai/api/connectors/v1/documents/497f6eca-6276-4993-bfeb-53cbbbba6f08/ai-rewrite' \ -H 'Content-Type: application/json' \ -d '{ "instructions": "Rewrite this for an executive audience in under one page."}'{ "event": "generation", "data": {}}