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

# Cancel RTP

> Request cancellation of an unsettled Request-to-Pay (RTP) payment. The payment must still be in a `P_INITIATED` or `P_RECEIVED` state; terminal payments cannot be cancelled. A `202 Accepted` response means the cancellation request was created and the camt.055 was posted to Raast - the final outcome is asynchronous. Poll the payment and inspect the cancellation `status`, which progresses from `PAYMENT_CANCEL_CREATED` to either `PAYMENT_CANCEL_ACCEPTED` or `PAYMENT_CANCEL_REJECTED`.




## OpenAPI

````yaml /api-reference/openapi.yaml post /v1/aggregators/{raast-aggregator-id}/payments/{payment-id}/cancel
openapi: 3.1.0
info:
  title: Raast Wire
  version: 1.0.0
  description: ''
servers:
  - url: https://api.getsafepay.com/raastwire
security: []
tags:
  - name: Aggregators
  - name: Access Keys
  - name: Merchants
  - name: Raast Merchants
  - name: Payments
  - name: Refunds
  - name: QRs
  - name: Utilities
  - name: Aliases
  - name: Ledgers
  - name: Webhooks
  - name: Settlement Operations
  - name: Settlement Reports
paths:
  /v1/aggregators/{raast-aggregator-id}/payments/{payment-id}/cancel:
    parameters:
      - $ref: '#/components/parameters/AggregatorIdParam'
      - $ref: '#/components/parameters/PaymentIdParam'
    post:
      tags:
        - Payments
      summary: Cancel RTP
      description: >
        Request cancellation of an unsettled Request-to-Pay (RTP) payment. The
        payment must still be in a `P_INITIATED` or `P_RECEIVED` state; terminal
        payments cannot be cancelled. A `202 Accepted` response means the
        cancellation request was created and the camt.055 was posted to Raast -
        the final outcome is asynchronous. Poll the payment and inspect the
        cancellation `status`, which progresses from `PAYMENT_CANCEL_CREATED` to
        either `PAYMENT_CANCEL_ACCEPTED` or `PAYMENT_CANCEL_REJECTED`.
      requestBody:
        $ref: '#/components/requestBodies/CancelPayment'
      responses:
        '202':
          $ref: '#/components/responses/CancelPaymentResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '500':
          $ref: '#/components/responses/InternalError'
      security:
        - apiKey: []
