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

# Download one chart document's bytes

> Streams the document's bytes with its `Content-Type`, named by the document id. Bytes not yet staged are pulled from the EHR first, through the same pull as `POST /patients/{id}/documents/{documentId}/fetch` (same 409 while a pull is in flight). When the platform cannot serve the bytes on its own credentials the answer is 422 `document_unavailable` with `data.reason` (`needs_user_session`, `ehr_auth`, or `not_staged` — the fetch endpoint's reasons, meaning the same), never an empty body. Requires read:patient_documents scope.



## OpenAPI

````yaml /openapi-v2.json get /patients/{id}/documents/{documentId}/content
openapi: 3.0.0
info:
  title: Max AI Public API
  description: API for third-party marketplace apps
  version: '2.0'
  contact: {}
servers:
  - url: https://api.maxcare.ai/v2
security: []
tags: []
paths:
  /patients/{id}/documents/{documentId}/content:
    get:
      tags:
        - Patients
      summary: Download one chart document's bytes
      description: >-
        Streams the document's bytes with its `Content-Type`, named by the
        document id. Bytes not yet staged are pulled from the EHR first, through
        the same pull as `POST /patients/{id}/documents/{documentId}/fetch`
        (same 409 while a pull is in flight). When the platform cannot serve the
        bytes on its own credentials the answer is 422 `document_unavailable`
        with `data.reason` (`needs_user_session`, `ehr_auth`, or `not_staged` —
        the fetch endpoint's reasons, meaning the same), never an empty body.
        Requires read:patient_documents scope.
      operationId: PatientsPublicController_getPatientDocumentContent
      parameters:
        - name: id
          required: true
          in: path
          description: Patient ID
          schema:
            type: string
        - name: documentId
          required: true
          in: path
          description: Document ID, as returned by GET /patients/{id}/documents
          schema:
            type: string
        - name: X-Organization-Id
          in: header
          required: true
          schema:
            type: string
          description: Target clinic organization ID
      responses:
        '200':
          description: Success
        '400':
          description: Missing or invalid request parameter
          content:
            application/octet-stream:
              schema:
                $ref: '#/components/schemas/PublicApiBadRequestResponse'
        '401':
          description: Invalid or missing API key
          content:
            application/octet-stream:
              schema:
                $ref: '#/components/schemas/PublicApiUnauthorizedResponse'
        '403':
          description: Insufficient scope
          content:
            application/octet-stream:
              schema:
                $ref: '#/components/schemas/PublicApiForbiddenResponse'
        '404':
          description: Resource not found
          content:
            application/octet-stream:
              schema:
                $ref: '#/components/schemas/PublicApiNotFoundResponse'
        '409':
          description: Resource conflict (e.g. editing a signed note)
          content:
            application/octet-stream:
              schema:
                $ref: '#/components/schemas/PublicApiConflictResponse'
        '422':
          description: Request refused by the EHR's state (named `code`)
          content:
            application/octet-stream:
              schema:
                $ref: '#/components/schemas/PublicApiUnprocessableResponse'
        '429':
          description: Rate limit exceeded
          content:
            application/octet-stream:
              schema:
                $ref: '#/components/schemas/PublicApiRateLimitResponse'
        '502':
          description: EHR sync failed
          content:
            application/octet-stream:
              schema:
                $ref: '#/components/schemas/PublicApiBadGatewayResponse'
      security:
        - api-key: []
components:
  schemas:
    PublicApiBadRequestResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code
          example: bad_request
        message:
          type: string
          description: Human-readable error message
          example: '''id'' must be a valid UUID'
        trace_id:
          type: string
          description: Trace ID for debugging
          example: 550e8400-e29b-41d4-a716-446655440000
      required:
        - code
        - message
        - trace_id
    PublicApiUnauthorizedResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code
          example: unauthorized
        message:
          type: string
          description: Human-readable error message
          example: Invalid or missing API key
        trace_id:
          type: string
          description: Trace ID for debugging
          example: 550e8400-e29b-41d4-a716-446655440000
      required:
        - code
        - message
        - trace_id
    PublicApiForbiddenResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code
          example: forbidden
        message:
          type: string
          description: Human-readable error message
          example: Insufficient scope
        trace_id:
          type: string
          description: Trace ID for debugging
          example: 550e8400-e29b-41d4-a716-446655440000
      required:
        - code
        - message
        - trace_id
    PublicApiNotFoundResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code
          example: not_found
        message:
          type: string
          description: Human-readable error message
          example: Resource not found
        trace_id:
          type: string
          description: Trace ID for debugging
          example: 550e8400-e29b-41d4-a716-446655440000
      required:
        - code
        - message
        - trace_id
    PublicApiConflictResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code
          example: conflict
        message:
          type: string
          description: Human-readable error message
          example: Cannot edit a signed note
        trace_id:
          type: string
          description: Trace ID for debugging
          example: 550e8400-e29b-41d4-a716-446655440000
      required:
        - code
        - message
        - trace_id
    PublicApiUnprocessableResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code
          example: controlled_substance_unsupported
        message:
          type: string
          description: Human-readable error message
          example: Controlled substances cannot be prescribed through the API
        data:
          type: object
          description: Condition-specific detail, when the code defines any
        trace_id:
          type: string
          description: Trace ID for debugging
          example: 550e8400-e29b-41d4-a716-446655440000
      required:
        - code
        - message
        - trace_id
    PublicApiRateLimitResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code
          example: rate_limit_exceeded
        message:
          type: string
          description: Human-readable error message
          example: Rate limit exceeded. Maximum 1000 requests per 60 seconds.
        trace_id:
          type: string
          description: Trace ID for debugging
          example: 550e8400-e29b-41d4-a716-446655440000
      required:
        - code
        - message
        - trace_id
    PublicApiBadGatewayResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code
          example: unexpected_integration_error
        message:
          type: string
          description: Human-readable error message
          example: EHR sync failed
        trace_id:
          type: string
          description: Trace ID for debugging
          example: 550e8400-e29b-41d4-a716-446655440000
      required:
        - code
        - message
        - trace_id
  securitySchemes:
    api-key:
      scheme: bearer
      bearerFormat: JWT
      type: http
      description: Marketplace API key

````

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