APIAI documents

AI create a document

POST /documents/ai-create

POST
/documents/ai-create

Authorization

apiKey connector:write
headerAuthorizationBearer <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

Request Body

application/json
  1. body
prompt*string

What the AI should write.

Length1 <= length <= 20000
context?string

Notes, research or requirements the AI should use.

Lengthlength <= 100000
templateId?string

Template ID from GET /templates, default for the ChatPRD PRD template, or none. Omit to use the user's default template.

projectId?string

Project to create the document in.

organizationId?string

Organization workspace to create the document in.

stream?boolean

Return Server-Sent Events instead of 202.

Defaultfalse

Response Body

Server-Sent Events stream (when stream: true). Each event's data is JSON.

text/event-stream
  1. 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
Value in"generation""document.started""content.delta""message.delta""document.completed""error""done"
data*
Example Request
curl -X POST 'https://app.chatprd.ai/api/connectors/v1/documents/ai-create' \  -H 'Content-Type: application/json' \  -d '{  "prompt": "PRD for SSO login for enterprise admins",  "templateId": "default",  "stream": true}'
Example Response
{  "event": "generation",  "data": {}}