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

# Get the cash-flow analysis of a bank connection

> Required scope: `bank:read`.

Growth plan. Switched on per workspace by Sahl: until then a key cannot be issued with this scope and calls answer `403` `bank_scope_not_allowed`. No bank data provider is live: data is a sandbox simulation (send `X-Sahl-Environment: sandbox`), and in production create, refresh, transactions and analysis answer `409` `bank_connect_unavailable`.

Simulated cash-flow analysis, sandbox only today. In production: `409` `bank_connect_unavailable`.

Guide: [Bank connections and open banking](/guides/open-banking).



## OpenAPI

````yaml /openapi.json get /v1/partner/bank-connections/{connection_id}/analysis
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 and eID checks. 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.
paths:
  /v1/partner/bank-connections/{connection_id}/analysis:
    get:
      tags:
        - Bank connections (Growth)
      summary: Get the cash-flow analysis of a bank connection
      description: >-
        Required scope: `bank:read`.


        Growth plan. Switched on per workspace by Sahl: until then a key cannot
        be issued with this scope and calls answer `403`
        `bank_scope_not_allowed`. No bank data provider is live: data is a
        sandbox simulation (send `X-Sahl-Environment: sandbox`), and in
        production create, refresh, transactions and analysis answer `409`
        `bank_connect_unavailable`.


        Simulated cash-flow analysis, sandbox only today. In production: `409`
        `bank_connect_unavailable`.


        Guide: [Bank connections and open banking](/guides/open-banking).
      operationId: partner_bank_get_connection_id_analysis
      parameters:
        - name: connection_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Connection Id
        - 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
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BankAnalysisResponse'
              example:
                income_regularity:
                  score: 0.93
                  pattern: monthly_25th
                  employer: OCP GROUP
                  day_of_month: 25
                  consecutive_months: 9
                  risk: low
                risk_flags:
                  overdrafts: 0
                  bounced_checks: 0
                  gambling_transactions: 0
                  large_cash_withdrawals: 1
                  debt_payments_detected: 2
                  flagged_items:
                    - Large cash withdrawal of 5000 MAD on 14/02
                savings_rate: 0.35
                estimated_dti: 0.31
                avg_end_of_month_balance: 9000
                avg_balance: 21000
                monthly_income: 18000
                monthly_expenses: 11700
        '401':
          description: Missing, invalid, revoked or expired API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: >-
            The key lacks the scope (`insufficient_scope`), or the workspace is
            not enabled for the partner bank API (`bank_scope_not_allowed`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail:
                  code: bank_scope_not_allowed
                  message: This workspace is not enabled for the partner bank API.
        '404':
          description: Unknown connection.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail: Bank connection not found
        '409':
          description: >-
            Production, or no Sandbox environment named: 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:
    BankAnalysisResponse:
      properties:
        income_regularity:
          $ref: '#/components/schemas/IncomeRegularity'
        risk_flags:
          $ref: '#/components/schemas/RiskFlags'
        savings_rate:
          type: number
        estimated_dti:
          type: number
        avg_end_of_month_balance:
          type: number
        avg_balance:
          type: number
        monthly_income:
          type: number
        monthly_expenses:
          type: number
      type: object
      required:
        - income_regularity
        - risk_flags
        - savings_rate
        - estimated_dti
        - avg_end_of_month_balance
        - avg_balance
        - monthly_income
        - monthly_expenses
    Error:
      type: object
      title: Error
      description: >-
        FastAPI error body. `detail` is a string, or an object with `code` and
        `message` (extra keys possible).
      properties:
        detail:
          oneOf:
            - type: string
            - 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
    IncomeRegularity:
      properties:
        score:
          type: number
        pattern:
          type: string
        employer:
          type: string
        day_of_month:
          type: integer
        consecutive_months:
          type: integer
        risk:
          type: string
      type: object
      required:
        - score
        - pattern
        - employer
        - day_of_month
        - consecutive_months
        - risk
    RiskFlags:
      properties:
        overdrafts:
          type: integer
        bounced_checks:
          type: integer
        gambling_transactions:
          type: integer
        large_cash_withdrawals:
          type: integer
        debt_payments_detected:
          type: integer
        flagged_items:
          type: array
          items:
            type: string
      type: object
      required:
        - overdrafts
        - bounced_checks
        - gambling_transactions
        - large_cash_withdrawals
        - debt_payments_detected
        - flagged_items
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key created in the console. Scopes: kyc:extract, kyc:verify,
        kyc:eid; bank:read, bank:write (Growth plan, enabled per workspace by
        Sahl).

````

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