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

# Create bank transfer return operation

> Prerequisite: the parent operation must be SETTLED before a return — read its state via getOperation (GET /v1/str/operations/{operationId}); the {operationId} path segment structurally ties the return to its parent. The handler resolves the original operation by operationId, validates that the lifecycle state admits a return (SPB-3006 otherwise), and delegates to the STR0010 return path. Idempotent — replaying the same X-Idempotency key with the same body returns the cached response.



## OpenAPI

````yaml en/openapi/v3-current/spb.yaml post /v1/str/operations/bank-transfers/{operationId}/returns
openapi: 3.1.0
info:
  contact:
    email: contact@lerian.studio
    name: Lerian Studio
    url: https://lerian.studio
  description: >-
    OpenAPI 3.1 surface for Lerian SPB, the direct integration between the
    institution and the Brazilian Payment System (SPB) over the National
    Financial System Network (RSFN). It covers the Reserve Transfer System
    (STR): message registry and capability catalog, operation lifecycle (bank
    transfers, IBS repasses, liquidity transfers, returns and cancellations),
    reserve-account and schedule queries, alçada governance, reconciliation, and
    event delivery.
  license:
    name: Lerian Studio General License
  title: Lerian SPB API
  version: 1.0.0
servers:
  - url: https://spb.sandbox.lerian.net
security: []
tags:
  - description: Immutable audit-record trails for STR operations and lifecycle events.
    name: Audit
  - description: >-
      STR capability catalog describing supported message types and their
      constraints.
    name: Capabilities
  - description: >-
      ICP-Brasil certificate inventory with hot-reloadable rotation and
      activation.
    name: Certificates
  - description: >-
      Maker-checker approval queue for emissions parked above their alçada band:
      list pending, sign (approve), and deny.
    name: EmissionApprovals
  - description: Webhook event-delivery records with retry control for failed dispatches.
    name: EventDeliveries
  - description: Operation event catalog enumerating the emitted domain event types.
    name: Events
  - description: >-
      Inbound GEN-family notice log (GEN0001 connectivity echo, GEN0004
      transmission error, GEN0005 administrative notice).
    name: GenNotices
  - description: >-
      SPB alçada governance: the value-band table and per-message-type signature
      requirements, hot-reloaded at runtime.
    name: Governance
  - description: >-
      Read raw STR message status: list messages and read a single message by
      NUOp.
    name: Messages
  - description: Aggregated operational summaries and metrics across STR operations.
    name: OperationalIntelligence
  - description: >-
      STR operation lifecycle for bank transfers and IBS repasses, including
      returns and cancellations.
    name: Operations
  - description: >-
      Service readiness state covering startup self-probes and dependency
      health.
    name: Readiness
  - description: Reconciliation cases and the actions that resolve operation discrepancies.
    name: Reconciliation
  - description: >-
      STR reports suite: synchronous, date-ranged aggregate reports (financial
      movement, rejected transactions, volumetria) over Lerian SPB's own
      transmission record.
    name: Reports
  - description: >-
      STR0013 reserve-account balance and STR0014 statement (extrato,
      message-mode) queries and their async results.
    name: ReserveQueries
  - description: >-
      GEN0019 participant responsável roster: full-replacement updates announced
      to BACEN.
    name: Responsibles
  - description: STR operating-window schedule governing when operations may be sent.
    name: Schedule
  - description: >-
      STR0001 single-party schedule queries (consulta de horários do STR) and
      their async STR0001R1 grid results.
    name: ScheduleQueries
  - description: Runtime SPB configuration settings for the STR integration.
    name: Settings
  - description: Webhook endpoint registration and management for event delivery.
    name: Webhooks
  - description: >-
      Flow (mandatory order): certificate → readiness → connectivity-test →
      submit. Activate a certificate, confirm the rail reports ready, pass a
      connectivity test, then submit an operation. Each step is its own
      resource; a submit must not be attempted before readiness passes.
    name: onboarding
  - description: >-
      Flow (mandatory order): parent operation SETTLED → return/cancel. A return
      or cancellation is a sub-resource of a settled parent operation; the
      {operationId}/{endToEndID} path segment enforces the parent structurally.
    name: lifecycle
paths:
  /v1/str/operations/bank-transfers/{operationId}/returns:
    post:
      tags:
        - Operations
        - lifecycle
      summary: Create bank transfer return operation
      description: >-
        Prerequisite: the parent operation must be SETTLED before a return —
        read its state via getOperation (GET /v1/str/operations/{operationId});
        the {operationId} path segment structurally ties the return to its
        parent. The handler resolves the original operation by operationId,
        validates that the lifecycle state admits a return (SPB-3006 otherwise),
        and delegates to the STR0010 return path. Idempotent — replaying the
        same X-Idempotency key with the same body returns the cached response.
      operationId: createBankTransferReturnOperation
      parameters:
        - description: Original bank-transfer operation UUID.
          in: path
          name: operationId
          required: true
          schema:
            description: Original bank-transfer operation UUID.
            type: string
        - description: Bearer JWT token.
          in: header
          name: Authorization
          schema:
            description: Bearer JWT token.
            type: string
        - description: Idempotency key (canonical).
          in: header
          name: X-Idempotency
          schema:
            description: Idempotency key (canonical).
            type: string
        - description: Idempotency key (legacy alias).
          in: header
          name: X-Idempotency-Key
          schema:
            description: Idempotency key (legacy alias).
            type: string
        - description: Idempotency key TTL in seconds.
          in: header
          name: X-TTL
          schema:
            description: Idempotency key TTL in seconds.
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateBankTransferReturnRequest'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OperationAcceptedResponse'
          description: Created
          links:
            prerequisite:
              description: >-
                Lifecycle prerequisite: the parent operation read by
                getOperation must be SETTLED before a return is accepted.
              operationId: getOperation
        default:
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Error
      security:
        - BearerAuth: []
