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

# Refresh a patient's chart-document list

> Asks the platform to re-list this patient's chart against the source EHR, so a document added minutes ago (a signed consent, a freshly scanned insurance card) becomes visible to `GET /patients/{id}/documents` without waiting for the nightly sweep. Returns 202 immediately: the listing runs in a background worker, and the caller polls the documents endpoint until `listFetchedAt` moves past the value returned here. Guarded beyond the shared rate limiter — one refresh per patient per few minutes (409) and a per-organization daily cap (429). Requires read:patient_documents scope.



## OpenAPI

````yaml /openapi-v4.json post /patients/{id}/documents/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/{id}/documents/refresh:
    post:
      tags:
        - Patients
      summary: Refresh a patient's chart-document list
      description: >-
        Asks the platform to re-list this patient's chart against the source
        EHR, so a document added minutes ago (a signed consent, a freshly
        scanned insurance card) becomes visible to `GET
        /patients/{id}/documents` without waiting for the nightly sweep. Returns
        202 immediately: the listing runs in a background worker, and the caller
        polls the documents endpoint until `listFetchedAt` moves past the value
        returned here. Guarded beyond the shared rate limiter — one refresh per
        patient per few minutes (409) and a per-organization daily cap (429).
        Requires read:patient_documents scope.
      operationId: PatientsPublicController_refreshPatientDocuments
      parameters:
        - name: id
          required: true
          in: path
          description: Patient ID
          schema:
            type: string
        - name: X-Organization-Id
          in: header
          required: true
          schema:
            type: string
          description: Target clinic organization ID
      responses:
        '202':
          description: Accepted — queued for background processing
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RefreshPatientDocumentsSuccessResponse'
        '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'
        '404':
          description: Resource not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiNotFoundResponse'
        '409':
          description: Resource conflict (e.g. editing a signed note)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiConflictResponse'
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiRateLimitResponse'
        '502':
          description: EHR sync failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiBadGatewayResponse'
      security:
        - api-key: []
components:
  schemas:
    RefreshPatientDocumentsSuccessResponse:
      type: object
      properties:
        code:
          type: string
          description: Response code
          example: success
        data:
          $ref: '#/components/schemas/RefreshPatientDocumentsResponseData'
      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
    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
    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
    RefreshPatientDocumentsResponseData:
      type: object
      properties:
        status:
          type: string
          description: >-
            Always `queued`. The refresh is performed by a background worker
            because it logs into the EHR and walks the chart — poll `GET
            /patients/{id}/documents` and watch `listFetchedAt` for the result.
          enum:
            - queued
          example: queued
        requestedAt:
          type: string
          description: When this refresh was requested
          example: '2026-08-15T20:15:00.000Z'
        listFetchedAt:
          type: string
          description: >-
            `listFetchedAt` as it stands BEFORE this refresh — the value to poll
            against. When `GET /patients/{id}/documents` reports a
            `listFetchedAt` newer than this one, the refresh has landed. Null
            when the chart has never been listed, in which case poll for any
            non-null value.
          nullable: true
          example: '2026-08-14T09:00:00.000Z'
        documentCount:
          type: number
          description: >-
            How many documents the cached listing holds right now, before this
            refresh runs.
          example: 12
      required:
        - status
        - requestedAt
        - listFetchedAt
        - documentCount
  securitySchemes:
    api-key:
      scheme: bearer
      bearerFormat: JWT
      type: http
      description: Marketplace API key

````