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

# Save a new KYC policy version

> Required scope: `policy:write`.

Validate and save the next version of one client type's policy, and return it.

Refused with 422 `kyc_policy_lock_required` when the config drops an item the
regulator locks, misses the regime's floors, or unlocks any item locked in the
policy in force (an API key can add locks and tighten values, never loosen a lock).
409 `policy_conflict` when another save landed at the same time.

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 put /v1/partner/policy
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/policy:
    put:
      tags:
        - Policy
      summary: Save a new KYC policy version
      description: >-
        Required scope: `policy:write`.


        Validate and save the next version of one client type's policy, and
        return it.


        Refused with 422 `kyc_policy_lock_required` when the config drops an
        item the

        regulator locks, misses the regime's floors, or unlocks any item locked
        in the

        policy in force (an API key can add locks and tighten values, never
        loosen a lock).

        409 `policy_conflict` when another save landed at the same time.


        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: policy_put
      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` parameter; if both are sent they must agree.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/app__routers__partner_policy__PolicyUpdate'
            examples:
              tighten:
                summary: Raise the sanctions name-match threshold
                description: >-
                  The whole policy is saved: fields you leave out take their
                  defaults. `GET /v1/partner/policy` returns the current config
                  in this shape; send it back with your change.
                value:
                  client_type: individual
                  config:
                    sanctions_name_match_threshold: 0.9
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClientPolicy'
        '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
        '409':
          description: >-
            `policy_conflict`: The policy was changed at the same time; read it
            again and retry.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail:
                  code: policy_conflict
                  message: >-
                    The policy was changed at the same time; read it again and
                    retry.
        '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.
            `kyc_policy_lock_required`: An API key cannot unlock items locked in
            the policy in force (or by the workspace's regime). A workspace
            admin can, in the dashboard.
          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: >-
            `commit_failed`: The change could not be saved; nothing changed.
            Retry. `internal_error`: Unexpected error. Quote X-Request-ID to
            support.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail:
                  code: commit_failed
                  message: The change could not be saved; nothing changed. Retry.
      security:
        - bearerAuth: []
components:
  schemas:
    app__routers__partner_policy__PolicyUpdate:
      properties:
        client_type:
          type: string
          enum:
            - individual
            - company
          title: Client Type
          description: individual (KYC) or company (KYB).
        environment:
          anyOf:
            - type: string
              enum:
                - sandbox
                - production
            - type: 'null'
          title: Environment
          description: >-
            Optional; must agree with X-Sahl-Environment when both are sent.
            Sandbox when neither is.
        config:
          $ref: '#/components/schemas/KycPolicyConfig'
          description: >-
            The whole policy (GET returns it in this shape). Fields left out
            take their defaults, not the current values: send the full config
            back.
      type: object
      required:
        - client_type
        - config
      title: PolicyUpdate
      description: A new version of one client type's policy.
    ClientPolicy:
      properties:
        client_type:
          type: string
          enum:
            - individual
            - company
          title: Client Type
          description: individual (KYC) or company (KYB).
        kind:
          type: string
          enum:
            - kyc
            - kyb
          title: Kind
          description: The stored policy kind for this client type.
        environment:
          type: string
          enum:
            - sandbox
            - production
          title: Environment
          description: The environment it applies to.
        source:
          type: string
          enum:
            - tenant
            - preset
            - legacy
            - fallback
          title: Source
          description: >-
            tenant = a saved version; preset = the regime's default; legacy =
            the unregulated default; fallback = a saved version that no longer
            validates, replaced by the default with the regime's locks.
        policy_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Policy Id
          description: The saved version's id; null for a default.
        version:
          type: integer
          title: Version
          description: The saved version number; 0 for a default.
        managed_by_flow:
          type: boolean
          title: Managed By Flow
          description: >-
            True when the version was compiled from a dashboard flow. Saving
            here detaches it.
        created_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Created At
          description: When this version was saved.
        parameters:
          $ref: '#/components/schemas/PolicyParameters'
          description: The main tunable parameters (also in config).
        locked:
          items:
            type: string
          type: array
          title: Locked
          description: >-
            Every item locked in this policy. An API key cannot unlock any of
            them.
        regulator_locked:
          items:
            type: string
          type: array
          title: Regulator Locked
          description: The subset of locked items the regulator mandates.
        config:
          $ref: '#/components/schemas/KycPolicyConfig'
          description: The full policy, in the shape PUT /v1/partner/policy accepts.
      type: object
      required:
        - client_type
        - kind
        - environment
        - source
        - policy_id
        - version
        - managed_by_flow
        - created_at
        - parameters
        - locked
        - regulator_locked
        - config
      title: ClientPolicy
      description: The policy in force for one client type in one environment.
    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
    KycPolicyConfig:
      properties:
        document_country:
          type: string
          enum:
            - CA
            - US
            - MA
          title: Document Country
          default: CA
        required_documents:
          additionalProperties:
            items:
              type: string
            type: array
          type: object
          title: Required Documents
        document_slot_enforcement:
          type: string
          enum:
            - 'off'
            - warning
            - critical
          title: Document Slot Enforcement
          default: 'off'
        enabled_checks:
          items:
            type: string
          type: array
          title: Enabled Checks
        thresholds:
          $ref: '#/components/schemas/Thresholds'
        risk_bands:
          $ref: '#/components/schemas/RiskBands'
        screening:
          $ref: '#/components/schemas/Screening'
        third_party_determination:
          type: boolean
          title: Third Party Determination
          default: false
        eid_required_non_face_to_face:
          type: boolean
          title: Eid Required Non Face To Face
          default: false
        corporations_canada_lookup:
          type: boolean
          title: Corporations Canada Lookup
          default: true
        beneficial_ownership_threshold_pct:
          type: number
          maximum: 25
          exclusiveMinimum: 0
          title: Beneficial Ownership Threshold Pct
          default: 25
        record_retention_days:
          type: integer
          maximum: 36500
          minimum: 1
          title: Record Retention Days
          default: 1825
        liveness_strictness:
          type: string
          enum:
            - standard
            - strict
            - lenient
          title: Liveness Strictness
          default: standard
        fake_image_action:
          type: string
          enum:
            - flag
            - review
            - reject
          title: Fake Image Action
          default: flag
        sanctions_pep_action:
          type: string
          enum:
            - refuse
            - review
            - flag
          title: Sanctions Pep Action
          default: refuse
        sanctions_name_match_threshold:
          type: number
          maximum: 0.98
          minimum: 0.75
          title: Sanctions Name Match Threshold
          default: 0.88
        locked:
          items:
            type: string
          type: array
          title: Locked
      additionalProperties: false
      type: object
      title: KycPolicyConfig
      description: One tenant's rules for one (kind, environment). Defaults = today.
    PolicyParameters:
      properties:
        duplicate_document_action:
          type: string
          enum:
            - flag
            - review
            - reject
          title: Duplicate Document Action
          description: >-
            What a document already seen on another case does: flag (a signal),
            review (hold the case for a person) or reject (a failed check, no
            automatic approval).
        duplicate_hamming_threshold:
          type: integer
          title: Duplicate Hamming Threshold
          description: >-
            Differing bits (0-12) of two pictures' 64-bit perceptual hashes that
            still count as the same picture. 0 = identical only.
        name_match_threshold:
          type: number
          title: Name Match Threshold
          description: >-
            Minimum similarity (0.5-1.0) for names across documents to agree.
            0.5 is the baseline; higher is stricter.
        max_document_age_days_by_type:
          additionalProperties:
            type: integer
          type: object
          title: Max Document Age Days By Type
          description: >-
            Document type -> its own maximum age in days. Types not listed use
            config.thresholds.document_recency_days.
        min_applicant_age_years:
          type: integer
          title: Min Applicant Age Years
          description: >-
            Minimum applicant age by the ID's date of birth. 0 = no minimum
            beyond the 18+ check that always runs.
        max_id_age_years:
          type: integer
          title: Max Id Age Years
          description: Maximum years since the ID's printed issue date. 0 = no limit.
        liveness_strictness:
          type: string
          enum:
            - standard
            - strict
            - lenient
          title: Liveness Strictness
          description: >-
            Face match and presentation-attack thresholds. lenient is refused
            while id_verification is locked.
        fake_image_action:
          type: string
          enum:
            - flag
            - review
            - reject
          title: Fake Image Action
          description: What an edited, web/stock or re-photographed image does to the case.
        sanctions_pep_action:
          type: string
          enum:
            - refuse
            - review
            - flag
          title: Sanctions Pep Action
          description: >-
            What a sanctions list hit does to the verdict. Must stay refuse
            while sanctions_screening is locked.
        sanctions_name_match_threshold:
          type: number
          title: Sanctions Name Match Threshold
          description: >-
            Name-match score (0.75-0.98) at or above which a party is a list
            hit. Lower = more hits; cannot rise above the default while
            sanctions_screening is locked.
      type: object
      required:
        - duplicate_document_action
        - duplicate_hamming_threshold
        - name_match_threshold
        - max_document_age_days_by_type
        - min_applicant_age_years
        - max_id_age_years
        - liveness_strictness
        - fake_image_action
        - sanctions_pep_action
        - sanctions_name_match_threshold
      title: PolicyParameters
      description: >-
        The verification parameters a partner tunes most, read out of
        ``config``.
    Thresholds:
      properties:
        document_recency_days:
          type: integer
          maximum: 365
          minimum: 1
          title: Document Recency Days
          default: 90
        backdate_days:
          type: integer
          maximum: 365
          minimum: 1
          title: Backdate Days
          default: 14
        id_expiry_days:
          type: integer
          maximum: 365
          minimum: 0
          title: Id Expiry Days
          default: 90
        duplicate_document_action:
          type: string
          enum:
            - flag
            - review
            - reject
          title: Duplicate Document Action
          default: flag
        duplicate_hamming_threshold:
          type: integer
          maximum: 12
          minimum: 0
          title: Duplicate Hamming Threshold
          default: 6
        name_match_threshold:
          type: number
          maximum: 1
          minimum: 0.5
          title: Name Match Threshold
          default: 0.5
        max_document_age_days_by_type:
          additionalProperties:
            type: integer
          type: object
          title: Max Document Age Days By Type
        min_applicant_age_years:
          type: integer
          maximum: 100
          minimum: 0
          title: Min Applicant Age Years
          default: 0
        max_id_age_years:
          type: integer
          maximum: 100
          minimum: 0
          title: Max Id Age Years
          default: 0
      additionalProperties: false
      type: object
      title: Thresholds
      description: >-
        Day counts ``verification`` used to hard-code, defaulting to its
        constants.
    RiskBands:
      properties:
        low_max_points:
          type: integer
          maximum: 1
          minimum: 0
          title: Low Max Points
          default: 1
        medium_max_points:
          type: integer
          maximum: 3
          minimum: 0
          title: Medium Max Points
          default: 3
      additionalProperties: false
      type: object
      title: RiskBands
      description: >-
        The compliance-risk bands, in points. STRICTER ONLY.


        The ceilings are ``scoring``'s own: a tenant can rate a file High
        sooner,

        never later. A policy that let a file with four risk points read Medium

        would be a policy for under-reporting.
    Screening:
      properties:
        sanctions_bundle:
          type: boolean
          const: true
          title: Sanctions Bundle
          default: true
        canchek:
          type: boolean
          title: the eID provider
          default: false
        pep_hio_determination:
          type: boolean
          title: Pep Hio Determination
          default: false
      additionalProperties: false
      type: object
      title: Screening
  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.