> ## 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.

# Set Structured Data

> Sets the value of one of a patient's structured data fields.

`patient_id` is the patient's `id` or MRN. Each field's `emr_id` is returned in `structured_data` on [POST /patients/fetch](https://docs.usecobalt.com/api-reference/patients/fetch.md). Send the value as text. For a field with options, send an option name, or comma-separated names for a multi-select field.

### Example Request

```bash theme={null}
curl -X PATCH https://api.usecobalt.com/v1/patients/81792/structured-data/9393 \
-H 'Content-Type: application/json' \
-H 'client_id: ci_live_198908HJDKJSH98789OHKJL' \
-H 'client_secret: cs_live_9827hofdsklOYYHJLJh' \
-H 'access_token: 493JKLHIU98789hLKH9HHJH' \
-d '{
    "value": "141",
    "notes": "Paid in full"
}'
```

### Example Response

```json theme={null}
{
  "success": true,
  "message": "Structured data update processing. A webhook event will be sent upon completion.",
  "job_id": 12345
}
```

### Webhook Events

You'll receive `structured_data.updated` or `structured_data.update_failed`. See [Operation Events](https://docs.usecobalt.com/docs/webhooks/operation-events.md).

```json theme={null}
{
  "id": "evt_abc123",
  "object": "event",
  "type": "structured_data.updated",
  "created": "2026-11-19T22:05:00.000Z",
  "job_id": "12345",
  "access_token_reference_id": "user_123",
  "data": {
    "patient_mrn": "81792",
    "emr_id": "9393",
    "item": "Shoes/Inserts In",
    "value": "141",
    "notes": "Paid in full"
  }
}
```


## OpenAPI

````yaml PATCH /patients/{patient_id}/structured-data/{emr_id}
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:
  /patients/{patient_id}/structured-data/{emr_id}:
    patch:
      tags:
        - Structured Data
      summary: Set a structured data entry
      description: >-
        Queues a value (and optional notes) for one of the patient's structured
        data fields.
      operationId: setStructuredData
      parameters:
        - name: patient_id
          in: path
          description: >-
            Cobalt patient ID (`id` from the patient endpoints) or the patient
            MRN.
          schema:
            type: string
            example: '12345'
          required: true
        - name: emr_id
          in: path
          description: >-
            EHR id of the structured data field: `structured_data[].emr_id` from
            POST /v1/patients/fetch.
          schema:
            type: string
            example: '9393'
          required: true
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - value
              properties:
                value:
                  type: string
                  x-supported-emrs:
                    - eClinicalWorks
                  description: >-
                    The entry's value as text. For a field with options, use an
                    option name (comma-separate several for a multi-select
                    field, e.g. "141, MAR").
                  example: '141'
                  x-required-for-emrs:
                    - eClinicalWorks
                notes:
                  type: string
                  x-supported-emrs:
                    - eClinicalWorks
                  description: Notes for the entry. Omit to keep the current notes.
                  example: Paid in full
                callback_urls:
                  type: array
                  items:
                    type: string
                  x-supported-emrs:
                    - eClinicalWorks
                  description: >-
                    URLs to receive the completion webhook, in addition to the
                    account webhook.
                  example:
                    - https://example.com/webhooks/cobalt
                expires_at:
                  type:
                    - string
                    - 'null'
                  format: date-time
                  x-supported-emrs:
                    - eClinicalWorks
                  description: >-
                    Optional ISO 8601 timestamp with an explicit timezone
                    offset, in the future when submitted. Cobalt starts no new
                    operation attempt after this deadline and reports
                    reasons[].code EXPIRED. An attempt already in progress,
                    including write reconciliation, may finish after it.
                  example: '2027-06-15T14:30:00Z'
      responses:
        '200':
          description: Structured data change queued for processing
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  message:
                    type: string
                    example: >-
                      Structured data update processing. A webhook event will be
                      sent upon completion.
                  job_id:
                    type: integer
                    example: 12345
                required:
                  - success
                  - message
                  - job_id
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '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
                example: false
              message:
                type: string
                example: Request could not be completed.
            required:
              - success
              - message
          example:
            success: false
            message: Bad request — missing or invalid parameters
    Unauthorized:
      description: Unauthorized — missing or invalid credentials
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                enum:
                  - false
                example: false
              message:
                type: string
                example: Request could not be completed.
            required:
              - success
              - message
          example:
            success: false
            message: Unauthorized — missing or invalid credentials
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                enum:
                  - false
                example: false
              message:
                type: string
                example: Request could not be completed.
            required:
              - success
              - message
          example:
            success: false
            message: Resource not found
    InternalServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                enum:
                  - false
                example: false
              message:
                type: string
                example: Request could not be completed.
            required:
              - success
              - message
          example:
            success: false
            message: Internal server error
  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

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.