> ## Documentation Index
> Fetch the complete documentation index at: https://docs.usecobalt.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Order

> Creates a lab, imaging, or procedure order in the provider's EMR system.

Orders are created asynchronously: a valid request returns immediately with a `202`, and an `order.created` webhook is sent when processing completes. If creation fails terminally, an `order.create_failed` webhook is sent instead.

Identify the test or procedure to order with either `item_id` or `name`. Discover valid values via [Search Order Catalog](/api-reference/orders/catalog). When both are provided, `item_id` wins.

Creating orders is only supported for eClinicalWorks.

### Request Parameters

#### Required Fields

* **type** (string, required): Order type. One of `lab`, `imaging`, or `procedure`.
* **patient\_mrn** (string, required): Medical Record Number of the patient the order is for.

One of the following is also required:

* **item\_id** (string): EMR catalog id of the test/procedure to order. Discover ids via `POST /v1/orders/catalog/fetch`.
* **name** (string): Catalog name of the test/procedure, resolved against the catalog when `item_id` is omitted.

#### Optional Fields

* **provider\_id** (string, optional): EMR id of the ordering provider.
* **facility\_id** (string, optional): EMR id of the ordering facility/location.
* **assigned\_to\_id** (string, optional): EMR staff id the order is assigned to.
* **order\_date** (string, optional): Order date (ISO 8601, YYYY-MM-DD).
* **collected\_date** (string, optional): Specimen collection date (ISO 8601, YYYY-MM-DD). Labs.
* **collection\_time** (string, optional): Specimen collection time, e.g. `"12:58 PM"`.
* **performed\_date** (string, optional): Performed date (ISO 8601, YYYY-MM-DD). Diagnostic imaging.
* **high\_priority** (boolean, optional): Flag the order high priority.
* **notes** (string, optional): Order notes.
* **clinical\_info** (string, optional): Clinical information for the order.
* **callback\_urls** (string\[], optional): URLs to receive the `order.created` webhook, in addition to the account webhook.

### Example Requests

<Tabs>
  <Tab title="By item_id">
    ```bash theme={null}
    curl -X POST https://api.usecobalt.com/v1/orders \
    -H 'Content-Type: application/json' \
    -H 'client_id: ci_live_198908HJDKJSH98789OHKJL' \
    -H 'client_secret: cs_live_9827hofdsklOYYHJLJh' \
    -H 'access_token: 493JKLHIU98789hLKH9HHJH' \
    -d '{
        "type": "lab",
        "patient_mrn": "12345",
        "item_id": "80048",
        "provider_id": "789",
        "facility_id": "25",
        "collected_date": "2026-03-15",
        "collection_time": "12:58 PM"
    }'
    ```
  </Tab>

  <Tab title="By name">
    ```bash theme={null}
    curl -X POST https://api.usecobalt.com/v1/orders \
    -H 'Content-Type: application/json' \
    -H 'client_id: ci_live_198908HJDKJSH98789OHKJL' \
    -H 'client_secret: cs_live_9827hofdsklOYYHJLJh' \
    -H 'access_token: 493JKLHIU98789hLKH9HHJH' \
    -d '{
        "type": "imaging",
        "patient_mrn": "12345",
        "name": "Chest X-Ray",
        "provider_id": "789",
        "performed_date": "2026-03-15",
        "high_priority": true,
        "clinical_info": "Persistent cough, rule out pneumonia."
    }'
    ```
  </Tab>
</Tabs>

### Example Response

```json theme={null}
{
  "success": true,
  "status": "queued",
  "message": "Order queued for creation. An order.created webhook will be sent when it completes.",
  "job_id": 12345
}
```

### Error Responses

#### Missing Required Field

```json theme={null}
{
  "success": false,
  "message": "Missing required field: patient_mrn"
}
```

#### Missing Order Identifier

```json theme={null}
{
  "success": false,
  "message": "Provide either item_id or name to identify the order."
}
```

### Webhook Notifications

When order processing completes, we send a webhook to your registered endpoint.

#### Success

```json theme={null}
{
  "id": "evt_1J9X2q2eZvKYlo2CluR9g9gV",
  "access_token_reference_id": "user_1J9X2q2eZvKYlo2Cxyz",
  "object": "event",
  "created": "2025-10-09T10:30:00Z",
  "type": "order.created",
  "job_id": "12345",
  "data": {
    "emr_order_id": "998877",
    "emr_encounter_id": "445566",
    "patient_mrn": "12345"
  }
}
```

#### Failure

