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

# Extract or retry document text extraction

> Starts or retries text extraction for a patient document and returns the latest extraction status.



## OpenAPI

````yaml /openapi/ext-api-v1.json post /patients/{patientId}/documents/{documentId}/extract
openapi: 3.0.0
info:
  title: Healos External API
  version: 1.0.0
  description: >-
    External API for managing patients, documents, and appointments, listing
    providers, and for pulling clinical notes (with transcript and patient
    context).
servers:
  - url: https://api.healos.ai/ext-api/v1
    description: Production
  - url: http://localhost:8787/ext-api/v1
    description: Local development
security:
  - ApiKeyAuth: []
paths:
  /patients/{patientId}/documents/{documentId}/extract:
    post:
      tags:
        - Documents
      summary: Extract or retry document text extraction
      description: >-
        Starts or retries text extraction for a patient document and returns the
        latest extraction status.
      parameters:
        - schema:
            type: string
            description: Patient ID
            example: '1743552000000'
          required: true
          name: patientId
          in: path
        - schema:
            type: string
            description: Document ID
            example: d4e5f6a7-b8c9-4d0e-1f2a-3b4c5d6e7f8a
          required: true
          name: documentId
          in: path
      responses:
        '200':
          description: Document extraction completed or was already complete
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocumentExtractionResponse'
        '403':
          description: Insufficient scope
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Patient or document not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitError'
        '500':
          description: Document extraction failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocumentExtractionResponse'
components:
  schemas:
    DocumentExtractionResponse:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/Document'
        success:
          type: boolean
          example: true
        message:
          type: string
          example: Text extracted successfully
        error:
          type: string
          example: Text extraction failed
        details:
          type: string
          example: No text could be extracted from the PDF
      required:
        - data
        - success
    Error:
      type: object
      properties:
        error:
          type: string
      required:
        - error
    RateLimitError:
      type: object
      properties:
        error:
          type: string
          example: Rate limit exceeded. Please retry after the window resets.
      required:
        - error
    Document:
      type: object
      properties:
        id:
          type: string
          description: Document ID
          example: d4e5f6a7-b8c9-4d0e-1f2a-3b4c5d6e7f8a
        filename:
          type: string
          description: Original uploaded filename
          example: intake_form_maria_santos.pdf
        file_type:
          type: string
          enum:
            - pdf
            - image
            - docx
          description: Type of the file
        file_size:
          type: number
          description: File size in bytes
          example: 245760
        public_url:
          type: string
          nullable: true
          description: Public URL if available
        upload_date:
          type: string
          description: ISO 8601 upload timestamp
          example: '2026-03-20T11:15:00.000Z'
        status:
          type: string
          enum:
            - pending
            - processing
            - completed
            - failed
          description: Document processing status
        extracted_date:
          type: string
          nullable: true
          description: ISO 8601 timestamp when extraction completed, if available
          example: '2026-03-20T11:16:00.000Z'
        extraction_error:
          type: string
          nullable: true
          description: Last extraction error, if extraction failed
          example: No text could be extracted from the PDF
        has_extracted_text:
          type: boolean
          description: Whether extracted text is stored for this document
          example: true
        extracted_text_length:
          type: number
          description: Length of the extracted text stored for this document
          example: 2048
        external_id:
          type: string
          nullable: true
          description: Caller-supplied external identifier (immutable once set)
          example: PARTNER-DOC-456
      required:
        - id
        - filename
        - file_type
        - file_size
        - public_url
        - upload_date
        - status
        - extracted_date
        - extraction_error
        - has_extracted_text
        - extracted_text_length
        - external_id
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: API key obtained from /api/v1/ext-api-keys

````