# Create reversal

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /v1/reversal:
    post:
      summary: Create reversal
      deprecated: false
      description: >
        Creates a reversal transaction that negates the financial effect of a
        previously posted transaction.

        This endpoint is used when an original transaction (for example: refund,
        fund, or payout) must be cancelled

        or undone due to rejection, failure, or post-processing validation.


        The reversal does not delete the original transaction. Instead, it
        creates a new transaction of type REVERSAL

        that mirrors the original transaction’s amount and currency, while
        inverting the debit and credit legs

        according to the original transaction type.


        Each reversal can optionally reference the original transaction (by ID
        or external reference) to ensure full

        auditability, ledger traceability, and regulatory compliance.


        Provide either original_transaction_id or
        original_transaction_external_reference (not both).


        ### Reversal Behavior by Transaction Type

        | Original Transaction Type | Reversal Effect |

        | ---- | ------------------------------ |

        | Refund | Debits the refunded amount back from the recipient |

        | Fund | Credits the amount back to the source (business) wallet |

        | Payout | Credits the business and debits the wallet |

        | Transfer | Credits the sender and debits the receiver |

        | Withdrawal | Credits the wallet/business and debits the "World" or
        Clearing wallet |

        | Any supported type | Debit and credit legs are inverted |


        ### Balance Handling

        - If canOverdraft = true, the reversal may cause the wallet balance to
        go negative.

        - If canOverdraft = false and the wallet lacks sufficient balance, the
        reversal is rejected with INSUFFICIENT_BALANCE.
      operationId: create-reversal
      tags:
        - Vrtx Closed loop/Money Movement
        - Money Movement
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReversalCreatePayload'
            examples:
              ReversalCreatePayload:
                value:
                  original_transaction_id: da6d857d-0bbf-411d-9902-ec90e0e92963
                  external_reference: REV-1
                  notes: Refund invoice rejected from ZATCA
                summary: ReversalCreatePayload
              ReversalCreatePayloadByExternalReference:
                value:
                  original_transaction_external_reference: ref-123
                  external_reference: REV-1
                  notes: Refund invoice rejected from ZATCA
                summary: ReversalCreatePayloadByExternalReference
      responses:
        '200':
          description: Reversal created
          content:
            application/json:
              schema:
                type: object
                x-apidog-orders: []
                properties: {}
                x-apidog-ignore-properties: []
              examples:
                ReversalResponse:
                  summary: ReversalResponse
                  value:
                    id: 4e0f5b1f-c449-4083-a408-bfe1355a3b6b
                    total_reversed_amount: '10.00'
                    currency: SAR
                    original_transaction_id: b6327558-741e-411c-866b-0eec8ea26005
                    original_transaction_amount: '10.00'
                    original_transaction_reference: PO-0013579
                    sender_account_number: '054200002027'
                    receiver_account_number: '054200001011'
                    external_reference: REV-1
                    notes: Refund invoice rejected from ZATCA
                    status: SUCCESS
                    created_at: '2025-10-25T14:35:46.011Z'
          headers: {}
          x-apidog-name: OK
        '400':
          description: Bad Request
          content:
            application/json:
              schema: &ref_0
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                BadRequest:
                  summary: BadRequest
                  value:
                    error_code: INVALID_INPUT
                    error_message: Input parameters failed validation
                    details:
                      - field: amount
                        message: amount must be greater than zero
                        code: out_of_range
                    status_code: 400
          headers: {}
          x-apidog-name: Bad Request
        '401':
          description: Not Authorized
          content:
            application/json:
              schema: *ref_0
              examples:
                Unauthorized:
                  summary: Unauthorized
                  value:
                    error_code: UNAUTHORIZED_ACCESS
                    error_message: You are not authorized to access this resource.
                    details:
                      - field: authorization
                        message: Valid Bearer token required
                        code: unauthorized_access
                    status_code: 401
          headers: {}
          x-apidog-name: Unauthorized
        '403':
          description: Not Allowed
          content:
            application/json:
              schema: *ref_0
              examples:
                Forbidden:
                  summary: Forbidden
                  value:
                    error_code: FORBIDDEN
                    error_message: Forbidden
                    details:
                      - field: authorization
                        message: Insufficient permissions to access this resource
                        code: forbidden
                    status_code: 403
          headers: {}
          x-apidog-name: Forbidden
        '404':
          description: Wallet not found
          content:
            application/json:
              schema: *ref_0
              examples:
                WalletNotFound:
                  summary: WalletNotFound
                  value:
                    error_code: WALLET_NOT_FOUND
                    error_message: Wallet not found
                    details:
                      - field: resource
                        message: Wallet with the specified ID was not found
                        code: WALLET_NOT_FOUND
                    status_code: 404
          headers: {}
          x-apidog-name: Not Found
        '422':
          description: Insufficient balance
          content:
            application/json:
              schema: *ref_0
              examples:
                InsufficientBalance:
                  summary: InsufficientBalance
                  value:
                    error_code: INSUFFICIENT_BALANCE
                    error_message: Insufficient balance
                    details:
                      - field: amount
                        message: >-
                          The wallet does not have sufficient balance for this
                          reversal
                        code: INSUFFICIENT_BALANCE
                    status_code: 422
          headers: {}
          x-apidog-name: Unprocessable Entity
      security:
        - bearerAuth3: []
          x-apidog:
            schemeGroups:
              - id: pVt2TQJS2pmrhhZgWEJcK
                schemeIds:
                  - bearerAuth3
            required: true
            use:
              id: pVt2TQJS2pmrhhZgWEJcK
            scopes:
              pVt2TQJS2pmrhhZgWEJcK:
                bearerAuth3: []
      x-apidog-folder: Vrtx Closed loop/Money Movement
      x-apidog-status: released
      x-run-in-apidog: https://app.apidog.com/web/project/1053095/apis/api-26255317-run
