Skip to main content
POST
Create a referral
Referrals are created in the provider’s EMR using an asynchronous processing model. Creating a referral this way is not instantaneous. Instead of leaving your POST request hanging until completion, we immediately return a success response if the request is properly formed. We then notify you via a webhook when the referral has been created in the EMR. This gives you flexibility around your user experience. For example, when you first make the /referrals call you can display a Processing status to your user, and when you receive the webhook notification you can update that to Completed.
Creating referrals is currently supported for eClinicalWorks.

Request Parameters

Required Fields

  • patient_mrn (string, required): The patient’s medical record number. The patient must already be synced to Cobalt.
  • referring_from_provider_ehr_id (string, required): EMR ID of the provider the referral is coming from.
  • referring_to_provider_ehr_id (string, required): EMR ID of the provider the referral is going to.
  • direction (string, required): Direction of the referral — incoming or outgoing.
  • priority (string, required): Referral priority — routine, urgent, or stat.
  • reason (string, required): Reason for the referral.

Optional Fields

  • diagnosis_codes (array of strings, optional): ICD-10 diagnosis codes associated with the referral.
  • documents (array, optional): Documents to attach to the referral in the EMR. Each entry is an object with filename and content_base64. See Attaching Documents below.
  • prior_authorization_code (string, optional): Prior authorization code to write on the referral.
  • specialty (string, optional): Referral specialty name — e.g. "Cardiology". Resolved against the EMR instance’s live specialty list when the referral is processed; an unrecognized specialty fails with a referral.failed webhook (error_type: "ecw_validation_failure").
  • location_id (string, optional): EMR location ID of the facility being referred to. Validated synchronously against the account’s synced locations — an unknown location returns a 404 and the referral is not queued. Resolve IDs with GET /v1/locations (use the location’s emr_id).

Direction and Provider Validation

The two provider IDs are validated against different directories depending on the referral’s direction: Pass 0 for a provider ID when there is no provider on that side. Providers must already be synced — use GET /v1/providers and GET /v1/referring-providers to resolve IDs.

Attaching Documents

Documents are optional and supplied inline as base64. Each document is an object:
  • filename must include a file extension (e.g. report.pdf).
  • content_base64 must be non-empty, valid base64.
Documents are attached to the referral in the EMR after the referral itself is created. Because the referral already exists at that point, attachment failures are non-fatal: the referral is still created and the webhook reports how many attachments succeeded and failed.
Requests carrying inline documents can be large. The POST /v1/referrals endpoint accepts request bodies up to 25 MB.

Example Request

Request with Documents

Example Response

The response includes:
  • referral_id: Cobalt referral ID (UUID without dashes). This is echoed back in the webhook payload so you can correlate the two.
  • job_id: Job execution identifier for tracking the async operation.

Error Responses

Missing Required Field

Invalid Priority

Invalid Direction

Invalid Document

Patient Not Found

Unknown Provider

Unknown Location

Returned when location_id does not match a synced location for the account.

User Not Found

This indicates an issue with your access token.

Webhook Notifications

When the referral has finished processing, we send a webhook to your registered endpoint.

Success

Note: documents_attached and documents_failed are only included when the request contained documents.

Failure

Authorizations

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

Body

application/json
patient_mrn
string
required

Medical Record Number of the patient the referral is for.

Example:

"12345"

referring_to_provider_ehr_id
string
required

EHR ID of the provider being referred to. Validated against the provider directory for the referral direction; "0" means no provider on that side.

Example:

"provider-123"

referring_from_provider_ehr_id
string
required

EHR ID of the provider making the referral. Validated against the provider directory for the referral direction; "0" means no provider on that side.

Example:

"provider-456"

priority
string
required

Referral priority. One of: routine, urgent, stat.

Example:

"routine"

reason
string
required

Reason for the referral.

Example:

"Specialist consultation"

direction
string
required

Referral direction. One of: incoming, outgoing.

Example:

"outgoing"

diagnosis_codes
string[]

ICD-10 diagnosis codes associated with the referral.

Example:
prior_authorization_code
string

Prior authorization code to write on the referral.

Example:

"AUTH-12345"

specialty
string

Referral specialty name. Resolved against the EMR instance’s live specialty list by the worker.

Example:

"Cardiology"

location_id
string

EMR location ID of the facility being referred to. Validated against the account’s locations and written as the referral’s to-facility.

Example:

"location-1"

documents
object[]

Documents to attach to the referral, supplied inline. Each item is { filename, content_base64 }; filename must include a file extension.

Example:
callback_urls
string[]

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

Example:

Response

Referral queued for creation

success
boolean
required
message
string
required
referral_id
string
required
job_id
required