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

# Upload Document

> Upload a document. To use it in a case, pass its ID in a Case or Check create request.

**Allowed file types:** PDF, PNG, JPG, CSV, XLSX, DOCX, MD.



## OpenAPI

````yaml /api_schema.yaml post /api/documents/
openapi: 3.0.3
info:
  title: Sphinx API
  version: 1.0.0
  description: >
    Automated compliance API for KYC/AML workflows. Sphinx handles PEP
    screening, sanctions checks, adverse media monitoring, and document
    verification with AI-powered decisions.


    **Quick Start:**

    1. **Upload Documents** (Optional) - Required for KYB, KYC EDD, and
    transaction monitoring. Not required for AML checks (PEP, Sanctions, Adverse
    Media).

    2. **Create a Case** - The case creation endpoint combines customer details
    and checks (typically a single alert) into one request.

    3. **Receive Webhook** - Results are sent to your webhook URL when
    processing completes.


    **Authentication:** All API requests require a bearer token. Include it in
    the Authorization header: `Authorization: Token <YOUR_API_KEY>`


    **Outcomes:** Each check returns an outcome (ACCEPTED, REJECTED, or PENDING)
    with detailed reasoning, risk scores (0.0-1.0), and audit-ready case notes
    in Markdown format.


    For detailed documentation, visit
    [docs.sphinxhq.com](https://docs.sphinxhq.com).
servers:
  - url: https://app.sphinxhq.com
    description: Production server (US)
  - url: https://eu.sphinxhq.com
    description: Production server (EU)
security: []
tags:
  - name: Cases
    description: >-
      Cases represent compliance reviews for a customer. Create a case, add
      checks, then start processing.
  - name: Checks
    description: >-
      Individual compliance checks within a case (e.g., PEP, Sanctions, Document
      Verification).
  - name: Customers
    description: >-
      Customer records linked to cases. Store customer details, type
      (individual/company), and external IDs.
  - name: Documents
    description: >-
      Upload and manage documents for cases and checks. Used for identity
      verification and document-based checks.


      **Allowed file types:** PDF, PNG, JPG, CSV, XLSX, DOCX, MD.
  - name: Events
    description: >-
      Timeline of activity on cases and checks: comments, outcome changes,
      assignments, status changes, reruns, and document activity.
paths:
  /api/documents/:
    post:
      tags:
        - Documents
      summary: Upload Document
      description: >-
        Upload a document. To use it in a case, pass its ID in a Case or Check
        create request.


        **Allowed file types:** PDF, PNG, JPG, CSV, XLSX, DOCX, MD.
      operationId: documents_create
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DocumentWrite'
            examples:
              UploadDocument:
                value:
                  file: >-
                    data:application/pdf;base64,JVBERi0xLjEKMSAwIG9iajw8L1R5cGUvQ2F0YWxvZy9QYWdlcyAyIDAgUj4+ZW5kb2JqCjIgMCBvYmo8PC9UeXBlL1BhZ2VzL0tpZHNbMyAwIFJdL0NvdW50IDE+PmVuZG9iagozIDAgb2JqPDwvVHlwZS9QYWdlL1BhcmVudCAyIDAgUi9NZWRpYUJveFswIDAgMjAwIDIwMF0+PmVuZG9iagp0cmFpbGVyPDwvUm9vdCAxIDAgUj4+CiUlRU9GCg==
                  original_name: passport.pdf
                  delete_after: 7
                summary: Upload document
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/DocumentWrite'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/DocumentWrite'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocumentRead'
          description: ''
      security:
        - OAuthToken: []
        - tokenAuth: []
        - tokenAuth: []
components:
  schemas:
    DocumentWrite:
      type: object
      description: Write serializer for Document upload.
      properties:
        case_id:
          type: integer
          writeOnly: true
          description: ID of the case
        check_id:
          type: integer
          writeOnly: true
          description: ID of the check
        file:
          type: string
          format: uri
          description: >-
            Base64 encoded file content. Allowed file types: PDF, PNG, JPG, CSV,
            XLSX, DOCX, MD. Maximum size: 40 MB.
        original_name:
          type: string
          maxLength: 255
        delete_after:
          type: integer
          description: >-
            Number of days until deletion. Use 0 for immediate deletion, or -1
            for indefinite retention (never delete). Defaults to -1.
      required:
        - file
        - original_name
    DocumentRead:
      type: object
      description: Read-only serializer for Document.
      properties:
        id:
          type: integer
          readOnly: true
        case:
          type: integer
          nullable: true
        check:
          type: integer
          readOnly: true
        file:
          type: string
          readOnly: true
          description: Storage path of the uploaded file.
        original_name:
          type: string
          maxLength: 255
        created_at:
          type: string
          format: date-time
          readOnly: true
        updated_at:
          type: string
          format: date-time
          readOnly: true
        delete_after:
          type: integer
          maximum: 2147483647
          minimum: -2147483648
          description: Days until deletion. -1 means never delete.
      required:
        - check
        - created_at
        - file
        - id
        - original_name
        - updated_at
  securitySchemes:
    OAuthToken:
      type: http
      scheme: bearer
      description: >-
        OAuth2 access token obtained from POST /api/oauth/token/ using client
        credentials.
    tokenAuth:
      type: http
      scheme: bearer

````