Skip to main content
POST
Create Service
A service is an episode visit written to the patient’s chart together with its form documentation (for example a scored questionnaire such as GAD-7). Services are created using an asynchronous processing model, so creating one 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 service has been written to the EMR. This gives you flexibility around your user experience. For example, when you first make the /services call you can display a Processing status to your user, and when you receive the webhook notification you can update that to Completed.
Creating services is currently supported for Credible.

How a service is created

Processing a service runs an ordered chain against the EMR:
  1. Team to episode — the patient is assigned to the given team. When the client has no open episode under that team, the assignment opens one. An existing episode is reused.
  2. Service type — the service_type is resolved against the client’s live billing matrix. A service type that is not billable for the client fails the service (see Failure).
  3. Form documentation — the answers you supply are validated against the synced form definition (form_id) and written on the service. For a scored questionnaire, per-question scores are entered and totals and risk bands are derived by the EMR.
  4. Read-back — after signing, the service is re-read from the EMR to confirm it persisted before the success webhook is sent.

Request Parameters

Required Fields

  • patient_mrn (string, required): The patient’s medical record number. For Credible this is the client id. The patient must already be synced to Cobalt.
  • team (string, required): Team name (or numeric team id) that owns the episode. Assigning the client to the team opens the episode when one does not already exist. The name is matched case-insensitively, preferring an exact match over a partial one.
  • service_type (string, required): The service type to add, by name or numeric visit-type id (for example "GAD-7"). Must be billable for the client — that is, present in the client’s billing matrix.
  • form_id (string, required): EMR form id whose answers you are providing — the emr_form_id of a form from GET /v1/forms. Required when the service type documents a form.
  • answers (object, required): Form answers keyed by EMR question id (the emrQuestionId of each question in the form definition — see GET /v1/forms/{id}). For a scored questionnaire, provide the numeric score for each scored question; totals and risk bands are derived automatically. Answers are validated against the synced form definition before the service is written.

Optional Fields

  • service_date (string, optional): Service date in YYYY-MM-DD format. Defaults to today. Cannot be in the future.
  • callback_urls (array of strings, optional): URLs to receive the completion webhook for this service, in addition to your account webhook.

Example Request

Example Response

The response includes:
  • service_id: Cobalt service 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

Answers Not An Object

Invalid Service Date

User Not Found

This indicates an issue with your access token.

Unsupported EMR

Your EMR system may not currently support service creation.

Webhook Notifications

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

Success

The webhook data includes:
  • service_id: The Cobalt service ID you received in the response.
  • emr_service_id: The service’s id in the EMR.
  • emr_episode_id: The episode the service was written under (reused if one was already open, otherwise the episode opened by the team assignment).
  • patient_mrn: The patient’s medical record number.

Failure

Transient problems are retried automatically and do not emit a webhook until they are resolved or the attempts are exhausted. A service.failed event is sent once, when the failure is permanent. Common failure_reason values:
  • Credible team '<team>' not found for client <mrn> — the team name or id did not match a team the client can be assigned to.
  • Service type '<type>' not available for client <mrn> (not in billing matrix) — the service type is not billable for the client.
  • Missing required answers: <question ids> — one or more required form questions were not answered.

Authorizations

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

Body

application/json
patient_mrn
string
required

The patient's medical record number (for Credible, the client id). The patient must already be synced to Cobalt.

Example:

"1234567"

team
string
required

Team name (or numeric team id) that owns the episode. Assigning the client to the team opens the episode when one does not already exist.

Example:

"Adult Outpatient"

service_type
string
required

Service type to add, by name or numeric visit-type id (e.g. "GAD-7"). Must be billable for the client (present in the client's billing matrix).

Example:

"GAD-7"

form_id
string
required

EMR form id whose answers are provided. Required when the service type documents a form.

Example:

"392"

answers
object
required

Form answers keyed by EMR question id. For a scored questionnaire provide the numeric score for each scored question; totals and risk bands are derived automatically. Validated against the synced form definition.

Example:
service_date
string

Service date (YYYY-MM-DD). Defaults to today. Cannot be in the future.

Example:

"2026-08-26"

callback_urls
string[]

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

Response

Service queued successfully

success
boolean
message
string
Example:

"Service processing. A webhook event will be sent upon completion."

service_id
string

Cobalt service ID (UUID without dashes). Echoed back in the webhook payload.

job_id
integer

Job execution identifier for tracking the async operation.