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

# Upload a contract PDF for ingestion

> Creates a contract ingestion task from the uploaded contract PDF and adds it to the review inbox of the billing app. Aira then reads the PDF in the background into a proposal of a contract, which a user approves or rejects in the billing app. The multipart form takes the PDF as its one file and, in the optional `contractShape` field, the contract shape of the PDF.

Requires the role `watchtower:write`.



## OpenAPI

````yaml /api-reference/openapi.yaml post /v1/watchtower/contract-ingestion
openapi: 3.1.0
info:
  title: API Reference
  version: '1.0'
  description: Aira API Reference
  x-logo:
    url: https://static.useaira.com/images/airalogo.svg
    backgroundColor: '#FFFFFF'
    altText: Aira Logo
servers:
  - url: https://api.useaira.com
    description: API base URL
security:
  - ApiKey: []
paths:
  /v1/watchtower/contract-ingestion:
    post:
      tags:
        - Watchtower
      summary: Upload a contract PDF for ingestion
      description: >-
        Creates a contract ingestion task from the uploaded contract PDF and
        adds it to the review inbox of the billing app. Aira then reads the PDF
        in the background into a proposal of a contract, which a user approves
        or rejects in the billing app. The multipart form takes the PDF as its
        one file and, in the optional `contractShape` field, the contract shape
        of the PDF.


        Requires the role `watchtower:write`.
      responses:
        '201':
          description: >-
            The task that reads the uploaded contract PDF, and whether another
            task of the tenant holds the same PDF.
          content:
            application/json:
              schema:
                type: object
                properties:
                  task:
                    type: object
                    description: The contract ingestion task that the upload created.
                    properties:
                      id:
                        type: string
                        format: uuid
                        description: The unique identifier of the task in our system.
                      type:
                        type: string
                        enum:
                          - contract_ingestion
                        description: >-
                          The kind of the task: `contract_ingestion` reads a
                          contract PDF into a proposal of a contract.
                      status:
                        type: string
                        enum:
                          - pending
                          - processing
                          - awaiting_action
                          - completed
                          - dismissed
                          - failed
                        description: >-
                          Where the task stands: `pending` until Aira starts to
                          read the PDF, `processing` while Aira reads it,
                          `awaiting_action` until a user approves or rejects it,
                          `completed` once a user approves it, `dismissed` once
                          a user rejects it, and `failed` when the reading of
                          the PDF or an approval failed.
                      createdAt:
                        type: string
                        format: date-time
                        description: >-
                          ISO 8601 timestamp in UTC indicating when Aira created
                          the task.
                    required:
                      - id
                      - type
                      - status
                      - createdAt
                    additionalProperties: false
                  duplicateWarning:
                    type: boolean
                    description: >-
                      Whether another task of the tenant holds the same PDF,
                      leaving out a task that a user rejected and a task whose
                      PDF Aira failed to read.
                required:
                  - task
                  - duplicateWarning
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `multiple_contract_pdfs_not_allowed`: the form has more than one
            file.

            - `contract_pdf_not_provided`: the form has no file, or its file has
            no name.

            - `invalid_contract_shape`: `contractShape` does not start with
            `default:` or `custom:`.

            - `invalid_contract_pdf`: the file is not a PDF.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - multiple_contract_pdfs_not_allowed
                      - contract_pdf_not_provided
                      - invalid_contract_shape
                      - invalid_contract_pdf
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                multiple_contract_pdfs_not_allowed:
                  value:
                    message: only one contract pdf may be uploaded at a time
                    code: multiple_contract_pdfs_not_allowed
                contract_pdf_not_provided:
                  value:
                    message: contract pdf not provided
                    code: contract_pdf_not_provided
                invalid_contract_shape:
                  value:
                    message: 'contract shape must be a default: or custom: key'
                    code: invalid_contract_shape
                invalid_contract_pdf:
                  value:
                    message: uploaded file is not a pdf
                    code: invalid_contract_pdf
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the tenant does not allow the IP of the request.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role watchtower:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '413':
          description: >-
            A file or the body of the request is larger than its limit.


            - `file_too_large`: a file of the form is larger than the limit of
            the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - file_too_large
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                file_too_large:
                  value:
                    message: a file of the request is larger than the limit
                    code: file_too_large
        '422':
          description: >-
            An outside service refuses the data of the request.


            - `contract_pdf_too_large`: the PDF is larger than the size that
            Aira can read.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - contract_pdf_too_large
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                contract_pdf_too_large:
                  value:
                    message: the PDF is larger than the size that Aira can read
                    code: contract_pdf_too_large
components:
  securitySchemes:
    ApiKey:
      type: apiKey
      description: API Key Authentication.
      name: X-API-KEY
      in: header

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.