> ## Documentation Index
> Fetch the complete documentation index at: https://api-doc.fidly.be/llms.txt
> Use this file to discover all available pages before exploring further.

# Import Document

> Import a document (the API equivalent of dropping a file in the interface).

The body is the file, and only the file: `type` is a query parameter because it does not
describe the document — the stored type stays `unknown` until the asynchronous chain
classifies it — it decides how the import is processed.

Only the new document's `id` is returned: every other field is still empty at creation.
The document is enriched asynchronously (type, amounts, third party) — poll
`GET /documents/{id}` to follow it. In sandbox mode the file is validated exactly as in
live mode but nothing is stored, so the returned `id` is not resolvable.



## OpenAPI

````yaml /openapi.json post /documents/import
openapi: 3.1.0
info:
  title: Fidly API
  version: 1.0.0
servers:
  - url: https://api.fidly.be
    description: Production
security: []
paths:
  /documents/import:
    post:
      tags:
        - documents
      summary: Import Document
      description: >-
        Import a document (the API equivalent of dropping a file in the
        interface).


        The body is the file, and only the file: `type` is a query parameter
        because it does not

        describe the document — the stored type stays `unknown` until the
        asynchronous chain

        classifies it — it decides how the import is processed.


        Only the new document's `id` is returned: every other field is still
        empty at creation.

        The document is enriched asynchronously (type, amounts, third party) —
        poll

        `GET /documents/{id}` to follow it. In sandbox mode the file is
        validated exactly as in

        live mode but nothing is stored, so the returned `id` is not resolvable.
      operationId: import_document_documents_import_post
      parameters:
        - name: type
          in: query
          required: false
          schema:
            type: string
            description: >-
              Role of the document: `purchase` (default), `sale` or `other`.
              `purchase` and `sale` are analysed automatically; `other` is
              stored as-is, without analysis.
            default: purchase
            title: Type
          description: >-
            Role of the document: `purchase` (default), `sale` or `other`.
            `purchase` and `sale` are analysed automatically; `other` is stored
            as-is, without analysis.
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/Body_import_document_documents_import_post'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocumentImportedOut'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    Body_import_document_documents_import_post:
      properties:
        file:
          type: string
          contentMediaType: application/octet-stream
          title: File
          description: >-
            The file to import. Allowed extensions: .pdf, .xml, .jpg, .jpeg,
            .png (max 10 MB).
      type: object
      required:
        - file
      title: Body_import_document_documents_import_post
    DocumentImportedOut:
      properties:
        id:
          type: string
          title: Id
          description: Opaque unique identifier of the created document.
      type: object
      required:
        - id
      title: DocumentImportedOut
      description: >-
        Identifier of a freshly imported document.


        Nothing else is returned: at creation every other field still holds its
        default value

        (no type, no amounts, no third party) — they are filled by the
        asynchronous chain.

        Read the document itself with `GET /documents/{id}` to follow its
        enrichment.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    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
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````