{
  "components": {
    "schemas": {
      "Balance": {
        "additionalProperties": false,
        "properties": {
          "balances": {
            "items": {
              "additionalProperties": false,
              "properties": {
                "activity_totals": {
                  "additionalProperties": {
                    "description": "Minor units as a decimal string (exact at any size)",
                    "example": "10050",
                    "pattern": "^-?[0-9]+$",
                    "type": "string"
                  },
                  "propertyNames": {
                    "type": "string"
                  },
                  "type": "object"
                },
                "currency": {
                  "description": "ISO 4217 currency code, upper case",
                  "example": "SAR",
                  "pattern": "^[A-Z]{3}$",
                  "type": "string"
                },
                "figures_as_of": {
                  "example": "2026-11-08T12:00:00.000Z",
                  "format": "date-time",
                  "type": "string"
                },
                "operational": {
                  "additionalProperties": {
                    "description": "Minor units as a decimal string (exact at any size)",
                    "example": "10050",
                    "pattern": "^-?[0-9]+$",
                    "type": "string"
                  },
                  "propertyNames": {
                    "type": "string"
                  },
                  "type": "object"
                },
                "pending_adjustments": {
                  "additionalProperties": false,
                  "properties": {
                    "fee_recovery_pending": {
                      "additionalProperties": false,
                      "properties": {
                        "amount": {
                          "description": "Minor units as a decimal string (exact at any size)",
                          "example": "10050",
                          "pattern": "^-?[0-9]+$",
                          "type": "string"
                        },
                        "count": {
                          "maximum": 9007199254740991,
                          "minimum": -9007199254740991,
                          "type": "integer"
                        }
                      },
                      "required": [
                        "count",
                        "amount"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "fee_recovery_pending"
                  ],
                  "type": "object"
                },
                "positions": {
                  "additionalProperties": {
                    "description": "Minor units as a decimal string (exact at any size)",
                    "example": "10050",
                    "pattern": "^-?[0-9]+$",
                    "type": "string"
                  },
                  "propertyNames": {
                    "type": "string"
                  },
                  "type": "object"
                }
              },
              "required": [
                "currency",
                "figures_as_of",
                "positions",
                "activity_totals",
                "operational",
                "pending_adjustments"
              ],
              "type": "object"
            },
            "type": "array"
          }
        },
        "required": [
          "balances"
        ],
        "type": "object"
      },
      "CheckoutLink": {
        "additionalProperties": false,
        "properties": {
          "expires_at": {
            "anyOf": [
              {
                "example": "2026-11-08T12:00:00.000Z",
                "format": "date-time",
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "id": {
            "type": "string"
          },
          "url": {
            "description": "Send the customer here (the hosted payment page)",
            "type": "string"
          }
        },
        "required": [
          "id",
          "url",
          "expires_at"
        ],
        "type": "object"
      },
      "ClientSecret": {
        "additionalProperties": false,
        "properties": {
          "client_secret": {
            "description": "For your own checkout page in the browser; never log it",
            "type": "string"
          },
          "expires_at": {
            "example": "2026-11-08T12:00:00.000Z",
            "format": "date-time",
            "type": "string"
          }
        },
        "required": [
          "client_secret",
          "expires_at"
        ],
        "type": "object"
      },
      "CreateCheckoutLinkRequest": {
        "additionalProperties": false,
        "properties": {
          "return_url": {
            "description": "Where the customer returns after paying",
            "maxLength": 2048,
            "minLength": 1,
            "type": "string"
          }
        },
        "required": [
          "return_url"
        ],
        "type": "object"
      },
      "CreatePaymentRequest": {
        "additionalProperties": false,
        "properties": {
          "amount": {
            "description": "In the minor unit of the currency (1050 = 10.50 SAR)",
            "type": "number"
          },
          "capture_method": {
            "default": "automatic",
            "description": "Only 'automatic' today (authorize and capture at once)",
            "enum": [
              "automatic",
              "manual"
            ],
            "type": "string"
          },
          "currency": {
            "description": "ISO 4217 currency code, upper case",
            "example": "SAR",
            "pattern": "^[A-Z]{3}$",
            "type": "string"
          },
          "customer_reference": {
            "maxLength": 255,
            "minLength": 1,
            "type": "string"
          },
          "description": {
            "maxLength": 1000,
            "minLength": 1,
            "type": "string"
          },
          "expires_in_seconds": {
            "default": 86400,
            "description": "How long the payment can be paid",
            "maximum": 604800,
            "minimum": 300,
            "type": "integer"
          },
          "merchant_reference": {
            "description": "Your order number; searchable with GET /v1/payments",
            "maxLength": 255,
            "minLength": 1,
            "type": "string"
          },
          "metadata": {
            "additionalProperties": {},
            "default": {},
            "description": "Your own key-value data, returned as sent (at most 8 KB as JSON)",
            "propertyNames": {
              "type": "string"
            },
            "type": "object"
          }
        },
        "required": [
          "amount",
          "currency"
        ],
        "type": "object"
      },
      "CreateRefundRequest": {
        "additionalProperties": false,
        "properties": {
          "amount": {
            "description": "In the minor unit; at most what is left to refund",
            "exclusiveMinimum": 0,
            "maximum": 9007199254740991,
            "type": "integer"
          },
          "metadata": {
            "additionalProperties": {},
            "description": "Your own key-value data, returned as sent (at most 8 KB as JSON)",
            "propertyNames": {
              "type": "string"
            },
            "type": "object"
          },
          "reason": {
            "maxLength": 500,
            "type": "string"
          }
        },
        "required": [
          "amount"
        ],
        "type": "object"
      },
      "CreateWebhookEndpointRequest": {
        "additionalProperties": false,
        "properties": {
          "description": {
            "maxLength": 200,
            "type": "string"
          },
          "enabled_events": {
            "description": "'*', a family such as 'payment.*', or exact types; all events unless given",
            "items": {
              "maxLength": 64,
              "minLength": 1,
              "type": "string"
            },
            "maxItems": 32,
            "type": "array"
          },
          "url": {
            "description": "https URL on the public internet",
            "maxLength": 2048,
            "minLength": 1,
            "type": "string"
          }
        },
        "required": [
          "url"
        ],
        "type": "object"
      },
      "Error": {
        "additionalProperties": false,
        "properties": {
          "error": {
            "additionalProperties": false,
            "properties": {
              "code": {
                "description": "Stable machine-readable code (see Errors)",
                "type": "string"
              },
              "details": {
                "additionalProperties": {},
                "propertyNames": {
                  "type": "string"
                },
                "type": "object"
              },
              "message": {
                "type": "string"
              },
              "request_id": {
                "description": "Quote it to support",
                "type": "string"
              }
            },
            "required": [
              "code",
              "message",
              "request_id"
            ],
            "type": "object"
          }
        },
        "required": [
          "error"
        ],
        "type": "object"
      },
      "FeeList": {
        "additionalProperties": false,
        "properties": {
          "fees": {
            "items": {
              "additionalProperties": false,
              "properties": {
                "assessed_at": {
                  "example": "2026-11-08T12:00:00.000Z",
                  "format": "date-time",
                  "type": "string"
                },
                "base_minor": {
                  "description": "Minor units as a decimal string (exact at any size)",
                  "example": "10050",
                  "pattern": "^-?[0-9]+$",
                  "type": "string"
                },
                "currency": {
                  "description": "ISO 4217 currency code, upper case",
                  "example": "SAR",
                  "pattern": "^[A-Z]{3}$",
                  "type": "string"
                },
                "gross_minor": {
                  "description": "Minor units as a decimal string (exact at any size)",
                  "example": "10050",
                  "pattern": "^-?[0-9]+$",
                  "type": "string"
                },
                "id": {
                  "type": "string"
                },
                "is_adjustment": {
                  "type": "boolean"
                },
                "tax_minor": {
                  "description": "Minor units as a decimal string (exact at any size)",
                  "example": "10050",
                  "pattern": "^-?[0-9]+$",
                  "type": "string"
                }
              },
              "required": [
                "id",
                "currency",
                "base_minor",
                "tax_minor",
                "gross_minor",
                "is_adjustment",
                "assessed_at"
              ],
              "type": "object"
            },
            "type": "array"
          }
        },
        "required": [
          "fees"
        ],
        "type": "object"
      },
      "Merchant": {
        "additionalProperties": false,
        "properties": {
          "country": {
            "type": "string"
          },
          "created_at": {
            "example": "2026-11-08T12:00:00.000Z",
            "format": "date-time",
            "type": "string"
          },
          "default_currency": {
            "type": "string"
          },
          "environment": {
            "description": "The environment of the API key used",
            "enum": [
              "test",
              "live"
            ],
            "type": "string"
          },
          "external_reference": {
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "example": "mer_01M5A9ME06FNJWN910V1Q0XRQZ",
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "status": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "status",
          "country",
          "default_currency",
          "external_reference",
          "environment",
          "created_at"
        ],
        "type": "object"
      },
      "Payment": {
        "additionalProperties": false,
        "properties": {
          "amount": {
            "description": "Amount in the minor unit of the currency (e.g. halalas: 1050 = 10.50 SAR)",
            "maximum": 9007199254740991,
            "minimum": -9007199254740991,
            "type": "integer"
          },
          "amount_authorized": {
            "description": "Amount in the minor unit of the currency (e.g. halalas: 1050 = 10.50 SAR)",
            "maximum": 9007199254740991,
            "minimum": -9007199254740991,
            "type": "integer"
          },
          "amount_captured": {
            "description": "Amount in the minor unit of the currency (e.g. halalas: 1050 = 10.50 SAR)",
            "maximum": 9007199254740991,
            "minimum": -9007199254740991,
            "type": "integer"
          },
          "amount_refunded": {
            "description": "Amount in the minor unit of the currency (e.g. halalas: 1050 = 10.50 SAR)",
            "maximum": 9007199254740991,
            "minimum": -9007199254740991,
            "type": "integer"
          },
          "capture_method": {
            "enum": [
              "automatic",
              "manual"
            ],
            "type": "string"
          },
          "created_at": {
            "example": "2026-11-08T12:00:00.000Z",
            "format": "date-time",
            "type": "string"
          },
          "currency": {
            "description": "ISO 4217 currency code, upper case",
            "example": "SAR",
            "pattern": "^[A-Z]{3}$",
            "type": "string"
          },
          "customer_reference": {
            "type": [
              "string",
              "null"
            ]
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "environment": {
            "enum": [
              "test",
              "live"
            ],
            "type": "string"
          },
          "expires_at": {
            "anyOf": [
              {
                "example": "2026-11-08T12:00:00.000Z",
                "format": "date-time",
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "id": {
            "example": "pay_01M6XF0H2MAC63MEKQAT4K3AXF",
            "pattern": "^pay_[0-9A-HJKMNP-TV-Z]{26}$",
            "type": "string"
          },
          "merchant_reference": {
            "type": [
              "string",
              "null"
            ]
          },
          "metadata": {
            "additionalProperties": {},
            "description": "Your own key-value data, returned as sent (at most 8 KB as JSON)",
            "propertyNames": {
              "type": "string"
            },
            "type": "object"
          },
          "status": {
            "enum": [
              "CREATED",
              "REQUIRES_PAYMENT_METHOD",
              "REQUIRES_ACTION",
              "PROCESSING",
              "AUTHORIZED",
              "CAPTURED",
              "SUCCEEDED",
              "FAILED",
              "CANCELED",
              "EXPIRED",
              "PARTIALLY_REFUNDED",
              "REFUNDED"
            ],
            "type": "string"
          }
        },
        "required": [
          "id",
          "status",
          "amount",
          "currency",
          "environment",
          "capture_method",
          "amount_authorized",
          "amount_captured",
          "amount_refunded",
          "description",
          "merchant_reference",
          "customer_reference",
          "metadata",
          "created_at",
          "expires_at"
        ],
        "type": "object"
      },
      "PaymentEvents": {
        "additionalProperties": false,
        "properties": {
          "data": {
            "items": {
              "additionalProperties": false,
              "properties": {
                "data": {
                  "additionalProperties": {},
                  "propertyNames": {
                    "type": "string"
                  },
                  "type": "object"
                },
                "occurred_at": {
                  "example": "2026-11-08T12:00:00.000Z",
                  "format": "date-time",
                  "type": "string"
                },
                "type": {
                  "example": "payment.succeeded",
                  "type": "string"
                }
              },
              "required": [
                "type",
                "data",
                "occurred_at"
              ],
              "type": "object"
            },
            "type": "array"
          }
        },
        "required": [
          "data"
        ],
        "type": "object"
      },
      "PaymentList": {
        "additionalProperties": false,
        "properties": {
          "data": {
            "items": {
              "$ref": "#/components/schemas/Payment"
            },
            "type": "array"
          }
        },
        "required": [
          "data"
        ],
        "type": "object"
      },
      "PayoutList": {
        "additionalProperties": false,
        "properties": {
          "payouts": {
            "items": {
              "additionalProperties": false,
              "properties": {
                "amount_minor": {
                  "description": "Minor units as a decimal string (exact at any size)",
                  "example": "10050",
                  "pattern": "^-?[0-9]+$",
                  "type": "string"
                },
                "created_at": {
                  "example": "2026-11-08T12:00:00.000Z",
                  "format": "date-time",
                  "type": "string"
                },
                "currency": {
                  "description": "ISO 4217 currency code, upper case",
                  "example": "SAR",
                  "pattern": "^[A-Z]{3}$",
                  "type": "string"
                },
                "id": {
                  "type": "string"
                },
                "status": {
                  "description": "COMPLETED: it left our account (not: it arrived in yours)",
                  "enum": [
                    "PENDING",
                    "PROCESSING",
                    "COMPLETED",
                    "FAILED",
                    "CANCELED"
                  ],
                  "type": "string"
                }
              },
              "required": [
                "id",
                "currency",
                "amount_minor",
                "status",
                "created_at"
              ],
              "type": "object"
            },
            "type": "array"
          }
        },
        "required": [
          "payouts"
        ],
        "type": "object"
      },
      "Refund": {
        "additionalProperties": false,
        "properties": {
          "amount": {
            "description": "Amount in the minor unit of the currency (e.g. halalas: 1050 = 10.50 SAR)",
            "maximum": 9007199254740991,
            "minimum": -9007199254740991,
            "type": "integer"
          },
          "created_at": {
            "example": "2026-11-08T12:00:00.000Z",
            "format": "date-time",
            "type": "string"
          },
          "currency": {
            "description": "ISO 4217 currency code, upper case",
            "example": "SAR",
            "pattern": "^[A-Z]{3}$",
            "type": "string"
          },
          "failure_code": {
            "type": [
              "string",
              "null"
            ]
          },
          "failure_message": {
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "example": "ref_01M6XF0H2MAC63MEKQAT4K3AXF",
            "type": "string"
          },
          "metadata": {
            "additionalProperties": {},
            "description": "Your own key-value data, returned as sent (at most 8 KB as JSON)",
            "propertyNames": {
              "type": "string"
            },
            "type": "object"
          },
          "object": {
            "const": "refund",
            "type": "string"
          },
          "payment_id": {
            "example": "pay_01M6XF0H2MAC63MEKQAT4K3AXF",
            "pattern": "^pay_[0-9A-HJKMNP-TV-Z]{26}$",
            "type": "string"
          },
          "reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "enum": [
              "PENDING",
              "PROCESSING",
              "SUCCEEDED",
              "FAILED",
              "CANCELED"
            ],
            "type": "string"
          }
        },
        "required": [
          "id",
          "object",
          "payment_id",
          "amount",
          "currency",
          "status",
          "reason",
          "failure_code",
          "failure_message",
          "metadata",
          "created_at"
        ],
        "type": "object"
      },
      "RefundList": {
        "items": {
          "$ref": "#/components/schemas/Refund"
        },
        "type": "array"
      },
      "SettlementList": {
        "additionalProperties": false,
        "properties": {
          "settlements": {
            "items": {
              "additionalProperties": false,
              "properties": {
                "currency": {
                  "description": "ISO 4217 currency code, upper case",
                  "example": "SAR",
                  "pattern": "^[A-Z]{3}$",
                  "type": "string"
                },
                "id": {
                  "type": "string"
                },
                "net_entitlement_minor": {
                  "description": "Minor units as a decimal string (exact at any size)",
                  "example": "10050",
                  "pattern": "^-?[0-9]+$",
                  "type": "string"
                },
                "period_end": {
                  "example": "2026-11-01",
                  "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                  "type": "string"
                },
                "period_start": {
                  "example": "2026-11-01",
                  "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                  "type": "string"
                },
                "status": {
                  "enum": [
                    "PENDING",
                    "SETTLED",
                    "REVISED"
                  ],
                  "type": "string"
                }
              },
              "required": [
                "id",
                "currency",
                "period_start",
                "period_end",
                "net_entitlement_minor",
                "status"
              ],
              "type": "object"
            },
            "type": "array"
          }
        },
        "required": [
          "settlements"
        ],
        "type": "object"
      },
      "Statement": {
        "additionalProperties": false,
        "properties": {
          "closing_positions": {
            "additionalProperties": {},
            "propertyNames": {
              "type": "string"
            },
            "type": "object"
          },
          "currency": {
            "description": "ISO 4217 currency code, upper case",
            "example": "SAR",
            "pattern": "^[A-Z]{3}$",
            "type": "string"
          },
          "entries": {
            "items": {
              "additionalProperties": false,
              "properties": {
                "amount_minor": {
                  "description": "Minor units as a decimal string (exact at any size)",
                  "example": "10050",
                  "pattern": "^-?[0-9]+$",
                  "type": "string"
                },
                "currency": {
                  "description": "ISO 4217 currency code, upper case",
                  "example": "SAR",
                  "pattern": "^[A-Z]{3}$",
                  "type": "string"
                },
                "date": {
                  "example": "2026-11-01",
                  "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                  "type": "string"
                },
                "description": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "id": {
                  "type": "string"
                },
                "order": {
                  "maximum": 9007199254740991,
                  "minimum": -9007199254740991,
                  "type": "integer"
                },
                "prior_period_correction": {
                  "type": "boolean"
                },
                "status": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              },
              "required": [
                "id",
                "order",
                "date",
                "description",
                "amount_minor",
                "currency",
                "status",
                "prior_period_correction"
              ],
              "type": "object"
            },
            "type": "array"
          },
          "figures_as_of": {
            "example": "2026-11-08T12:00:00.000Z",
            "format": "date-time",
            "type": "string"
          },
          "id": {
            "type": "string"
          },
          "opening_positions": {
            "additionalProperties": {},
            "propertyNames": {
              "type": "string"
            },
            "type": "object"
          },
          "operational": {
            "additionalProperties": {},
            "propertyNames": {
              "type": "string"
            },
            "type": "object"
          },
          "period_activity": {
            "additionalProperties": {},
            "propertyNames": {
              "type": "string"
            },
            "type": "object"
          },
          "period_end": {
            "example": "2026-11-01",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "type": "string"
          },
          "period_start": {
            "example": "2026-11-01",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "type": "string"
          },
          "status": {
            "enum": [
              "GENERATING",
              "ISSUED",
              "SUPERSEDED"
            ],
            "type": "string"
          },
          "version": {
            "maximum": 9007199254740991,
            "minimum": -9007199254740991,
            "type": "integer"
          }
        },
        "required": [
          "id",
          "currency",
          "period_start",
          "period_end",
          "version",
          "status",
          "figures_as_of",
          "opening_positions",
          "closing_positions",
          "period_activity",
          "operational",
          "entries"
        ],
        "type": "object"
      },
      "StatementList": {
        "additionalProperties": false,
        "properties": {
          "statements": {
            "items": {
              "additionalProperties": false,
              "properties": {
                "closing_positions": {
                  "additionalProperties": {},
                  "propertyNames": {
                    "type": "string"
                  },
                  "type": "object"
                },
                "currency": {
                  "description": "ISO 4217 currency code, upper case",
                  "example": "SAR",
                  "pattern": "^[A-Z]{3}$",
                  "type": "string"
                },
                "figures_as_of": {
                  "example": "2026-11-08T12:00:00.000Z",
                  "format": "date-time",
                  "type": "string"
                },
                "id": {
                  "type": "string"
                },
                "opening_positions": {
                  "additionalProperties": {},
                  "propertyNames": {
                    "type": "string"
                  },
                  "type": "object"
                },
                "period_end": {
                  "example": "2026-11-01",
                  "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                  "type": "string"
                },
                "period_start": {
                  "example": "2026-11-01",
                  "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                  "type": "string"
                },
                "status": {
                  "enum": [
                    "GENERATING",
                    "ISSUED",
                    "SUPERSEDED"
                  ],
                  "type": "string"
                },
                "version": {
                  "maximum": 9007199254740991,
                  "minimum": -9007199254740991,
                  "type": "integer"
                }
              },
              "required": [
                "id",
                "currency",
                "period_start",
                "period_end",
                "version",
                "status",
                "figures_as_of",
                "opening_positions",
                "closing_positions"
              ],
              "type": "object"
            },
            "type": "array"
          }
        },
        "required": [
          "statements"
        ],
        "type": "object"
      },
      "Void": {
        "additionalProperties": false,
        "properties": {
          "created_at": {
            "example": "2026-11-08T12:00:00.000Z",
            "format": "date-time",
            "type": "string"
          },
          "failure_code": {
            "type": [
              "string",
              "null"
            ]
          },
          "failure_message": {
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "type": "string"
          },
          "metadata": {
            "additionalProperties": {},
            "description": "Your own key-value data, returned as sent (at most 8 KB as JSON)",
            "propertyNames": {
              "type": "string"
            },
            "type": "object"
          },
          "object": {
            "const": "void",
            "type": "string"
          },
          "payment_id": {
            "example": "pay_01M6XF0H2MAC63MEKQAT4K3AXF",
            "pattern": "^pay_[0-9A-HJKMNP-TV-Z]{26}$",
            "type": "string"
          },
          "reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "enum": [
              "PENDING",
              "PROCESSING",
              "SUCCEEDED",
              "FAILED"
            ],
            "type": "string"
          }
        },
        "required": [
          "id",
          "object",
          "payment_id",
          "status",
          "reason",
          "failure_code",
          "failure_message",
          "metadata",
          "created_at"
        ],
        "type": "object"
      },
      "WebhookDeliveryList": {
        "additionalProperties": false,
        "properties": {
          "data": {
            "items": {
              "additionalProperties": false,
              "properties": {
                "attempts": {
                  "maximum": 9007199254740991,
                  "minimum": -9007199254740991,
                  "type": "integer"
                },
                "created_at": {
                  "example": "2026-11-08T12:00:00.000Z",
                  "format": "date-time",
                  "type": "string"
                },
                "delivered_at": {
                  "anyOf": [
                    {
                      "example": "2026-11-08T12:00:00.000Z",
                      "format": "date-time",
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "event_id": {
                  "type": "string"
                },
                "event_type": {
                  "type": "string"
                },
                "id": {
                  "type": "string"
                },
                "last_error": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "last_http_status": {
                  "anyOf": [
                    {
                      "maximum": 9007199254740991,
                      "minimum": -9007199254740991,
                      "type": "integer"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "next_attempt_at": {
                  "anyOf": [
                    {
                      "example": "2026-11-08T12:00:00.000Z",
                      "format": "date-time",
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "object": {
                  "const": "webhook_delivery",
                  "type": "string"
                },
                "status": {
                  "enum": [
                    "PENDING",
                    "DELIVERED",
                    "FAILED",
                    "DISABLED"
                  ],
                  "type": "string"
                }
              },
              "required": [
                "id",
                "object",
                "event_id",
                "event_type",
                "status",
                "attempts",
                "last_http_status",
                "last_error",
                "next_attempt_at",
                "delivered_at",
                "created_at"
              ],
              "type": "object"
            },
            "type": "array"
          },
          "object": {
            "const": "list",
            "type": "string"
          }
        },
        "required": [
          "object",
          "data"
        ],
        "type": "object"
      },
      "WebhookEndpoint": {
        "additionalProperties": false,
        "properties": {
          "created_at": {
            "example": "2026-11-08T12:00:00.000Z",
            "format": "date-time",
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "enabled_events": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "environment": {
            "enum": [
              "test",
              "live"
            ],
            "type": "string"
          },
          "id": {
            "example": "whe_01M6XF0H2MAC63MEKQAT4K3AXF",
            "type": "string"
          },
          "object": {
            "const": "webhook_endpoint",
            "type": "string"
          },
          "previous_secret_valid_until": {
            "anyOf": [
              {
                "example": "2026-11-08T12:00:00.000Z",
                "format": "date-time",
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "status": {
            "enum": [
              "ENABLED",
              "DISABLED"
            ],
            "type": "string"
          },
          "updated_at": {
            "example": "2026-11-08T12:00:00.000Z",
            "format": "date-time",
            "type": "string"
          },
          "url": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "object",
          "url",
          "description",
          "enabled_events",
          "status",
          "environment",
          "previous_secret_valid_until",
          "created_at",
          "updated_at"
        ],
        "type": "object"
      },
      "WebhookEndpointList": {
        "additionalProperties": false,
        "properties": {
          "data": {
            "items": {
              "$ref": "#/components/schemas/WebhookEndpoint"
            },
            "type": "array"
          },
          "object": {
            "const": "list",
            "type": "string"
          }
        },
        "required": [
          "object",
          "data"
        ],
        "type": "object"
      },
      "WebhookEndpointWithSecret": {
        "additionalProperties": false,
        "properties": {
          "created_at": {
            "example": "2026-11-08T12:00:00.000Z",
            "format": "date-time",
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "enabled_events": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "environment": {
            "enum": [
              "test",
              "live"
            ],
            "type": "string"
          },
          "id": {
            "example": "whe_01M6XF0H2MAC63MEKQAT4K3AXF",
            "type": "string"
          },
          "object": {
            "const": "webhook_endpoint",
            "type": "string"
          },
          "previous_secret_valid_until": {
            "anyOf": [
              {
                "example": "2026-11-08T12:00:00.000Z",
                "format": "date-time",
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "secret": {
            "description": "Shown once: verify signatures with it, store it safely",
            "type": "string"
          },
          "status": {
            "enum": [
              "ENABLED",
              "DISABLED"
            ],
            "type": "string"
          },
          "updated_at": {
            "example": "2026-11-08T12:00:00.000Z",
            "format": "date-time",
            "type": "string"
          },
          "url": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "object",
          "url",
          "description",
          "enabled_events",
          "status",
          "environment",
          "previous_secret_valid_until",
          "created_at",
          "updated_at",
          "secret"
        ],
        "type": "object"
      },
      "WebhookResend": {
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "const": "PENDING",
            "type": "string"
          }
        },
        "required": [
          "id",
          "status"
        ],
        "type": "object"
      }
    },
    "securitySchemes": {
      "apiKey": {
        "description": "Authorization: Bearer sw_test_… (or sw_live_…)",
        "scheme": "bearer",
        "type": "http"
      }
    }
  },
  "info": {
    "description": "The merchant API. Authenticate with an API key as a bearer token: sw_test_… keys work in the test environment, sw_live_… keys in live.",
    "license": {
      "identifier": "LicenseRef-SitesWay",
      "name": "Proprietary"
    },
    "title": "Sites Way API",
    "version": "v1"
  },
  "openapi": "3.1.0",
  "paths": {
    "/v1/balance": {
      "get": {
        "description": "Live figures from your financial history: what is held, available and paid out.",
        "operationId": "getBalance",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Balance"
                }
              }
            },
            "description": "The balances"
          },
          "4XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A refused request (see the error catalog)"
          },
          "5XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A failure on our side; retry later"
          }
        },
        "summary": "Your balance, per currency",
        "tags": [
          "Finance"
        ],
        "x-order": 20,
        "x-permission": "finance:read"
      }
    },
    "/v1/fees": {
      "get": {
        "description": "The most recent 100, newest first.",
        "operationId": "listFees",
        "parameters": [
          {
            "description": "ISO 4217 currency code, upper case",
            "in": "query",
            "name": "currency",
            "required": false,
            "schema": {
              "example": "SAR",
              "pattern": "^[A-Z]{3}$",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FeeList"
                }
              }
            },
            "description": "The fees"
          },
          "4XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A refused request (see the error catalog)"
          },
          "5XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A failure on our side; retry later"
          }
        },
        "summary": "Fees charged to you",
        "tags": [
          "Finance"
        ],
        "x-order": 25,
        "x-permission": "finance:read"
      }
    },
    "/v1/merchant": {
      "get": {
        "description": "The account of the API key used, and the environment the key belongs to.",
        "operationId": "getMerchant",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Merchant"
                }
              }
            },
            "description": "The merchant"
          },
          "4XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A refused request (see the error catalog)"
          },
          "5XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A failure on our side; retry later"
          }
        },
        "summary": "Your merchant account",
        "tags": [
          "Merchant"
        ],
        "x-order": 0,
        "x-permission": "merchant:read"
      }
    },
    "/v1/payments": {
      "get": {
        "description": "Newest first. Page with starting_after (the last id of the previous page).",
        "operationId": "listPayments",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 20,
              "maximum": 100,
              "minimum": 1,
              "type": "integer"
            }
          },
          {
            "description": "The last id of the previous page",
            "in": "query",
            "name": "starting_after",
            "required": false,
            "schema": {
              "pattern": "^pay_[0-9A-HJKMNP-TV-Z]{26}$",
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "enum": [
                "CREATED",
                "REQUIRES_PAYMENT_METHOD",
                "REQUIRES_ACTION",
                "PROCESSING",
                "AUTHORIZED",
                "CAPTURED",
                "SUCCEEDED",
                "FAILED",
                "CANCELED",
                "EXPIRED",
                "PARTIALLY_REFUNDED",
                "REFUNDED"
              ],
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "merchant_reference",
            "required": false,
            "schema": {
              "maxLength": 255,
              "minLength": 1,
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentList"
                }
              }
            },
            "description": "A page of payments"
          },
          "4XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A refused request (see the error catalog)"
          },
          "5XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A failure on our side; retry later"
          }
        },
        "summary": "List payments",
        "tags": [
          "Payments"
        ],
        "x-order": 2,
        "x-permission": "payments:read"
      },
      "post": {
        "description": "Creates a payment to be paid on the hosted page (POST /v1/payments/{id}/checkout-link) or on your own page (client secret). The same Idempotency-Key with the same body answers the first result again (header Idempotency-Replayed: true); with another body it is refused.",
        "operationId": "createPayment",
        "parameters": [
          {
            "description": "A unique key per operation (1-255 visible ASCII characters). Retrying with the same key and body answers the first result.",
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "maxLength": 255,
              "minLength": 1,
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreatePaymentRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Payment"
                }
              }
            },
            "description": "The payment"
          },
          "4XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A refused request (see the error catalog)"
          },
          "5XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A failure on our side; retry later"
          }
        },
        "summary": "Create a payment",
        "tags": [
          "Payments"
        ],
        "x-order": 1,
        "x-permission": "payments:write"
      }
    },
    "/v1/payments/{id}": {
      "get": {
        "operationId": "getPayment",
        "parameters": [
          {
            "description": "The payment id (pay_…)",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Payment"
                }
              }
            },
            "description": "The payment"
          },
          "4XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A refused request (see the error catalog)"
          },
          "5XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A failure on our side; retry later"
          }
        },
        "summary": "Retrieve a payment",
        "tags": [
          "Payments"
        ],
        "x-order": 3,
        "x-permission": "payments:read"
      }
    },
    "/v1/payments/{id}/cancel": {
      "post": {
        "description": "Only a payment nobody has started paying can be canceled.",
        "operationId": "cancelPayment",
        "parameters": [
          {
            "description": "The payment id (pay_…)",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Payment"
                }
              }
            },
            "description": "The canceled payment"
          },
          "4XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A refused request (see the error catalog)"
          },
          "5XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A failure on our side; retry later"
          }
        },
        "summary": "Cancel an unpaid payment",
        "tags": [
          "Payments"
        ],
        "x-order": 5,
        "x-permission": "payments:write"
      }
    },
    "/v1/payments/{id}/checkout-link": {
      "post": {
        "description": "Redirect the customer to the returned url. After paying they return to return_url; confirm the result from your server (GET the payment, or a webhook), never from the return alone.",
        "operationId": "createCheckoutLink",
        "parameters": [
          {
            "description": "The payment id (pay_…)",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCheckoutLinkRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckoutLink"
                }
              }
            },
            "description": "The link"
          },
          "4XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A refused request (see the error catalog)"
          },
          "5XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A failure on our side; retry later"
          }
        },
        "summary": "A hosted payment page for the payment",
        "tags": [
          "Payments"
        ],
        "x-order": 6,
        "x-permission": "payments:write"
      }
    },
    "/v1/payments/{id}/client-secret": {
      "post": {
        "description": "For a checkout page you host: the browser uses the secret, never your API key. Ask for it from your server.",
        "operationId": "createClientSecret",
        "parameters": [
          {
            "description": "The payment id (pay_…)",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "return_url": {
                    "description": "Where the customer returns; its origin must be one of your registered origins",
                    "maxLength": 2048,
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": false
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientSecret"
                }
              }
            },
            "description": "The secret"
          },
          "4XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A refused request (see the error catalog)"
          },
          "5XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A failure on our side; retry later"
          }
        },
        "summary": "A client secret for your own checkout page",
        "tags": [
          "Payments"
        ],
        "x-order": 7,
        "x-permission": "payments:write"
      }
    },
    "/v1/payments/{id}/events": {
      "get": {
        "description": "Every state change of the payment, oldest first.",
        "operationId": "listPaymentEvents",
        "parameters": [
          {
            "description": "The payment id (pay_…)",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentEvents"
                }
              }
            },
            "description": "The events"
          },
          "4XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A refused request (see the error catalog)"
          },
          "5XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A failure on our side; retry later"
          }
        },
        "summary": "A payment's history",
        "tags": [
          "Payments"
        ],
        "x-order": 4,
        "x-permission": "payments:read"
      }
    },
    "/v1/payments/{id}/refunds": {
      "get": {
        "operationId": "listRefunds",
        "parameters": [
          {
            "description": "The payment id (pay_…)",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RefundList"
                }
              }
            },
            "description": "The refunds"
          },
          "4XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A refused request (see the error catalog)"
          },
          "5XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A failure on our side; retry later"
          }
        },
        "summary": "A payment's refunds",
        "tags": [
          "Refunds"
        ],
        "x-order": 9,
        "x-permission": "refunds:read"
      },
      "post": {
        "description": "Full or partial, several times up to the captured amount. The answer may be PENDING or PROCESSING: the final result comes as a webhook (refund.succeeded / refund.failed).",
        "operationId": "createRefund",
        "parameters": [
          {
            "description": "The payment id (pay_…)",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "A unique key per operation (1-255 visible ASCII characters). Retrying with the same key and body answers the first result.",
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "maxLength": 255,
              "minLength": 1,
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateRefundRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refund"
                }
              }
            },
            "description": "The same refund, replayed"
          },
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refund"
                }
              }
            },
            "description": "The refund"
          },
          "4XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A refused request (see the error catalog)"
          },
          "5XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A failure on our side; retry later"
          }
        },
        "summary": "Refund a payment",
        "tags": [
          "Refunds"
        ],
        "x-order": 8,
        "x-permission": "refunds:write"
      }
    },
    "/v1/payments/{id}/void": {
      "post": {
        "description": "Releases an authorization that was not captured.",
        "operationId": "voidPayment",
        "parameters": [
          {
            "description": "The payment id (pay_…)",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "A unique key per operation (1-255 visible ASCII characters). Retrying with the same key and body answers the first result.",
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "maxLength": 255,
              "minLength": 1,
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "reason": {
                    "maxLength": 500,
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": false
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Void"
                }
              }
            },
            "description": "The same void, replayed"
          },
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Void"
                }
              }
            },
            "description": "The void"
          },
          "4XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A refused request (see the error catalog)"
          },
          "5XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A failure on our side; retry later"
          }
        },
        "summary": "Void an authorized payment",
        "tags": [
          "Refunds"
        ],
        "x-order": 11,
        "x-permission": "payments:write"
      }
    },
    "/v1/payouts": {
      "get": {
        "operationId": "listPayouts",
        "parameters": [
          {
            "description": "ISO 4217 currency code, upper case",
            "in": "query",
            "name": "currency",
            "required": false,
            "schema": {
              "example": "SAR",
              "pattern": "^[A-Z]{3}$",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PayoutList"
                }
              }
            },
            "description": "The payouts"
          },
          "4XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A refused request (see the error catalog)"
          },
          "5XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A failure on our side; retry later"
          }
        },
        "summary": "Payouts to your bank account",
        "tags": [
          "Finance"
        ],
        "x-order": 24,
        "x-permission": "finance:read"
      }
    },
    "/v1/refunds/{id}": {
      "get": {
        "operationId": "getRefund",
        "parameters": [
          {
            "description": "The refund id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refund"
                }
              }
            },
            "description": "The refund"
          },
          "4XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A refused request (see the error catalog)"
          },
          "5XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A failure on our side; retry later"
          }
        },
        "summary": "Retrieve a refund",
        "tags": [
          "Refunds"
        ],
        "x-order": 10,
        "x-permission": "refunds:read"
      }
    },
    "/v1/settlements": {
      "get": {
        "operationId": "listSettlements",
        "parameters": [
          {
            "description": "ISO 4217 currency code, upper case",
            "in": "query",
            "name": "currency",
            "required": false,
            "schema": {
              "example": "SAR",
              "pattern": "^[A-Z]{3}$",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SettlementList"
                }
              }
            },
            "description": "The settlements"
          },
          "4XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A refused request (see the error catalog)"
          },
          "5XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A failure on our side; retry later"
          }
        },
        "summary": "Settlements",
        "tags": [
          "Finance"
        ],
        "x-order": 26,
        "x-permission": "finance:read"
      }
    },
    "/v1/statements": {
      "get": {
        "operationId": "listStatements",
        "parameters": [
          {
            "description": "ISO 4217 currency code, upper case",
            "in": "query",
            "name": "currency",
            "required": false,
            "schema": {
              "example": "SAR",
              "pattern": "^[A-Z]{3}$",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatementList"
                }
              }
            },
            "description": "The statements"
          },
          "4XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A refused request (see the error catalog)"
          },
          "5XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A failure on our side; retry later"
          }
        },
        "summary": "Monthly statements",
        "tags": [
          "Finance"
        ],
        "x-order": 21,
        "x-permission": "finance:read"
      }
    },
    "/v1/statements/{id}": {
      "get": {
        "operationId": "getStatement",
        "parameters": [
          {
            "description": "The statement id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Statement"
                }
              }
            },
            "description": "The statement"
          },
          "4XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A refused request (see the error catalog)"
          },
          "5XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A failure on our side; retry later"
          }
        },
        "summary": "A statement with its entries",
        "tags": [
          "Finance"
        ],
        "x-order": 22,
        "x-permission": "finance:read"
      }
    },
    "/v1/statements/{id}/export": {
      "get": {
        "operationId": "exportStatement",
        "parameters": [
          {
            "description": "The statement id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "text/csv": {
                "schema": {
                  "description": "The statement as CSV",
                  "type": "string"
                }
              }
            },
            "description": "The CSV file"
          },
          "4XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A refused request (see the error catalog)"
          },
          "5XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A failure on our side; retry later"
          }
        },
        "summary": "A statement as CSV",
        "tags": [
          "Finance"
        ],
        "x-order": 23,
        "x-permission": "finance:read"
      }
    },
    "/v1/webhook_deliveries/{id}/resend": {
      "post": {
        "operationId": "resendWebhookDelivery",
        "parameters": [
          {
            "description": "The delivery id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "202": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookResend"
                }
              }
            },
            "description": "Queued again"
          },
          "4XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A refused request (see the error catalog)"
          },
          "5XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A failure on our side; retry later"
          }
        },
        "summary": "Send a delivery again",
        "tags": [
          "Webhook endpoints"
        ],
        "x-order": 19,
        "x-permission": "webhooks:write"
      }
    },
    "/v1/webhook_endpoints": {
      "get": {
        "operationId": "listWebhookEndpoints",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpointList"
                }
              }
            },
            "description": "The endpoints"
          },
          "4XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A refused request (see the error catalog)"
          },
          "5XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A failure on our side; retry later"
          }
        },
        "summary": "List webhook endpoints",
        "tags": [
          "Webhook endpoints"
        ],
        "x-order": 13,
        "x-permission": "webhooks:read"
      },
      "post": {
        "description": "The answer carries the signing secret, once.",
        "operationId": "createWebhookEndpoint",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateWebhookEndpointRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpointWithSecret"
                }
              }
            },
            "description": "The endpoint"
          },
          "4XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A refused request (see the error catalog)"
          },
          "5XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A failure on our side; retry later"
          }
        },
        "summary": "Add a webhook endpoint",
        "tags": [
          "Webhook endpoints"
        ],
        "x-order": 12,
        "x-permission": "webhooks:write"
      }
    },
    "/v1/webhook_endpoints/{id}": {
      "get": {
        "operationId": "getWebhookEndpoint",
        "parameters": [
          {
            "description": "The endpoint id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpoint"
                }
              }
            },
            "description": "The endpoint"
          },
          "4XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A refused request (see the error catalog)"
          },
          "5XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A failure on our side; retry later"
          }
        },
        "summary": "Retrieve a webhook endpoint",
        "tags": [
          "Webhook endpoints"
        ],
        "x-order": 14,
        "x-permission": "webhooks:read"
      }
    },
    "/v1/webhook_endpoints/{id}/deliveries": {
      "get": {
        "operationId": "listWebhookDeliveries",
        "parameters": [
          {
            "description": "The endpoint id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Newest first",
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 50,
              "maximum": 100,
              "minimum": 1,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookDeliveryList"
                }
              }
            },
            "description": "The deliveries"
          },
          "4XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A refused request (see the error catalog)"
          },
          "5XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A failure on our side; retry later"
          }
        },
        "summary": "An endpoint's recent deliveries",
        "tags": [
          "Webhook endpoints"
        ],
        "x-order": 18,
        "x-permission": "webhooks:read"
      }
    },
    "/v1/webhook_endpoints/{id}/disable": {
      "post": {
        "operationId": "disableWebhookEndpoint",
        "parameters": [
          {
            "description": "The endpoint id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpoint"
                }
              }
            },
            "description": "The endpoint"
          },
          "4XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A refused request (see the error catalog)"
          },
          "5XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A failure on our side; retry later"
          }
        },
        "summary": "Stop deliveries to an endpoint",
        "tags": [
          "Webhook endpoints"
        ],
        "x-order": 15,
        "x-permission": "webhooks:write"
      }
    },
    "/v1/webhook_endpoints/{id}/enable": {
      "post": {
        "operationId": "enableWebhookEndpoint",
        "parameters": [
          {
            "description": "The endpoint id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpoint"
                }
              }
            },
            "description": "The endpoint"
          },
          "4XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A refused request (see the error catalog)"
          },
          "5XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A failure on our side; retry later"
          }
        },
        "summary": "Resume deliveries to an endpoint",
        "tags": [
          "Webhook endpoints"
        ],
        "x-order": 16,
        "x-permission": "webhooks:write"
      }
    },
    "/v1/webhook_endpoints/{id}/rotate_secret": {
      "post": {
        "description": "A new secret signs from now on; the old one keeps verifying for previous_secret_valid_for_hours, so you can switch without missing a delivery.",
        "operationId": "rotateWebhookSecret",
        "parameters": [
          {
            "description": "The endpoint id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "previous_secret_valid_for_hours": {
                    "description": "How long the old secret keeps verifying (default 24)",
                    "maximum": 168,
                    "minimum": 0,
                    "type": "integer"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": false
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpointWithSecret"
                }
              }
            },
            "description": "The new secret"
          },
          "4XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A refused request (see the error catalog)"
          },
          "5XX": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A failure on our side; retry later"
          }
        },
        "summary": "Rotate the signing secret",
        "tags": [
          "Webhook endpoints"
        ],
        "x-order": 17,
        "x-permission": "webhooks:write"
      }
    }
  },
  "security": [
    {
      "apiKey": []
    }
  ],
  "servers": [
    {
      "description": "Staging",
      "url": "https://api.sw-staging.dev"
    }
  ],
  "tags": [
    {
      "description": "The account behind the API key.",
      "name": "Merchant"
    },
    {
      "description": "Create payments and send customers to pay them.",
      "name": "Payments"
    },
    {
      "description": "Give money back, fully or in part.",
      "name": "Refunds"
    },
    {
      "description": "Where we send events, signed, so your server learns of every change.",
      "name": "Webhook endpoints"
    },
    {
      "description": "Balance, settlements, payouts, fees and statements.",
      "name": "Finance"
    }
  ],
  "x-error-codes": [
    {
      "code": "INVALID_REQUEST",
      "message": "Invalid request",
      "status": 400
    },
    {
      "code": "AUTHENTICATION_FAILED",
      "message": "Authentication failed",
      "status": 401
    },
    {
      "code": "PERMISSION_DENIED",
      "message": "Permission denied",
      "status": 403
    },
    {
      "code": "MERCHANT_NOT_ACTIVE",
      "message": "Merchant account is not active",
      "status": 403
    },
    {
      "code": "NOT_FOUND",
      "message": "Resource not found",
      "status": 404
    },
    {
      "code": "CONFLICT",
      "message": "Conflict",
      "status": 409
    },
    {
      "code": "IDEMPOTENCY_CONFLICT",
      "message": "Idempotency key was reused with a different request",
      "status": 422
    },
    {
      "code": "RATE_LIMITED",
      "message": "Too many requests",
      "status": 429
    },
    {
      "code": "PAYLOAD_TOO_LARGE",
      "message": "Payload too large",
      "status": 413
    },
    {
      "code": "INVALID_STATE_TRANSITION",
      "message": "Operation not allowed in the current state",
      "status": 409
    },
    {
      "code": "REFUND_CAP_EXCEEDED",
      "message": "Refund amount exceeds the refundable balance",
      "status": 422
    },
    {
      "code": "LEDGER_INVARIANT_VIOLATION",
      "message": "Internal ledger error",
      "status": 500
    },
    {
      "code": "SETTLEMENT_INTEGRITY_VIOLATION",
      "message": "Settlement item does not match the batch",
      "status": 422
    },
    {
      "code": "ATTEMPT_NOT_ALLOWED",
      "message": "A new payment attempt is not allowed in the current state",
      "status": 409
    },
    {
      "code": "CAPTURE_POLICY_VIOLATION",
      "message": "Capture not allowed",
      "status": 409
    },
    {
      "code": "VOID_NOT_APPLICABLE",
      "message": "This payment was never authorized at the provider; there is nothing to void",
      "status": 409
    },
    {
      "code": "IMMUTABLE_RECORD",
      "message": "Record is immutable",
      "status": 409
    },
    {
      "code": "PROVIDER_UNAVAILABLE",
      "message": "Payment provider unavailable",
      "status": 502
    },
    {
      "code": "PROVIDER_TIMEOUT",
      "message": "Payment provider timed out",
      "status": 504
    },
    {
      "code": "SERVICE_UNAVAILABLE",
      "message": "Service temporarily unavailable",
      "status": 503
    },
    {
      "code": "INTERNAL_ERROR",
      "message": "Internal error",
      "status": 500
    }
  ]
}
