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

# Cancel a Transfer

> Use this endpoint to cancel a transfer that has not yet been submitted for processing. Only transfers in CREATED or PENDING status can be cancelled. Cancelling a transfer releases the held funds in Midaz and sets the status to CANCELLED. Calling cancel on an already-cancelled transfer returns success.



## OpenAPI

````yaml /en/openapi/v3-current/ted.yaml post /v1/transfers/{transferId}/cancel
openapi: 3.0.3
info:
  title: Bank Transfer (TED) Plugin API
  description: >-
    Complete API for Brazilian bank transfers (TED OUT, TED IN, P2P) through the
    Lerian platform, including transfer initiation, processing, status tracking,
    and cancellation.
  version: 2.4.0
servers:
  - url: https://plugin-br-bank-transfer.sandbox.lerian.net
    description: Sandbox (placeholder — not yet available for public access)
security:
  - BearerAuth: []
tags:
  - name: Transfers API
    description: Endpoints for initiating, processing, tracking, and cancelling transfers.
  - name: Webhook DLQ
    description: Endpoints for inspecting and retrying webhook dead-letter queue messages.
  - name: Health API
    description: Endpoints for checking service liveness and readiness.
paths:
  /v1/transfers/{transferId}/cancel:
    post:
      tags:
        - Transfers API
      summary: Cancel a Transfer
      description: >-
        Use this endpoint to cancel a transfer that has not yet been submitted
        for processing. Only transfers in CREATED or PENDING status can be
        cancelled. Cancelling a transfer releases the held funds in Midaz and
        sets the status to CANCELLED. Calling cancel on an already-cancelled
        transfer returns success.
      operationId: cancelTransfer
      parameters:
        - $ref: '#/components/parameters/XOrganizationId'
        - $ref: '#/components/parameters/XIdempotencyKey'
        - name: transferId
          in: path
          required: true
          description: The unique identifier of the transfer to cancel.
          schema:
            type: string
            format: uuid
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                reason:
                  type: string
                  maxLength: 500
                  description: The reason for the cancellation.
            examples:
              withReason:
                summary: With cancellation reason
                value:
                  reason: User requested cancellation
      responses:
        '200':
          description: >-
            Indicates that the transfer was successfully cancelled and funds
            were released.


            Repeated calls with the same `X-Idempotency` key replay the cached
            response.


            See [Retries and idempotency](/en/reference/retries-idempotency) for
            more details.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CancelTransferResponse'
              examples:
                success:
                  summary: Cancellation successful
                  value:
                    transferId: 019c96a0-ab10-7cde-f1a2-0e1f2a3b4c5d
                    status: CANCELLED
                    cancelledAt: '2026-02-01T15:35:00-03:00'
        '404':
          $ref: '#/components/responses/TransferNotFound'
        '422':
          $ref: '#/components/responses/CannotCancel'
        '429':
          $ref: '#/components/responses/RateLimitExceeded'
components:
  parameters:
    XOrganizationId:
      name: X-Organization-Id
      in: header
      required: true
      description: >-
        Organization ID used as the tenant identifier. All data is scoped to
        this organization. Must match the JWT tenantId claim when authentication
        is enabled.
      schema:
        type: string
        format: uuid
      example: 019c96a0-0a98-7287-9a31-786e0809c769
    XIdempotencyKey:
      name: X-Idempotency
      in: header
      required: true
      description: >-
        Required idempotency key for safe retries. Use a UUID v4 or unique
        business identifier. If the same key is sent again and the original
        request was already processed, the cached response is returned.


        See [Retries and idempotency](/en/reference/retries-idempotency) for
        details.
      schema:
        type: string
        maxLength: 255
      example: 019c96a0-aa10-7abc-d1e2-8c9d0e1f2a3b
  schemas:
    CancelTransferResponse:
      type: object
      required:
        - transferId
        - status
        - cancelledAt
      properties:
        transferId:
          type: string
          format: uuid
          example: 019c96a0-ab10-7cde-f1a2-0e1f2a3b4c5d
        status:
          type: string
          enum:
            - CANCELLED
          example: CANCELLED
        cancelledAt:
          type: string
          format: date-time
          example: '2026-02-01T15:35:00-03:00'
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              pattern: ^BTF-[0-9]{4}$
              description: The error code in BTF-XXXX format.
              example: BTF-0010
            title:
              type: string
              description: A short, human-readable title for the error.
              example: Operating Hours Violation
            message:
              type: string
              description: A detailed description of the error.
              example: >-
                Transfers can only be initiated Monday-Friday between 06:30 and
                17:00 Brasília time
            fields:
              type: object
              additionalProperties: true
              description: Field-level validation errors for request body parameters.
              example:
                currentTime: '2026-02-01T18:30:00-03:00'
                operatingHours: Mon-Fri 06:30-17:00 UTC-3
            headers:
              type: object
              additionalProperties: true
              description: Validation errors for request headers.
            paths:
              type: object
              additionalProperties: true
              description: Validation errors for path parameters.
            queryParams:
              type: object
              additionalProperties: true
              description: Validation errors for query parameters.
  responses:
    TransferNotFound:
      description: >-
        Indicates that the transfer was not found or belongs to a different
        organization.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            transferNotFound:
              summary: Transfer ID invalid
              value:
                error:
                  code: BTF-0200
                  title: Transfer Not Found
                  message: Transfer not found
    CannotCancel:
      description: >-
        Indicates that the transfer cannot be cancelled because its current
        status does not allow cancellation.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            cannotCancel:
              summary: Already processing
              value:
                error:
                  code: BTF-0204
                  title: Cannot Cancel
                  message: >-
                    Transfer cannot be cancelled in its current status. Only
                    CREATED or PENDING transfers can be cancelled.
                  fields:
                    currentStatus: PROCESSING
                    allowedStatuses:
                      - CREATED
                      - PENDING
    RateLimitExceeded:
      description: >-
        Indicates that the rate limit has been exceeded. Retry after the number
        of seconds specified in the Retry-After header.
      headers:
        Retry-After:
          description: Seconds until rate limit resets
          schema:
            type: integer
            example: 60
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            rateLimitExceeded:
              summary: Too many requests
              value:
                error:
                  code: BTF-0001
                  title: Invalid input
                  message: >-
                    Too many requests. Retry after the interval indicated by the
                    `Retry-After` header.
              description: >
                Rate-limit responses share the `BTF-0001` code with other 4xx
                validation errors. Clients should detect rate limiting via HTTP
                status `429` and the `Retry-After` header rather than the error
                code.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        JWT Bearer token authentication. The token must include a tenantId claim
        that matches the X-Organization-Id header.

````