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

# Read a bank statement

> Required scope: `statements:read`.

Send one statement as multipart `file` (native PDF, scanned PDF, JPEG, PNG, WebP or TIFF). Up to 6 pages (the default limit) the answer is the statement itself (200, `status: completed`): header data, every transaction, and a reconciliation of the balances. A longer statement is queued: 202 with a `statement_id`; the `statement.extracted` webhook fires when it is read and `GET /v1/statements/{statement_id}` returns it. A synchronous read stores nothing; a queued result is kept for 7 days by default.

Billed per started block of 10 pages (1 to 10 pages is 1 document, 11 to 20 is 2). Over 60 pages (the default maximum) the call answers 413 `statement_too_long`; split the statement by period.

Choose the environment with the `X-Sahl-Environment` header or the `environment` field/parameter; the Sandbox is the default. Two values that disagree are refused (422 `environment_conflict`). In Production the workspace must be approved by Sahl (403 `production_api_not_approved` until then), its subscription must be active (403 `production_requires_paid_plan`), and a Free workspace needs a verified work email (403 `work_email_required`). The Sandbox is always open.

A workspace created on or after 2026-10-24 reads only specimen documents in the Sandbox: take them from `GET /v1/sandbox/specimens`. Anything else answers 422 `sandbox_specimen_required`; use Production for real documents.



## OpenAPI

````yaml /openapi.json post /v1/statements/extract
openapi: 3.1.0
info:
  title: Sahl Partner API
  version: 0.2.0
  description: >-
    Server-to-server API for lenders and banks: document reading, verification,
    risk assessment, eID checks, Moroccan company (KYB) onboarding, bank
    statements, document requests, webhooks, registry checks, cases, scoring,
    KYC policy, webhook deliveries and bank connections. Authenticate with
    `Authorization: Bearer <API key>`. Paths are relative to the server URL. New
    workspaces start in sandbox.
servers:
  - url: https://app.sahlfinancial.com/api
    description: Single API host. Send environment=sandbox (the default) for test data.
security:
  - bearerAuth: []
tags:
  - name: KYC
    description: Read documents, verify a profile, assess risk, start an eID check.
  - name: Bank connections (Growth)
    description: >-
      Growth plan, switched on per workspace by Sahl. Sandbox simulation today;
      production answers 409 until a bank data provider is live.
  - name: KYB
    description: >-
      Moroccan company file: read the Modèle J, the IF attestation and the
      manager's CIN, check an ICE. Every plan.
  - name: Statements
    description: Read a bank statement line by line and reconcile it. Every plan.
  - name: Webhooks
    description: >-
      Manage webhook endpoints with an API key (scope `webhooks:manage`). Every
      plan.
  - name: Document requests
    description: >-
      Ask an applicant for documents through a link or an embedded page, and
      follow the request.
  - name: Sandbox
    description: 'The specimen gallery: the only documents a new workspace''s Sandbox reads.'
  - name: Registry
    description: >-
      Check a SIREN, a VAT number, a LEI, an IBAN, a Moroccan RIB or ICE. Scope
      `registry:read`.
  - name: Cases
    description: >-
      Read the cases your calls filed, their documents and the fields read.
      Scope `cases:read`.
  - name: Scoring
    description: >-
      Read, re-run or simulate a case's credit score. Scopes `scoring:read`,
      `scoring:write`.
  - name: Policy
    description: >-
      Read and save the KYC policy your `/v1/kyc/*` calls run under. Scopes
      `policy:read`, `policy:write`.
  - name: Webhook deliveries
    description: >-
      See what was sent to your endpoints and send a delivery again. Scope
      `webhooks:manage`.
  - name: Account
    description: The calling key, its usage, its recent calls and the error catalogue.
