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

# Add Diagnosis Codes

> Adds ICD-10 diagnosis codes to an existing appointment's encounter.

<Info>
  This is an asynchronous operation. The request returns a `job_id` immediately, and a webhook is sent when the operation completes. Codes already on the encounter are skipped, so re-sending a code is safe. Only ICD-10 diagnosis codes are supported today; CPT codes are not. Currently available on eClinicalWorks.
</Info>

Each code is `{ "type": "icd10", "code": "..." }`. The dot in a code is optional (`E119` and `E11.9` are equivalent). Send one or many codes in a single request.

### Example Request

```bash theme={null}
curl -X POST https://api.usecobalt.com/v1/appointments/APPT-12345/codes \
-H 'Content-Type: application/json' \
-H 'client_id: ci_live_198908HJDKJSH98789OHKJL' \
-H 'client_secret: cs_live_9827hofdsklOYYHJLJh' \
-H 'access_token: 493JKLHIU98789hLKH9HHJH' \
-d '{
    "codes": [
        { "type": "icd10", "code": "E11.9" },
        { "type": "icd10", "code": "I10" }
    ]
}'
```

### Example Response

```json theme={null}
{
    "success": true,
    "message": "Codes operation in progress. A webhook event will be sent upon completion.",
    "job_id": "12345"
}
```

### Webhook

On completion we send a `codes.added` event (or `codes.failed` on error). `icd` reports which codes were applied versus skipped as duplicates, not matched in the EMR catalog, or rejected as invalid for the encounter date.

```json theme={null}
{
    "id": "evt_1J9X2q2eZvKYlo2CluR9g9gV",
    "access_token_reference_id": "user_1J9X2q2eZvKYlo2Cxyz",
    "object": "event",
    "created": "2025-10-09T10:30:00Z",
    "type": "codes.added",
    "job_id": "12345",
    "data": {
        "appointment_id": "APPT-12345",
        "operation": "add",
        "icd": {
            "added": ["E11.9", "I10"],
            "skipped": [],
            "unmatched": [],
            "invalid": []
        }
    }
}
```

See [Operation Events](/docs/webhooks/operation-events) for the failure payload and error codes.


## OpenAPI

````yaml POST /appointments/{appointment_id}/codes
openapi: 3.0.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
security:
  - ClientCredentials: []
    ClientSecret: []
    AccessToken: []
paths:
  /appointments/{appointment_id}/codes:
    post:
      summary: Add Diagnosis Codes
      description: >-
        Adds one or more ICD-10 diagnosis codes to an existing appointment's
        encounter. Asynchronous: returns a job_id immediately and sends a
        webhook on completion. Re-sending a code already on the encounter is a
        no-op (deduplicated). Currently supported on eClinicalWorks.
      parameters:
        - in: path
          name: appointment_id
          required: true
          schema:
            type: string
          description: The Cobalt appointment ID.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - codes
              properties:
                codes:
                  type: array
                  description: Codes to add. Accepts one or many.
                  items:
                    type: object
                    required:
                      - type
                      - code
                    properties:
                      type:
                        type: string
                        enum:
                          - icd10
                        description: >-
                          Code type. Only icd10 is currently supported (CPT is
                          not yet supported).
                      code:
                        type: string
                        description: >-
                          ICD-10 code, e.g. E11.9. The dot is optional (E119 is
                          accepted).
                callback_urls:
                  type: array
                  items:
                    type: string
                  description: Optional per-request webhook URLs to notify on completion.
      responses:
        '200':
          description: Operation queued.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  message:
                    type: string
                  job_id:
                    type: string
                    description: Job execution identifier for tracking the async operation.
        '400':
          description: >-
            Validation error, e.g. missing codes or an unsupported code type
            such as CPT.
        '404':
          description: Appointment not found for this connection.
components:
  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

````