Skip to main content
POST
Fetch a document
Queues an on-demand fetch of a document’s file from the EMR. This is asynchronous: the endpoint returns a job_id, Cobalt retrieves the file from the EMR and stores it, then sends a document.live_fetch_completed webhook. Retrieve the file with GET /documents/. Depending on the EMR, the request takes either document_ids (a batch of 1-10 Cobalt document IDs) or a single document_id. See the request body below for which field your EMR uses.

Getting document IDs

Use the IDs Cobalt returns for EMR documents:
  • documents[].id on each patient in a patient live fetch: a file in the patient’s chart.
  • encounters[].visit_note_document_id on a patient live fetch, or visit_note_document_id on each appointment in an appointment live fetch: the encounter’s visit note, delivered as a PDF.
Cobalt document IDs are UUIDs, accepted with or without dashes. They are stable: the same EMR document always has the same ID, so you can store them.

Flow

  1. POST /documents/fetch returns 202 and a job_id.
  2. Cobalt fetches each file from the EMR and stores it. Visit notes are rendered to PDF.
  3. A document.live_fetch_completed webhook is sent with a result per document.
  4. GET /documents/{id} returns the file.

Example Request

Webhook

With document_ids, data.documents has one result per requested document. A document that could not be fetched has success: false and a message; the other documents in the batch are not affected.

Status Codes

  • 202: Fetch accepted; results are delivered via webhook and files are retrievable at GET /documents/{id}.
  • 400: Missing or invalid document_ids / document_id, more than 10 document_ids, or the connected EMR is not supported.
  • 404: One or more document_ids are not documents of this linked account. The message lists them as sent.

Authorizations

client_id
string
header
required
client_secret
string
header
required
access_token
string
header
required

Body

application/json
document_id
string
required

Cobalt document id identifying the EMR document to fetch (e.g. from the patient live-fetch response).

Example:

"swf1_eyJtIjoiMjg3IiwiZiI6IjI2IiwiaSI6IjEwNDE5NTE3NyJ9"

document_ids
string[]
required

Cobalt document ids to fetch (1-10), e.g. documents[].id or visit_note_document_id from the patient or appointment live fetch. Each document's file is fetched from the EMR (visit notes are rendered to PDF) and stored; results arrive per document in the webhook.

Required array length: 1 - 10 elements
Example:
callback_urls
string[]

URLs to receive the completion webhook for this fetch, in addition to the account webhook.

Example:

Response

Document fetch accepted

success
boolean
required
message
string
required
job_id
required