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

# Create a document request

> Required scope: `requests:write`.

Asks an applicant for documents. The answer carries a `url` to give the applicant (a link, or a page to embed when `channel` is `embed`). The link's token exists only in the response of create and resend; Sahl keeps only its hash.

A request is open while `pending`, `opened` or `submitted`. Creating again for the same `reference` returns the open request (200, `existing: true`, no `url`); send `force_new: true` to revoke it and mint a new one (201). `send_email: true` needs `applicant.email`. The workspace must have named its data controller (Settings, Privacy and compliance), otherwise 409 `privacy_controller_missing`. A new reference counts against the workspace's case quota.

This route also accepts a signed-in dashboard user; this reference documents the API-key use. 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.



## OpenAPI

````yaml /openapi.json post /v1/requests
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/requests:
    post:
      tags:
        - Document requests
      summary: Create a document request
      description: >-
        Required scope: `requests:write`.


        Asks an applicant for documents. The answer carries a `url` to give the
        applicant (a link, or a page to embed when `channel` is `embed`). The
        link's token exists only in the response of create and resend; Sahl
        keeps only its hash.


        A request is open while `pending`, `opened` or `submitted`. Creating
        again for the same `reference` returns the open request (200, `existing:
        true`, no `url`); send `force_new: true` to revoke it and mint a new one
        (201). `send_email: true` needs `applicant.email`. The workspace must
        have named its data controller (Settings, Privacy and compliance),
        otherwise 409 `privacy_controller_missing`. A new reference counts
        against the workspace's case quota.


        This route also accepts a signed-in dashboard user; this reference
        documents the API-key use. 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.
      operationId: requests_create
      parameters:
        - name: environment
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Environment
          description: >-
            `sandbox` (default) or `production`. Same meaning as the
            `X-Sahl-Environment` header; if both are sent they must agree.
        - 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:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateRequest'
            examples:
              link:
                summary: A link by email
                value:
                  reference: client-0001
                  applicant:
                    name: Test Client
                    email: test.client@example.com
                  documents:
                    - payslip
                    - national_id
                  reason: Salary advance file
                  locale: en
                  expires_in_days: 7
                  send_email: true
                  channel: link
                  metadata:
                    loan_ref: L-1042
              embed:
                summary: A page to embed, no email
                value:
                  reference: client-0002
                  documents:
                    - bank_statement
                  channel: embed
      responses:
        '200':
          description: >-
            An open request already exists for this `reference`: returned as is,
            without a `url`. Send `force_new: true` to replace it.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocumentRequest'
              example:
                id: 3f2b8c1e-5a47-4d0e-9b6a-1c7e2d4f8a90
                reference: client-0001
                status: pending
                environment: sandbox
                case_id: 7e3b9a14-2d6c-4c85-b1f0-6a8d4e2c9b37
                url: null
                expires_at: '2026-12-01T09:00:00+00:00'
                created_at: '2026-11-24T09:00:00+00:00'
                opened_at: null
                submitted_at: null
                completed_at: null
                applicant:
                  name: Test Client
                  email_masked: t***@example.com
                  phone_masked: null
                documents:
                  - type: payslip
                    label: Payslip
                    status: missing
                  - type: national_id
                    label: National ID card (CIN)
                    status: missing
                channel: link
                locale: en
                reason: Salary advance file
                email_sent_at: null
                resend_count: 0
                metadata:
                  loan_ref: L-1042
                email_sent: false
                existing: true
        '201':
          description: Created. `url` is shown here only.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocumentRequest'
              example:
                id: 3f2b8c1e-5a47-4d0e-9b6a-1c7e2d4f8a90
                reference: client-0001
                status: pending
                environment: sandbox
                case_id: 7e3b9a14-2d6c-4c85-b1f0-6a8d4e2c9b37
                url: https://app.sahlfinancial.com/r/EXAMPLE-TOKEN-SHOWN-ONCE
                expires_at: '2026-12-01T09:00:00+00:00'
                created_at: '2026-11-24T09:00:00+00:00'
                opened_at: null
                submitted_at: null
                completed_at: null
                applicant:
                  name: Test Client
                  email_masked: t***@example.com
                  phone_masked: null
                documents:
                  - type: payslip
                    label: Payslip
                    status: missing
                  - type: national_id
                    label: National ID card (CIN)
                    status: missing
                channel: link
                locale: en
                reason: Salary advance file
                email_sent_at: null
                resend_count: 0
                metadata:
                  loan_ref: L-1042
                email_sent: false
        '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.
        '409':
          description: >-
            The workspace has not named its data controller
            (`privacy_controller_missing`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail:
                  code: privacy_controller_missing
                  message: >-
                    This workspace has not named its data controller (Settings >
                    Privacy & compliance), so it cannot collect documents yet.
        '422':
          description: >-
            `email_required` (`send_email` without `applicant.email`),
            `invalid_environment`, `environment_conflict`, or a validation error
            (unknown document type, bad `reference`, unknown key).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail:
                  code: email_required
                  message: send_email needs applicant.email.
        '429':
          description: >-
            Per-key rate limit, or the workspace's case quota for a new
            reference.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail:
                  code: rate_limit_exceeded
                  message: More than 60 calls a minute with this API key. Slow down.
                  limit: 60
        '500':
          description: Unexpected server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorFlat'
              example:
                code: internal_error
                message: An unexpected error occurred
                details: null
      security:
        - bearerAuth: []
components:
  schemas:
    CreateRequest:
      properties:
        reference:
          type: string
          maxLength: 64
          minLength: 1
          pattern: ^[A-Za-z0-9_.:-]+$
          title: Reference
          description: >-
            Your own id for the client, 1 to 64 characters of `A-Z a-z 0-9 _ . :
            -`. It names the case the documents are filed on.
        applicant:
          $ref: '#/components/schemas/Applicant'
          description: Who is asked. Unknown keys are refused.
        documents:
          items:
            type: string
          type: array
          maxItems: 12
          minItems: 1
          title: Documents
          description: >-
            Document type keys to ask for, 1 to 12, repeats ignored:
            bank_statement, payslip, national_id, passport, proof_of_address,
            employment_attestation, salary_certificate, tax_clearance,
            cnss_attestation, rib_certificate, company_registration, invoice.
            Another key is refused.
        reason:
          anyOf:
            - type: string
              maxLength: 500
            - type: 'null'
          title: Reason
          description: >-
            Shown to the applicant. Up to 500 characters; control characters are
            removed.
        locale:
          type: string
          enum:
            - en
            - fr
            - ar
          title: Locale
          default: en
          description: 'Language of the page and the email: `en`, `fr` or `ar`.'
        expires_in_days:
          type: integer
          maximum: 30
          minimum: 1
          title: Expires In Days
          default: 7
          description: 1 to 30. Default 7.
        send_email:
          type: boolean
          title: Send Email
          default: false
          description: Email the link to `applicant.email`. Default false.
        channel:
          type: string
          enum:
            - link
            - embed
          title: Channel
          default: link
          description: >-
            `link` (a page you send) or `embed` (a page you frame in your own
            app; allow your origin in the workspace's widget frame origins).
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Metadata
          description: >-
            Your own small JSON object, returned as is. Size and shape are
            checked; an invalid value answers 422.
        force_new:
          type: boolean
          title: Force New
          default: false
          description: >-
            When an open request exists for the reference, revoke it and create
            a new one. Default false: the open one is returned.
      additionalProperties: false
      type: object
      required:
        - reference
        - documents
      title: CreateRequest
    DocumentRequest:
      type: object
      title: DocumentRequest
      properties:
        id:
          type: string
          format: uuid
          description: Request id.
        reference:
          type: string
          description: Your id for the client.
        status:
          type: string
          enum:
            - pending
            - opened
            - submitted
            - completed
            - expired
            - revoked
        environment:
          type: string
          enum:
            - sandbox
            - production
        case_id:
          type:
            - string
            - 'null'
          format: uuid
          description: The case the documents are filed on.
        url:
          type:
            - string
            - 'null'
          description: >-
            The applicant's link. Only in the response of create (201) and
            resend; null everywhere else.
        expires_at:
          type:
            - string
            - 'null'
          format: date-time
        created_at:
          type:
            - string
            - 'null'
          format: date-time
        opened_at:
          type:
            - string
            - 'null'
          format: date-time
        submitted_at:
          type:
            - string
            - 'null'
          format: date-time
        completed_at:
          type:
            - string
            - 'null'
          format: date-time
        applicant:
          type: object
          description: Contact details are masked.
          properties:
            name:
              type:
                - string
                - 'null'
            email_masked:
              type:
                - string
                - 'null'
            phone_masked:
              type:
                - string
                - 'null'
        documents:
          type: array
          items:
            $ref: '#/components/schemas/DocumentRequestDocument'
        channel:
          type: string
          enum:
            - link
            - embed
        locale:
          type: string
          enum:
            - en
            - fr
            - ar
        reason:
          type:
            - string
            - 'null'
          description: Why the documents are asked for.
        email_sent_at:
          type:
            - string
            - 'null'
          format: date-time
        resend_count:
          type: integer
          description: Times the link was sent again (maximum 3).
        metadata:
          type:
            - object
            - 'null'
          additionalProperties: true
          description: What you sent in `metadata`.
        email_sent:
          type: boolean
          description: 'Only on create and resend: whether the email left.'
        existing:
          type: boolean
          description: >-
            Only on a create that returned the open request for the reference
            (200).
        result:
          type: object
          description: Only on `GET /v1/requests/{request_id}` once `completed`.
          properties:
            risk_level:
              type:
                - string
                - 'null'
            score_band:
              type:
                - string
                - 'null'
              description: >-
                A 100-point band of the 0 to 1000 score, for example `600-699`.
                Null when not scored.
      required:
        - id
        - reference
        - status
        - environment
        - applicant
        - documents
        - channel
        - locale
        - resend_count
    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
    Applicant:
      properties:
        name:
          anyOf:
            - type: string
              maxLength: 120
            - type: 'null'
          title: Name
          description: Up to 120 characters. Whitespace is collapsed.
        email:
          anyOf:
            - type: string
              format: email
            - type: 'null'
          title: Email
          description: Needed when `send_email` is true.
        phone:
          anyOf:
            - type: string
              maxLength: 32
              pattern: ^[0-9+()\-. ]{5,32}$
            - type: 'null'
          title: Phone
          description: >-
            5 to 32 characters of digits, `+`, parentheses, dashes, dots and
            spaces.
      additionalProperties: false
      type: object
      title: Applicant
    DocumentRequestDocument:
      type: object
      title: DocumentRequestDocument
      properties:
        type:
          type: string
          description: Document type key requested.
        label:
          type: string
          description: The label the applicant sees, in the request's `locale`.
        status:
          type: string
          enum:
            - missing
            - received
            - readable
            - unreadable
      required:
        - type
        - label
        - status
  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.