components:
  parameters:
    AggregatorIdParam:
      name: raast-aggregator-id
      in: path
      required: true
      schema:
        type: string
        example: agg_2288490a-2176-4de5-b373-0ffb6f8e2e6e
      description: The unique identifier for the aggregator
    PaymentIdParam:
      name: payment-id
      in: path
      required: true
      schema:
        type: string
        example: pm_2288490a-2176-4de5-b373-0ffb6f8e2e6e
      description: The unique identifier for the payment
  requestBodies:
    CancelPayment:
      description: Request to cancel an unsettled RTP payment
      content:
        application/json:
          schema:
            type: object
            description: RTP cancellation payload
            properties:
              request_id:
                type: string
                description: >
                  Client-supplied UUID v4 idempotency key for the cancellation
                  (exactly 36 characters with hyphens). Must be distinct from
                  the original payment's request id.
                format: uuid
                example: f0a3b1c2-8d4e-4f6a-9b1c-2d3e4f5a6b7c
              reason:
                type: string
                description: >
                  Public reason for the cancellation. Only
                  `PAYMENT_CANCEL_REASON_CUSTOMER_REQUEST` is currently
                  accepted; the remaining reason codes are reserved until Raast
                  confirms support for them.
                enum:
                  - PAYMENT_CANCEL_REASON_CUSTOMER_REQUEST
                example: PAYMENT_CANCEL_REASON_CUSTOMER_REQUEST
              additional_info:
                type: string
                description: >-
                  Optional free-text context for the cancellation (max 105
                  characters).
                maxLength: 105
            required:
              - request_id
              - reason
          examples:
            Cancel RTP:
              value:
                request_id: f0a3b1c2-8d4e-4f6a-9b1c-2d3e4f5a6b7c
                reason: PAYMENT_CANCEL_REASON_CUSTOMER_REQUEST
                additional_info: Customer requested cancellation
  responses:
    CancelPaymentResponse:
      description: >
        Cancellation request accepted. The camt.055 has been posted to Raast and
        the final outcome is delivered asynchronously.
      headers:
        Content-Length:
          $ref: '#/components/headers/ContentLengthHeader'
        Date:
          $ref: '#/components/headers/DateHeader'
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/StandardResponse'
              - type: object
                properties:
                  data:
                    type: object
                    description: The created cancellation record.
                    properties:
                      token:
                        type: string
                        description: Unique cancellation identifier.
                        example: pc_3b2a1c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d
                      payment_id:
                        type: string
                        description: Token of the payment being cancelled.
                        example: pm_96bc0ef4-7857-47fb-a345-c411a23aeb92
                      request_id:
                        type: string
                        description: Client-supplied idempotency key for the cancellation.
                      status:
                        type: string
                        description: >
                          Lifecycle of the cancellation.
                          `PAYMENT_CANCEL_CREATED` is the pending state
                          (including while a camt.029 diagnostic has been
                          received but no terminal rail result has arrived); it
                          resolves to `PAYMENT_CANCEL_ACCEPTED` or
                          `PAYMENT_CANCEL_REJECTED`.
                        enum:
                          - PAYMENT_CANCEL_CREATED
                          - PAYMENT_CANCEL_ACCEPTED
                          - PAYMENT_CANCEL_REJECTED
                      reason:
                        type: string
                        description: Public reason supplied for the cancellation.
                      additional_info:
                        type: string
                        description: Free-text context supplied with the cancellation.
                      iso_reason:
                        type: string
                        description: Exact camt.055 cancellation reason code sent to Raast.
                      iso_status:
                        type: string
                        description: >-
                          Exact camt.029 investigation status (CNCL, RJCR, or
                          PDCR); empty until received.
                      iso_status_reason:
                        type: string
                        description: >-
                          Reason code accompanying the camt.029 status, when
                          present.
                      iso_status_additional_info:
                        type: string
                        description: >-
                          Additional information accompanying the camt.029
                          status, when present.
                      dispatch_error:
                        type: string
                        description: >-
                          Populated when an admi.002 rejects the outgoing
                          camt.055 message.
                      resolved_at:
                        type: string
                        format: date-time
                        nullable: true
                        description: When the cancellation reached a terminal status.
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
          examples:
            CancellationRequested:
              value:
                api_version: v1
                data:
                  token: pc_3b2a1c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d
                  payment_id: pm_96bc0ef4-7857-47fb-a345-c411a23aeb92
                  request_id: f0a3b1c2-8d4e-4f6a-9b1c-2d3e4f5a6b7c
                  status: PAYMENT_CANCEL_CREATED
                  reason: PAYMENT_CANCEL_REASON_CUSTOMER_REQUEST
                  additional_info: Customer requested cancellation
                  iso_reason: CUST
                  iso_status: ''
                  created_at: '2025-06-26T10:58:17Z'
                  updated_at: '2025-06-26T10:58:17Z'
    BadRequest:
      description: Bad request
      headers:
        Content-Length:
          $ref: '#/components/headers/ContentLengthHeader'
        Date:
          $ref: '#/components/headers/DateHeader'
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/ErrorResponse'
              - type: object
                properties:
                  code:
                    example: error.bad_request
                  message:
                    example: Invalid request parameters
    Unauthorized:
      description: Unauthorized
      headers:
        Content-Length:
          $ref: '#/components/headers/ContentLengthHeader'
        Date:
          $ref: '#/components/headers/DateHeader'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiErrorEnvelope'
          examples:
            Unauthorized:
              value:
                api_version: v1
                error:
                  code: error.unauthorized_access
                  message: partner access key is required in request header
    NotFound:
      description: Resource not found
      headers:
        Content-Length:
          $ref: '#/components/headers/ContentLengthHeader'
        Date:
          $ref: '#/components/headers/DateHeader'
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/ErrorResponse'
              - type: object
                properties:
                  code:
                    example: error.not_found
                  message:
                    example: Requested resource not found
    InternalError:
      description: Internal server error response
      headers:
        Content-Length:
          $ref: '#/components/headers/ContentLengthHeader'
        Date:
          $ref: '#/components/headers/DateHeader'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiErrorEnvelope'
          examples:
            InternalServerError:
              value:
                api_version: v1
                error:
                  code: error.internal_server_error
                  message: rpc error code Internal desc = something went wrong
  headers:
    ContentLengthHeader:
      schema:
        type: string
        example: '256'
    DateHeader:
      schema:
        type: string
        example: Sat, 12 Aug 2023 08:55:04 GMT
  schemas:
    StandardResponse:
      type: object
      description: Standard response structure for successful operations
      properties:
        api_version:
          type: string
          example: v1
          description: The current version of the API spec
        data:
          type: object
          description: Contains the response data
    ErrorResponse:
      type: object
      description: Standard error response structure
      properties:
        code:
          type: string
          description: Error code identifying the type of error
        message:
          type: string
          description: Human-readable error message
    ApiErrorEnvelope:
      type: object
      description: Error wrapper that includes the API version and error metadata
      properties:
        api_version:
          type: string
          description: Indicates the API version associated with the response
          example: v1
        error:
          description: Structured error details describing why the request failed
          allOf:
            - $ref: '#/components/schemas/ErrorResponse'
          example:
            code: error.unauthorized_access
            message: partner access key is required in request header
  securitySchemes:
    apiKey:
      type: apiKey
      name: X-SFPY-AGGREGATOR-SECRET-KEY
      in: header

````

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