> ## 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.

# Document quota and call counts

> Required scope: `usage:read`.

Production documents this month vs the plan, today's Sandbox counter vs its cap,
and this key's calls per endpoint over the last 7 days (in the call's environment).

Choose the environment with the `X-Sahl-Environment` header or the `environment` parameter or field; the Sandbox is the default. Two values that disagree are refused (422 `environment_conflict`).



## OpenAPI

````yaml /openapi.json get /v1/partner/usage
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/partner/usage:
    get:
      tags:
        - Account
      summary: Document quota and call counts
      description: >-
        Required scope: `usage:read`.


        Production documents this month vs the plan, today's Sandbox counter vs
        its cap,

        and this key's calls per endpoint over the last 7 days (in the call's
        environment).


        Choose the environment with the `X-Sahl-Environment` header or the
        `environment` parameter or field; the Sandbox is the default. Two values
        that disagree are refused (422 `environment_conflict`).
      operationId: account_usage
      parameters:
        - name: environment
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: sandbox or production for the call counts; Sandbox by default.
            title: Environment
          description: sandbox or production for the call counts; Sandbox by default.
        - 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` parameter; if both are sent they must agree.
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageOut'
        '401':
          description: >-
            Missing, invalid, revoked or expired API key (plain-string
            `detail`), or `partner_identity_rejected`: The key is bound to a
            service account and X-Partner-Identity was missing or did not verify
            for it.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail:
                  code: partner_identity_rejected
                  message: >-
                    The key is bound to a service account and X-Partner-Identity
                    was missing or did not verify for it.
        '403':
          description: >-
            `insufficient_scope`: The API key does not hold the scope this route
            needs. Issue a key with that scope in Settings > API. The body's
            detail is a plain string for this one.
            `production_api_not_approved`: The workspace is not yet approved for
            Production API calls. Request production access in Settings > API;
            Sandbox stays open. `production_requires_paid_plan`: The
            subscription is not active. Update billing to use Production.
            `production_trial_ended`: A Free bank workspace's Production trial
            has ended. Upgrade the plan. `work_email_required`: Production on
            the Free plan needs a verified work email on the workspace.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail: API key lacks the required scope
        '422':
          description: >-
            Validation error (`detail` is a list), or a coded 422:
            `invalid_environment`: environment / X-Sahl-Environment must be
            'sandbox' or 'production'. `environment_conflict`:
            X-Sahl-Environment and the environment field disagree.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail:
                  code: invalid_environment
                  message: >-
                    environment / X-Sahl-Environment must be 'sandbox' or
                    'production'.
        '429':
          description: >-
            `rate_limit_exceeded`: Too many calls a minute: per API key on the
            partner routes, or per key / per address at the edge. Wait for
            Retry-After.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail:
                  code: rate_limit_exceeded
                  message: >-
                    Too many calls a minute: per API key on the partner routes,
                    or per key / per address at the edge. Wait for Retry-After.
        '500':
          description: '`internal_error`: Unexpected error. Quote X-Request-ID to support.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail:
                  code: internal_error
                  message: Unexpected error. Quote X-Request-ID to support.
      security:
        - bearerAuth: []
components:
  schemas:
    UsageOut:
      properties:
        plan:
          type: string
          title: Plan
          description: The workspace's plan.
        production:
          $ref: '#/components/schemas/ProductionUsage'
          description: The monthly Production quota.
        sandbox:
          $ref: '#/components/schemas/SandboxUsage'
          description: Today's Sandbox fair-use counter.
        environment:
          type: string
          enum:
            - sandbox
            - production
          title: Environment
          description: The environment the call counts are for.
        window_days:
          type: integer
          title: Window Days
          description: Days the call counts cover.
          default: 7
        endpoints:
          items:
            $ref: '#/components/schemas/EndpointCount'
          type: array
          title: Endpoints
          description: This key's calls per endpoint in the window, most called first.
      type: object
      required:
        - plan
        - production
        - sandbox
        - environment
        - endpoints
      title: UsageOut
    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
    ProductionUsage:
      properties:
        period_start:
          type: string
          format: date
          title: Period Start
          description: First day of the month counted (UTC).
        resets_at:
          type: string
          format: date-time
          title: Resets At
          description: When the monthly count starts again.
        documents_used:
          type: integer
          title: Documents Used
          description: 'Production documents this month: dashboard uploads + API reads.'
        api_documents:
          type: integer
          title: Api Documents
          description: Of which read through the partner APIs.
        document_limit:
          type: integer
          title: Document Limit
          description: The plan's monthly document quota.
        remaining:
          type: integer
          title: Remaining
          description: Documents left this month.
        refused:
          type: integer
          title: Refused
          description: API reads refused this month for the quota.
        locked:
          type: boolean
          title: Locked
          description: Production is refused (a Free bank's trial ended).
      type: object
      required:
        - period_start
        - resets_at
        - documents_used
        - api_documents
        - document_limit
        - remaining
        - refused
        - locked
      title: ProductionUsage
    SandboxUsage:
      properties:
        day:
          type: string
          format: date
          title: Day
          description: The UTC day counted.
        resets_at:
          type: string
          format: date-time
          title: Resets At
          description: Next 00:00 UTC.
        documents_used:
          type: integer
          title: Documents Used
          description: Sandbox documents read today by the API.
        daily_cap:
          anyOf:
            - type: integer
            - type: 'null'
          title: Daily Cap
          description: Fair-use cap per day; null = no cap.
        remaining:
          anyOf:
            - type: integer
            - type: 'null'
          title: Remaining
          description: Left today; null when there is no cap.
        refused:
          type: integer
          title: Refused
          description: Reads refused today for the cap.
      type: object
      required:
        - day
        - resets_at
        - documents_used
        - refused
      title: SandboxUsage
    EndpointCount:
      properties:
        method:
          type: string
          title: Method
          description: HTTP method.
        path:
          type: string
          title: Path
          description: Route template, relative to the API base (/api).
        calls:
          type: integer
          title: Calls
          description: Calls in the window.
        errors:
          type: integer
          title: Errors
          description: Of which answered with a status >= 400.
      type: object
      required:
        - method
        - path
        - calls
        - errors
      title: EndpointCount
  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.