{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/methodfi/main/json-schema/methodfi-payment-reversal-list-response-schema.json",
  "title": "PaymentReversalListResponse",
  "x-generated": "2026-10-12",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/methodfi-payment-reversals-api-openapi.yml#/components/schemas/PaymentReversalListResponse",
  "allOf": [
    {
      "$ref": "#/$defs/ListEnvelope"
    },
    {
      "type": "object",
      "properties": {
        "data": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/PaymentReversal"
          }
        }
      }
    }
  ],
  "$defs": {
    "ListEnvelope": {
      "type": "object",
      "description": "Standard envelope for successful responses that return a list payload.",
      "required": [
        "success",
        "data",
        "message"
      ],
      "properties": {
        "success": {
          "type": "boolean",
          "description": "Always `true` for successful responses."
        },
        "data": {
          "description": "Operation-specific list payload."
        },
        "message": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "PaymentReversal": {
      "type": "object",
      "description": "A reversal for a payment, representing a return of funds.",
      "required": [
        "id",
        "pmt_id",
        "status",
        "direction",
        "trace_id",
        "target_account",
        "amount",
        "description",
        "fee",
        "created_at",
        "updated_at"
      ],
      "properties": {
        "id": {
          "type": "string",
          "description": "Unique identifier for the reversal.",
          "pattern": "^rvs_\\w+$"
        },
        "pmt_id": {
          "type": "string",
          "description": "Identifier of the payment being reversed.",
          "pattern": "^pmt_\\w+$"
        },
        "status": {
          "type": "string",
          "description": "Current status of the reversal.",
          "enum": [
            "pending_approval",
            "pending",
            "processing",
            "failed",
            "sent",
            "pending_settlement"
          ]
        },
        "direction": {
          "type": "string",
          "description": "Direction of the reversal relative to the original payment.",
          "enum": [
            "credit",
            "debit"
          ]
        },
        "trace_id": {
          "type": [
            "string",
            "null"
          ],
          "description": "Trace identifier for the reversal."
        },
        "target_account": {
          "type": [
            "string",
            "null"
          ],
          "description": "The target account for the reversal."
        },
        "amount": {
          "type": "integer",
          "description": "Reversal amount in cents.",
          "minimum": 0
        },
        "description": {
          "type": [
            "string",
            "null"
          ],
          "description": "Human-readable description for the reversal."
        },
        "fee": {
          "type": [
            "object",
            "null"
          ],
          "description": "Fee information for the reversal."
        },
        "error": {
          "$ref": "#/$defs/PaymentReversalResourceError"
        },
        "created_at": {
          "type": "string",
          "format": "date-time",
          "description": "Timestamp when the reversal was created."
        },
        "updated_at": {
          "type": "string",
          "format": "date-time",
          "description": "Timestamp when the reversal was last updated."
        }
      }
    },
    "PaymentReversalResourceError": {
      "type": [
        "object",
        "null"
      ],
      "description": "Error details when a payment reversal fails.",
      "required": [
        "type",
        "code",
        "sub_type",
        "message"
      ],
      "properties": {
        "type": {
          "type": "string",
          "description": "The category of reversal error.",
          "enum": [
            "PAYMENT_REVERSAL_FAILED"
          ]
        },
        "code": {
          "type": "integer",
          "description": "Numeric error code (14XXX range).",
          "enum": [
            14001,
            14002,
            14003
          ]
        },
        "sub_type": {
          "type": "string",
          "description": "Specific reversal error classification.",
          "enum": [
            "PAYMENT_REVERSAL_INSUFFICIENT_FUNDS",
            "PAYMENT_REVERSAL_UNAUTHORIZED",
            "PAYMENT_REVERSAL_INVALID_ACCOUNT"
          ]
        },
        "message": {
          "type": "string",
          "description": "Human-readable error description."
        }
      }
    }
  }
}