components:
  schemas:
    ReversalCreatePayload:
      type: object
      description: >-
        API payload for requesting a reversal. Provide either
        original_transaction_id or original_transaction_external_reference.
      properties:
        original_transaction_id:
          examples:
            - 3f2c8d35-d1e4-4dc1-90b5-3ea9fca8c1d7
          description: Original transaction identifier that will be reversed
          anyOf:
            - $ref: '#/components/schemas/UUID'
            - type: 'null'
        original_transaction_external_reference:
          type: string
          examples:
            - PO-0013579
          maxLength: 64
          description: Original transaction external reference
          nullable: true
        external_reference:
          type: string
          examples:
            - REV-1
          maxLength: 64
          description: External reference
          nullable: true
        notes:
          type: string
          examples:
            - Refund invoice rejected from ZATCA
          maxLength: 512
          description: Additional notes
          nullable: true
      x-apidog-orders:
        - original_transaction_id
        - original_transaction_external_reference
        - external_reference
        - notes
      x-apidog-ignore-properties: []
      x-apidog-folder: ''
    UUID:
      type: string
      format: uuid
      pattern: >-
        [a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}
      x-apidog-folder: ''
    ErrorResponse:
      type: object
      properties:
        error_code:
          type: string
        error_message:
          type: string
        details:
          type: array
          items:
            $ref: '#/components/schemas/ErrorDetail'
        status_code:
          type: integer
          format: int32
      x-apidog-orders:
        - error_code
        - error_message
        - details
        - status_code
      x-apidog-ignore-properties: []
      x-apidog-folder: ''
    ErrorDetail:
      type: object
      properties:
        field:
          type: string
        message:
          type: string
        code:
          type: string
      x-apidog-orders:
        - field
        - message
        - code
      x-apidog-ignore-properties: []
      x-apidog-folder: ''
  securitySchemes:
    bearerAuth:
      type: jwt
      scheme: bearer
      bearerFormat: JWT
      description: Enter your JWT access token for authentication
    bearerAuth1:
      type: jwt
      scheme: bearer
      bearerFormat: JWT
    bearerAuth2:
      type: jwt
      scheme: bearer
      bearerFormat: JWT
      description: Enter your JWT access token for authentication
    bearerAuth3:
      type: jwt
      scheme: bearer
      bearerFormat: JWT
      description: >-
        JWT issued by Keycloak. The client_id/azp in the token must map to a
        configured tenant (public, fai, neomrs; e.g., fai-sandbox -> fai) or
        requests will return 403.
    bearerAuth4:
      type: jwt
      scheme: bearer
      bearerFormat: JWT
      description: Enter your JWT access token for authentication
    bearer:
      type: http
      scheme: bearer
servers:
  - url: https://api.sandbox.vrtx.sa
    description: Sandbox
security:
  - bearer: []

```
