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

# Upload document content

> Upload a file's bytes and get back a content reference to attach to a document. Send the file base64-encoded in `data` together with its `contentType`; the response returns an `id` that you then place in a document reference's `content[].attachment.url` (see [Create document reference](/document-references)). Use this when you hold the raw file rather than an already-hosted URL.



## OpenAPI

````yaml /openapi.json post /document-references/content
openapi: 3.1.0
info:
  title: OpenLoop API
  version: 0.1.0
  description: >-
    Unified reference for the OpenLoop Patient (clinical) and Payments & Revenue
    APIs.
servers:
  - url: https://api.openloophealth.com/v0.1
    description: Production partner edge
  - url: https://api-staging.openloophealth.com/v0.1
    description: Staging partner edge (sandbox credentials)
security: []
paths:
  /document-references/content:
    post:
      tags:
        - Document References
      summary: Upload document content
      description: >-
        Upload a file's bytes and get back a content reference to attach to a
        document. Send the file base64-encoded in `data` together with its
        `contentType`; the response returns an `id` that you then place in a
        document reference's `content[].attachment.url` (see [Create document
        reference](/document-references)). Use this when you hold the raw file
        rather than an already-hosted URL.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                contentType:
                  type: string
                  enum:
                    - application/pdf
                    - image/jpeg
                    - image/png
                    - image/heic
                    - text/plain
                  description: MIME type of the file being uploaded.
                data:
                  type: string
                  minLength: 1
                  description: >-
                    The file contents, base64-encoded. Maximum decoded size 6
                    MiB.
                title:
                  type: string
                  maxLength: 500
                  description: Optional human-readable title for the content.
              required:
                - contentType
                - data
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: string
                        description: >-
                          Content reference for the uploaded file. Place this
                          value in a document reference's
                          `content[].attachment.url`.
                      contentType:
                        type: string
                        description: MIME type of the stored content.
                      size:
                        type: integer
                        description: Decoded size of the stored content, in bytes.
                    required:
                      - id
                      - size
                  request_id:
                    type: string
                required:
                  - data
                  - request_id
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - serviceToken: []
        - userToken: []
components:
  schemas:
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            error_code:
              type: string
          required:
            - message
            - error_code
        request_id:
          type: string
      required:
        - error
        - request_id
  securitySchemes:
    serviceToken:
      type: oauth2
      description: >-
        Service (M2M) access token issued by POST /auth/token using the
        client_credentials grant. Required scopes, where known, are listed on
        each operation below.
      flows:
        clientCredentials:
          tokenUrl: https://api.openloophealth.com/v0.1/auth/token
          scopes: {}
    userToken:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        User access token issued by POST /auth/token via the verification-code
        grant (after Verify a one-time code) or the refresh_token grant.

````

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