```json theme={null}
{
  "id": "evt_1J9X2q2eZvKYlo2CluR9g9gW",
  "access_token_reference_id": "user_1J9X2q2eZvKYlo2Cxyz",
  "object": "event",
  "created": "2025-10-09T10:35:00Z",
  "type": "order.create_failed",
  "job_id": "12345",
  "data": {
    "patient_mrn": "12345",
    "failure_reason": "Order create failed after multiple attempts. Please try again later or contact support."
  }
}
```


## OpenAPI

````yaml POST /orders
openapi: 3.1.0
info:
  title: Cobalt API
  version: 1.0.1
  description: API for interacting with Cobalt's EHR integration services
servers:
  - url: https://api.usecobalt.com/v1
    description: Production
security:
  - ClientCredentials: []
    ClientSecret: []
    AccessToken: []
paths:
  /orders:
    post:
      tags:
        - Orders
      summary: Create an order
      description: Queues a lab/imaging/procedure order for creation in the connected EMR.
      operationId: createOrder
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - type
                - patient_mrn
              properties:
                type:
                  type: string
                  enum:
                    - lab
                    - imaging
                    - procedure
                  x-supported-emrs:
                    - eClinicalWorks
                  description: Order type.
                  example: lab
                  x-required-for-emrs:
                    - eClinicalWorks
                patient_mrn:
                  type: string
                  x-supported-emrs:
                    - eClinicalWorks
                  description: Medical Record Number of the patient the order is for.
                  example: '12345'
                  x-required-for-emrs:
                    - eClinicalWorks
                item_id:
                  type: string
                  x-supported-emrs:
                    - eClinicalWorks
                  description: >-
                    EMR catalog id of the test/procedure to order. Provide
                    item_id OR name (enforced in the controller); item_id wins
                    when both are given. Discover ids via POST
                    /v1/orders/catalog/fetch.
                name:
                  type: string
                  x-supported-emrs:
                    - eClinicalWorks
                  description: >-
                    Catalog name of the test/procedure to order, resolved
                    against the catalog when item_id is omitted.
                provider_id:
                  type: string
                  x-supported-emrs:
                    - eClinicalWorks
                  description: EMR id of the ordering provider.
                facility_id:
                  type: string
                  x-supported-emrs:
                    - eClinicalWorks
                  description: EMR id of the ordering facility/location.
                assigned_to_id:
                  type: string
                  x-supported-emrs:
                    - eClinicalWorks
                  description: EMR staff id the order is assigned to.
                order_date:
                  type: string
                  x-supported-emrs:
                    - eClinicalWorks
                  description: Order date (ISO 8601, YYYY-MM-DD).
                  example: '2026-03-15'
                collected_date:
                  type: string
                  x-supported-emrs:
                    - eClinicalWorks
                  description: Specimen collection date (ISO 8601, YYYY-MM-DD). Labs.
                collection_time:
                  type: string
                  x-supported-emrs:
                    - eClinicalWorks
                  description: Specimen collection time, e.g. "12:58 PM".
                performed_date:
                  type: string
                  x-supported-emrs:
                    - eClinicalWorks
                  description: Performed date (ISO 8601, YYYY-MM-DD). Diagnostic imaging.
                high_priority:
                  type: boolean
                  x-supported-emrs:
                    - eClinicalWorks
                  description: Flag the order high priority.
                notes:
                  type: string
                  x-supported-emrs:
                    - eClinicalWorks
                  description: Order notes.
                clinical_info:
                  type: string
                  x-supported-emrs:
                    - eClinicalWorks
                  description: Clinical information for the order.
                callback_urls:
                  type: array
                  items:
                    type: string
                  x-supported-emrs:
                    - eClinicalWorks
                  description: >-
                    URLs to receive the order.created webhook, in addition to
                    the account webhook.
      responses:
        '202':
          description: Queued for processing
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  status:
                    type: string
                  message:
                    type: string
                  job_id:
                    anyOf:
                      - type: string
                      - type: number
                required:
                  - success
                  - status
                  - message
                  - job_id
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  responses:
    BadRequest:
      description: Bad request — missing or invalid parameters
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                enum:
                  - false
              message:
                type: string
            required:
              - success
              - message
    Unauthorized:
      description: Unauthorized — missing or invalid credentials
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                enum:
                  - false
              message:
                type: string
            required:
              - success
              - message
    InternalServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                enum:
                  - false
              message:
                type: string
            required:
              - success
              - message
  securitySchemes:
    ClientCredentials:
      type: apiKey
      in: header
      name: client_id
    ClientSecret:
      type: apiKey
      in: header
      name: client_secret
    AccessToken:
      type: apiKey
      in: header
      name: access_token

````