> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lead.bank/llms.txt
> Use this file to discover all available pages before exploring further.

# Simulate ACH

> Simulates an ACH scenario in sandbox. Set `scenario` to choose what happens; each scenario takes the fields listed in its request shape. The response body is empty; read the ACH with Retrieve an ACH V2, the list endpoint, or its webhook. Available in Sandbox only.

If the ACH isn't in a state the scenario allows, the call returns `422 object_state_mismatched` with `errors[].code` `object_status_not_permitted`, and the message names the required state. For example, `incoming_return` on an ACH still in `scheduled`. If two calls race on the same ACH, the first wins and the other returns `409 object_modified_concurrently`; fetch the ACH and retry.

> [!NOTE]
>
> See [Errors](https://docs.lead.bank/api-reference/using-the-api/errors-v2.md) for the common errors every v2 endpoint can return.


## OpenAPI

````yaml openapi.json POST /v2/simulate/ach
openapi: 3.0.1
info:
  title: Lead Bank
  description: Lead Bank's APIs
  version: v1.0
servers:
  - url: https://api.sandbox.lead.bank
  - url: https://api.lead.bank
security:
  - bearerAuth: []
tags:
  - name: ACH
  - name: ACHv2
  - name: Account Number
  - name: OAuth
  - name: Events
  - name: Instant Payments
  - name: Lending
  - name: Simulation
  - name: Sandbox
  - name: Internal Transfer
  - name: Disbursement
  - name: Entity
  - name: Wire
  - name: Originator
  - name: Funding
  - name: Receivable Sale
  - name: Balances
  - name: Compliance
  - name: Application
  - name: User Account
  - name: Blockchain Payment
  - name: Core Account
  - name: Core Balance
  - name: Core Transaction
  - name: Event Subscription
  - name: Receivable
  - name: User Credit Transaction
  - name: Files
paths:
  /v2/simulate/ach:
    post:
      tags:
        - Simulation
      summary: Simulate ACH V2
      description: >-
        Simulates an ACH scenario in sandbox. Set `scenario` to choose what
        happens; each scenario takes the fields listed in its request shape. The
        response body is empty; read the ACH with Retrieve an ACH V2, the list
        endpoint, or its webhook. Available in Sandbox only.


        If the ACH isn't in a state the scenario allows, the call returns `422
        object_state_mismatched` with `errors[].code`
        `object_status_not_permitted`, and the message names the required state.
        For example, `incoming_return` on an ACH still in `scheduled`. If two
        calls race on the same ACH, the first wins and the other returns `409
        object_modified_concurrently`; fetch the ACH and retry.
      operationId: simulate-ach-v2
      parameters:
        - name: Idempotency-Key
          in: header
          description: Idempotency key
          required: true
          schema:
            $ref: '#/components/schemas/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SimulateAchRequestV2'
      responses:
        '200':
          description: The simulation was accepted. The response body is empty.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SimulateResponse'
        4XX:
          $ref: '#/components/responses/Error4XX'
        5XX:
          $ref: '#/components/responses/Error5XX'
components:
  schemas:
    IdempotencyKey:
      type: string
      description: >-
        A unique key for this request, up to 255 characters. Retrying with the
        same key and body returns the original response instead of performing
        the operation again.
      minLength: 1
      maxLength: 255
      example: 3f1c9a52-7d4e-4b8a-9c21-6e0f5d2a8b14
    SimulateAchRequestV2:
      type: object
      description: >-
        The ACH scenario to simulate in sandbox. `scenario` selects which of the
        request shapes below applies.
      oneOf:
        - $ref: '#/components/schemas/SimulateIncomingAchRequestV2'
        - $ref: '#/components/schemas/SimulateIncomingAchReturnRequestV2'
      discriminator:
        propertyName: scenario
        mapping:
          incoming_payment: '#/components/schemas/SimulateIncomingAchRequestV2'
          incoming_return: '#/components/schemas/SimulateIncomingAchReturnRequestV2'
    SimulateResponse:
      type: object
    SimulateIncomingAchRequestV2:
      title: Incoming payment
      type: object
      description: >-
        Simulates an incoming ACH originated by another financial institution.
        The entry is created in `scheduled` and stays there until you advance
        it.
      required:
        - scenario
        - account_number_id
        - sec_code
        - transaction_type
        - amount
        - currency
        - statement_descriptor
        - company_name
        - company_identification
        - counterparty
      properties:
        scenario:
          type: string
          description: Creates an incoming ACH in `scheduled`.
          enum:
            - incoming_payment
          example: incoming_payment
        amount:
          allOf:
            - $ref: '#/components/schemas/Amount'
          description: The amount of the transaction in cents.
          minimum: 0
        currency:
          $ref: '#/components/schemas/USDCurrency'
        transaction_type:
          $ref: '#/components/schemas/TransactionType'
        account_number_id:
          $ref: '#/components/schemas/AccountNumberID'
        sec_code:
          $ref: '#/components/schemas/SecCode'
        statement_descriptor:
          $ref: '#/components/schemas/StatementDescriptor'
        company_name:
          type: string
          description: >-
            The name of the company that originated the ACH. Also returned as
            `counterparty.name` on the ACH.
          example: Lorum Inc.
          maxLength: 16
          pattern: ^(?!\s*$)[\x20-\x7E]*$
        company_identification:
          type: string
          description: The originating company's 10-character identifier.
          example: '1234567890'
          maxLength: 10
        counterparty:
          type: object
          description: The originating bank.
          required:
            - routing_number
          properties:
            routing_number:
              type: string
              description: The 9 digit ACH routing number of the originating bank.
              example: '021000021'
              pattern: ^\d{9}$
    SimulateIncomingAchReturnRequestV2:
      title: Incoming return
      type: object
      description: >-
        Simulates the counterparty bank's side of a return: a return or
        contested dishonor on an outgoing ACH, or a dishonor of the partner's
        return on an incoming ACH. The return code decides which. The entry
        moves to `pending_return`, `pending_dishonored_return`, or
        `pending_contested_return`; advance it to finish the return.
      required:
        - scenario
        - ach_id
        - network_code
      properties:
        scenario:
          type: string
          description: Opens the pending return state on an ACH.
          enum:
            - incoming_return
          example: incoming_return
        ach_id:
          type: string
          description: ID of the ACH you want to return.
          pattern: ^ach_\w+$
          example: ach_xyz001
        network_code:
          $ref: '#/components/schemas/ReturnCode'
        details:
          type: string
          maxLength: 44
          description: >-
            The other bank's addenda text on the return. It appears in
            `returns[].details` only when `network_code` maps to `reason`
            `other` (R32, R33, R40, R83, R84); for other codes,
            `returns[].details` uses Lead's text for the reason.
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          $ref: '#/components/schemas/ErrorCode'
        message:
          type: string
          description: >-
            A human-readable description of the error family. Identical for
            every occurrence of a given `code`; carries no request-specific
            detail.
          example: One or more parameters are invalid. See errors for each one.
        errors:
          type: array
          description: >-
            Zero or more specific errors within this family. Always present for
            validation errors, one entry per failing field.
          items:
            $ref: '#/components/schemas/ErrorItem'
    Amount:
      description: >-
        A monetary amount as an integer in the ISO 4217 minor units of its
        `currency` (cents for USD).
      type: integer
      format: int64
      example: 5000
    USDCurrency:
      type: string
      description: >-
        A three-letter currency code as defined in ISO 4217. `USD` is the only
        supported value.
      example: USD
      enum:
        - USD
    TransactionType:
      type: string
      description: ACH transaction type.
      example: credit
      enum:
        - credit
        - debit
    AccountNumberID:
      type: string
      description: The ID of the Lead Bank Account Number object.
      example: account_number_xyz123
      pattern: ^account_number_\w+$
    SecCode:
      type: string
      description: >-
        Standard Entry Class (SEC) code for this ACH object. This list covers
        every code Lead can receive on incoming ACH. Outgoing ACH accept a
        narrower list, `OutgoingSecCode`, which is what Lead originates.
      example: WEB
      enum:
        - PPD
        - CCD
        - ARC
        - BOC
        - CIE
        - CTX
        - IAT
        - POP
        - POS
        - RCK
        - TEL
        - WEB
        - ADV
        - DNE
        - ENR
        - MTE
        - SHR
        - TRC
        - TRX
        - COR
    StatementDescriptor:
      type: string
      description: >-
        The description you would like to appear on your customers’ statement.
        Maximum number of characters is 10.
      example: P2P Credit
      minLength: 1
      maxLength: 10
      pattern: ^(?!0+$)(?! +$)[\x20-\x7E]*$
    ReturnCode:
      type: string
      description: NACHA Return codes.
      example: R02
      enum:
        - R01
        - R02
        - R03
        - R04
        - R05
        - R06
        - R07
        - R08
        - R09
        - R10
        - R11
        - R12
        - R13
        - R14
        - R15
        - R16
        - R17
        - R18
        - R19
        - R20
        - R21
        - R22
        - R23
        - R24
        - R25
        - R26
        - R27
        - R28
        - R29
        - R30
        - R31
        - R32
        - R33
        - R34
        - R35
        - R36
        - R37
        - R38
        - R39
        - R40
        - R41
        - R42
        - R43
        - R44
        - R45
        - R46
        - R47
        - R50
        - R51
        - R52
        - R53
        - R61
        - R62
        - R67
        - R68
        - R69
        - R70
        - R71
        - R72
        - R73
        - R74
        - R75
        - R76
        - R77
        - R80
        - R81
        - R82
        - R83
        - R84
        - R85
    ErrorCode:
      type: string
      description: >-
        A snake_case code identifying the error family — the stable,
        machine-readable value partners branch on, together with the HTTP
        status.
      example: parameters_invalid
      enum:
        - request_malformed
        - content_too_large
        - headers_invalid
        - unsupported_media_type
        - authentication_missing
        - token_invalid
        - source_ip_not_permitted
        - client_credentials_invalid
        - url_invalid
        - object_not_found
        - method_not_allowed
        - idempotency_key_in_use
        - idempotency_request_mismatched
        - rate_limit_exceeded
        - internal_server_error
        - service_unavailable
        - endpoint_disabled
        - gateway_timeout
        - parameters_invalid
        - related_object_invalid
        - related_object_not_ready
        - related_object_incompatible
        - limit_exceeded
        - partner_control_restricted
        - lead_control_restricted
        - object_state_mismatched
        - object_modified_concurrently
        - operation_invalid
    ErrorItem:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: A snake_case code naming the specific error or sub-category.
          example: schema_violation
        message:
          type: string
          description: >-
            A human-readable description of this specific error, with
            interpolated values where relevant.
          example: account_number_id is required.
        parameters:
          type: array
          description: >-
            The request fields that caused this error, as `jq` paths without the
            leading dot. For example, a nested field is `address.city` and an
            array item is `beneficial_owners[1].ownership`. A key with
            characters other than letters, digits, and underscores is
            JSON-quoted, like `metadata["order.id"]`. Headers appear by name,
            like `Idempotency-Key`. Present for validation errors.
          items:
            type: string
          example:
            - account_number_id
  responses:
    Error4XX:
      x-api-version: v2
      description: >-
        A client error. The HTTP status and `code` identify the problem; `code`
        is one of the top-level codes in the Lead Error Registry. Branch on
        `code` together with the status. The examples show each registry code
        that can return a 4xx status. Not every code applies to every endpoint.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            request_malformed:
              summary: 400 request_malformed
              value:
                code: request_malformed
                message: The request couldn't be parsed. Fix its format and resend it.
                errors:
                  - code: url_malformed
                    message: >-
                      The request URL contains characters that can't be parsed.
                      URL-encode path and query values.
            headers_invalid:
              summary: 400 headers_invalid
              value:
                code: headers_invalid
                message: One or more headers are invalid. See errors for each one.
                errors:
                  - code: idempotency_key_invalid
                    message: >-
                      This endpoint requires an Idempotency-Key header of up to
                      255 characters. Set the header and resend the request.
                    parameters:
                      - Idempotency-Key
            client_credentials_invalid:
              summary: 401 client_credentials_invalid
              value:
                code: client_credentials_invalid
                message: >-
                  Your client ID or client secret is wrong. Check them and
                  resend the request.
            authentication_missing:
              summary: 403 authentication_missing
              value:
                code: authentication_missing
                message: >-
                  The request has no authentication credentials. Send your API
                  token in the Authorization header.
            token_invalid:
              summary: 403 token_invalid
              value:
                code: token_invalid
                message: >-
                  Your bearer token is expired, invalid, or lacks required
                  scopes. Get a new token.
            source_ip_not_permitted:
              summary: 403 source_ip_not_permitted
              value:
                code: source_ip_not_permitted
                message: >-
                  This request came from an IP address that isn't on your
                  program's allowlist. Send from an allowlisted IP, or contact
                  Lead to update the list.
            url_invalid:
              summary: 404 url_invalid
              value:
                code: url_invalid
                message: >-
                  This path isn't a valid endpoint. Check the URL against the
                  API reference.
            object_not_found:
              summary: 404 object_not_found
              value:
                code: object_not_found
                message: >-
                  No object with this ID exists, or your program can't access
                  it. Check the ID.
            method_not_allowed:
              summary: 405 method_not_allowed
              value:
                code: method_not_allowed
                message: >-
                  This path doesn't support this HTTP method. Check the API
                  reference for the methods it accepts.
            idempotency_key_in_use:
              summary: 409 idempotency_key_in_use
              value:
                code: idempotency_key_in_use
                message: >-
                  Another request with this Idempotency-Key is still processing.
                  Wait for it to finish, then retry.
            object_modified_concurrently:
              summary: 409 object_modified_concurrently
              value:
                code: object_modified_concurrently
                message: >-
                  Another request changed this object while yours was
                  processing, so yours wasn't applied. Fetch the object's
                  current state and retry.
            content_too_large:
              summary: 413 content_too_large
              value:
                code: content_too_large
                message: >-
                  The request is over a size limit for this endpoint. Make it
                  smaller and resend it.
            unsupported_media_type:
              summary: 415 unsupported_media_type
              value:
                code: unsupported_media_type
                message: >-
                  The request is in a format this endpoint doesn't accept.
                  Change it to a supported format and resend it.
            idempotency_request_mismatched:
              summary: 422 idempotency_request_mismatched
              value:
                code: idempotency_request_mismatched
                message: >-
                  This Idempotency-Key was already used with a different request
                  body. Use a new key, or resend the original body.
            parameters_invalid:
              summary: 422 parameters_invalid
              value:
                code: parameters_invalid
                message: One or more parameters are invalid. See errors for each one.
                errors:
                  - code: parameter_bound_exceeded
                    message: limit is 500, which is over the maximum of 100.
                    parameters:
                      - limit
            related_object_invalid:
              summary: 422 related_object_invalid
              value:
                code: related_object_invalid
                message: >-
                  An object this request refers to doesn't exist or can't be
                  used. Fix the reference, or create the object first.
            related_object_not_ready:
              summary: 422 related_object_not_ready
              value:
                code: related_object_not_ready
                message: >-
                  An object this request depends on isn't ready for it. Update
                  that object, then retry the same request.
            related_object_incompatible:
              summary: 422 related_object_incompatible
              value:
                code: related_object_incompatible
                message: >-
                  This request conflicts with an object it refers to. Change the
                  request to match the object.
            limit_exceeded:
              summary: 422 limit_exceeded
              value:
                code: limit_exceeded
                message: >-
                  This request is over a limit. Lower the amount or count. Check
                  errors for when, or whether, the limit resets.
            partner_control_restricted:
              summary: 422 partner_control_restricted
              value:
                code: partner_control_restricted
                message: >-
                  A partner-configured control blocks this request. Update the
                  control, then retry the same request.
            lead_control_restricted:
              summary: 422 lead_control_restricted
              value:
                code: lead_control_restricted
                message: >-
                  A Lead-configured control blocks this request. Contact Lead
                  with the Lead-Request-ID.
            object_state_mismatched:
              summary: 422 object_state_mismatched
              value:
                code: object_state_mismatched
                message: >-
                  The object isn't in the state this request expected. Fetch its
                  current state before you retry.
            operation_invalid:
              summary: 422 operation_invalid
              value:
                code: operation_invalid
                message: This operation isn't available for this object.
            rate_limit_exceeded:
              summary: 429 rate_limit_exceeded
              value:
                code: rate_limit_exceeded
                message: >-
                  You've sent too many requests to this endpoint. Retry with
                  exponential backoff.
    Error5XX:
      x-api-version: v2
      description: >-
        A server error on Lead's side. `code` is one of the 5xx codes in the
        Lead Error Registry. Retry with exponential backoff, and reuse the same
        Idempotency-Key for a POST, PATCH or DELETE.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            internal_server_error:
              summary: 500 internal_server_error
              value:
                code: internal_server_error
                message: >-
                  Internal server error. Retry with exponential backoff. For a
                  POST, PATCH or DELETE, reuse the same Idempotency-Key so the
                  request isn't processed twice. If it keeps failing, contact
                  Lead with the Lead-Request-ID.
            service_unavailable:
              summary: 503 service_unavailable
              value:
                code: service_unavailable
                message: >-
                  A system this request depends on is temporarily unavailable.
                  Retry with exponential backoff.
            endpoint_disabled:
              summary: 503 endpoint_disabled
              value:
                code: endpoint_disabled
                message: >-
                  This endpoint is temporarily disabled. Retry after the time in
                  the Retry-After header.
            gateway_timeout:
              summary: 504 gateway_timeout
              value:
                code: gateway_timeout
                message: >-
                  A system this request depends on didn't respond in time. Retry
                  with exponential backoff. For a POST, PATCH or DELETE, reuse
                  the same Idempotency-Key so the request isn't processed twice.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````