components:
  schemas:
    CreateBankTransferReturnRequest:
      additionalProperties: false
      properties:
        amount:
          description: >-
            Optional partial return amount as a decimal string in BRL,
            minor-unit precision; defaults to the full original amount when
            omitted.
          examples:
            - '50.00'
          pattern: ^[0-9]+(\.[0-9]+)?$
          type: string
        description:
          description: Optional free-text description of the return.
          examples:
            - Wrong account
          type: string
        metadata:
          additionalProperties: {}
          description: >-
            Opaque client-side metadata forwarded verbatim to the legacy submit
            DTO; not persisted on the return intent.
          type: object
        recipientIspb:
          description: >-
            ISPB of the participant receiving the return, the 8-digit BACEN
            institution identifier.
          examples:
            - 38166
          type: string
        returnCode:
          description: BACEN STR return reason code (devolução) for the reversal.
          examples:
            - '01'
          type: string
        senderIspb:
          description: >-
            ISPB of the participant initiating the return, the 8-digit BACEN
            institution identifier.
          examples:
            - '12345678'
          type: string
      required:
        - returnCode
        - senderIspb
        - recipientIspb
      type: object
    OperationAcceptedResponse:
      additionalProperties: false
      properties:
        acceptedAt:
          description: UTC RFC 3339 timestamp at which the command was accepted.
          examples:
            - '2026-05-06T18:30:00Z'
          format: date-time
          type: string
        capabilityId:
          description: >-
            STR capability identifier resolved for the accepted operation (e.g.
            STR0004).
          examples:
            - STR0004
          type: string
        correlationId:
          description: >-
            Request correlation identifier for tracing the accept across logs
            and traces.
          examples:
            - req-7c8b3a2e-9f1d-4a55-9b8e-1e1234567890
          type: string
        isReplay:
          description: >-
            True when this response replays a prior idempotent accept rather
            than creating a new operation.
          examples:
            - false
          type: boolean
        operationFamily:
          description: >-
            Operation family the accepted command belongs to (e.g.
            bankTransfer).
          examples:
            - bankTransfer
          type: string
        operationId:
          description: >-
            Server-assigned operation aggregate UUID used for subsequent status,
            return, and cancellation calls.
          examples:
            - 7c8b3a2e-9f1d-4a55-9b8e-1e1234567890
          format: uuid
          type: string
        protocolMetadata:
          $ref: '#/components/schemas/OperationProtocolMetadata'
          description: >-
            Optional SAFE protocol correlation fields; present once the
            operation is mapped to STR wire identifiers.
        status:
          description: >-
            Current control-plane lifecycle status of the operation; ACCEPTED on
            initial accept.
          examples:
            - ACCEPTED
          type: string
      required:
        - operationId
        - operationFamily
        - capabilityId
        - status
        - acceptedAt
        - isReplay
        - correlationId
      type: object
    Detail:
      additionalProperties: false
      properties:
        code:
          description: >-
            Stable, machine-readable domain error code scoped to the emitting
            service (format: <SERVICE>-NNNN).
          examples:
            - ERR-0001
          type: string
        detail:
          description: >-
            A human-readable explanation specific to this occurrence of the
            problem.
          examples:
            - Property foo is required but is missing.
          type: string
        errors:
          description: Optional list of individual error details
          items:
            $ref: '#/components/schemas/ErrorDetail'
          type:
            - array
            - 'null'
        instance:
          description: >-
            A URI reference that identifies the specific occurrence of the
            problem.
          examples:
            - https://example.com/error-log/abc123
          format: uri
          type: string
        status:
          description: HTTP status code
          examples:
            - 400
          format: int64
          type: integer
        title:
          description: >-
            A short, human-readable summary of the problem type. This value
            should not change between occurrences of the error.
          examples:
            - Bad Request
          type: string
        type:
          default: about:blank
          description: A URI reference to human-readable documentation for the error.
          examples:
            - https://example.com/errors/example
          format: uri
          type: string
      type: object
    OperationProtocolMetadata:
      additionalProperties: false
      properties:
        controlNumber:
          description: >-
            STR control number, 14 digits identifying the message on the SPB
            network.
          examples:
            - '20260506000001'
          maxLength: 14
          minLength: 14
          type: string
        nuOp:
          description: >-
            STR operation number (NUOp), 23 digits: 8-digit ISPB + 8-digit date
            + 7-digit sequence.
          examples:
            - '12345678202605060000001'
          maxLength: 23
          minLength: 23
          pattern: ^[0-9]{8}[0-9]{8}[0-9]{7}$
          type: string
      type: object
    ErrorDetail:
      additionalProperties: false
      properties:
        location:
          description: >-
            Where the error occurred, e.g. 'body.items[3].tags' or
            'path.thing-id'
          type: string
        message:
          description: Error message text
          type: string
        value:
          description: The value at the given location
      type: object
  securitySchemes:
    BearerAuth:
      bearerFormat: JWT
      description: JWT bearer token issued by the identity provider.
      scheme: bearer
      type: http

````