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

# Create Ingestion



## OpenAPI

````yaml https://api.aiql.io/openapi.json post /ingestions
openapi: 3.1.0
info:
  title: aiql-api
  version: 0.1.0
servers:
  - url: https://api.aiql.io
security: []
tags:
  - name: Health
    description: Service health checks.
  - name: Workspaces
    description: Workspace management.
  - name: Ingestions
    description: Document ingestion pipeline.
  - name: Queries
    description: Natural-language queries.
  - name: Sources
    description: Ingested sources and their contents.
  - name: Requests
    description: Source addition/removal requests awaiting review.
  - name: Request Changes
    description: Individual source add/remove changes on a request.
  - name: Request Reviews
    description: Reviews of a request, including draft and submit.
  - name: Request Comments
    description: Comments on a request review.
  - name: Canvases
    description: Brainstorm canvases.
  - name: Dashboards
    description: Dashboards.
  - name: Presentations
    description: Slide presentations.
  - name: Tools
    description: Standalone convert/split/shape/extract tools.
  - name: Connectors
    description: Connector catalog and connect flows.
  - name: Connections
    description: Workspace connector connections.
paths:
  /ingestions:
    post:
      tags:
        - Ingestions
      summary: Create Ingestion
      operationId: create_ingestion_ingestions_post
      parameters:
        - name: AiQL-Workspace
          in: header
          required: true
          schema:
            type: string
            description: ID of the workspace the request operates on.
            title: Aiql-Workspace
          description: ID of the workspace the request operates on.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
                - type: object
                  required:
                    - url
                  properties:
                    url:
                      type: string
                      description: URL of the file to ingest.
                    metadata:
                      type: object
                      additionalProperties: true
                      description: Optional free-form JSON metadata.
                    schema:
                      type: object
                      description: >-
                        Optional strict extraction schema. When provided, schema
                        extraction and refinement are skipped and this schema is
                        used for knowledge extraction. Same shape as POST
                        /extract.
                      properties:
                        classes:
                          type: array
                          items:
                            type: object
                            required:
                              - name
                            properties:
                              name:
                                type: string
                              definition:
                                type: string
                              cardinality:
                                type: string
                                enum:
                                  - one
                                  - many
                                default: many
                        properties:
                          type: array
                          items:
                            type: object
                            required:
                              - name
                              - type
                              - domain
                            properties:
                              name:
                                type: string
                              type:
                                type: string
                              domain:
                                items:
                                  type: string
                                type: array
                              definition:
                                type: string
                              values:
                                items:
                                  type: string
                                type: array
                        relationships:
                          type: array
                          items:
                            type: object
                            required:
                              - name
                              - domain
                              - range
                            properties:
                              name:
                                type: string
                              domain:
                                items:
                                  type: string
                                type: array
                              range:
                                items:
                                  type: string
                                type: array
                              definition:
                                type: string
                - type: object
                  required:
                    - filename
                  properties:
                    filename:
                      type: string
                      description: >-
                        Name of the file that will be uploaded via the returned
                        presigned URL.
                    mime_type:
                      type: string
                      description: MIME type of the file that will be uploaded.
                    size:
                      type: integer
                      minimum: 0
                      description: Declared size of the file in bytes.
                    metadata:
                      type: object
                      additionalProperties: true
                      description: Optional free-form JSON metadata.
                    schema:
                      type: object
                      description: >-
                        Optional strict extraction schema. When provided, schema
                        extraction and refinement are skipped and this schema is
                        used for knowledge extraction. Same shape as POST
                        /extract.
                      properties:
                        classes:
                          type: array
                          items:
                            type: object
                            required:
                              - name
                            properties:
                              name:
                                type: string
                              definition:
                                type: string
                              cardinality:
                                type: string
                                enum:
                                  - one
                                  - many
                                default: many
                        properties:
                          type: array
                          items:
                            type: object
                            required:
                              - name
                              - type
                              - domain
                            properties:
                              name:
                                type: string
                              type:
                                type: string
                              domain:
                                items:
                                  type: string
                                type: array
                              definition:
                                type: string
                              values:
                                items:
                                  type: string
                                type: array
                        relationships:
                          type: array
                          items:
                            type: object
                            required:
                              - name
                              - domain
                              - range
                            properties:
                              name:
                                type: string
                              domain:
                                items:
                                  type: string
                                type: array
                              range:
                                items:
                                  type: string
                                type: array
                              definition:
                                type: string
          multipart/form-data:
            schema:
              type: object
              required:
                - file
              properties:
                file:
                  type: string
                  format: binary
                  description: File to ingest.
                metadata:
                  type: string
                  description: Optional JSON object serialized as a string.
                schema:
                  type: string
                  description: >-
                    Optional strict extraction schema serialized as a JSON
                    string. Same shape as POST /extract.
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Ingestion'
        '401':
          description: 'Authentication failed: missing or invalid API key.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X POST https://api.aiql.io/ingestions \
              -H "Authorization: Bearer $AIQL_API_KEY" \
              -H "AiQL-Workspace: $AIQL_WORKSPACE_ID" \
              -H "Content-Type: application/json" \
              -d '{"url": "https://example.com/report.pdf", "metadata": {"customerId": "abc"}, "schema": {"classes": [{"name": "Person", "definition": "An individual human.", "cardinality": "many"}], "properties": [{"name": "name", "type": "STRING", "definition": "The person's full name.", "domain": ["Person"]}], "relationships": []}}'

            curl -X POST https://api.aiql.io/ingestions \
              -H "Authorization: Bearer $AIQL_API_KEY" \
              -H "AiQL-Workspace: $AIQL_WORKSPACE_ID" \
              -F "metadata={"customerId": "abc"}" \
              -F "schema={"classes":[{"name":"Person","cardinality":"many"}],"properties":[{"name":"name","type":"STRING","domain":["Person"]}],"relationships":[]}" \
              -F "file=@report.pdf"
        - lang: python
          label: Python SDK
          source: >-
            import os

            from aiql import AiQL


            client = AiQL(api_key=os.environ["AIQL_API_KEY"])


            ingestion = client.ingestions.create(
                workspace_id="ws_3a1b",
                url="https://example.com/report.pdf",
                metadata={"customerId": "abc"},
                schema={
                    "classes": [{"name": "Person", "cardinality": "many"}],
                    "properties": [{"name": "name", "type": "STRING", "domain": ["Person"]}],
                    "relationships": [],
                },
            )


            # Or upload a file directly instead of a URL:

            with open("report.pdf", "rb") as f:
                ingestion = client.ingestions.create(
                    workspace_id="ws_3a1b",
                    file=f,
                    metadata={"customerId": "abc"},
                )

            # Or request a presigned upload URL for a large file:

            ingestion = client.ingestions.create(
                workspace_id="ws_3a1b",
                filename="report.pdf",
                mime_type="application/pdf",
                size=12_345_678,
            )

            # Then PUT the bytes to ingestion.upload.url with
            ingestion.upload.headers
        - lang: typescript
          label: TypeScript SDK
          source: >-
            import { AiQL } from "@aiql.io/sdk";


            const client = new AiQL({ apiKey: process.env.AIQL_API_KEY });


            const ingestion = await client.ingestions.create({
              workspaceId: "ws_3a1b",
              url: "https://example.com/report.pdf",
              metadata: { customerId: "abc" },
              schema: {
                classes: [{ name: "Person", cardinality: "many" }],
                properties: [{ name: "name", type: "STRING", domain: ["Person"] }],
                relationships: [],
              },
            });


            // Or upload a file directly instead of a URL:

            const uploaded = await client.ingestions.create({
              workspaceId: "ws_3a1b",
              file: fs.createReadStream("report.pdf"),
              metadata: { customerId: "abc" },
            });


            // Or request a presigned upload URL for a large file:

            const ticket = await client.ingestions.create({
              workspaceId: "ws_3a1b",
              filename: "report.pdf",
              mimeType: "application/pdf",
              size: 12345678,
            });

            // Then PUT the bytes to ticket.upload.url with
            ticket.upload.headers
