APIAI documents

AI create a document

POST /documents/ai-create

POST
/documents/ai-create
AuthorizationBearer <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.

In: header

Scope: connector:write

promptstring

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

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  }'
{
  "event": "generation",
  "data": {}
}
{
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "kind": "create",
  "status": "generating",
  "threadId": "51f72284-0555-48fe-a20a-4369ee94dc3e",
  "documentId": "4704590c-004e-410d-adf7-acb7ca0a7052",
  "url": "http://example.com",
  "pollUrl": "string"
}
{
  "error": {
    "code": "unauthorized",
    "message": "Invalid or missing API key."
  }
}
{
  "error": {
    "code": "unauthorized",
    "message": "Invalid or missing API key."
  }
}
{
  "error": {
    "code": "unauthorized",
    "message": "Invalid or missing API key."
  }
}
{
  "error": {
    "code": "unauthorized",
    "message": "Invalid or missing API key."
  }
}
{
  "error": {
    "code": "unauthorized",
    "message": "Invalid or missing API key."
  }
}
{
  "error": {
    "code": "unauthorized",
    "message": "Invalid or missing API key."
  }
}