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

# Read whole appointment histories from the EHR for up to 25 charts

> Queues one patient-scoped EHR read per chart. When it finishes, the chart's appointment `readiness` in POST /v4/patients/history reads `complete` with `basis: patient` — independent of any facility sweep or other patient — until it is a day old. EZDerm charts only: ModMed has no verified patient-scoped history call, so ModMed charts answer `unsupported` and keep facility-sweep readiness.



## OpenAPI

````yaml /openapi-v4.json post /patients/history/refresh
openapi: 3.0.0
info:
  title: Max AI Public API
  description: API for third-party marketplace apps
  version: '4.0'
  contact: {}
servers:
  - url: https://api.maxcare.ai/v4
security: []
tags: []
paths:
  /patients/history/refresh:
    post:
      tags:
        - Patients
      summary: Read whole appointment histories from the EHR for up to 25 charts
      description: >-
        Queues one patient-scoped EHR read per chart. When it finishes, the
        chart's appointment `readiness` in POST /v4/patients/history reads
        `complete` with `basis: patient` — independent of any facility sweep or
        other patient — until it is a day old. EZDerm charts only: ModMed has no
        verified patient-scoped history call, so ModMed charts answer
        `unsupported` and keep facility-sweep readiness.
      operationId: PatientHistoryPublicController_refreshHistory
      parameters:
        - name: X-Organization-Id
          in: header
          required: true
          schema:
            type: string
          description: Target clinic organization ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PatientHistoryRefreshBody'
      responses:
        '202':
          description: Accepted — queued for background processing
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PatientHistoryRefreshSuccessResponse'
        '400':
          description: Missing or invalid request parameter
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiBadRequestResponse'
        '401':
          description: Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiUnauthorizedResponse'
        '403':
          description: Insufficient scope
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiForbiddenResponse'
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiRateLimitResponse'
      security:
        - api-key: []
components:
  schemas:
    PatientHistoryRefreshBody:
      type: object
      properties:
        patientIds:
          description: Charts to refresh, 1–25.
          type: array
          items:
            type: string
        sessionToken:
          type: string
          description: >-
            The App Bridge session token of the logged-in user making this
            request, verified server-side. When the practice has no live office
            (system) EZDerm connection, a chart is read through THIS user's own
            personal EZDerm connection, and never anyone else's; without it such
            a refresh fails at run time. A token that does not verify for this
            app and organization is a 401.
      required:
        - patientIds
    PatientHistoryRefreshSuccessResponse:
      type: object
      properties:
        code:
          type: string
          description: Response code
          example: success
        data:
          $ref: '#/components/schemas/PatientHistoryRefreshData'
      required:
        - code
        - data
    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
    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
    PatientHistoryRefreshData:
      type: object
      properties:
        patients:
          type: array
          items:
            $ref: '#/components/schemas/PatientHistoryRefreshItem'
      required:
        - patients
    PatientHistoryRefreshItem:
      type: object
      properties:
        patientId:
          type: string
        status:
          type: string
          enum:
            - queued
            - already_queued
            - dispatch_failed
            - unsupported
            - not_found
          description: >-
            `unsupported`: this chart's EHR has no verified patient-scoped
            history call (ModMed today); its readiness comes from facility
            sweeps only.
        reason:
          type: string
          nullable: true
      required:
        - patientId
        - status
  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.