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

# Start ingestion workflow

> Ingest either an unstructured document (multipart/form-data) or a FHIR bundle (application/json).

Ingested unstructured documents are added to the patient record incrementally. Creating a summary for a given patient will use all ingested unstructured documents up to that point.

Ingested FHIR bundles replace the existing patient record: ingesting a new FHIR bundle will overwrite any previously ingested FHIR bundles for that patient, but will not affect previously ingested unstructured documents.



## OpenAPI

````yaml /api-reference/hermes.yml post /ai/v1/ingest
openapi: 3.1.0
info:
  title: AI Engine
  description: Turn data into health intelligence
  version: 1.0.0
servers:
  - url: https://api.{workspaceId}.clinia.cloud
    variables:
      workspaceId:
        default: ''
        description: The workspace id.
security: []
paths:
  /ai/v1/ingest:
    post:
      tags:
        - Ingest
      summary: Start ingestion workflow
      description: >-
        Ingest either an unstructured document (multipart/form-data) or a FHIR
        bundle (application/json).


        Ingested unstructured documents are added to the patient record
        incrementally. Creating a summary for a given patient will use all
        ingested unstructured documents up to that point.


        Ingested FHIR bundles replace the existing patient record: ingesting a
        new FHIR bundle will overwrite any previously ingested FHIR bundles for
        that patient, but will not affect previously ingested unstructured
        documents.
      parameters:
        - in: header
          name: x-user-id
          schema:
            type: string
          required: false
          description: >-
            The ID of the user making the request. Used to associate the request
            with a specific user.
      requestBody:
        required: false
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                patientId:
                  type: string
                  minLength: 1
                file:
                  type: string
                  format: binary
                  description: >-
                    Unstructured document with MIME type of: [application/pdf,
                    image/tiff]
              required:
                - patientId
                - file
              additionalProperties: false
          application/json:
            schema:
              type: object
              properties:
                patientId:
                  type: string
                  minLength: 1
                  description: >-
                    The ID of the patient to ingest data for, this does not have
                    to be the ID of the patient resource in the bundle, the
                    bundle can contain no or many patient resources, the API
                    caller is responsible for correctly scoping the bundle to
                    the patient's records.
                bundle:
                  type: object
                  properties:
                    resourceType:
                      type: string
                      enum:
                        - Bundle
                    type:
                      type: string
                      enum:
                        - document
                        - message
                        - transaction
                        - transaction-response
                        - batch
                        - batch-response
                        - history
                        - searchset
                        - collection
                    entry:
                      type: array
                      items:
                        type: object
                        properties:
                          fullUrl:
                            type: string
                          resource:
                            type: object
                            properties:
                              resourceType:
                                type: string
                              id:
                                type: string
                            required:
                              - resourceType
                            additionalProperties: {}
                        additionalProperties: {}
                  required:
                    - resourceType
                    - type
                  additionalProperties: {}
                  description: >-
                    Must be a valid FHIR R4 Bundle resource. The `type` field
                    and `entry` field are required. At least one entry must be
                    provided. The spec does not exhaustively enumerate all valid
                    FHIR resource shapes under `bundle.entry.resource`. Refer to
                    the FHIR specification for more details.
              required:
                - patientId
                - bundle
              additionalProperties: false
          application/fhir+json:
            schema:
              type: object
              properties:
                patientId:
                  type: string
                  minLength: 1
                  description: >-
                    The ID of the patient to ingest data for, this does not have
                    to be the ID of the patient resource in the bundle, the
                    bundle can contain no or many patient resources, the API
                    caller is responsible for correctly scoping the bundle to
                    the patient's records.
                bundle:
                  type: object
                  properties:
                    resourceType:
                      type: string
                      enum:
                        - Bundle
                    type:
                      type: string
                      enum:
                        - document
                        - message
                        - transaction
                        - transaction-response
                        - batch
                        - batch-response
                        - history
                        - searchset
                        - collection
                    entry:
                      type: array
                      items:
                        type: object
                        properties:
                          fullUrl:
                            type: string
                          resource:
                            type: object
                            properties:
                              resourceType:
                                type: string
                              id:
                                type: string
                            required:
                              - resourceType
                            additionalProperties: {}
                        additionalProperties: {}
                  required:
                    - resourceType
                    - type
                  additionalProperties: {}
                  description: >-
                    Must be a valid FHIR R4 Bundle resource. The `type` field
                    and `entry` field are required. At least one entry must be
                    provided. The spec does not exhaustively enumerate all valid
                    FHIR resource shapes under `bundle.entry.resource`. Refer to
                    the FHIR specification for more details.
              required:
                - patientId
                - bundle
              additionalProperties: false
      responses:
        '202':
          description: Ingestion accepted
          content:
            application/json:
              schema:
                type: object
                properties:
                  runId:
                    type: string
                    minLength: 1
                    description: The ID of the ingestion workflow
                  status:
                    type: string
                    enum:
                      - started
                required:
                  - runId
                  - status
                description: >-
                  Ingestion workflows are async, this response only indicates
                  how to poll the workflow status, not the status of the
                  ingestion itself. Typically, ingesting unstructured documents
                  can take several minutes, while ingesting structured FHIR
                  bundles should complete within seconds (depending on size).
        '400':
          description: Invalid request parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              example:
                code: 400
                type: INVALID_ARGUMENT
                message: Invalid request parameters
        '401':
          description: Authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              example:
                code: 401
                type: UNAUTHENTICATED
                message: Unauthenticated
        '403':
          description: Permission denied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              example:
                code: 403
                type: PERMISSION_DENIED
                message: Permission denied
        '413':
          description: Payload too large
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              example:
                code: 413
                type: CONTENT_TOO_LARGE
                message: Payload too large
        '415':
          description: Unsupported media type
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              example:
                code: 415
                type: UNSUPPORTED_MEDIA_TYPE
                message: Unsupported media type
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              example:
                code: 500
                type: INTERNAL
                message: Internal Server Error
components:
  schemas:
    ApiError:
      type: object
      properties:
        code:
          type: number
          exclusiveMinimum: 0
        type:
          type: string
          enum:
            - ALREADY_EXISTS
            - FAILED_PRECONDITION
            - INTERNAL
            - INVALID_ARGUMENT
            - NOT_FOUND
            - OUT_OF_RANGE
            - UNIMPLEMENTED
            - UNAUTHENTICATED
            - PERMISSION_DENIED
            - CONTENT_TOO_LARGE
            - UNSUPPORTED_MEDIA_TYPE
        message:
          type: string
      required:
        - code
        - type
        - message

````