APIAI documents

AI rewrite a document

POST /documents/{id}/ai-rewrite

POST
/documents/{id}/ai-rewrite
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

Path Parameters

idstring

Document ID (UUID), as returned by GET /documents.

Formatuuid
instructionsstring

What to change.

Length1 <= length <= 20000
context?string

Notes or requirements the AI should use.

Lengthlength <= 100000
organizationId?string

Organization the document belongs to, if any.

stream?boolean

Return Server-Sent Events instead of 202.

Defaultfalse

Response Body

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": {}
}
{
  "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."
  }
}