> For the complete documentation index, see [llms.txt](https://docs.dropzone.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.dropzone.ai/api/chat.md).

# Chat

## POST /app/api/v1/chat/

> Send a chat query and receive an AI response.\
> \<br>\
> This endpoint creates a new chat session if no \<code>session\_id\</code> is provided,\
> or reuses an existing session to maintain conversation context.\
> \<br>\<br>\
> \<strong>Usage:\</strong>\
> \<br>\<br>\
> POST to this endpoint with your question\<br>\<br>\
> Receive \<code>session\_id\</code>, \<code>message\_id\</code>, and \<code>message\_url\</code> in response\<br>\<br>\
> Poll the \<code>message\_url\</code> or \<code>GET /app/api/v1/chat/{session\_id}/message/{message\_id}\</code> for results\<br>\<br>\
> (Optional) Include \<code>session\_id\</code> query param in subsequent queries to maintain context\<br>\<br>\
> (Optional) Include \<code>retry\_from\_query\_id\</code> to retry a failed query\
> (\<code>error\</code> or \<code>timed\_out\</code>) in the same session.\
> Attached files from the source query are reused when present.\<br><br>

```json
{"openapi":"3.0.3","info":{"title":"Dropzone AI","version":"0.1.0"},"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"Authorization"}}},"paths":{"/app/api/v1/chat/":{"post":{"operationId":"chat_create","description":"Send a chat query and receive an AI response.\n<br>\nThis endpoint creates a new chat session if no <code>session_id</code> is provided,\nor reuses an existing session to maintain conversation context.\n<br><br>\n<strong>Usage:</strong>\n<br><br>\nPOST to this endpoint with your question<br><br>\nReceive <code>session_id</code>, <code>message_id</code>, and <code>message_url</code> in response<br><br>\nPoll the <code>message_url</code> or <code>GET /app/api/v1/chat/{session_id}/message/{message_id}</code> for results<br><br>\n(Optional) Include <code>session_id</code> query param in subsequent queries to maintain context<br><br>\n(Optional) Include <code>retry_from_query_id</code> to retry a failed query\n(<code>error</code> or <code>timed_out</code>) in the same session.\nAttached files from the source query are reused when present.<br>\n","parameters":[{"in":"query","name":"session_id","schema":{"type":"string"},"description":"Optional: UUID of existing chat session to maintain conversation context"}],"tags":["chat"],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"text":{"type":"string","description":"Your question or chat message"},"files":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","description":"File name (e.g., 'document.pdf')"},"content":{"type":"string","description":"Base64-encoded file content"}},"required":["name","content"]},"description":"Optional: Files to include with your query. Each file must have 'name' and 'content' (base64-encoded) fields."},"retry_from_query_id":{"type":"integer","description":"Optional: message ID of a failed query in the same session to retry (source must be error or timed_out). Reuses attached files from the source query when present."}},"required":["text"]}}}},"responses":{"201":{"content":{"application/json":{"schema":{"type":"object","properties":{"session_id":{"type":"string","format":"uuid"},"message_id":{"type":"integer"},"message_url":{"type":"string"}}}}},"description":"Chat query created successfully. Use the message_url to poll for results."},"400":{"content":{"application/json":{"schema":{"type":"object","properties":{"error_msg":{"type":"string"}}}}},"description":"Bad request - invalid input"},"401":{"content":{"application/json":{"schema":{"type":"object","properties":{"error_msg":{"type":"string"}}}}},"description":"Unauthorized"},"403":{"content":{"application/json":{"schema":{"type":"object","properties":{"detail":{"type":"string"},"error_msg":{"type":"string"},"required_permission":{"type":"object","description":"RBAC permission the caller lacks. Present when the permission check denies the request.","properties":{"resource":{"type":"string"},"action":{"type":"string"}}}}}}},"description":"Access denied"},"404":{"content":{"application/json":{"schema":{"type":"object","properties":{"error_msg":{"type":"string"}}}}},"description":"Resource not found"},"409":{"content":{"application/json":{"schema":{"type":"object","properties":{"error_msg":{"type":"string"},"in_flight_query_id":{"type":"integer"}}}}},"description":"Another query in this session is still pending"},"500":{"content":{"application/json":{"schema":{"type":"object","properties":{"error_msg":{"type":"string"}}}}},"description":"System error"},"503":{"content":{"application/json":{"schema":{"type":"object","properties":{"error_msg":{"type":"string"}}}}},"description":"System not ready for requests"}}}}}}
```

## GET /app/api/v1/chat/{session\_id}/message/{message\_id}

> Get the status and result of a chat message.\
> \<br>\<br>\
> Poll until \<code>status\</code> is no longer \<code>pending\</code>\
> (\<code>done\</code>, \<code>canceled\</code>, \<code>error\</code>, or \<code>timed\_out\</code>).\
> \<br>\<br>\
> \<code>response\_text\</code> is null while pending; set on success or with an error message on failure.\
> \<br>\<br>\
> \<code>response\_citations\</code> is populated only when \<code>status\</code> is \<code>done\</code>.\
> \<br>\<br>\
> \<code>progress\_messages\</code> lists processing updates while pending (last entry is current).<br>

```json
{"openapi":"3.0.3","info":{"title":"Dropzone AI","version":"0.1.0"},"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"Authorization"}},"schemas":{"ChatQueryNested":{"type":"object","description":"A chat query with its CSV citation bodies inline, as core sent them.\n\nThe bodies are stored in `ChatQueryCsvPart` and put back here: API-key clients can't reach the preview /\ndownload endpoints. Reads the parts through `instance.csv_parts`, so a list read should prefetch them.","properties":{"id":{"type":"integer","readOnly":true},"created_at":{"type":"string","format":"date-time","readOnly":true},"updated_at":{"type":"string","format":"date-time","readOnly":true},"chat_session":{"type":"string","format":"uuid","nullable":true},"request_user":{"$ref":"#/components/schemas/CustomUser"},"request_text":{"type":"string"},"request_files":{},"response_text":{"type":"string","nullable":true},"response_citations":{"nullable":true},"interview":{"$ref":"#/components/schemas/Interview"},"status":{"$ref":"#/components/schemas/ChatQueryNestedStatusEnum"},"progress_messages":{"type":"array","items":{"$ref":"#/components/schemas/ChatQueryProgress"},"readOnly":true}},"required":["created_at","id","interview","progress_messages","request_text","request_user","updated_at"]},"CustomUser":{"type":"object","description":"Basic serializer to pass CustomUser details to the front end.\nExtend with any fields your app needs.","properties":{"id":{"type":"integer","readOnly":true},"first_name":{"type":"string","maxLength":150},"last_name":{"type":"string","maxLength":150},"email":{"title":"Email address","oneOf":[{"type":"string","format":"email","maxLength":254},{"type":"string","maxLength":0}]},"role":{"$ref":"#/components/schemas/UserRoleEnum"},"oidc_user_id":{"type":"string","nullable":true}},"required":["id","role"]},"UserRoleEnum":{"enum":["admin","member","restricted-read-only"],"type":"string","description":"* `admin` - admin\n* `member` - member\n* `restricted-read-only` - restricted-read-only"},"Interview":{"type":"object","properties":{"id":{"type":"integer","readOnly":true},"summary":{"type":"string"},"created_at":{"type":"string","format":"date-time","readOnly":true},"started_at":{"type":"string","format":"date-time","readOnly":true,"nullable":true},"updated_at":{"type":"string","format":"date-time","readOnly":true},"completed_at":{"type":"string","format":"date-time","nullable":true},"status":{"$ref":"#/components/schemas/InterviewStatusEnum"},"auto_approved":{"type":"boolean"},"interviewee_email":{"type":"string"},"question":{"type":"string"},"context":{"type":"string","nullable":true},"chat_history":{},"error_msg":{"type":"string","nullable":true},"communicator":{"type":"string","nullable":true},"investigation":{"type":"integer","nullable":true}},"required":["created_at","id","interviewee_email","question","started_at","summary","updated_at"]},"InterviewStatusEnum":{"enum":["pending","approved","active","finished","finished_with_referral","declined","failed","timed_out","canceled"],"type":"string","description":"* `pending` - pending\n* `approved` - approved\n* `active` - active\n* `finished` - finished\n* `finished_with_referral` - finished_with_referral\n* `declined` - declined\n* `failed` - failed\n* `timed_out` - timed_out\n* `canceled` - canceled"},"ChatQueryNestedStatusEnum":{"enum":["pending","done","canceled","error","timed_out"],"type":"string","description":"* `pending` - Pending\n* `done` - Done\n* `canceled` - Canceled\n* `error` - Error\n* `timed_out` - Timed Out"},"ChatQueryProgress":{"type":"object","properties":{"id":{"type":"integer","readOnly":true},"message":{"type":"string"},"timestamp":{"type":"number","format":"double"}},"required":["id","message","timestamp"]}}},"paths":{"/app/api/v1/chat/{session_id}/message/{message_id}":{"get":{"operationId":"chat_message_retrieve","description":"Get the status and result of a chat message.\n<br><br>\nPoll until <code>status</code> is no longer <code>pending</code>\n(<code>done</code>, <code>canceled</code>, <code>error</code>, or <code>timed_out</code>).\n<br><br>\n<code>response_text</code> is null while pending; set on success or with an error message on failure.\n<br><br>\n<code>response_citations</code> is populated only when <code>status</code> is <code>done</code>.\n<br><br>\n<code>progress_messages</code> lists processing updates while pending (last entry is current).\n","parameters":[{"in":"path","name":"message_id","schema":{"type":"integer"},"description":"The message ID returned from POST /app/api/v1/chat/","required":true},{"in":"path","name":"session_id","schema":{"type":"string"},"description":"The chat session ID (UUID)","required":true}],"tags":["chat"],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatQueryNested"}}},"description":"Chat message details with status and response (if complete)"},"400":{"content":{"application/json":{"schema":{"type":"object","properties":{"error_msg":{"type":"string"}}}}},"description":"Bad request - invalid input"},"401":{"content":{"application/json":{"schema":{"type":"object","properties":{"error_msg":{"type":"string"}}}}},"description":"Unauthorized"},"403":{"content":{"application/json":{"schema":{"type":"object","properties":{"detail":{"type":"string"},"error_msg":{"type":"string"},"required_permission":{"type":"object","description":"RBAC permission the caller lacks. Present when the permission check denies the request.","properties":{"resource":{"type":"string"},"action":{"type":"string"}}}}}}},"description":"Access denied"},"404":{"content":{"application/json":{"schema":{"type":"object","properties":{"error_msg":{"type":"string"}}}}},"description":"Resource not found"},"500":{"content":{"application/json":{"schema":{"type":"object","properties":{"error_msg":{"type":"string"}}}}},"description":"System error"},"503":{"content":{"application/json":{"schema":{"type":"object","properties":{"error_msg":{"type":"string"}}}}},"description":"System not ready for requests"}}}}}}
```
