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

> **Who can call it:** Any signed-in member of the workspace.

Runs the flow on a synthetic borrower with the workspace's active scoring policy. Nothing is stored. `profile_seed` overrides profile fields.

**Auth:** dashboard session (`Authorization: Bearer <access token>`). Not available with a partner API key.



## OpenAPI

````yaml /openapi-console.json post /v1/flows/{flow_id}/simulate
openapi: 3.1.0
info:
  title: Sahl Console API
  version: 0.1.0
  description: >-
    **Used by the Sahl console. Not available with partner API keys. Contact
    Sahl if you need programmatic access.**


    These are the routes the Sahl console calls with a signed-in user's session.
    They are documented so that a developer or a workspace admin can see what
    the console does, with the real request and response models. They are
    **not** part of the [Partner API](/api-reference/introduction): an API key
    is refused here (401), there is no try-it, and the shapes can change with
    the console.


    Authentication: `Authorization: Bearer <access token>`, the JWT the console
    gets from `POST /v1/auth/login` (30 minutes; renewed with `POST
    /v1/auth/refresh`, refresh token valid 7 days). There is no cookie. The role
    of the user is read from the user's record on every call, not from the
    token. Every call is scoped to the workspace of the user.


    Common answers: 401 (no or bad session), 403 `Insufficient permissions`
    (role), 422 (validation), 429 (100 requests per minute and IP). Error bodies
    have the same three shapes as the Partner API: see [Errors](/errors).
servers:
  - url: https://app.sahlfinancial.com/api
    description: Console host. Same host as the Partner API.
security:
  - dashboardSession: []
tags:
  - name: Bank connections
    description: Simulated in the Sandbox; 409 `bank_connect_unavailable` elsewhere.
  - name: Cases
    description: Client files that group documents, a score and a decision.
  - name: Documents
    description: Upload, status, result and download.
  - name: Webhooks
    description: Manage the endpoints that receive events.
  - name: API keys
    description: Create, rotate and revoke the keys used with the Partner API.
  - name: Scoring policies
    description: Weights and thresholds of the credit score.
  - name: Flows
    description: Verification flows (graphs) and their simulation.
paths:
  /v1/flows/{flow_id}/simulate:
    post:
      tags:
        - Flows
      summary: Simulate a flow
      description: >-
        **Who can call it:** Any signed-in member of the workspace.


        Runs the flow on a synthetic borrower with the workspace's active
        scoring policy. Nothing is stored. `profile_seed` overrides profile
        fields.


        **Auth:** dashboard session (`Authorization: Bearer <access token>`).
        Not available with a partner API key.
      operationId: simulateFlow
      parameters:
        - name: flow_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Flow Id
      requestBody:
        content:
          application/json:
            schema:
              anyOf:
                - $ref: '#/components/schemas/FlowSimulationRequest'
                - type: 'null'
              title: Body
            example:
              profile_seed:
                factors:
                  dti_bam: 0.3
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FlowSimulationResult'
              example:
                steps: []
                decisions: []
                path:
                  - start
                  - end
                total_time_ms: 42
                result: approve
                end_node_id: end
                score: 742
                score_result: null
                profile:
                  borrower_name: Demo borrower
                borrower_name: Demo borrower
        '400':
          description: Structural or runtime error of the flow.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail: Flow has no Start node.
        '401':
          description: No session, expired token, ended session or inactive account.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail: Invalid or expired token
        '403':
          description: >-
            The role is not allowed, MFA enrolment is pending, or the
            environment is refused.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail: Insufficient permissions
        '404':
          description: Unknown flow.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail: Flow not found
        '422':
          description: Validation error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail:
                  - type: missing
                    loc:
                      - body
                      - bank_code
                    msg: Field required
                    input: {}
        '429':
          description: >-
            More than 100 requests per minute from one IP address. The body has
            no `detail`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitError'
              example:
                code: rate_limit_exceeded
                message: Too many requests. Please slow down.
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait.
components:
  schemas:
    FlowSimulationRequest:
      properties:
        profile_seed:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
      type: object
      description: |-
        Optional body for the simulate endpoint.

        ``profile_seed`` lets a caller override any field of the synthetic
        borrower profile (e.g. ``{"factors": {"dti_bam": 0.3}}`` to push DTI
        into review territory). Useful for demoing edge cases without
        rewriting the policy.
    FlowSimulationResult:
      properties:
        steps:
          items:
            $ref: '#/components/schemas/SimulationStepResult'
          type: array
        decisions:
          items:
            $ref: '#/components/schemas/SimulationDecisionResult'
          type: array
        path:
          items:
            type: string
          type: array
        total_time_ms:
          type: integer
        result:
          type: string
        end_node_id:
          anyOf:
            - type: string
            - type: 'null'
        score:
          anyOf:
            - type: integer
            - type: 'null'
        score_result:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
        profile:
          additionalProperties: true
          type: object
        borrower_name:
          type: string
          default: Amine Benchekroun
      type: object
      required:
        - steps
        - total_time_ms
        - result
      description: Full simulation result for a flow.
    Error:
      type: object
      description: >-
        FastAPI error body. `detail` is a string, a list (422), or an object
        with `code` and `message` (extra keys possible).
      properties:
        detail:
          oneOf:
            - type: string
            - items:
                additionalProperties: true
                type: object
              type: array
            - type: object
              additionalProperties: true
              properties:
                code:
                  type: string
                message:
                  type: string
      required:
        - detail
    RateLimitError:
      type: object
      description: Top-level `code` and `message`, no `detail`.
      properties:
        code:
          type: string
        message:
          type: string
      required:
        - code
        - message
    SimulationStepResult:
      properties:
        node_id:
          type: string
        node_type:
          type: string
          default: stepNode
        step_type:
          anyOf:
            - type: string
            - type: 'null'
        label:
          type: string
        category:
          anyOf:
            - type: string
            - type: 'null'
        status:
          type: string
        duration_ms:
          type: integer
        result:
          additionalProperties: true
          type: object
      type: object
      required:
        - node_id
        - label
        - status
        - duration_ms
        - result
      description: Result of a single simulated step.
    SimulationDecisionResult:
      properties:
        node_id:
          type: string
        label:
          type: string
        condition_summary:
          type: string
        branch_taken:
          type: string
        available_branches:
          items:
            type: string
          type: array
      type: object
      required:
        - node_id
        - label
        - condition_summary
        - branch_taken
        - available_branches
      description: 'Per-decision-node result: which branch fired and why.'
  securitySchemes:
    dashboardSession:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        The access token (JWT) of a signed-in console user, from `POST
        /v1/auth/login`. It lasts 30 minutes. It is not an API key: a partner
        API key is refused here. There is no cookie.

````

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