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

# Process (sync)

> Send one or more documents for processing and wait for the result.

The request blocks until processing completes and returns the extracted data directly in the response.

## Request body

- `documents` (required): Array of document objects. Each document must have a `type` field (`url`, `base64`, or `text`).
- `metadata` (optional): Custom key-value object stored with the result.

## Response fields

- `entry_id`: Unique identifier for this result.
- `resource_type`: Always `"structure"`.
- `resource_id`: The structure used for extraction.
- `resource_version_number`: The version of the structure applied.
- `data`: The extracted data as structured JSON.
- `errors`: Validation errors, if any. `null` when everything is correct.
- `status`: `completed`, `completed_with_errors`, or `failed`.
- `time_ms`: Processing time in milliseconds.
- `price`: Cost of this request.



## OpenAPI

````yaml /api-reference/openapi.json post /v3/deployments/{deployment_id}
openapi: 3.1.0
info:
  title: matil API
  description: Structured data extraction for documents
  version: 3.0.0
servers:
  - url: https://api.matil.ai
security:
  - ApiKeyAuth: []
paths:
  /v3/deployments/{deployment_id}:
    post:
      tags:
        - Deployments
      summary: Process (sync)
      description: >-
        Send one or more documents for processing and wait for the result.


        The request blocks until processing completes and returns the extracted
        data directly in the response.


        ## Request body


        - `documents` (required): Array of document objects. Each document must
        have a `type` field (`url`, `base64`, or `text`).

        - `metadata` (optional): Custom key-value object stored with the result.


        ## Response fields


        - `entry_id`: Unique identifier for this result.

        - `resource_type`: Always `"structure"`.

        - `resource_id`: The structure used for extraction.

        - `resource_version_number`: The version of the structure applied.

        - `data`: The extracted data as structured JSON.

        - `errors`: Validation errors, if any. `null` when everything is
        correct.

        - `status`: `completed`, `completed_with_errors`, or `failed`.

        - `time_ms`: Processing time in milliseconds.

        - `price`: Cost of this request.
      operationId: process_v3_deployments__deployment_id__post
      parameters:
        - name: deployment_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Deployment Id
        - name: authorization
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Authorization
        - name: x-api-key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Api-Key
        - name: X-Tenant-ID
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Tenant-Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProcessRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProcessResponse'
        '400':
          description: >-
            Document error. Possible codes: DOCUMENT_DOWNLOAD_ERROR,
            DOCUMENT_URL_NOT_FOUND, DOCUMENT_URL_ACCESS_DENIED,
            DOCUMENT_URL_RETURNED_HTML, DOCUMENT_TOO_LARGE,
            DOCUMENT_URL_UNREACHABLE.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: DOCUMENT_DOWNLOAD_ERROR
                message: Failed to download document from the provided URL
                details: null
        '401':
          description: >-
            Authentication required. Provide a valid `x-api-key` or
            `Authorization: Bearer` token.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: AUTHENTICATION_REQUIRED
                message: Authentication required. Provide a valid x-api-key header.
                details: null
        '402':
          description: Insufficient credits. Top up your balance to continue processing.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: INSUFFICIENT_CREDITS
                message: >-
                  Insufficient credits. Top up your balance to continue
                  processing.
                details: null
        '404':
          description: No valid deployments found for the provided identifiers.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: DEPLOYMENT_NOT_FOUND
                message: No valid deployment found for the provided ID.
                details: null
        '422':
          description: Validation error. Check request body and document format.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: VALIDATION_ERROR
                message: >-
                  Each document must include a type field (url, base64, or
                  text).
                details: null
