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

# Simulate a score without saving

> Required scope: `scoring:read`.

The score a case would get with other loan inputs, factor weights or thresholds.

Runs the real scoring engine on the case's stored extractions with the overrides
applied, inside a transaction savepoint that is always rolled back: the case, the
policy and the audit log are left exactly as they were.

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 post /v1/partner/scoring/what-if
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/scoring/what-if:
    post:
      tags:
        - Scoring
      summary: Simulate a score without saving
      description: >-
        Required scope: `scoring:read`.


        The score a case would get with other loan inputs, factor weights or
        thresholds.


        Runs the real scoring engine on the case's stored extractions with the
        overrides

        applied, inside a transaction savepoint that is always rolled back: the
        case, the

        policy and the audit log are left exactly as they were.


        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: scoring_what_if
      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_scoring__WhatIfRequest
            examples:
              loan:
                summary: Another loan and tighter thresholds
                value:
                  reference: client-0001
                  inputs:
                    requested_amount: 150000
                    duration_months: 60
                    annual_rate_pct: 6.5
                  approve_threshold: 650
                  refuse_threshold: 400
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WhatIfResult'
        '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.
            `invalid_reference`: reference must be 1-64 characters of A-Z a-z
            0-9 _ . : - `invalid_weights`: Scoring weights must be >= 0, known
            factors, and at least one positive. `invalid_thresholds`:
            refuse_threshold must not exceed approve_threshold. `not_scorable`:
            The case has not enough read data to be scored yet.
          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_scoring__WhatIfRequest:
      properties:
        reference:
          type: string
          maxLength: 64
          minLength: 1
          title: Reference
          description: Your reference for the case.
        environment:
          anyOf:
            - type: string
            - type: 'null'
          title: Environment
          description: >-
            sandbox or production; must agree with X-Sahl-Environment if both
            are sent.
        inputs:
          $ref: '#/components/schemas/WhatIfInputs'
          description: Loan request overrides.
        weights:
          anyOf:
            - additionalProperties:
                type: number
              type: object
            - type: 'null'
          title: Weights
          description: >-
            Factor weights to try (keys of the policy's factor catalogue, >= 0).
            Merged over the active policy's and re-normalised to sum to 1.
        approve_threshold:
          anyOf:
            - type: integer
              maximum: 1000
              minimum: 0
            - type: 'null'
          title: Approve Threshold
          description: Approve at or above.
        refuse_threshold:
          anyOf:
            - type: integer
              maximum: 1000
              minimum: 0
            - type: 'null'
          title: Refuse Threshold
          description: Refuse at or below.
      type: object
      required:
        - reference
      title: WhatIfRequest
    WhatIfResult:
      properties:
        persisted:
          type: boolean
          const: false
          title: Persisted
          description: 'Always false: nothing was stored.'
          default: false
        current:
          $ref: '#/components/schemas/WhatIfCurrent'
          description: The case as stored.
        hypothetical:
          $ref: '#/components/schemas/PartnerScore'
          description: The score under the overrides.
        decision:
          anyOf:
            - type: string
            - type: 'null'
          title: Decision
          description: >-
            What the automatic decision would be: approved, manual_review,
            refused, or null when not assessable.
        applied:
          $ref: '#/components/schemas/WhatIfApplied'
          description: The settings the hypothetical score ran under.
      type: object
      required:
        - current
        - hypothetical
        - decision
        - applied
      title: WhatIfResult
    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
    WhatIfInputs:
      properties:
        requested_amount:
          anyOf:
            - type: number
              maximum: 10000000000
              exclusiveMinimum: 0
            - type: 'null'
          title: Requested Amount
          description: Amount asked for.
        duration_months:
          anyOf:
            - type: integer
              maximum: 360
              minimum: 1
            - type: 'null'
          title: Duration Months
          description: Loan term in months.
        monthly_payment:
          anyOf:
            - type: number
              maximum: 1000000000
              minimum: 0
            - type: 'null'
          title: Monthly Payment
          description: Instalment of the new loan.
        annual_rate_pct:
          anyOf:
            - type: number
              maximum: 40
              minimum: 0
            - type: 'null'
          title: Annual Rate Pct
          description: Annual rate, in percent.
      type: object
      title: WhatIfInputs
      description: Loan request values to try instead of the case's own.
    WhatIfCurrent:
      properties:
        score:
          anyOf:
            - type: integer
            - type: 'null'
          title: Score
          description: The stored score.
        risk_level:
          anyOf:
            - type: string
            - type: 'null'
          title: Risk Level
          description: The stored risk level.
        decision:
          anyOf:
            - type: string
            - type: 'null'
          title: Decision
          description: The case's current decision, if any.
      type: object
      required:
        - score
        - risk_level
        - decision
      title: WhatIfCurrent
    PartnerScore:
      properties:
        reference:
          type: string
          title: Reference
          description: Your reference for the case.
        case_id:
          type: string
          format: uuid
          title: Case Id
          description: Sahl's case id.
        environment:
          type: string
          enum:
            - sandbox
            - production
          title: Environment
          description: The case's environment.
        scored:
          type: boolean
          title: Scored
          description: False when the case has never been scored.
        subject_kind:
          type: string
          enum:
            - individual
            - company
          title: Subject Kind
          description: 'individual: retail blocks; company: the SME model.'
        model:
          type: string
          title: Model
          description: retail_v1 or sme_v1.
        score:
          anyOf:
            - type: integer
            - type: 'null'
          title: Score
          description: The score, 0-1000. Null when not assessable.
        max_score:
          type: integer
          title: Max Score
          description: Always 1000.
          default: 1000
        risk_level:
          anyOf:
            - type: string
            - type: 'null'
          title: Risk Level
          description: >-
            low, medium, high, or not_assessable until the file holds enough to
            grade.
        coverage:
          anyOf:
            - type: number
            - type: 'null'
          title: Coverage
          description: Share (0-1) of the model's weight the file could feed.
        missing_documents:
          items:
            type: string
          type: array
          title: Missing Documents
          description: >-
            Documents that would make the non calculé blocks computable
            (French).
        blocks:
          items:
            $ref: '#/components/schemas/ScoreBlock'
          type: array
          title: Blocks
          description: The blocks, in model order.
        fraud_penalty:
          anyOf:
            - type: integer
            - type: 'null'
          title: Fraud Penalty
          description: Points removed for fraud signals (0 or negative); individuals only.
        summary:
          anyOf:
            - type: string
            - type: 'null'
          title: Summary
          description: The engine's one-paragraph reading (French).
        sme:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Sme
          description: 'The full SME model output for a company: factors, gates, thresholds.'
        project_review:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Project Review
          description: A crowdfunding project file's review, when the case is one.
      type: object
      required:
        - reference
        - case_id
        - environment
        - scored
        - subject_kind
        - model
        - score
        - risk_level
        - coverage
        - missing_documents
        - blocks
        - fraud_penalty
        - summary
        - sme
        - project_review
      title: PartnerScore
      description: A case's score, as stored on the case.
    WhatIfApplied:
      properties:
        policy_path:
          type: string
          enum:
            - kyc
            - kyb
          title: Policy Path
          description: The scoring policy the case is graded on.
        weights:
          additionalProperties:
            type: number
          type: object
          title: Weights
          description: The factor weights the hypothetical score used.
        approve_threshold:
          type: integer
          title: Approve Threshold
          description: Approve threshold used.
        refuse_threshold:
          type: integer
          title: Refuse Threshold
          description: Refuse threshold used.
        inputs:
          additionalProperties:
            anyOf:
              - type: number
              - type: integer
          type: object
          title: Inputs
          description: The loan inputs overridden.
      type: object
      required:
        - policy_path
        - weights
        - approve_threshold
        - refuse_threshold
        - inputs
      title: WhatIfApplied
    ScoreBlock:
      properties:
        key:
          type: string
          title: Key
          description: Block key, e.g. repayment_capacity or capacite_remboursement.
        label_fr:
          type: string
          title: Label Fr
          description: Block name in French.
        label_en:
          type: string
          title: Label En
          description: Block name in English.
        points:
          anyOf:
            - type: integer
            - type: 'null'
          title: Points
          description: >-
            Points scored, on the 1000 scale. Null when the block is non
            calculé.
        max:
          type: integer
          title: Max
          description: The block's maximum, on the 1000 scale (its policy weight).
        computed:
          type: boolean
          title: Computed
          description: False when nothing on file feeds the block.
        status:
          type: string
          enum:
            - calculé
            - non calculé
          title: Status
          description: 'calculé, or non calculé: missing data, never a zero.'
        provisional:
          type: boolean
          title: Provisional
          description: True while a field it reads still awaits review (identity only).
        notes:
          anyOf:
            - type: string
            - type: 'null'
          title: Notes
          description: How the points were reached, or what is missing (French).
      type: object
      required:
        - key
        - label_fr
        - label_en
        - points
        - max
        - computed
        - status
        - provisional
        - notes
      title: ScoreBlock
      description: One block of the 0-1000 scale.
  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.