components:
  schemas:
    Ingestion:
      properties:
        id:
          type: string
          title: Id
        url:
          type: string
          title: Url
        status:
          type: string
          title: Status
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
        filename:
          anyOf:
            - type: string
            - type: 'null'
          title: Filename
        size:
          anyOf:
            - type: integer
            - type: 'null'
          title: Size
        mime_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Mime Type
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Metadata
        schema:
          anyOf:
            - $ref: '#/components/schemas/Schema'
            - type: 'null'
        created_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Created At
        updated_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Updated At
        processing:
          $ref: '#/components/schemas/ProcessingState'
        upload:
          anyOf:
            - $ref: '#/components/schemas/UploadTarget'
            - type: 'null'
      type: object
      required:
        - id
        - url
        - status
        - created_at
        - updated_at
        - processing
      title: Ingestion
    ErrorResponse:
      type: object
      title: ErrorResponse
      properties:
        detail:
          type: string
          title: Detail
      required:
        - detail
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    Schema:
      properties:
        classes:
          items:
            $ref: '#/components/schemas/Class'
          type: array
          title: Classes
          description: Classes in the schema.
        relationships:
          items:
            $ref: '#/components/schemas/Relationship'
          type: array
          title: Relationships
          description: Relationships between classes.
        properties:
          items:
            $ref: '#/components/schemas/Property'
          type: array
          title: Properties
          description: Properties of classes.
      type: object
      title: Schema
    ProcessingState:
      properties:
        current_step:
          anyOf:
            - type: string
            - type: 'null'
          title: Current Step
        percent_complete:
          anyOf:
            - type: number
            - type: 'null'
          title: Percent Complete
        steps:
          additionalProperties:
            $ref: '#/components/schemas/StageTimestamps'
          type: object
          title: Steps
        progress:
          additionalProperties:
            $ref: '#/components/schemas/StageProgress'
          type: object
          title: Progress
      type: object
      required:
        - steps
        - progress
      title: ProcessingState
    UploadTarget:
      properties:
        url:
          type: string
          title: Url
        method:
          type: string
          title: Method
          default: PUT
        headers:
          additionalProperties:
            type: string
          type: object
          title: Headers
        expires_at:
          type: string
          format: date-time
          title: Expires At
      type: object
      required:
        - url
        - expires_at
      title: UploadTarget
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    Class:
      properties:
        name:
          type: string
          title: Name
          description: Unique name of the class.
        definition:
          anyOf:
            - type: string
            - type: 'null'
          title: Definition
          description: Natural-language definition of the class.
        cardinality:
          type: string
          enum:
            - one
            - many
          title: Cardinality
          description: >-
            Instance cardinality within a document. 'one' means at most one
            instance per document.
          default: many
      type: object
      required:
        - name
      title: Class
    Relationship:
      properties:
        name:
          type: string
          title: Name
          description: Name of the relationship.
        domain:
          items:
            type: string
          type: array
          title: Domain
          description: Class or classes the relationship starts from.
        range:
          items:
            type: string
          type: array
          title: Range
          description: Class or classes the relationship points to.
        definition:
          anyOf:
            - type: string
            - type: 'null'
          title: Definition
          description: Natural-language definition of the relationship.
      type: object
      required:
        - name
        - domain
        - range
      title: Relationship
    Property:
      properties:
        name:
          type: string
          title: Name
          description: Name of the property.
        type:
          type: string
          title: Type
          description: Data type of the property.
        domain:
          items:
            type: string
          type: array
          title: Domain
          description: Class or classes the property applies to.
        definition:
          anyOf:
            - type: string
            - type: 'null'
          title: Definition
          description: Natural-language definition of the property.
        values:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Values
          description: Enumerated allowed values for the property.
      type: object
      required:
        - name
        - type
        - domain
      title: Property
    StageTimestamps:
      properties:
        started_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Started At
        completed_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Completed At
        failed_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Failed At
      type: object
      title: StageTimestamps
    StageProgress:
      properties:
        completed:
          type: integer
          title: Completed
          default: 0
        total:
          type: integer
          title: Total
          default: 0
        is_approximate:
          type: boolean
          title: Is Approximate
          default: false
        eta_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Eta At
      type: object
      title: StageProgress
  securitySchemes:
    HTTPBearer:
      type: http
      description: API key passed as a Bearer token in the Authorization header.
      scheme: bearer

````