> ## 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 bank connection

> **Who can call it:** `tenant_admin`, `tenant_reviewer`, `tenant_api_manager` or `platform_admin`. A `tenant_viewer` is read-only and gets 403.

Creates a simulated connection and marks it `connected` at once, with figures generated from its id. It is always filed as `sandbox`. `case_id` is stored only if the case belongs to your workspace; an unknown or foreign case id is silently ignored.

**Production behaviour.** No open-banking provider is live. This route answers `409` with the code `bank_connect_unavailable` unless the request is made in the Sandbox: send `X-Sahl-Environment: sandbox` (or `?environment=sandbox`). In the Sandbox the data is simulated and derived from the connection id; it is not read from a bank. A request with no environment is also refused.

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



## OpenAPI

````yaml /openapi-console.json post /v1/bank-connections
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/bank-connections:
    post:
      tags:
        - Bank connections
      summary: Create a bank connection
      description: >-
        **Who can call it:** `tenant_admin`, `tenant_reviewer`,
        `tenant_api_manager` or `platform_admin`. A `tenant_viewer` is read-only
        and gets 403.


        Creates a simulated connection and marks it `connected` at once, with
        figures generated from its id. It is always filed as `sandbox`.
        `case_id` is stored only if the case belongs to your workspace; an
        unknown or foreign case id is silently ignored.


        **Production behaviour.** No open-banking provider is live. This route
        answers `409` with the code `bank_connect_unavailable` unless the
        request is made in the Sandbox: send `X-Sahl-Environment: sandbox` (or
        `?environment=sandbox`). In the Sandbox the data is simulated and
        derived from the connection id; it is not read from a bank. A request
        with no environment is also refused.


        **Auth:** dashboard session (`Authorization: Bearer <access token>`).
        Not available with a partner API key.
      operationId: createBankConnection
      parameters:
        - name: environment
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Environment
        - name: X-Sahl-Environment
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Sahl-Environment
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BankConnectionCreate'
            example:
              bank_code: attijariwafa
              bank_name: Attijariwafa bank
              case_id: 7e3b9a14-2d6c-4c85-b1f0-6a8d4e2c9b37
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BankConnectionResponse'
              example:
                id: c1a4e2d7-93b5-4f08-8a6d-2e7b1f9c3d54
                tenant_id: 0b6f5a3e-7c1d-4e0a-9d2f-3a1c5e8b7f10
                case_id: 7e3b9a14-2d6c-4c85-b1f0-6a8d4e2c9b37
                bank_code: attijariwafa
                bank_name: Attijariwafa bank
                account_holder: Test Client
                account_last4: '4821'
                status: connected
                link_token: Zk3x...redacted
                connected_at: '2026-10-07T09:14:22Z'
                expires_at: '2027-01-05T09:14:22Z'
                avg_balance: 21450
                monthly_income: 18200
                monthly_expenses: 11800
                transaction_count: 96
                cash_flow_data: null
                environment: sandbox
                created_at: '2026-10-07T09:14:22Z'
                updated_at: '2026-10-07T09:14:22Z'
        '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
        '409':
          description: >-
            `bank_connect_unavailable`: not a Sandbox request, so no simulated
            data. No bank data provider is live.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail:
                  code: bank_connect_unavailable
                  message: >-
                    Bank connection is not available yet. No bank data provider
                    is live for this workspace.
        '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:
    BankConnectionCreate:
      properties:
        bank_code:
          type: string
          maxLength: 50
        bank_name:
          type: string
          maxLength: 100
        case_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
      type: object
      required:
        - bank_code
        - bank_name
    BankConnectionResponse:
      properties:
        id:
          type: string
          format: uuid
        tenant_id:
          type: string
          format: uuid
        case_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
        bank_code:
          type: string
        bank_name:
          type: string
        account_holder:
          anyOf:
            - type: string
            - type: 'null'
        account_last4:
          anyOf:
            - type: string
            - type: 'null'
        status:
          type: string
        link_token:
          anyOf:
            - type: string
            - type: 'null'
        connected_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
        expires_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
        avg_balance:
          anyOf:
            - type: number
            - type: 'null'
        monthly_income:
          anyOf:
            - type: number
            - type: 'null'
        monthly_expenses:
          anyOf:
            - type: number
            - type: 'null'
        transaction_count:
          type: integer
        cash_flow_data:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
        environment:
          type: string
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      type: object
      required:
        - id
        - tenant_id
        - case_id
        - bank_code
        - bank_name
        - account_holder
        - account_last4
        - status
        - link_token
        - connected_at
        - expires_at
        - avg_balance
        - monthly_income
        - monthly_expenses
        - transaction_count
        - cash_flow_data
        - environment
        - created_at
        - updated_at
    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
  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.