components:
  schemas:
    ProcessRequest:
      properties:
        documents:
          items:
            anyOf:
              - $ref: '#/components/schemas/DocumentInputText'
              - $ref: '#/components/schemas/DocumentInputURL'
              - $ref: '#/components/schemas/DocumentInputBase64'
              - $ref: '#/components/schemas/DocumentInputId'
          type: array
          minItems: 1
          title: Documents
          description: >-
            List of documents to process (text, url, base64, or id of
            pre-uploaded document)
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Metadata
          description: >-
            Optional client-provided metadata. Stored with the entry for
            correlation.
      type: object
      required:
        - documents
      title: ProcessRequest
      description: Request for synchronous document processing via deployment.
    ProcessResponse:
      properties:
        entry_id:
          type: string
          format: uuid
          title: Entry Id
          description: Unique identifier for the created entry
        resource_type:
          type: string
          title: Resource Type
          description: Type of resource processed
          default: structure
        resource_id:
          type: string
          format: uuid
          title: Resource Id
          description: ID of the structure used
        resource_version_number:
          type: integer
          title: Resource Version Number
          description: Version number of the structure used
        data:
          additionalProperties: true
          type: object
          title: Data
          description: Processed data
        errors:
          anyOf:
            - items:
                additionalProperties: true
                type: object
              type: array
            - type: 'null'
          title: Errors
          description: Processing or validation errors
        status:
          type: string
          title: Status
          description: 'Processing status: completed, completed_with_errors, or failed'
        time_ms:
          anyOf:
            - type: integer
            - type: 'null'
          title: Time Ms
          description: Processing time in milliseconds
        price:
          anyOf:
            - type: number
            - type: 'null'
          title: Price
          description: Processing cost
      type: object
      required:
        - entry_id
        - resource_id
        - resource_version_number
        - data
        - status
      title: ProcessResponse
      description: Unified response for synchronous processing.
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
          description: Machine-readable error code.
        message:
          type: string
          description: Human-readable description.
        details:
          type: object
          nullable: true
          description: Additional context when available.
      required:
        - error
        - message
    DocumentInputText:
      properties:
        type:
          type: string
          const: text
          title: Type
          description: Document type indicator for direct text content
          default: text
        text:
          type: string
          title: Text
          description: Raw text content to process
          examples:
            - |-
              Invoice #12345
              Date: 2024-01-15
              Total: $1,234.56
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Metadata
          description: Optional metadata for processing hints
      type: object
      required:
        - text
      title: DocumentInputText
      description: Direct text content for processing.
    DocumentInputURL:
      properties:
        type:
          enum:
            - url
          description: >-
            Document type indicator for URL reference. Only 'url' is shown in
            the schema.
      type: object
      required:
        - url
      title: DocumentInputURL
      description: >-
        URL reference to fetch document from.


        Accepts type "url" (shown in schema), but also allows "pdf", "png", etc.
        at runtime.
    DocumentInputBase64:
      properties:
        type:
          type: string
          const: base64
          title: Type
          description: Document type indicator for base64-encoded content
          default: base64
        content:
          type: string
          maxLength: 70000000
          minLength: 1
          title: Content
          description: Base64-encoded document bytes
          examples:
            - JVBERi0xLjQKJeLjz9MKNCAwIG9iago8PC9MZW5ndGg...
        mime_type:
          anyOf:
            - type: string
              maxLength: 100
            - type: 'null'
          title: Mime Type
          description: >-
            MIME type of the encoded document (e.g., 'application/pdf'). If not
            provided, will be auto-detected
          examples:
            - application/pdf
            - image/jpeg
            - image/png
            - text/plain
            - application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
        filename:
          anyOf:
            - type: string
              maxLength: 255
              minLength: 1
            - type: 'null'
          title: Filename
          description: Original filename for storage and processing hints
          examples:
            - invoice.pdf
            - receipt.jpg
            - document.txt
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Metadata
          description: Optional metadata for processing hints
      type: object
      required:
        - content
      title: DocumentInputBase64
      description: |-
        Base64-encoded document for inline processing.

        Allows direct submission of document bytes as base64-encoded strings,
        eliminating the need for URL fetching or pre-upload steps.
    DocumentInputId:
      properties:
        type:
          type: string
          const: id
          title: Type
          description: >-
            Document type indicator - references a document previously uploaded
            via POST /documents
          default: id
        id:
          type: string
          format: uuid
          title: Id
          description: >-
            ID of document previously uploaded and processed via POST /documents
            endpoint
          examples:
            - 550e8400-e29b-41d4-a716-446655440000
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Metadata
          description: Optional metadata for processing hints
      type: object
      required:
        - id
      title: DocumentInputId
      description: Reference to pre-uploaded MATIL document.
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````