paths:
  /v1/statements/extract:
    post:
      tags:
        - Statements
      summary: Read a bank statement
      description: >-
        Required scope: `statements:read`.


        Send one statement as multipart `file` (native PDF, scanned PDF, JPEG,
        PNG, WebP or TIFF). Up to 6 pages (the default limit) the answer is the
        statement itself (200, `status: completed`): header data, every
        transaction, and a reconciliation of the balances. A longer statement is
        queued: 202 with a `statement_id`; the `statement.extracted` webhook
        fires when it is read and `GET /v1/statements/{statement_id}` returns
        it. A synchronous read stores nothing; a queued result is kept for 7
        days by default.


        Billed per started block of 10 pages (1 to 10 pages is 1 document, 11 to
        20 is 2). Over 60 pages (the default maximum) the call answers 413
        `statement_too_long`; split the statement by period.


        Choose the environment with the `X-Sahl-Environment` header or the
        `environment` field/parameter; the Sandbox is the default. Two values
        that disagree are refused (422 `environment_conflict`). In Production
        the workspace must be approved by Sahl (403
        `production_api_not_approved` until then), its subscription must be
        active (403 `production_requires_paid_plan`), and a Free workspace needs
        a verified work email (403 `work_email_required`). The Sandbox is always
        open.


        A workspace created on or after 2026-10-24 reads only specimen documents
        in the Sandbox: take them from `GET /v1/sandbox/specimens`. Anything
        else answers 422 `sandbox_specimen_required`; use Production for real
        documents.
      operationId: statements_extract
      parameters:
        - name: X-Sahl-Environment
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Sahl-Environment
          description: >-
            `sandbox` (default) or `production`. Same meaning as the
            `environment` field or parameter; if both are sent they must agree.
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/Body_extract_api_v1_statements_extract_post'
      responses:
        '200':
          description: The statement, read synchronously.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StatementExtractResponse'
              example:
                statement_id: null
                status: completed
                environment: sandbox
                reference: client-0001
                bank: Specimen Bank
                account_holder: Test Client
                account_number: '000000000000'
                rib: null
                iban: null
                currency: MAD
                period_start: '2026-10-01'
                period_end: '2026-10-31'
                opening_balance: 10000
                closing_balance: 10850
                transactions:
                  - date: '2026-10-03'
                    value_date: '2026-10-03'
                    label: SALAIRE OCTOBRE
                    debit: null
                    credit: 12000
                    amount: 12000
                    balance: 22000
                  - date: '2026-10-05'
                    value_date: '2026-10-05'
                    label: LOYER
                    debit: 11150
                    credit: null
                    amount: -11150
                    balance: 10850
                reconciliation:
                  opening_balance: 10000
                  movements_total: 850
                  expected_closing_balance: 10850
                  closing_balance: 10850
                  difference: 0
                  passed: true
                  gaps: []
                  totals: {}
                warnings: []
                read:
                  pages: 1
                  scanned: false
                  source: text
                  model_calls: 0
                billing:
                  documents_billed: 1
                  pages: 1
                  environment: sandbox
                latency_ms: 2100
        '202':
          description: >-
            Queued: too many pages to read synchronously. Poll `poll_url` or
            wait for the `statement.extracted` event.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StatementQueued'
              example:
                statement_id: 4d7e1a93-2b6c-4f08-9a15-8c3e5f0b7d21
                status: queued
                environment: sandbox
                reference: client-0001
                pages: 24
                poll_url: /api/v1/statements/4d7e1a93-2b6c-4f08-9a15-8c3e5f0b7d21
                webhook_event: statement.extracted
                billing:
                  documents_billed: 3
                  pages: 24
                  environment: sandbox
        '400':
          description: >-
            Empty file (`empty_file`), unsupported type, or content that does
            not match the declared type.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail:
                  code: empty_file
                  message: modele_j is empty.
        '401':
          description: Missing, invalid, revoked or expired API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail: Invalid or revoked API key
        '403':
          description: >-
            The key lacks the scope (`insufficient_scope`), or a Production call
            from a workspace Sahl has not approved
            (`production_api_not_approved`), without an active subscription
            (`production_requires_paid_plan`), or on the Free plan without a
            verified work email (`work_email_required`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail:
                  code: production_api_not_approved
                  message: >-
                    This workspace is not yet approved for Production API calls.
                    Request production access in Settings → API. Sandbox stays
                    open meanwhile.
        '413':
          description: >-
            File too large, or more pages than the API reads
            (`statement_too_long`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail:
                  code: statement_too_long
                  message: >-
                    The statement has 80 pages; the API reads up to 60. Split it
                    by period.
        '422':
          description: >-
            `invalid_reference`, `invalid_environment`, `environment_conflict`,
            `sandbox_specimen_required` (a non-specimen document in a
            specimen-only Sandbox), or a validation error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail:
                  code: sandbox_specimen_required
                  message: >-
                    Sandbox only accepts specimen documents. Use Production for
                    real documents.
        '429':
          description: >-
            Sandbox fair use per day (`sandbox_daily_cap_reached`, with
            `Retry-After` until 00:00 UTC), the plan's monthly limit in
            Production (`usage_limit_reached`), or the per-key rate limit.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail:
                  code: sandbox_daily_cap_reached
                  message: >-
                    Sandbox fair use is 200 documents a day per workspace; 200
                    read today. Retry after 00:00 UTC, or use Production.
                  current: 200
                  limit: 200
        '500':
          description: Unexpected server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorFlat'
              example:
                code: internal_error
                message: An unexpected error occurred
                details: null
        '503':
          description: >-
            The statement could not be queued (`storage_unavailable`). The
            documents were given back; retry.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail:
                  code: storage_unavailable
                  message: Could not queue the statement; retry.
      security:
        - bearerAuth: []
components:
  schemas:
    Body_extract_api_v1_statements_extract_post:
      properties:
        file:
          type: string
          title: File
          description: >-
            The statement: PDF (native or scanned) or image (JPEG, PNG, WebP,
            TIFF), up to 30 MB.
          format: binary
        reference:
          anyOf:
            - type: string
            - type: 'null'
          title: Reference
          description: >-
            Your own id: 1 to 64 characters of `A-Z a-z 0-9 _ . : -`. Another
            value answers 422 `invalid_reference`.
        environment:
          anyOf:
            - type: string
            - type: 'null'
          title: Environment
          description: '`sandbox` (default) or `production`.'
      type: object
      required:
        - file
      title: Statement request
    StatementExtractResponse:
      type: object
      title: StatementExtractResponse
      description: A statement read synchronously (200).
      properties:
        statement_id:
          type: 'null'
          description: 'Always null: a synchronous read stores nothing.'
        status:
          type: string
          enum:
            - completed
        environment:
          type: string
          enum:
            - sandbox
            - production
        reference:
          type:
            - string
            - 'null'
          description: The `reference` you sent.
        bank:
          type:
            - string
            - 'null'
          description: Bank name read from the statement.
        account_holder:
          type:
            - string
            - 'null'
          description: Account holder.
        account_number:
          type:
            - string
            - 'null'
          description: Account number.
        rib:
          type:
            - string
            - 'null'
          description: RIB, when read.
        iban:
          type:
            - string
            - 'null'
          description: IBAN, when read.
        currency:
          type:
            - string
            - 'null'
          description: Currency code.
        period_start:
          type:
            - string
            - 'null'
          description: '`YYYY-MM-DD`.'
        period_end:
          type:
            - string
            - 'null'
          description: '`YYYY-MM-DD`.'
        opening_balance:
          type:
            - number
            - 'null'
        closing_balance:
          type:
            - number
            - 'null'
        transactions:
          type: array
          items:
            $ref: '#/components/schemas/StatementTransaction'
        reconciliation:
          type: object
          description: >-
            Do the rows add up? `passed` is null when the balances were not
            read.
          properties:
            opening_balance:
              type:
                - number
                - 'null'
            movements_total:
              type: number
            expected_closing_balance:
              type:
                - number
                - 'null'
            closing_balance:
              type:
                - number
                - 'null'
            difference:
              type:
                - number
                - 'null'
            passed:
              type:
                - boolean
                - 'null'
            gaps:
              type: array
              items:
                additionalProperties: true
                type: object
              description: Rows where the running balance does not follow.
            totals:
              type: object
              additionalProperties: true
              description: Totals printed on the statement, compared with the rows.
        warnings:
          type: array
          items:
            additionalProperties: true
            type: object
        read:
          type: object
          description: How the statement was read.
          properties:
            pages:
              type: integer
            scanned:
              type: boolean
            source:
              type: string
            model_calls:
              type: integer
        billing:
          $ref: '#/components/schemas/PartnerBilling'
        latency_ms:
          type: integer
      required:
        - status
        - environment
        - transactions
        - reconciliation
        - billing
    StatementQueued:
      type: object
      title: StatementQueued
      description: A statement too long to read synchronously (202).
      properties:
        statement_id:
          type: string
          format: uuid
          description: Poll `GET /v1/statements/{statement_id}` with it.
        status:
          type: string
          enum:
            - queued
        environment:
          type: string
          enum:
            - sandbox
            - production
        reference:
          type:
            - string
            - 'null'
          description: The `reference` you sent.
        pages:
          type: integer
        poll_url:
          type: string
          description: Path to poll, `/api/v1/statements/{statement_id}`.
        webhook_event:
          type: string
          enum:
            - statement.extracted
        billing:
          $ref: '#/components/schemas/PartnerBilling'
      required:
        - statement_id
        - status
        - environment
        - pages
        - poll_url
        - webhook_event
        - billing
    Error:
      type: object
      title: Error
      description: >-
        FastAPI error body. `detail` is a string, a list (validation 422), or an
        object with `code` and `message` (extra keys possible).
      properties:
        detail:
          oneOf:
            - type: string
            - type: array
              items:
                additionalProperties: true
                type: object
              description: Validation errors (422).
            - type: object
              additionalProperties: true
              properties:
                code:
                  type: string
                message:
                  type: string
      required:
        - detail
    ErrorFlat:
      type: object
      title: ErrorFlat
      description: >-
        Body of a rate-limit 429, an unknown route 404 and a 500: `code` and
        `message` at the top level, with no `detail`.
      properties:
        code:
          type: string
        message:
          type: string
        details:
          type:
            - string
            - 'null'
          description: Present on a 500 only; null unless the server runs in debug mode.
      required:
        - code
        - message
    StatementTransaction:
      type: object
      title: StatementTransaction
      properties:
        date:
          type:
            - string
            - 'null'
          description: Booking date, `YYYY-MM-DD`.
        value_date:
          type:
            - string
            - 'null'
          description: Value date, `YYYY-MM-DD`.
        label:
          type:
            - string
            - 'null'
          description: Description.
        debit:
          type:
            - number
            - 'null'
        credit:
          type:
            - number
            - 'null'
        amount:
          type: number
          description: credit minus debit.
        balance:
          type:
            - number
            - 'null'
          description: Balance after the line, when the statement prints it.
    PartnerBilling:
      type: object
      title: PartnerBilling
      description: What this call counted against the workspace.
      properties:
        documents_billed:
          type: integer
          description: Documents counted.
        pages:
          type: integer
          description: 'Statements only: pages read.'
        environment:
          type: string
          enum:
            - sandbox
            - production
      required:
        - documents_billed
        - environment
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key created in the console. Scopes: kyc:extract, kyc:verify,
        kyc:eid; kyb:onboard, kyb:ice; statements:read; webhooks:manage;
        requests:read, requests:write; bank:read, bank:write (Growth plan,
        enabled per workspace by Sahl); registry:read; cases:read; scoring:read,
        scoring:write; policy:read, policy:write; usage:read. The Sandbox
        specimen routes, `GET /v1/partner/me` and `GET /v1/partner/errors` need
        any valid key.

````

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