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

# Upload Document

> Upload a document to a patient's chart.

Documents are processed asynchronously. You'll receive a webhook notification when the upload is complete or if there was an error.

### Example Request

```bash theme={null}
curl -X POST https://api.usecobalt.com/v1/documents \
-H 'Content-Type: multipart/form-data' \
-H 'client_id: ci_live_198908HJDKJSH98789OHKJL' \
-H 'client_secret: cs_live_9827hofdsklOYYHJLJh' \
-H 'access_token: 493JKLHIU98789hLKH9HHJH' \
-F 'folder_name=MedicalRecords' \
-F 'patient_mrn=123456' \
-F 'location_id=20' \
-F 'tags=Estimate' \
-F 'tags=Referral' \
-F 'document=@/path/to/document.pdf'
```

### Example Response

```json theme={null}
{
    "success": true,
    "message": "Document uploaded successfully. It will be processed soon.",
    "document_id": "9988776655443322"
}
```

### Example Success Webhook

```json theme={null}
{
    "id": "123e4567-e89b-12d3-a456-426614174000",
    "object": "event",
    "created": "2023-10-01T12:34:56Z",
    "type": "document.uploaded",
    "data": {
        "document_id": "9988776655443322",
        "patient_mrn": "123456",
        "folder_name": "MedicalRecords"
    }
}
```

### Example Failure Webhook

```json theme={null}
{
    "id": "123e4567-e89b-12d3-a456-426614174001",
    "object": "event",
    "created": "2023-10-01T12:34:56Z",
    "type": "document.upload_failed",
    "data": {
        "document_id": "9988776655443322",
        "patient_mrn": "123456",
        "folder_name": "MedicalRecords",
        "failure_reason": "Patient not found. Please check the patient MRN and try again."
    }
}
```


## OpenAPI

````yaml POST /documents
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:
  /documents:
    post:
      summary: Upload Document
      description: Upload a document to a patient's chart.
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                folder_name:
                  type: string
                  description: >-
                    The name of the folder where the document will be stored.
                    Supports nested folders using forward slashes (e.g.,
                    'MedicalRecords/LabResults').
                patient_mrn:
                  type: string
                  description: The medical record number of the patient.
                document:
                  type: string
                  format: binary
                  description: >-
                    The document file to be uploaded. Only PDF, JPEG, and PNG
                    files are allowed. Maximum file size is 10MB.
                emr_assigned_to_id:
                  type: string
                  description: >-
                    The EMR staff ID to assign the document to. Must match a
                    staff member in your organization's staff list.
                is_reviewed:
                  type: boolean
                  description: Mark the document as reviewed. Defaults to false.
                notes:
                  type: string
                  description: >-
                    Description or notes for the document. Maximum 1000
                    characters.
                is_high_priority:
                  type: boolean
                  description: Mark the document as high priority. Defaults to false.
                template_name:
                  type: string
                  description: >-
                    The template name to use when filling out the document
                    upload form.
                location_id:
                  type: string
                  description: >-
                    The EMR ID of the location/facility to associate with the
                    document. Must match a location returned by GET /locations.
                tags:
                  type: array
                  items:
                    type: string
                  description: >-
                    Zero or more tag names to apply to the document. Repeat the
                    field in multipart form data to send multiple tags.
              required:
                - folder_name
                - patient_mrn
                - document
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  message:
                    type: string
                  document_id:
                    type: string
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

````