curl --request POST \
--url https://api.healos.ai/ext-api/v1/patients/{patientId}/documents \
--header 'Content-Type: multipart/form-data' \
--header 'X-API-Key: <api-key>' \
--form 'file=<unknown>' \
--form external_id=PARTNER-DOC-456const form = new FormData();
form.append('file', '<unknown>');
form.append('external_id', 'PARTNER-DOC-456');
const options = {method: 'POST', headers: {'X-API-Key': '<api-key>'}};
options.body = form;
fetch('https://api.healos.ai/ext-api/v1/patients/{patientId}/documents', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.healos.ai/ext-api/v1/patients/{patientId}/documents"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"\r\n\r\n<unknown>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"external_id\"\r\n\r\nPARTNER-DOC-456\r\n-----011000010111000001101001--"
headers = {"X-API-Key": "<api-key>"}
response = requests.post(url, data=payload, headers=headers)
print(response.text){
"data": {
"id": "d4e5f6a7-b8c9-4d0e-1f2a-3b4c5d6e7f8a",
"filename": "intake_form_maria_santos.pdf",
"file_type": "pdf",
"file_size": 245760,
"public_url": "<string>",
"upload_date": "2026-03-20T11:15:00.000Z",
"status": "pending",
"extracted_date": "2026-03-20T11:16:00.000Z",
"extraction_error": "No text could be extracted from the PDF",
"extraction_deferred": false,
"has_extracted_text": true,
"extracted_text_length": 2048,
"external_id": "PARTNER-DOC-456"
},
"message": "Document uploaded successfully; text extraction started",
"extraction_deferred_until": "2026-11-04T00:00:00.000Z"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "external_id already in use",
"existing": {
"id": "<string>",
"external_id": "<string>"
}
}{
"error": "<string>"
}{
"error": "<string>",
"code": "idempotency_key_invalid"
}{
"error": "Rate limit exceeded. Please retry after the window resets.",
"code": "daily_cap_reached",
"reset_at": "2026-10-28T00:00:00.000Z"
}Upload a document
Upload a document for a patient. Accepts PDF, JPEG, PNG, and DOCX files up to 10MB; the file content must match its extension, and the stored content type is the detected one. Pass an optional external_id form field to attach a caller-supplied identifier (immutable once set; unique per organization).
Text extraction runs asynchronously. This endpoint returns as soon as the file is stored — it does not wait for extraction (which can take 10–30s for a PDF). The returned document is typically in pending status (extraction may occasionally finish before the response is built). Track progress by polling GET /patients/{patientId}/documents (pass ?external_id=<your id> to fetch just this document) until its status is completed (has_extracted_text becomes true) or failed. Note: these endpoints report extraction status and availability (status, has_extracted_text, extracted_text_length) — the extracted text content itself is not returned. You can (re-)trigger extraction at any time with POST /patients/{patientId}/documents/{documentId}/extract.
Daily extraction limit. If your organization has a daily document extraction limit, extraction counts against it (per UTC day, shared with the /extract endpoint); most organizations have none. Over the limit the upload still succeeds (201): the document is stored and stays pending with extraction_deferred: true, the response carries extraction_deferred_until (the next 00:00 UTC), and extraction runs automatically after that, counted against that day’s limit. Uploads are never refused with 429 for this limit.
Rarely, if extraction could not be queued, the upload still succeeds (201) but the response message omits “text extraction started” and the document stays pending with no work scheduled. Check the response message; if extraction was not started, call the /extract endpoint to trigger it (otherwise a poller would wait indefinitely).
Prefer webhooks over polling. Register a DOCUMENT_STATUS_CHANGED outbound webhook to be notified the moment extraction reaches a terminal state — the event payload carries document_id, external_id, status (completed/failed), any error, and a document_url (a direct document lookup when external_id is set, otherwise the patient’s document collection), so no polling loop is required.
curl --request POST \
--url https://api.healos.ai/ext-api/v1/patients/{patientId}/documents \
--header 'Content-Type: multipart/form-data' \
--header 'X-API-Key: <api-key>' \
--form 'file=<unknown>' \
--form external_id=PARTNER-DOC-456const form = new FormData();
form.append('file', '<unknown>');
form.append('external_id', 'PARTNER-DOC-456');
const options = {method: 'POST', headers: {'X-API-Key': '<api-key>'}};
options.body = form;
fetch('https://api.healos.ai/ext-api/v1/patients/{patientId}/documents', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.healos.ai/ext-api/v1/patients/{patientId}/documents"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"\r\n\r\n<unknown>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"external_id\"\r\n\r\nPARTNER-DOC-456\r\n-----011000010111000001101001--"
headers = {"X-API-Key": "<api-key>"}
response = requests.post(url, data=payload, headers=headers)
print(response.text){
"data": {
"id": "d4e5f6a7-b8c9-4d0e-1f2a-3b4c5d6e7f8a",
"filename": "intake_form_maria_santos.pdf",
"file_type": "pdf",
"file_size": 245760,
"public_url": "<string>",
"upload_date": "2026-03-20T11:15:00.000Z",
"status": "pending",
"extracted_date": "2026-03-20T11:16:00.000Z",
"extraction_error": "No text could be extracted from the PDF",
"extraction_deferred": false,
"has_extracted_text": true,
"extracted_text_length": 2048,
"external_id": "PARTNER-DOC-456"
},
"message": "Document uploaded successfully; text extraction started",
"extraction_deferred_until": "2026-11-04T00:00:00.000Z"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "external_id already in use",
"existing": {
"id": "<string>",
"external_id": "<string>"
}
}{
"error": "<string>"
}{
"error": "<string>",
"code": "idempotency_key_invalid"
}{
"error": "Rate limit exceeded. Please retry after the window resets.",
"code": "daily_cap_reached",
"reset_at": "2026-10-28T00:00:00.000Z"
}| Requirement | Detail |
|---|---|
| Scope | documents:write |
| Rate limit | About 60 requests per minute per API key (shared by all endpoints; approximate). Files up to 10 MB. If your organization has a daily document extraction limit (most have none), extraction counts against it, shared with /extract; over it the upload still succeeds and extraction is deferred to the next UTC day (extraction_deferred: true), never a 429. |
| Cost | Free |
- Writes data: Yes. Stores the file on the patient and starts text extraction. A
DOCUMENT_STATUS_CHANGEDwebhook fires when extraction finishes. - Safe to retry: Only with
external_id: a repeat with the sameexternal_idreturns409with the existing record instead of a duplicate. Without it, a retry creates a second record. - Contacts an outside system: None
- Dry run: Not available.
Headers
Makes a retry of this request safe. A repeat with the same key and the same request within 24 hours does not run again: it returns the original status with the resource as it is now, and an Idempotent-Replayed: true header. Keys are scoped to your organization and API key. See https://docs.healos.ai/idempotency.
Up to 255 printable ASCII characters. Use a new random value (a UUID) for each new request and resend the same value when you retry it.
1 - 255"5f0c3a8e-2b7d-4c1e-9a64-0d3f2e1b7c90"
Body
Response
Document uploaded. The file is stored and, in the normal case, text extraction is queued to run asynchronously — the returned document is then typically pending. If extraction could not be queued, the file is still saved and message reflects that (trigger extraction later via the extract endpoint). Poll the GET endpoint to track extraction status.
Human-readable status. text extraction started when extraction was queued; text extraction deferred when the organization's daily document extraction limit was reached (extraction runs automatically after extraction_deferred_until); Document uploaded successfully if the file was stored but extraction could not be queued (retry via the extract endpoint).
"Document uploaded successfully; text extraction started"
Was this page helpful?

