{
  "openapi": "3.1.0",
  "info": {
    "title": "OnCharge Merchant API",
    "version": "1.0.0",
    "summary": "Create checkout sessions, report shipments, refund payments, read payments, payouts, balance and events, and receive webhooks.",
    "description": "The OnCharge Merchant API is called from your **server**. Every request is signed with\nHMAC-SHA256 using your store's API secret (see the `OnChargeSignature` security scheme and\nhttps://oncharge.io/docs/authentication). Never call it from a browser: the API secret must\nstay on your server.\n\n* Amounts are integers in the currency's minor unit (cents for USD).\n* Currencies are ISO 4217 codes (`USD`).\n* Errors are JSON objects with an `error` code and a human-readable `message`.\n* The signed path is the URL path exactly as listed here (for example `/api/v1/shipments`),\n  without the query string.\n\nWebhooks that OnCharge sends to your server are described in the `webhooks` section.\n",
    "contact": {
      "name": "OnCharge support",
      "url": "https://oncharge.io/contact"
    },
    "license": {
      "name": "Proprietary",
      "identifier": "LicenseRef-OnCharge-Proprietary"
    },
    "x-oncharge-docs": "https://oncharge.io/docs"
  },
  "servers": [
    {
      "url": "https://app.oncharge.io",
      "description": "Production"
    }
  ],
  "security": [
    {
      "OnChargeSignature": []
    }
  ],
  "tags": [
    {
      "name": "Checkout sessions",
      "description": "Start a payment and show OnCharge's hosted or embedded checkout."
    },
    {
      "name": "Shipments",
      "description": "Report carrier tracking so delivered orders are paid out."
    },
    {
      "name": "Refunds",
      "description": "Refund captured payments."
    },
    {
      "name": "Disputes",
      "description": "Read and respond to disputes (chargebacks)."
    },
    {
      "name": "Customers",
      "description": "Your store's customers and the cards they saved with you, and charges to a saved card while the customer is away."
    },
    {
      "name": "Risk",
      "description": "Read risk decisions and manage the store's risk policy."
    },
    {
      "name": "Recurring",
      "description": "Merchant-initiated charges on a saved card."
    },
    {
      "name": "Catalog",
      "description": "Send your products to OnCharge for shopping ads on Google Merchant Center and the Meta catalog. The whole catalog is sent and each ad platform reviews it against its own policies; only products that name a controlled substance, and products you exclude, are stored but not sent."
    },
    {
      "name": "Events",
      "description": "Every webhook event of the last 30 days, and sending one to an endpoint again."
    },
    {
      "name": "Payments and balance",
      "description": "Payments on every rail, payouts to your bank and your balance, as the portal shows them."
    },
    {
      "name": "Payment links",
      "description": "Shareable OnCharge pages (/l/<code>) that take a payment without a website. Each payment is an ordinary checkout session."
    },
    {
      "name": "Invoices",
      "description": "Bill a customer: draft, finalize, send and get paid on OnCharge's hosted invoice page through OnCharge checkout, by card or crypto. Reminders, mark paid, void and credit notes."
    },
    {
      "name": "Subscriptions",
      "description": "Recurring billing: plans and add-ons, and subscriptions on them. Each period is an OnCharge invoice charged to the customer's card saved at your store; customers sign up and agree to the recurring charges on OnCharge's own pages. Subscriptions are not available yet: until they are turned on, every endpoint here answers 404 `not_found`."
    }
  ],
  "paths": {
    "/api/v1/checkout/sessions": {
      "post": {
        "operationId": "createCheckoutSession",
        "tags": [
          "Checkout sessions"
        ],
        "summary": "Create a checkout session",
        "description": "Creates a checkout session for one order or cart. Show the shopper the returned\n`iframe_url` (a path on `https://app.oncharge.io`), either embedded in an iframe on one of\nyour registered domains or as a full-page redirect.\n\n`return_url` must be on one of the store's registered domains. Sessions expire 30 minutes\nafter creation.\n\nSend an `Idempotency-Key` to make retries safe: while a session created with the same key\nis still open (`created` or `pending`) and less than 50 minutes old, the same session is\nreturned with status 200 instead of a new one.\n\nFor physical goods, send `shipping`: OnCharge releases the payout after the carrier\nconfirms delivery to this address, and the address cannot be changed later. When the\nsession is for an existing order (`order_id` is given) and the order ships by carrier,\n`shipping` is required (`422 shipping_address_required`). A session created from a cart,\nbefore the order exists, may attach the address later with\n`POST /api/v1/checkout/sessions/{session_id}/order`; such a response carries\n`shipping_required: true`, and tracking for the order is refused until the address is on file.\n\nCard payments are accepted in `USD` only for now (`400 currency_not_supported`).\n\nOn a store that sells both shipped and unshipped things, set `requires_shipping` on each\nline item: an order with a shipped item is paid out after carrier-confirmed delivery, one\nwithout it 7 days after payment.\n\nA store closed to new payments answers `403 store_checkout_closed`; a session that is already open can then no longer be paid (the checkout shows an error).\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCheckoutSessionRequest"
              },
              "example": {
                "amount": 4900,
                "currency": "USD",
                "reference": "order-1001",
                "return_url": "https://shop.example.com/checkout/complete?order=1001",
                "order_id": "1001",
                "customer_email": "shopper@example.com",
                "shipping": {
                  "name": "Alex Rivera",
                  "line1": "500 Market St",
                  "city": "San Francisco",
                  "state": "CA",
                  "postal_code": "94105",
                  "country": "US"
                },
                "line_items": [
                  {
                    "description": "Example product",
                    "quantity": 1,
                    "amount_including_tax": 4900
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Idempotent replay: an open session created with the same `Idempotency-Key` within the\nlast 50 minutes. A fresh `pay_token` is issued.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckoutSessionReplay"
                }
              }
            }
          },
          "201": {
            "description": "Session created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckoutSession"
                },
                "example": {
                  "session_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
                  "status": "created",
                  "iframe_url": "/checkout/8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11?token=pt_eyJzZXNzaW9uSWQiOi4uLn0.3f9c",
                  "pay_token": "pt_eyJzZXNzaW9uSWQiOi4uLn0.3f9c",
                  "created_at": "2026-01-01T00:00:00.000Z",
                  "expires_at": "2026-01-01T00:30:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "`validation_error`, `invalid_json`, `invalid_return_url` (the return URL is not on a\nregistered store domain), `no_domains` (the store has no registered domain) or\n`currency_not_supported` (card payments are accepted in USD only).\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "invalid_return_url",
                  "message": "Return URL domain is not in your store's allowed domains. Add this domain in your store settings."
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "`store_inactive` (the store is not active yet, for example while its processing account is being opened, or it is suspended), `store_checkout_closed` (OnCharge has closed the store to new payments, for example while the account is being offboarded; shipments and refunds still work), `domain_mismatch`, or `global_ban` (the shopper's email or phone is blocked across OnCharge; show the `message` to the shopper and do not retry).",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "$ref": "#/components/schemas/GlobalBanError"
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "`shipping_address_required`: the order ships by carrier and `order_id` was given, but no\n`shipping` address (postal code or city). The order is paid out only after the carrier\nconfirms delivery to that address. Show the `message` to the shopper.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/api/v1/checkout/sessions/{session_id}": {
      "get": {
        "operationId": "getCheckoutSession",
        "tags": [
          "Checkout sessions"
        ],
        "summary": "Retrieve a checkout session",
        "description": "Returns the session's current status. Use it to confirm a payment server-side (for\nexample when the shopper lands on your `return_url`) in addition to webhooks.\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/SessionId"
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "responses": {
          "200": {
            "description": "The session.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckoutSessionDetail"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/api/v1/checkout/sessions/{session_id}/order": {
      "post": {
        "operationId": "attachOrder",
        "tags": [
          "Checkout sessions"
        ],
        "summary": "Attach your order to a session",
        "description": "For sessions created from a cart before your order existed: records your `order_id` and\nthe shipping destination. Each value is set once; later calls do not overwrite it.\n\nThe shipping address is recorded only if the session has none yet, no tracking number has\nbeen reported, and the session is less than 24 hours old. Check `shipping_recorded` and\n`shipping_on_file` in the response.\n\nAn order that ships by carrier is paid out only after delivery to its shipping address. If\nit is attached without one and none is on file, the `order_id` is still recorded and the\nresponse is `422 shipping_address_required`.\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/SessionId"
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AttachOrderRequest"
              },
              "example": {
                "order_id": "1001",
                "shipping": {
                  "name": "Alex Rivera",
                  "line1": "500 Market St",
                  "city": "San Francisco",
                  "state": "CA",
                  "postal_code": "94105",
                  "country": "US"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "What is on file for the session now.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachOrderResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "`session_not_found`: no such session for this store.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "`shipping_address_required`: the order ships by carrier and no shipping address is on file\n(none was sent, or it can no longer be recorded).\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/api/v1/checkout/sessions/{session_id}/cancel": {
      "post": {
        "operationId": "cancelCheckoutSession",
        "tags": [
          "Checkout sessions"
        ],
        "summary": "Cancel an authorized payment",
        "description": "Cancels a payment that is `authorized` but not yet captured. Captured payments must be\nrefunded instead. Send an empty body (`\"\"`) and sign it as such.\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/SessionId"
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "The payment was cancelled.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CancelResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`invalid_state` (only `authorized` sessions can be cancelled) or `missing_psp_ref`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "502": {
            "$ref": "#/components/responses/ProviderError"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/api/v1/refunds": {
      "post": {
        "operationId": "createRefund",
        "tags": [
          "Refunds"
        ],
        "summary": "Refund a captured payment",
        "description": "Refunds all or part of a `captured` payment. Always send an `Idempotency-Key` (for example\nyour refund ID) so a retried request cannot refund twice: a repeat with the same key\nreturns the first refund with `idempotent: true`.\n\nThe final outcome arrives as a `refund.succeeded` webhook.\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateRefundRequest"
              },
              "example": {
                "session_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
                "amount": 1500,
                "currency": "USD",
                "reference": "refund-1001-1"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Idempotent replay of an earlier refund with the same `Idempotency-Key`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RefundReplay"
                }
              }
            }
          },
          "201": {
            "description": "Refund requested.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refund"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`invalid_state`: only `captured` payments can be refunded (cancel `authorized` ones), or\n`missing_psp_ref`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "502": {
            "$ref": "#/components/responses/ProviderError"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/api/v1/shipments": {
      "post": {
        "operationId": "reportShipments",
        "tags": [
          "Shipments"
        ],
        "summary": "Report tracking numbers for a paid order",
        "description": "Reports the carrier and tracking number(s) a paid order shipped with. OnCharge confirms\ndelivery with the carrier and pays the order out once every package is delivered to the\norder's shipping address.\n\nIdentify the order by `session_id` or by your `order_id` (the latest captured session with\nthat order ID). Supported carriers: USPS, UPS, FedEx and DHL Express, by name or by the\ncodes shipping tools use (e.g. `ups_walleted`, `stamps_com`, `fedex_ground`). `carrier` may be\nomitted, or be one OnCharge does not recognise, when the tracking number's format identifies\nthe carrier (UPS `1Z…`, USPS IMpb/S10; FedEx and DHL Express numbers when no carrier is given). Reporting a number that is already on the order again is harmless. Each\ntracking number is accepted or rejected individually.\n\nTo replace a tracking number (the package was lost, returned, or the label cancelled, and the\norder was shipped again), name it in `replaces`. Without `replaces`, a new number replaces\nevery package of the order that has a problem. A replaced number stays tied to the order.\n\nAn order that is not confirmed delivered is refunded to the shopper automatically: 30 days\nafter payment with no tracking, 45 days with no confirmed delivery (`delivery.auto_refund_at`).\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReportShipmentsRequest"
              },
              "example": {
                "session_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
                "shipments": [
                  {
                    "carrier": "ups",
                    "tracking_number": "1Z999AA10123456784"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Per-number results and the order's delivery state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReportShipmentsResponse"
                },
                "example": {
                  "session_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
                  "shipments": [
                    {
                      "tracking_number": "1Z999AA10123456784",
                      "carrier": "ups",
                      "status": "accepted"
                    }
                  ],
                  "delivery": {
                    "state": "in_transit",
                    "hold_reason": null
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "`session_not_found`: no such order for this store.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "`order_not_paid`: tracking can be added once the order has been paid. `order_refunded`: the\norder was refunded in full.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "`shipping_address_missing`: the order ships by carrier but has no shipping address, so its\ndelivery cannot be confirmed.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      },
      "get": {
        "operationId": "getDeliveryStatus",
        "tags": [
          "Shipments"
        ],
        "summary": "Get an order's delivery status",
        "description": "The order's delivery state and every reported tracking number with the carrier's result.\nThe query string is not part of the signature: sign the path `/api/v1/shipments`.\n",
        "parameters": [
          {
            "name": "session_id",
            "in": "query",
            "required": true,
            "description": "The checkout session ID.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "responses": {
          "200": {
            "description": "Delivery status.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeliveryStatusResponse"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: `session_id` is missing or not a UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "`session_not_found`: no such order for this store.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/api/v1/disputes": {
      "get": {
        "operationId": "listDisputes",
        "tags": [
          "Disputes"
        ],
        "summary": "List disputes",
        "description": "The store's 50 most recent disputes, newest first.\n\nNewest first, paged by cursor: pass `next_cursor` back as `cursor`. Filters are optional.",
        "parameters": [
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "open",
                "won",
                "lost"
              ]
            }
          },
          {
            "name": "reason",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "fraudulent",
                "product_not_received",
                "product_unacceptable",
                "duplicate",
                "subscription_canceled",
                "credit_not_processed",
                "unrecognized",
                "general"
              ]
            }
          },
          {
            "name": "due_before",
            "in": "query",
            "description": "Evidence due on or before this day (UTC).",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "from",
            "in": "query",
            "description": "Opened on or after this day (UTC).",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Opened on or before this day (UTC).",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "min",
            "in": "query",
            "description": "Smallest amount, in major units.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "max",
            "in": "query",
            "description": "Largest amount, in major units.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "description": "A dispute or payment reference, a dispute id, or an order number.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "`next_cursor` of the previous page.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Disputes.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "disputes"
                  ],
                  "properties": {
                    "disputes": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Dispute"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Pass as `cursor` for the next page; null on the last page."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/api/v1/disputes/{dispute_id}": {
      "get": {
        "operationId": "getDispute",
        "tags": [
          "Disputes"
        ],
        "summary": "Retrieve a dispute",
        "description": "A dispute with the evidence files uploaded for it.",
        "parameters": [
          {
            "$ref": "#/components/parameters/DisputeId"
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "responses": {
          "200": {
            "description": "The dispute.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "dispute",
                    "evidence"
                  ],
                  "properties": {
                    "dispute": {
                      "$ref": "#/components/schemas/Dispute"
                    },
                    "evidence": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/DisputeEvidence"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/api/v1/disputes/{dispute_id}/evidence": {
      "post": {
        "operationId": "uploadDisputeEvidence",
        "tags": [
          "Disputes"
        ],
        "summary": "Upload dispute evidence",
        "description": "Uploads one evidence document as `multipart/form-data`. **Sign this request with an empty\nbody**: the body hash in the signing string is the SHA-256 of the empty string\n(`e3b0c442…b855`), not of the multipart payload.\n\nUpload evidence for every dispute, including those the OnCharge team responds to (`responded_by: \"oncharge\"`): the team uses your uploads.\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/DisputeId"
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file",
                  "doc_type"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "The document (PDF or image)."
                  },
                  "doc_type": {
                    "type": "string",
                    "description": "What the document is.",
                    "examples": [
                      "proof_of_delivery",
                      "invoice",
                      "customer_communication"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Evidence stored.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "evidence"
                  ],
                  "properties": {
                    "evidence": {
                      "$ref": "#/components/schemas/DisputeEvidence"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`missing_field`: `file` and `doc_type` are required.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/api/v1/disputes/{dispute_id}/accept": {
      "post": {
        "operationId": "acceptDispute",
        "tags": [
          "Disputes"
        ],
        "summary": "Accept a dispute",
        "description": "Concedes the dispute. The disputed amount is not contested. Send an empty body. Disputes with `responded_by: \"oncharge\"` are answered by the OnCharge team: this returns `409 responded_by_oncharge`.",
        "parameters": [
          {
            "$ref": "#/components/parameters/DisputeId"
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "responses": {
          "200": {
            "description": "Result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "dispute_id",
                    "accepted"
                  ],
                  "properties": {
                    "dispute_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "accepted": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/DisputeNotActionable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "502": {
            "$ref": "#/components/responses/DisputeActionFailed"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/api/v1/disputes/{dispute_id}/defend": {
      "post": {
        "operationId": "defendDispute",
        "tags": [
          "Disputes"
        ],
        "summary": "Submit a dispute defense",
        "description": "Submits the defense with the evidence already uploaded. Send an empty body. Disputes with `responded_by: \"oncharge\"` are answered by the OnCharge team: this returns `409 responded_by_oncharge`.",
        "parameters": [
          {
            "$ref": "#/components/parameters/DisputeId"
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "responses": {
          "200": {
            "description": "Result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "dispute_id",
                    "defended"
                  ],
                  "properties": {
                    "dispute_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "defended": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/DisputeNotActionable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "502": {
            "$ref": "#/components/responses/DisputeActionFailed"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/api/v1/disputes/{dispute_id}/auto-defend": {
      "post": {
        "operationId": "autoDefendDispute",
        "tags": [
          "Disputes"
        ],
        "summary": "Build and submit a defense automatically",
        "description": "Builds an evidence packet from the order's checkout records and uploaded evidence and\nsubmits the defense. Send an empty body. Disputes with `responded_by: \"oncharge\"` are answered by the OnCharge team: this returns `409 responded_by_oncharge`.",
        "parameters": [
          {
            "$ref": "#/components/parameters/DisputeId"
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "responses": {
          "200": {
            "description": "Result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AutoDefendResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/DisputeNotActionable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "description": "`build_failed` (the evidence packet could not be built) or `internal_error`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/api/v1/risk/decisions": {
      "get": {
        "operationId": "listRiskDecisions",
        "tags": [
          "Risk"
        ],
        "summary": "List risk decisions",
        "description": "Risk decisions made at checkout for the store, newest first.",
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "description": "Earliest `created_at` (ISO 8601).",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Latest `created_at` (ISO 8601).",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "decision",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/RiskDecisionValue"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of decisions.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "decisions",
                    "total",
                    "limit",
                    "offset"
                  ],
                  "properties": {
                    "decisions": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/RiskDecision"
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "limit": {
                      "type": "integer"
                    },
                    "offset": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/api/v1/risk/decisions/{decision_id}": {
      "get": {
        "operationId": "getRiskDecision",
        "tags": [
          "Risk"
        ],
        "summary": "Retrieve a risk decision",
        "parameters": [
          {
            "name": "decision_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "responses": {
          "200": {
            "description": "The decision with its feature snapshot and outcome label, if any.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RiskDecisionDetail"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/api/v1/risk/feedback": {
      "post": {
        "operationId": "sendRiskFeedback",
        "tags": [
          "Risk"
        ],
        "summary": "Label the outcome of a risk decision",
        "description": "Tells OnCharge how an order turned out, to improve future decisions.",
        "parameters": [
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "session_id",
                  "label"
                ],
                "properties": {
                  "session_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "label": {
                    "type": "string",
                    "enum": [
                      "fraud_confirmed",
                      "false_positive",
                      "legitimate",
                      "chargeback"
                    ]
                  },
                  "notes": {
                    "type": "string",
                    "maxLength": 1000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Recorded.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "label"
                  ],
                  "properties": {
                    "status": {
                      "type": "string",
                      "const": "ok"
                    },
                    "label": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/api/v1/risk/policies": {
      "get": {
        "operationId": "getRiskPolicy",
        "tags": [
          "Risk"
        ],
        "summary": "Get the store's risk policy",
        "description": "The store's policy, or the defaults (`is_default: true`) if none was saved.",
        "parameters": [
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "responses": {
          "200": {
            "description": "The policy.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RiskPolicy"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      },
      "put": {
        "operationId": "updateRiskPolicy",
        "tags": [
          "Risk"
        ],
        "summary": "Create or update the store's risk policy",
        "description": "Each top-level section you send replaces that section; sections you omit are unchanged.\nThresholds must satisfy `score_allow < score_review < score_deny`. In `monitor` mode\ndecisions are recorded but never block a payment.\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RiskPolicyUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Policy updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoredRiskPolicy"
                }
              }
            }
          },
          "201": {
            "description": "Policy created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoredRiskPolicy"
                }
              }
            }
          },
          "400": {
            "description": "`validation_error`, `invalid_json` or `invalid_thresholds`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/api/v1/risk/simulate": {
      "post": {
        "operationId": "simulateRiskPolicy",
        "tags": [
          "Risk"
        ],
        "summary": "Replay a decision under a different policy",
        "description": "Shows what a past decision would have been with the policy you send. Nothing is saved.",
        "parameters": [
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "decision_id",
                  "policy"
                ],
                "properties": {
                  "decision_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "policy": {
                    "$ref": "#/components/schemas/RiskPolicyUpdate"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The original and simulated outcomes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RiskSimulation"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/api/v1/recurring/charge": {
      "post": {
        "operationId": "createRecurringCharge",
        "tags": [
          "Recurring"
        ],
        "summary": "Charge a saved card",
        "description": "A merchant-initiated charge on a card the shopper saved during an earlier OnCharge checkout\n(subscriptions, installments). Availability depends on your account configuration; ask\nOnCharge support before relying on it. Uses the shopper's most recent saved card unless\n`stored_card_id` is given.\n\nOn a store with its own card account the shopper is your customer with that email and\n`stored_card_id` one of their saved cards: it charges through\n`POST /api/v1/customers/{customer_id}/charges`, which new integrations should use instead.\n",
        "x-oncharge-availability": "limited",
        "parameters": [
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "shopper_email",
                  "amount",
                  "currency",
                  "reference"
                ],
                "properties": {
                  "shopper_email": {
                    "type": "string",
                    "format": "email"
                  },
                  "amount": {
                    "$ref": "#/components/schemas/Amount"
                  },
                  "currency": {
                    "$ref": "#/components/schemas/Currency"
                  },
                  "reference": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 255
                  },
                  "recurring_model": {
                    "type": "string",
                    "enum": [
                      "Subscription",
                      "UnscheduledCardOnFile"
                    ],
                    "default": "Subscription"
                  },
                  "stored_card_id": {
                    "type": "string",
                    "format": "uuid"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Charge attempted. Check `status`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "session_id",
                    "status"
                  ],
                  "properties": {
                    "session_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "authorized",
                        "refused",
                        "pending"
                      ]
                    },
                    "result_code": {
                      "type": "string",
                      "description": "Raw authorization result. Use `status` instead."
                    },
                    "psp_reference": {
                      "type": "string",
                      "description": "Opaque payment reference."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "`no_shopper`, `card_not_found` or `no_cards`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "502": {
            "$ref": "#/components/responses/ProviderError"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/api/v1/catalog/products/batch": {
      "post": {
        "operationId": "upsertCatalogProducts",
        "tags": [
          "Catalog"
        ],
        "summary": "Add, update and remove catalog products",
        "description": "Sends up to 500 products and deletes to the store's advertising catalog, which OnCharge sends to Google Merchant Center and the Meta catalog. Products are matched by `id`; sending a product again updates it, and an identical product is not rewritten (`unchanged`). Deletes remove the product from ad platforms.\n\nOnCharge sends the whole catalog to the ad platforms, which review each product against their own policies. `ruo: true` is a label only. Products that name a controlled substance, and products with no image, no price, an http link or `excluded: true`, are stored but not sent. Each result says whether the product is `advertisable` and why not. The WooCommerce plugin (1.5.0+) calls this for you.\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CatalogBatchRequest"
              },
              "example": {
                "items": [
                  {
                    "id": "205",
                    "item_group_id": "200",
                    "title": "Linen shirt - Blue, M",
                    "description": "Soft linen shirt.",
                    "link": "https://shop.example.com/product/linen-shirt/?attribute_pa_color=blue&attribute_pa_size=m",
                    "image_link": "https://shop.example.com/wp-content/uploads/linen-shirt-blue.jpg",
                    "price_minor": 4900,
                    "sale_price_minor": 3900,
                    "currency": "USD",
                    "availability": "in_stock",
                    "brand": "Acme",
                    "gtin": "0012345678905",
                    "product_type": "Apparel > Shirts",
                    "attributes": {
                      "Color": "Blue",
                      "Size": "M"
                    }
                  }
                ],
                "deletes": [
                  "198"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Per-product results and counts.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CatalogBatchResponse"
                },
                "example": {
                  "results": [
                    {
                      "id": "205",
                      "status": "created",
                      "advertisable": true,
                      "ruo": false,
                      "excluded_reason": null
                    },
                    {
                      "id": "198",
                      "status": "deleted"
                    }
                  ],
                  "counts": {
                    "created": 1,
                    "updated": 0,
                    "unchanged": 0,
                    "deleted": 1,
                    "not_found": 0,
                    "rejected": 0
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "`payload_too_large`: more than 5 MB. Send smaller batches.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/api/v1/catalog/products": {
      "get": {
        "operationId": "listCatalogProducts",
        "tags": [
          "Catalog"
        ],
        "summary": "List catalog products",
        "description": "The store's catalog, oldest first. Use it to find products you no longer sell and remove them. Sign an empty body.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          },
          {
            "name": "include_deleted",
            "in": "query",
            "description": "Also list removed products.",
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "name": "updated_since",
            "in": "query",
            "description": "Only products changed at or after this time (ISO 8601).",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of products.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "products",
                    "total",
                    "limit",
                    "offset"
                  ],
                  "properties": {
                    "products": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CatalogProduct"
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "limit": {
                      "type": "integer"
                    },
                    "offset": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/api/v1/events": {
      "get": {
        "operationId": "listEvents",
        "tags": [
          "Events"
        ],
        "summary": "List events",
        "description": "The store's events from the last 30 days, newest first, each exactly as its webhook endpoints received it (data.rail included). Use it to catch up on events your server missed. Paged by cursor.",
        "parameters": [
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "An event type (`payment.captured`) or a group (`payout.*`)."
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "Created on or after this day (UTC)."
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "Created on or before this day (UTC)."
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "`next_cursor` of the previous page, sent with the same filters."
          }
        ],
        "responses": {
          "200": {
            "description": "Events.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "events",
                    "next_cursor"
                  ],
                  "properties": {
                    "events": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/MerchantEvent"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Pass as `cursor` for the next page; null on the last page."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/api/v1/events/{event_id}": {
      "get": {
        "operationId": "getEvent",
        "tags": [
          "Events"
        ],
        "summary": "Retrieve an event",
        "description": "One event from the last 30 days, exactly as your endpoints received it. An older event or another store's answers 404.",
        "parameters": [
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          },
          {
            "$ref": "#/components/parameters/EventId"
          }
        ],
        "responses": {
          "200": {
            "description": "The event.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MerchantEvent"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/api/v1/events/{event_id}/replay": {
      "post": {
        "operationId": "replayEvent",
        "tags": [
          "Events"
        ],
        "summary": "Send an event to an endpoint again",
        "description": "Sends an event from the last 30 days to one of your webhook endpoints again, with the same id and body, signed with that endpoint's secret. It goes even to an endpoint that has not chosen the event's type; a disabled endpoint answers 409. The delivery is retried like any other.",
        "parameters": [
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          },
          {
            "$ref": "#/components/parameters/EventId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "endpoint_id"
                ],
                "properties": {
                  "endpoint_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "One of your webhook endpoints (the Webhooks page shows their ids)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Queued.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "event_id",
                    "delivery_id",
                    "status"
                  ],
                  "properties": {
                    "event_id": {
                      "type": "string"
                    },
                    "delivery_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "pending"
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "The endpoint is disabled.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/api/v1/payments": {
      "get": {
        "operationId": "listPayments",
        "tags": [
          "Payments and balance"
        ],
        "summary": "List payments",
        "description": "The store's payments on every rail, newest first, from the activity ledger the portal reads: card checkout, crypto checkout, and crypto and Card to Crypto paid straight to your wallet through the plugin and the gateway API. `kind` lists refunds, disputes or crypto conversions instead, or all of them.",
        "parameters": [
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          },
          {
            "name": "kind",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "payment",
                "refund",
                "dispute",
                "swap",
                "all"
              ],
              "default": "payment"
            },
            "description": "payment (default), refund, dispute, swap or all."
          },
          {
            "name": "rail",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/EventRail"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "paid",
                "pending",
                "refunded",
                "failed",
                "disputed",
                "review",
                "waiting",
                "uncaptured"
              ]
            }
          },
          {
            "name": "source",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "wallet",
                "plugin",
                "gateway"
              ]
            },
            "description": "Paid straight to your wallet (plugin or gateway API), or one of them."
          },
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "An OnCharge reference or id, a transaction hash, an email or an order number."
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "min",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Smallest amount, in major units."
          },
          {
            "name": "max",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Largest amount, in major units."
          },
          {
            "name": "method",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "card",
                "crypto",
                "cashapp",
                "venmo",
                "bank"
              ]
            }
          },
          {
            "name": "signals",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated: review, fraud_warning, disputed (every one listed must hold)."
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "`next_cursor` of the previous page, sent with the same filters."
          }
        ],
        "responses": {
          "200": {
            "description": "Payments.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "payments",
                    "next_cursor"
                  ],
                  "properties": {
                    "payments": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Payment"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Pass as `cursor` for the next page; null on the last page."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/api/v1/payouts": {
      "get": {
        "operationId": "listPayouts",
        "tags": [
          "Payments and balance"
        ],
        "summary": "List payouts",
        "description": "The store's payouts to its bank, newest first: on their way, paid, not delivered, returned or canceled, and bank debits. Payouts pay orders whose delivery was confirmed; crypto paid to your own wallet is never in a payout.",
        "parameters": [
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "paid",
                "on_its_way",
                "failed",
                "returned",
                "canceled"
              ]
            }
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "min",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "max",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "An order number, payment id or payout id."
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "`next_cursor` of the previous page, sent with the same filters."
          }
        ],
        "responses": {
          "200": {
            "description": "Payouts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "payouts",
                    "next_cursor"
                  ],
                  "properties": {
                    "payouts": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Payout"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Pass as `cursor` for the next page; null on the last page."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/api/v1/payouts/summary": {
      "get": {
        "operationId": "getPayoutSummary",
        "tags": [
          "Payments and balance"
        ],
        "summary": "Card totals for a period",
        "description": "Gross volume, refunds, OnCharge's fees and what you keep, per currency, for a period (default the last 30 days, at most a year).",
        "parameters": [
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "First day (UTC)."
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "Last day (UTC)."
          }
        ],
        "responses": {
          "200": {
            "description": "Totals.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PayoutSummary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/api/v1/payouts/instant": {
      "get": {
        "operationId": "getInstantPayout",
        "tags": [
          "Payments and balance"
        ],
        "summary": "Quote a debit card payout",
        "description": "Whether the store can take a debit card payout now: what would reach the card, OnCharge's fee (1.5%, at least 0.50, taken out of the payout), what would leave the balance and when it should arrive; or why it cannot. Only money already released for delivered orders, and only what the next standard payout would pay, is ever payable. Claims nothing. The debit card is added in the dashboard (it needs a one-time code). 404 `not_available` where debit card payouts are not switched on.",
        "parameters": [
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "responses": {
          "200": {
            "description": "The quote.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "instant_payout"
                  ],
                  "properties": {
                    "instant_payout": {
                      "$ref": "#/components/schemas/InstantPayoutQuote"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "createInstantPayout",
        "tags": [
          "Payments and balance"
        ],
        "summary": "Make a debit card payout",
        "description": "Sends what the quote showed to the store's debit card. An `Idempotency-Key` is required: the same key always answers with the same payout (200, `replay: true`) and never pays twice. Send `expected_amount` (the quote's `amount`): when what is payable changed, nothing is paid and the answer is 409 `quote_changed` with a fresh quote. Refused (409) while payouts are paused (a bank change's cooling-off included), during a new card's cooling-off, over the daily limits, or when nothing released is payable. The result arrives as `payout.paid` or `payout.failed` with `method: \"instant\"`; a failed debit card payout goes to your bank with your next payout, its fee refunded.",
        "parameters": [
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "expected_amount": {
                    "type": "integer",
                    "minimum": 1,
                    "description": "What you expect to reach the card, in minor units."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "This key was used before: the same payout.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "payout",
                    "replay"
                  ],
                  "properties": {
                    "payout": {
                      "$ref": "#/components/schemas/InstantPayout"
                    },
                    "replay": {
                      "type": "boolean",
                      "description": "True when this Idempotency-Key was used before: the same payout, not a new one."
                    }
                  }
                }
              }
            }
          },
          "201": {
            "description": "Made.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "payout",
                    "replay"
                  ],
                  "properties": {
                    "payout": {
                      "$ref": "#/components/schemas/InstantPayout"
                    },
                    "replay": {
                      "type": "boolean",
                      "description": "True when this Idempotency-Key was used before: the same payout, not a new one."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Refused: `error` is the block's code (or `quote_changed`, `invalid_request_key`, `invalid_amount`), `message` says why in plain words, `until` when it lifts by itself. With `quote_changed`, `instant_payout` is a fresh quote.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "until": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "instant_payout": {
                      "oneOf": [
                        {
                          "$ref": "#/components/schemas/InstantPayoutQuote"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "Refused: `error` is the block's code (or `quote_changed`, `invalid_request_key`, `invalid_amount`), `message` says why in plain words, `until` when it lifts by itself. With `quote_changed`, `instant_payout` is a fresh quote.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "until": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "instant_payout": {
                      "oneOf": [
                        {
                          "$ref": "#/components/schemas/InstantPayoutQuote"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "502": {
            "description": "Refused: `error` is the block's code (or `quote_changed`, `invalid_request_key`, `invalid_amount`), `message` says why in plain words, `until` when it lifts by itself. With `quote_changed`, `instant_payout` is a fresh quote.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "until": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "instant_payout": {
                      "oneOf": [
                        {
                          "$ref": "#/components/schemas/InstantPayoutQuote"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Refused: `error` is the block's code (or `quote_changed`, `invalid_request_key`, `invalid_amount`), `message` says why in plain words, `until` when it lifts by itself. With `quote_changed`, `instant_payout` is a fresh quote.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "until": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "instant_payout": {
                      "oneOf": [
                        {
                          "$ref": "#/components/schemas/InstantPayoutQuote"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/balance": {
      "get": {
        "operationId": "getBalance",
        "tags": [
          "Payments and balance"
        ],
        "summary": "Retrieve the balance",
        "description": "Where your money is, as the Balances page shows it.",
        "parameters": [
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "responses": {
          "200": {
            "description": "The balance.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Balance"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          }
        }
      }
    },
    "/api/v1/payment-methods": {
      "get": {
        "operationId": "listPaymentMethods",
        "tags": [
          "Payments and balance"
        ],
        "summary": "List payment methods",
        "description": "The store's ways to pay beyond cards (bank debit, Cash App Pay, Klarna, Affirm, Afterpay), whether each is turned on, and its status in plain words. Read-only: owners and admins turn methods on in the portal.",
        "parameters": [
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "responses": {
          "200": {
            "description": "The store's payment methods.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentMethodList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/payment-links": {
      "get": {
        "operationId": "listPaymentLinks",
        "tags": [
          "Payment links"
        ],
        "summary": "List payment links",
        "description": "The store's payment links, newest first, each with its views, checkouts, payments and revenue. Sign an empty body.",
        "parameters": [
          {
            "name": "active",
            "in": "query",
            "description": "Only links that are on (`true`) or off (`false`).",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "before",
            "in": "query",
            "description": "`next_before` from the previous page.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of payment links.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentLinkList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "createPaymentLink",
        "tags": [
          "Payment links"
        ],
        "summary": "Create a payment link",
        "description": "Makes a link at `https://app.oncharge.io/l/<code>`. Each visit that pays creates an ordinary checkout session (card or crypto, whichever the store has on), so the `payment.*` webhooks fire for it with `data.reference` = `link_<code>`, and shipped goods are paid out after delivery like any other order.\n\nLimits: a fixed amount of at least 50 cents; `amount` × `max_quantity` (or `max_amount`) at most $10,000; quantity up to 99; expiry at most two years ahead. A store that ships what it sells must set `collect_shipping`. `success_url` must be https on one of the store's registered domains.\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreatePaymentLinkRequest"
              },
              "example": {
                "title": "Consultation deposit",
                "amount": 5000,
                "currency": "USD",
                "collect_phone": true,
                "success_url": "https://shop.example.com/thank-you"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The new link, with its QR code.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentLink"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "`payment_method_unavailable`: none of the link's ways to pay (`rails`) is on for the store yet.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/payment-links/{link_id}": {
      "get": {
        "operationId": "getPaymentLink",
        "tags": [
          "Payment links"
        ],
        "summary": "Retrieve a payment link",
        "description": "One link with its stats and QR code. Another store's link answers `404`. Sign an empty body.",
        "parameters": [
          {
            "name": "link_id",
            "in": "path",
            "required": true,
            "description": "The payment link's `id`.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "responses": {
          "200": {
            "description": "The link.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentLink"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "updatePaymentLink",
        "tags": [
          "Payment links"
        ],
        "summary": "Update a payment link",
        "description": "Changes any field of the link, checked as a whole link again, or turns it off (`active: false`) or back on (`active: true`). Switching `amount_type` drops the other kind's amounts.",
        "parameters": [
          {
            "name": "link_id",
            "in": "path",
            "required": true,
            "description": "The payment link's `id`.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdatePaymentLinkRequest"
              },
              "example": {
                "title": "Consultation deposit (December)",
                "expires_at": "2026-12-31T23:59:59Z"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The changed link.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentLink"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`payment_method_unavailable`: none of the link's ways to pay (`rails`) is on for the store yet.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/payment-links/{link_id}/deactivate": {
      "post": {
        "operationId": "deactivatePaymentLink",
        "tags": [
          "Payment links"
        ],
        "summary": "Deactivate a payment link",
        "description": "Turns the link off: visits say it is no longer active and no new checkout starts. Its payments stay. Idempotent. Sign an empty body or `{}`.",
        "parameters": [
          {
            "name": "link_id",
            "in": "path",
            "required": true,
            "description": "The payment link's `id`.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "responses": {
          "200": {
            "description": "The link, now off.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentLink"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/invoices": {
      "get": {
        "operationId": "listInvoices",
        "tags": [
          "Invoices"
        ],
        "summary": "List invoices",
        "description": "The store's invoices, newest first. `kind=credit_note` lists credit notes.",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "draft",
                "open",
                "overdue",
                "paid",
                "void",
                "all"
              ],
              "default": "all"
            }
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "An invoice number, a customer email, or part of a customer name."
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "`next_cursor` from the previous page."
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          },
          {
            "name": "kind",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "invoice",
                "credit_note"
              ],
              "default": "invoice"
            }
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of invoices.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "createInvoice",
        "tags": [
          "Invoices"
        ],
        "summary": "Create an invoice",
        "description": "A new draft. With `finalize` it is also numbered and opened for payment; with `send` it is also emailed to the customer (PDF attached). The bill-to details live on the invoice. A repeat with the same `Idempotency-Key` returns the first draft with `idempotent: true`.",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateInvoiceRequest"
              },
              "example": {
                "customer": {
                  "name": "Ada Lovelace",
                  "email": "ada@example.com"
                },
                "lines": [
                  {
                    "description": "Consulting, November",
                    "quantity": 10,
                    "unit_amount": 15000,
                    "tax_rate": 8.875
                  }
                ],
                "days_until_due": 14,
                "send": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Idempotent replay.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Invoice"
                }
              }
            }
          },
          "201": {
            "description": "Created (and finalized or sent when asked).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Invoice"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`store_inactive`: the store is not taking payments.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "`invoice_incomplete`: finalizing needs a line, a total above zero and the customer's name; `invoice_too_large`: the lines would total more than 100000000000 minor units.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/invoices/{invoice_id}": {
      "get": {
        "operationId": "getInvoice",
        "tags": [
          "Invoices"
        ],
        "summary": "Retrieve an invoice",
        "description": "The invoice or credit note with its lines, history, payments (OnCharge references), credit notes and how it can be paid now.",
        "parameters": [
          {
            "$ref": "#/components/parameters/InvoiceId"
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "responses": {
          "200": {
            "description": "The invoice.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Invoice"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "updateInvoice",
        "tags": [
          "Invoices"
        ],
        "summary": "Update a draft",
        "description": "Any draft field; `lines` replaces every line. A finalized invoice cannot be edited: void it and create another, or issue a credit note.",
        "parameters": [
          {
            "$ref": "#/components/parameters/InvoiceId"
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoiceUpdateRequest"
              },
              "example": {
                "memo": "Thanks for your business."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The draft.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Invoice"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`invoice_locked`: a finalized invoice cannot be edited; `invoice_not_draft`, `invalid_transition` or `invoice_partly_paid`: not possible in its status; `payment_in_progress`: a payment for the invoice is under way (try again in a few minutes); `store_inactive`: the store is not taking payments.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "operationId": "deleteInvoice",
        "tags": [
          "Invoices"
        ],
        "summary": "Delete a draft",
        "description": "Only a draft can be deleted.",
        "parameters": [
          {
            "$ref": "#/components/parameters/InvoiceId"
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "deleted": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`invoice_locked`: a finalized invoice cannot be edited; `invoice_not_draft`, `invalid_transition` or `invoice_partly_paid`: not possible in its status; `payment_in_progress`: a payment for the invoice is under way (try again in a few minutes); `store_inactive`: the store is not taking payments.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/invoices/{invoice_id}/finalize": {
      "post": {
        "operationId": "finalizeInvoice",
        "tags": [
          "Invoices"
        ],
        "summary": "Finalize a draft",
        "description": "Gives the draft its store's next number (`INV-0001`), a due date and its hosted invoice page (`hosted_url`). Nothing on it can change afterwards. With `send`, also emails it.",
        "parameters": [
          {
            "$ref": "#/components/parameters/InvoiceId"
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "send": {
                    "type": "boolean"
                  }
                }
              },
              "example": {
                "send": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The invoice.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Invoice"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`invoice_locked`: a finalized invoice cannot be edited; `invoice_not_draft`, `invalid_transition` or `invoice_partly_paid`: not possible in its status; `payment_in_progress`: a payment for the invoice is under way (try again in a few minutes); `store_inactive`: the store is not taking payments.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "`invoice_incomplete`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/invoices/{invoice_id}/send": {
      "post": {
        "operationId": "sendInvoice",
        "tags": [
          "Invoices"
        ],
        "summary": "Email an open invoice",
        "description": "Emails the invoice (again) to the customer with its PDF attached and the payment link. Needs the customer's email.",
        "parameters": [
          {
            "$ref": "#/components/parameters/InvoiceId"
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "responses": {
          "200": {
            "description": "The invoice.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Invoice"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`invoice_locked`: a finalized invoice cannot be edited; `invoice_not_draft`, `invalid_transition` or `invoice_partly_paid`: not possible in its status; `payment_in_progress`: a payment for the invoice is under way (try again in a few minutes); `store_inactive`: the store is not taking payments.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "`invoice_incomplete`: no customer email.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "502": {
            "description": "`email_failed`: try again, or share `hosted_url`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/invoices/{invoice_id}/void": {
      "post": {
        "operationId": "voidInvoice",
        "tags": [
          "Invoices"
        ],
        "summary": "Void an open invoice",
        "description": "Cancels an open invoice nothing was paid on. Checkouts not yet started for it are closed; a payment already under way that completes is recorded on the invoice's history for you to refund.",
        "parameters": [
          {
            "$ref": "#/components/parameters/InvoiceId"
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "reason": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 500
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The invoice.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Invoice"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`invoice_locked`: a finalized invoice cannot be edited; `invoice_not_draft`, `invalid_transition` or `invoice_partly_paid`: not possible in its status; `payment_in_progress`: a payment for the invoice is under way (try again in a few minutes); `store_inactive`: the store is not taking payments.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/invoices/{invoice_id}/mark-paid": {
      "post": {
        "operationId": "markInvoicePaid",
        "tags": [
          "Invoices"
        ],
        "summary": "Mark an invoice paid outside OnCharge",
        "description": "Records what is left to pay as paid by bank transfer, cash or cheque. The payment link stops working.",
        "parameters": [
          {
            "$ref": "#/components/parameters/InvoiceId"
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "note": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 500
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The invoice.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Invoice"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`invoice_locked`: a finalized invoice cannot be edited; `invoice_not_draft`, `invalid_transition` or `invoice_partly_paid`: not possible in its status; `payment_in_progress`: a payment for the invoice is under way (try again in a few minutes); `store_inactive`: the store is not taking payments.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/invoices/{invoice_id}/credit-notes": {
      "post": {
        "operationId": "createCreditNote",
        "tags": [
          "Invoices"
        ],
        "summary": "Issue a credit note",
        "description": "A numbered credit note (`CN-0001`) against an open or paid invoice. On an open invoice it lowers what is left to pay (a credit for all of it settles the invoice); on a paid one it records a credit, and with `refund` (only for an invoice paid through OnCharge) also refunds it to the customer's payment. The customer is emailed the note.",
        "parameters": [
          {
            "$ref": "#/components/parameters/InvoiceId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreditNoteRequest"
              },
              "example": {
                "amount": 5000,
                "reason": "order_change",
                "memo": "Two hours fewer than quoted."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Idempotent replay.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Invoice"
                }
              }
            }
          },
          "201": {
            "description": "The credit note (with `refund` when one was asked for).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Invoice"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "refund": {
                          "type": "object",
                          "properties": {
                            "ok": {
                              "type": "boolean"
                            },
                            "status": {
                              "type": "string"
                            },
                            "amount": {
                              "type": "integer"
                            },
                            "message": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`invoice_locked`: a finalized invoice cannot be edited; `invoice_not_draft`, `invalid_transition` or `invoice_partly_paid`: not possible in its status; `payment_in_progress`: a payment for the invoice is under way (try again in a few minutes); `store_inactive`: the store is not taking payments.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "`credit_too_large`: more than is left to pay (or, once paid, than the invoice).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/invoices/{invoice_id}/pdf": {
      "get": {
        "operationId": "getInvoicePdf",
        "tags": [
          "Invoices"
        ],
        "summary": "Download an invoice PDF",
        "description": "The invoice or credit note as a PDF.",
        "parameters": [
          {
            "$ref": "#/components/parameters/InvoiceId"
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "responses": {
          "200": {
            "description": "The PDF.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/invoices/{invoice_id}/refund-extra": {
      "post": {
        "operationId": "refundExtraInvoicePayment",
        "tags": [
          "Invoices"
        ],
        "summary": "Refund an extra payment",
        "description": "Refunds what a payment paid beyond what the invoice took: a payment for an invoice that was already settled, voided or credited, or the part of one over what was left to pay. Such payments show in the invoice's history as `payment_unapplied` and the merchant is told. Refunded at most once per payment.",
        "parameters": [
          {
            "$ref": "#/components/parameters/InvoiceId"
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "payment_reference"
                ],
                "properties": {
                  "payment_reference": {
                    "type": "string",
                    "description": "The payment's OnCharge reference (`ocpay_…`)."
                  }
                }
              },
              "example": {
                "payment_reference": "ocpay_3f2a9c1e0b7d4e6f8a1b2c3d4e5f6a7b"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The invoice, with `refund`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Invoice"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`refund_failed`: the refund could not be made.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/customers": {
      "get": {
        "operationId": "listCustomers",
        "tags": [
          "Customers"
        ],
        "summary": "List customers",
        "description": "Your store's customers, newest first, with their totals.\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          },
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 200
            },
            "description": "An OnCharge customer ID, or part of an email, name, phone or your reference."
          },
          {
            "name": "email",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "email"
            }
          },
          {
            "name": "reference",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "`next_cursor` of the previous page."
          }
        ],
        "responses": {
          "200": {
            "description": "A page of customers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "createCustomer",
        "tags": [
          "Customers"
        ],
        "summary": "Add a customer",
        "description": "Adds a customer to your store. One email, and one reference, is one customer of a store: a second\nis refused with `409 customer_exists` and the existing customer's ID in `customer_id`.\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCustomerRequest"
              },
              "example": {
                "email": "ann@example.com",
                "name": "Ann Smith",
                "reference": "crm-1042",
                "metadata": {
                  "tier": "gold"
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Customer added.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Customer"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "`customer_exists`: the store already has a customer with that email or reference (`customer_id`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/customers/{customer_id}": {
      "get": {
        "operationId": "retrieveCustomer",
        "tags": [
          "Customers"
        ],
        "summary": "Retrieve a customer",
        "description": "One of your store's customers, with totals and saved cards. Another store's customer answers 404.\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          },
          {
            "$ref": "#/components/parameters/CustomerId"
          }
        ],
        "responses": {
          "200": {
            "description": "The customer.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Customer"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/customers/{customer_id}/payment-methods": {
      "get": {
        "operationId": "listSavedCards",
        "tags": [
          "Customers"
        ],
        "summary": "List saved cards",
        "parameters": [
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          },
          {
            "$ref": "#/components/parameters/CustomerId"
          }
        ],
        "responses": {
          "200": {
            "description": "The customer's saved cards that can be charged.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SavedCardList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "createSetupSession",
        "tags": [
          "Customers"
        ],
        "summary": "Create a save-card page",
        "description": "Creates a page where the customer saves a card without paying. Send them to `url`: it shows\nthe consent text first and the card form only after they agree; the card is saved for your\nstore only. The same `Idempotency-Key` returns the same page.\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/CustomerId"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateSetupSessionRequest"
              },
              "example": {
                "return_url": "https://shop.example.com/account"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The page created earlier with this `Idempotency-Key`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SetupSession"
                }
              }
            }
          },
          "201": {
            "description": "Page created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SetupSession"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`saved_cards_unavailable`: card payments are not set up on this store.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/customers/{customer_id}/payment-methods/{payment_method_id}": {
      "delete": {
        "operationId": "removeSavedCard",
        "tags": [
          "Customers"
        ],
        "summary": "Remove a saved card",
        "description": "Removes a saved card for good: it is detached at the processor and can never be charged again.\nRemoving a card that is already removed answers the same. If it cannot be removed right now\n(`502 try_again`) nothing changed.\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          },
          {
            "$ref": "#/components/parameters/CustomerId"
          },
          {
            "$ref": "#/components/parameters/PaymentMethodId"
          }
        ],
        "responses": {
          "200": {
            "description": "Removed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "object",
                    "deleted"
                  ],
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "object": {
                      "type": "string",
                      "const": "payment_method"
                    },
                    "deleted": {
                      "type": "boolean",
                      "const": true
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "502": {
            "description": "`try_again`: the card could not be removed right now; nothing changed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/customers/{customer_id}/charges": {
      "post": {
        "operationId": "createCustomerCharge",
        "tags": [
          "Customers"
        ],
        "summary": "Charge a saved card",
        "description": "Charges a customer's saved card while they are away. Use it only for what the customer agreed\nto when they saved the card. Always send an `Idempotency-Key`: a retry returns the same charge\nand never charges twice.\n\nIt is a payment like any checkout payment: same fee, same delivery-gated payout (card payments\non these stores are USD; an order that ships by carrier needs `shipping` with `order_id`), same\n`payment.*` webhooks, and it appears under Payments.\n\nWhen the customer's bank asks them to confirm the payment, the status is\n`requires_authentication` and OnCharge emails them a link to confirm it.\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/CustomerId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCustomerChargeRequest"
              },
              "example": {
                "amount": 2900,
                "currency": "USD",
                "reference": "subscription-2026-12"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The charge made earlier with this `Idempotency-Key` (`idempotent: true`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerCharge"
                }
              }
            }
          },
          "201": {
            "description": "Charge made: `succeeded`, `processing` or `requires_authentication`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerCharge"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "description": "Declined: `decline.reason` and `decline.message` say why in plain words. `limit_exceeded`: the charge would go over a limit OnCharge set for the store (for example a daily volume cap); nothing was sent to the bank. Charge again with a new `Idempotency-Key` once the limit allows it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerCharge"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`no_saved_card`, `payment_method_unusable` (the card was removed, also when resuming a charge started with it), `charge_not_completed` (an interrupted charge more than 20 hours old), `idempotency_conflict` or `saved_cards_unavailable`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "502": {
            "description": "`try_again`: the outcome is not known yet. Retry with the same `Idempotency-Key` (within 20 hours); the card is never charged twice. After that the charge answers `409 charge_not_completed`: start a new one with a new key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/plans": {
      "get": {
        "operationId": "listPlans",
        "tags": [
          "Subscriptions"
        ],
        "summary": "List plans",
        "description": "Your store's plans and add-ons, newest first (at most 200). Archived ones only with `include_archived=true`.",
        "parameters": [
          {
            "name": "include_archived",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "Also list archived plans."
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "responses": {
          "200": {
            "description": "The plans.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlanList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "`not_found`: subscriptions are not available yet (every subscription endpoint answers 404 until they are turned on).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "createPlan",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Create a plan or add-on",
        "description": "A plan: a price every `interval_count` `interval`s (a period is at most a year), with an optional free trial and intro price. Or an add-on (`kind: \"addon\"`): billed with the plan it is added to, in the same periods. A plan's price and terms never change once created: create another plan and move subscriptions to it with `change`. A repeat with the same `Idempotency-Key` returns the first plan (200).",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreatePlanRequest"
              },
              "example": {
                "name": "Monthly box",
                "description": "A box of our best sellers, every month.",
                "amount": 3000,
                "currency": "USD",
                "interval": "month",
                "trial_days": 14,
                "intro": {
                  "amount": 1500,
                  "periods": 2
                },
                "requires_shipping": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Idempotent replay.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Plan"
                }
              }
            }
          },
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Plan"
                },
                "example": {
                  "id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
                  "object": "plan",
                  "store_id": "0f1e2d3c-4b5a-4968-8776-655443322110",
                  "name": "Monthly box",
                  "description": "A box of our best sellers, every month.",
                  "amount": 3000,
                  "currency": "USD",
                  "interval": "month",
                  "interval_count": 1,
                  "interval_text": "month",
                  "trial_days": 14,
                  "intro": {
                    "amount": 1500,
                    "periods": 2
                  },
                  "requires_shipping": true,
                  "active": true,
                  "metadata": {},
                  "created_at": "2026-12-01T00:00:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: the message names the first invalid field (an intro price must be lower than the plan's price); `invalid_json`: the body is not JSON; `invalid_idempotency_key`: the `Idempotency-Key` is longer than 255 characters or has control characters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "`store_not_found`; `not_found` while subscriptions are not available yet (every subscription endpoint answers 404 until they are turned on).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/plans/{plan_id}": {
      "get": {
        "operationId": "getPlan",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Retrieve a plan",
        "parameters": [
          {
            "$ref": "#/components/parameters/PlanId"
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "responses": {
          "200": {
            "description": "The plan or add-on.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Plan"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "`plan_not_found`: no such plan in your store; `not_found` while subscriptions are not available yet (every subscription endpoint answers 404 until they are turned on).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "operationId": "updatePlan",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Update or archive a plan",
        "description": "Its name, description or metadata, or archive it with `active: false` (subscriptions already on it go on; it takes no new ones). The price and terms cannot change. Signed like any request, with `PATCH` as the method.",
        "parameters": [
          {
            "$ref": "#/components/parameters/PlanId"
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdatePlanRequest"
              },
              "example": {
                "active": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The plan.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Plan"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: the message names the first invalid field; `invalid_json`: the body is not JSON.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "`plan_not_found`: no such plan in your store; `not_found` while subscriptions are not available yet (every subscription endpoint answers 404 until they are turned on).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/plans/{plan_id}/payment-link": {
      "post": {
        "operationId": "createPlanPaymentLink",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Create a sign-up link for a plan",
        "description": "A payment link (https://app.oncharge.io/l/<code>) that signs shoppers up to the plan: they enter their email (and their shipping address if the plan ships), then agree to the recurring terms and enter a card on OnCharge's sign-up page. It is one of your payment links: it appears with them, and you turn it off the same way (`POST /api/v1/payment-links/{link_id}/deactivate`).",
        "parameters": [
          {
            "$ref": "#/components/parameters/PlanId"
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "title": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120,
                    "description": "What the link page shows. Default: the plan's name."
                  }
                }
              },
              "example": {
                "title": "Join the Monthly box"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The link.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlanPaymentLink"
                },
                "example": {
                  "id": "5f0c9d4e-2a1b-4c3d-9e8f-7a6b5c4d3e2f",
                  "code": "k7Hq2mNpR4sT",
                  "url": "https://app.oncharge.io/l/k7Hq2mNpR4sT",
                  "plan_id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: the message names the first invalid field; `invalid_json`: the body is not JSON.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "`plan_not_found`: no such plan (add-ons have no links); `not_found` while subscriptions are not available yet (every subscription endpoint answers 404 until they are turned on).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "`plan_inactive`: the plan is archived.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/subscriptions": {
      "get": {
        "operationId": "listSubscriptions",
        "tags": [
          "Subscriptions"
        ],
        "summary": "List subscriptions",
        "description": "Your store's subscriptions, newest first.",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/SubscriptionStatus"
            },
            "description": "Only this status."
          },
          {
            "name": "customer_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Only this customer's."
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          },
          {
            "name": "starting_after",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The last `id` of the previous page."
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of subscriptions.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubscriptionList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "`not_found`: subscriptions are not available yet (every subscription endpoint answers 404 until they are turned on).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "operationId": "createSubscription",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Start a subscription for a customer",
        "description": "For an existing customer of your store. It starts as `incomplete`: OnCharge emails the customer a link to its sign-up page, where they read the terms, agree to the recurring charges and choose one of their saved cards or add one. It starts when they agree (the trial starts, or the first period is charged). The link is never returned to you, and it works for 7 days; after that the subscription is `incomplete_expired`. A repeat with the same `Idempotency-Key` returns the first subscription (200).",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateSubscriptionRequest"
              },
              "example": {
                "customer_id": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
                "plan_id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
                "quantity": 1,
                "addons": [
                  {
                    "plan_id": "d2e3f4a5-b6c7-4d8e-9f0a-1b2c3d4e5f6a",
                    "quantity": 1
                  }
                ],
                "shipping": {
                  "name": "Ada Lovelace",
                  "line1": "1 Main St",
                  "city": "Austin",
                  "state": "TX",
                  "postal_code": "78701",
                  "country": "US"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Idempotent replay.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Subscription"
                }
              }
            }
          },
          "201": {
            "description": "Created, waiting for the customer (`incomplete`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Subscription"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: the message names the first invalid field (also an add-on listed twice, or in another currency); `invalid_json`: the body is not JSON; `invalid_idempotency_key`: the `Idempotency-Key` is longer than 255 characters or has control characters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "`customer_not_found`, `plan_not_found` or `addon_not_found`; `not_found` while subscriptions are not available yet (every subscription endpoint answers 404 until they are turned on).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "`customer_email_required`: the customer has no email address; `plan_inactive`: the plan (or an add-on) is archived; `store_inactive`: the store is not taking payments; `subscriptions_unavailable`: the store has no card payments set up for saved cards; `idempotency_conflict`: the `Idempotency-Key` was used for another customer or plan.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "`shipping_address_required`: the subscription ships each period: send `shipping`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/subscriptions/checkout": {
      "post": {
        "operationId": "createSubscriptionCheckout",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Create a hosted sign-up page",
        "description": "A sign-up page on OnCharge for one customer: the answer is the subscription (`incomplete`) with its `url`. Send the customer there; they read the terms, agree to the recurring charges and enter a card, and the subscription starts (the trial starts, or the first period is charged). The page works for 24 hours and never offers the customer's saved cards. A repeat with the same `Idempotency-Key` returns the first subscription and its page (200).",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateSubscriptionCheckoutRequest"
              },
              "example": {
                "plan_id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
                "customer_email": "ada@example.com",
                "customer_name": "Ada Lovelace",
                "shipping": {
                  "name": "Ada Lovelace",
                  "line1": "1 Main St",
                  "city": "Austin",
                  "state": "TX",
                  "postal_code": "78701",
                  "country": "US"
                },
                "success_url": "https://shop.example.com/welcome"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Idempotent replay.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubscriptionCheckout"
                }
              }
            }
          },
          "201": {
            "description": "Created: send the customer to `url`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubscriptionCheckout"
                },
                "example": {
                  "id": "7e2f9a1c-3b4d-4e5f-8a6b-9c0d1e2f3a4b",
                  "object": "subscription",
                  "store_id": "0f1e2d3c-4b5a-4968-8776-655443322110",
                  "customer_id": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
                  "customer": {
                    "email": "ada@example.com",
                    "name": "Ada Lovelace"
                  },
                  "plan": {
                    "id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
                    "name": "Monthly box",
                    "amount": 3000,
                    "currency": "USD",
                    "interval": "month",
                    "interval_count": 1
                  },
                  "quantity": 1,
                  "addons": [],
                  "intro": {
                    "amount": 1500,
                    "periods": 2
                  },
                  "credit_balance": 0,
                  "pending_change": null,
                  "cancel_at_period_end": false,
                  "canceled_at": null,
                  "ended_at": null,
                  "cancel_reason": null,
                  "pause": null,
                  "shipping": {
                    "name": "Ada Lovelace",
                    "address": {
                      "line1": "1 Main St",
                      "line2": null,
                      "city": "Austin",
                      "state": "TX",
                      "postal_code": "78701",
                      "country": "US"
                    }
                  },
                  "payment_link_id": null,
                  "metadata": {},
                  "created_at": "2026-12-01T00:00:00.000Z",
                  "status": "incomplete",
                  "status_text": "Waiting for customer",
                  "payment_method": null,
                  "trial_end": null,
                  "current_period": null,
                  "next_billing_at": null,
                  "source": "checkout",
                  "sign_up_expires_at": "2026-12-02T00:00:00.000Z",
                  "url": "https://app.oncharge.io/s/subscribe/7e2f9a1c-3b4d-4e5f-8a6b-9c0d1e2f3a4b?token=ocs_…"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: the message names the first invalid field (also neither `customer_id` nor `customer_email`, or an add-on listed twice or in another currency); `invalid_json`: the body is not JSON; `invalid_idempotency_key`: the `Idempotency-Key` is longer than 255 characters or has control characters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "`customer_not_found`, `plan_not_found` or `addon_not_found`; `not_found` while subscriptions are not available yet (every subscription endpoint answers 404 until they are turned on).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "`plan_inactive`: the plan (or an add-on) is archived; `store_inactive`: the store is not taking payments; `subscriptions_unavailable`: the store has no card payments set up for saved cards; `idempotency_conflict`: the `Idempotency-Key` was used for another customer or plan.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "`shipping_address_required`: the subscription ships each period: send `shipping`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/subscriptions/{subscription_id}": {
      "get": {
        "operationId": "getSubscription",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Retrieve a subscription",
        "description": "The subscription with every bill (each period and prorated plan change, its invoice, attempts, failure and payment reference) and its history.",
        "parameters": [
          {
            "$ref": "#/components/parameters/SubscriptionId"
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "responses": {
          "200": {
            "description": "The subscription.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubscriptionDetail"
                },
                "example": {
                  "id": "7e2f9a1c-3b4d-4e5f-8a6b-9c0d1e2f3a4b",
                  "object": "subscription",
                  "store_id": "0f1e2d3c-4b5a-4968-8776-655443322110",
                  "customer_id": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
                  "customer": {
                    "email": "ada@example.com",
                    "name": "Ada Lovelace"
                  },
                  "plan": {
                    "id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
                    "name": "Monthly box",
                    "amount": 3000,
                    "currency": "USD",
                    "interval": "month",
                    "interval_count": 1
                  },
                  "quantity": 1,
                  "addons": [],
                  "intro": {
                    "amount": 1500,
                    "periods": 2
                  },
                  "credit_balance": 0,
                  "pending_change": null,
                  "cancel_at_period_end": false,
                  "canceled_at": null,
                  "ended_at": null,
                  "cancel_reason": null,
                  "pause": null,
                  "shipping": {
                    "name": "Ada Lovelace",
                    "address": {
                      "line1": "1 Main St",
                      "line2": null,
                      "city": "Austin",
                      "state": "TX",
                      "postal_code": "78701",
                      "country": "US"
                    }
                  },
                  "payment_link_id": null,
                  "metadata": {},
                  "created_at": "2026-12-01T00:00:00.000Z",
                  "status": "active",
                  "status_text": "Active",
                  "payment_method": {
                    "id": "5b6c7d8e-9f0a-4b1c-8d2e-3f4a5b6c7d8e",
                    "object": "payment_method",
                    "type": "card",
                    "brand": "Visa",
                    "last4": "4242",
                    "exp_month": 12,
                    "exp_year": 2029,
                    "funding": "credit",
                    "country": "US",
                    "wallet": null,
                    "is_default": true,
                    "status": "active",
                    "expired": false,
                    "saved_via": "save_card_page",
                    "created_at": "2026-12-01T00:00:00.000Z",
                    "last_used_at": "2026-12-15T00:00:00.000Z",
                    "updated_by_card_network_at": null,
                    "removed_at": null
                  },
                  "trial_end": "2026-12-15T00:00:00.000Z",
                  "current_period": {
                    "index": 0,
                    "start": "2026-12-15T00:00:00.000Z",
                    "end": "2027-01-15T00:00:00.000Z",
                    "amount": 1500
                  },
                  "next_billing_at": "2027-01-15T00:00:00.000Z",
                  "source": "api",
                  "sign_up_expires_at": null,
                  "billings": [
                    {
                      "id": "2b3c4d5e-6f7a-4b8c-9d0e-1f2a3b4c5d6e",
                      "object": "subscription_billing",
                      "subscription_id": "7e2f9a1c-3b4d-4e5f-8a6b-9c0d1e2f3a4b",
                      "reason": "period",
                      "period_index": 0,
                      "period_start": "2026-12-15T00:00:00.000Z",
                      "period_end": "2027-01-15T00:00:00.000Z",
                      "lines": [
                        {
                          "description": "Monthly box (introductory price)",
                          "quantity": 1,
                          "unit_amount": 1500,
                          "requires_shipping": true
                        }
                      ],
                      "subtotal": 1500,
                      "credit_applied": 0,
                      "amount_due": 1500,
                      "ships": true,
                      "status": "paid",
                      "invoice": {
                        "id": "4d5e6f7a-8b9c-4d0e-8f1a-2b3c4d5e6f7a",
                        "number": "INV-0042"
                      },
                      "attempts": 1,
                      "next_attempt_at": null,
                      "failure": null,
                      "paid_at": "2026-12-15T00:05:00.000Z",
                      "payment_reference": "ocpay_8f14e45fceea467a95752c3b8e1f0b6d",
                      "created_at": "2026-12-15T00:00:00.000Z"
                    }
                  ],
                  "history": [
                    {
                      "kind": "billing_paid",
                      "actor": "system",
                      "data": {
                        "amount": 1500,
                        "period_index": 0,
                        "reason": "period"
                      },
                      "created_at": "2026-12-15T00:05:00.000Z"
                    },
                    {
                      "kind": "consent_granted",
                      "actor": "customer",
                      "data": {
                        "version": "2026-12-01-draft"
                      },
                      "created_at": "2026-12-01T00:10:00.000Z"
                    },
                    {
                      "kind": "created",
                      "actor": "system",
                      "data": {
                        "source": "api",
                        "plan_id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
                        "quantity": 1
                      },
                      "created_at": "2026-12-01T00:00:00.000Z"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "`not_found`: no such subscription in your store; `not_found` while subscriptions are not available yet (every subscription endpoint answers 404 until they are turned on).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "operationId": "updateSubscription",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Update a subscription",
        "description": "Change where it ships, replace its metadata, or ask the customer to switch to another of their saved cards at your store. Only the customer changes the card: with `payment_method_id` they are emailed a link to switch to that card on their subscription page (once an hour at most), and the answer is `202` with `card_change`. If that email cannot be sent, nothing in the request is saved. Nothing changes, and nothing is charged to that card, until the customer switches and agrees to the charges on it. Signed like any request, with `PATCH` as the method.",
        "parameters": [
          {
            "$ref": "#/components/parameters/SubscriptionId"
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateSubscriptionRequest"
              },
              "example": {
                "payment_method_id": "5b6c7d8e-9f0a-4b1c-8d2e-3f4a5b6c7d8e"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The subscription.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Subscription"
                }
              }
            }
          },
          "202": {
            "description": "With `payment_method_id`: the customer was emailed a link to switch to that card (`card_change.status: \"customer_asked\"`, with the card's brand and last four digits). The subscription keeps its card until they do; any shipping or metadata change in the same request is saved.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Subscription"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "card_change": {
                          "type": "object",
                          "properties": {
                            "status": {
                              "type": "string",
                              "enum": [
                                "customer_asked"
                              ]
                            },
                            "payment_method": {
                              "type": "object",
                              "properties": {
                                "brand": {
                                  "type": "string"
                                },
                                "last4": {
                                  "type": "string"
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: the message names the first invalid field; `invalid_json`: the body is not JSON.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "`not_found`: no such subscription; `payment_method_not_found`: not an active saved card of this customer; `not_found` while subscriptions are not available yet (every subscription endpoint answers 404 until they are turned on).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "`subscription_ended`: it has ended; `not_started`: the customer chooses the card when they sign up; `customer_email_required`: the customer has no email address to ask them to switch cards; `conflict`: the subscription changed meanwhile (try again). A `429 too_many_requests` means you asked this customer to switch cards less than an hour ago; a `502 customer_not_emailed` means the email could not be sent and nothing in the request was saved: try again.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/subscriptions/{subscription_id}/cancel": {
      "post": {
        "operationId": "cancelSubscription",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Cancel a subscription",
        "description": "By default an active or trialing subscription ends when its current period (or trial) ends: nothing more is charged, and `subscription.canceled` follows then. With `at_period_end: false`, or for any other status, it ends now: anything unpaid is voided. The customer is emailed. To keep a subscription whose cancellation is waiting, `resume` it (not when the customer cancelled it).",
        "parameters": [
          {
            "$ref": "#/components/parameters/SubscriptionId"
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CancelSubscriptionRequest"
              },
              "example": {
                "at_period_end": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The subscription: `cancel_at_period_end: true`, or `canceled`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Subscription"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: the message names the first invalid field; `invalid_json`: the body is not JSON.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "`not_found`: no such subscription in your store; `not_found` while subscriptions are not available yet (every subscription endpoint answers 404 until they are turned on).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "`subscription_ended`: it has already ended; `payment_in_progress`: a payment for it is being collected (try again in a minute); `conflict`: the subscription changed meanwhile (try again).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/subscriptions/{subscription_id}/pause": {
      "post": {
        "operationId": "pauseSubscription",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Pause a subscription",
        "description": "From the end of the current period (nothing already paid is lost), for `periods` periods, until `resume_at`, or until resumed. While paused nothing is charged or shipped. Only an active or trialing subscription can be paused; a past-due one must be paid first.",
        "parameters": [
          {
            "$ref": "#/components/parameters/SubscriptionId"
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PauseSubscriptionRequest"
              },
              "example": {
                "periods": 2
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The subscription, with `pause.at_period_end: true`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Subscription"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: the message names the first invalid field (also both `periods` and `resume_at`, or a `resume_at` not after the end of the current period); `invalid_json`: the body is not JSON.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "`not_found`: no such subscription in your store; `not_found` while subscriptions are not available yet (every subscription endpoint answers 404 until they are turned on).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "`payment_required`: it is past due; `not_pausable`: it is not active or trialing; `cancel_scheduled`: it ends at the period's end; `conflict`: the subscription changed meanwhile (try again).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/subscriptions/{subscription_id}/resume": {
      "post": {
        "operationId": "resumeSubscription",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Resume a subscription",
        "description": "A paused subscription starts again now: a new period begins and is charged at once. On a subscription with a pause or cancellation waiting for the period's end, the pause or cancellation is called off. A cancellation the customer asked for is theirs to undo, by subscribing again.",
        "parameters": [
          {
            "$ref": "#/components/parameters/SubscriptionId"
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "responses": {
          "200": {
            "description": "The subscription.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Subscription"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "`not_found`: no such subscription in your store; `not_found` while subscriptions are not available yet (every subscription endpoint answers 404 until they are turned on).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "`not_paused`: nothing to resume; `canceled_by_customer`: the customer cancelled it; `conflict`: the subscription changed meanwhile (try again).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/subscriptions/{subscription_id}/change": {
      "post": {
        "operationId": "changeSubscription",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Change the plan, quantity or add-ons",
        "description": "A change that **raises the price** the customer pays is never applied at once: it waits in `pending_change` (with `increase`) for the first period that starts at least 7 days after the customer is emailed a notice, which goes 7 to 30 days before the new price is first charged. Asking for `proration: \"now\"` on an increase is refused (`409 price_increase_needs_notice`); leave `proration` out (or send `\"next_period\"`) to schedule it. Any other change applies at once by default: the rest of the current period is prorated and the difference for the time left (to the second, rounded half up) is credited to the next bills. With `\"next_period\"` it applies at the renewal (`pending_change`). A shipped subscription (each period is one order) and a plan with another interval change at the next period only; a paused subscription always does. The customer is emailed the new price.",
        "parameters": [
          {
            "$ref": "#/components/parameters/SubscriptionId"
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChangeSubscriptionRequest"
              },
              "example": {
                "plan_id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
                "quantity": 2,
                "proration": "next_period"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The subscription; for a change applied now, with `proration`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubscriptionChangeResult"
                },
                "example": {
                  "id": "7e2f9a1c-3b4d-4e5f-8a6b-9c0d1e2f3a4b",
                  "object": "subscription",
                  "store_id": "0f1e2d3c-4b5a-4968-8776-655443322110",
                  "customer_id": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
                  "customer": {
                    "email": "ada@example.com",
                    "name": "Ada Lovelace"
                  },
                  "plan": {
                    "id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
                    "name": "Monthly box",
                    "amount": 3000,
                    "currency": "USD",
                    "interval": "month",
                    "interval_count": 1
                  },
                  "quantity": 2,
                  "addons": [],
                  "intro": {
                    "amount": 1500,
                    "periods": 2
                  },
                  "credit_balance": 0,
                  "pending_change": null,
                  "cancel_at_period_end": false,
                  "canceled_at": null,
                  "ended_at": null,
                  "cancel_reason": null,
                  "pause": null,
                  "shipping": {
                    "name": "Ada Lovelace",
                    "address": {
                      "line1": "1 Main St",
                      "line2": null,
                      "city": "Austin",
                      "state": "TX",
                      "postal_code": "78701",
                      "country": "US"
                    }
                  },
                  "payment_link_id": null,
                  "metadata": {},
                  "created_at": "2026-12-01T00:00:00.000Z",
                  "status": "active",
                  "status_text": "Active",
                  "payment_method": {
                    "id": "5b6c7d8e-9f0a-4b1c-8d2e-3f4a5b6c7d8e",
                    "object": "payment_method",
                    "type": "card",
                    "brand": "Visa",
                    "last4": "4242",
                    "exp_month": 12,
                    "exp_year": 2029,
                    "funding": "credit",
                    "country": "US",
                    "wallet": null,
                    "is_default": true,
                    "status": "active",
                    "expired": false,
                    "saved_via": "save_card_page",
                    "created_at": "2026-12-01T00:00:00.000Z",
                    "last_used_at": "2026-12-15T00:00:00.000Z",
                    "updated_by_card_network_at": null,
                    "removed_at": null
                  },
                  "trial_end": "2026-12-15T00:00:00.000Z",
                  "current_period": {
                    "index": 0,
                    "start": "2026-12-15T00:00:00.000Z",
                    "end": "2027-01-15T00:00:00.000Z",
                    "amount": 4500
                  },
                  "next_billing_at": "2027-01-15T00:00:00.000Z",
                  "source": "api",
                  "sign_up_expires_at": null,
                  "proration": {
                    "charge": 1452,
                    "credit": 0,
                    "outcome": "paid"
                  }
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: the message names the first invalid field (also nothing to change, or an add-on listed twice or in another currency); `currency_mismatch`: the new plan is in another currency; `invalid_json`: the body is not JSON.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "`not_found`, `plan_not_found` or `addon_not_found`; `not_found` while subscriptions are not available yet (every subscription endpoint answers 404 until they are turned on).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "`not_changeable`: it is not active, trialing or paused (a past-due subscription must be paid first); `price_increase_needs_notice`: the change raises the price, so it cannot apply now: leave `proration` out or use `\"next_period\"`; `change_at_next_period`: it ships, or the new plan has another interval: use `proration: \"next_period\"`; `plan_inactive`: the new plan or an add-on is archived; `store_inactive`; `conflict`: the subscription changed meanwhile (try again).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "`shipping_address_required`: the new plan ships and the subscription has no shipping address: set one with PATCH first.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api/v1/subscriptions/{subscription_id}/retry": {
      "post": {
        "operationId": "retrySubscription",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Retry a past-due payment now",
        "description": "Charges a past-due subscription's unpaid bills to its card now, instead of waiting for the next scheduled retry (for example after the customer told you they fixed their card).",
        "parameters": [
          {
            "$ref": "#/components/parameters/SubscriptionId"
          },
          {
            "$ref": "#/components/parameters/Timestamp"
          },
          {
            "$ref": "#/components/parameters/Signature"
          },
          {
            "$ref": "#/components/parameters/StoreDomain"
          }
        ],
        "responses": {
          "200": {
            "description": "The subscription, with how each charge went.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubscriptionRetryResult"
                },
                "example": {
                  "id": "7e2f9a1c-3b4d-4e5f-8a6b-9c0d1e2f3a4b",
                  "object": "subscription",
                  "store_id": "0f1e2d3c-4b5a-4968-8776-655443322110",
                  "customer_id": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
                  "customer": {
                    "email": "ada@example.com",
                    "name": "Ada Lovelace"
                  },
                  "plan": {
                    "id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
                    "name": "Monthly box",
                    "amount": 3000,
                    "currency": "USD",
                    "interval": "month",
                    "interval_count": 1
                  },
                  "quantity": 1,
                  "addons": [],
                  "intro": {
                    "amount": 1500,
                    "periods": 2
                  },
                  "credit_balance": 0,
                  "pending_change": null,
                  "cancel_at_period_end": false,
                  "canceled_at": null,
                  "ended_at": null,
                  "cancel_reason": null,
                  "pause": null,
                  "shipping": {
                    "name": "Ada Lovelace",
                    "address": {
                      "line1": "1 Main St",
                      "line2": null,
                      "city": "Austin",
                      "state": "TX",
                      "postal_code": "78701",
                      "country": "US"
                    }
                  },
                  "payment_link_id": null,
                  "metadata": {},
                  "created_at": "2026-12-01T00:00:00.000Z",
                  "status": "active",
                  "status_text": "Active",
                  "payment_method": {
                    "id": "5b6c7d8e-9f0a-4b1c-8d2e-3f4a5b6c7d8e",
                    "object": "payment_method",
                    "type": "card",
                    "brand": "Visa",
                    "last4": "4242",
                    "exp_month": 12,
                    "exp_year": 2029,
                    "funding": "credit",
                    "country": "US",
                    "wallet": null,
                    "is_default": true,
                    "status": "active",
                    "expired": false,
                    "saved_via": "save_card_page",
                    "created_at": "2026-12-01T00:00:00.000Z",
                    "last_used_at": "2026-12-15T00:00:00.000Z",
                    "updated_by_card_network_at": null,
                    "removed_at": null
                  },
                  "trial_end": "2026-12-15T00:00:00.000Z",
                  "current_period": {
                    "index": 0,
                    "start": "2026-12-15T00:00:00.000Z",
                    "end": "2027-01-15T00:00:00.000Z",
                    "amount": 1500
                  },
                  "next_billing_at": "2027-01-15T00:00:00.000Z",
                  "source": "api",
                  "sign_up_expires_at": null,
                  "retry": [
                    "paid"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "`not_found`: no such subscription in your store; `not_found` while subscriptions are not available yet (every subscription endpoint answers 404 until they are turned on).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "`not_past_due`: only a past-due subscription is retried.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    }
  },
  "webhooks": {
    "payment.pending": {
      "post": {
        "operationId": "onPaymentPending",
        "summary": "payment.pending",
        "description": "The shopper started paying but the money has not arrived yet. Do not ship yet. On a gateway wallet, a payment seen on the chain and not confirmed yet.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "examples": {
                "checkout": {
                  "summary": "A checkout payment",
                  "value": {
                    "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                    "type": "payment.pending",
                    "created": 1767225600,
                    "livemode": true,
                    "data": {
                      "session_id": "8f14e45f-ceea-467a-9575-2c3b8e1f0b6d",
                      "order_id": "1042",
                      "reference": "cart-1042",
                      "amount": 4900,
                      "currency": "USD",
                      "status": "pending",
                      "rail": "card",
                      "payment_reference": "ocpay_8f14e45fceea467a95752c3b8e1f0b6d"
                    },
                    "event": "payment.pending",
                    "status": "pending",
                    "psp_reference": "ocpay_8f14e45fceea467a95752c3b8e1f0b6d"
                  }
                },
                "wallet": {
                  "summary": "Crypto paid to your wallet (gateway API)",
                  "value": {
                    "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                    "type": "payment.pending",
                    "created": 1767225600,
                    "livemode": true,
                    "data": {
                      "payment_id": "5c2e8a1d-0b4f-4e6a-9c3d-7f1e2a5b8c90",
                      "payment_reference": "ocpay_5c2e8a1d0b4f4e6a9c3d7f1e2a5b8c90",
                      "session_id": null,
                      "order_id": null,
                      "reference": null,
                      "amount": null,
                      "currency": null,
                      "status": "pending",
                      "rail": "crypto",
                      "source": "gateway",
                      "method": "crypto",
                      "coin": "BTC",
                      "coin_amount": "0.00051",
                      "wallet": "0x2f1c…9a4e",
                      "payment_tx": "9f2c4e6a8b0d1f3e5c7a9b1d3f5e7c9a0b2d4f6e8a0c2e4f6b8d0a2c4e6f8a0b",
                      "payout_tx": null
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "payment.authorized": {
      "post": {
        "operationId": "onPaymentAuthorized",
        "summary": "payment.authorized",
        "description": "The card was approved and the money is held for you. It is collected next.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "payment.authorized",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "session_id": "8f14e45f-ceea-467a-9575-2c3b8e1f0b6d",
                  "order_id": "1042",
                  "reference": "cart-1042",
                  "amount": 4900,
                  "currency": "USD",
                  "status": "authorized",
                  "rail": "card",
                  "payment_reference": "ocpay_8f14e45fceea467a95752c3b8e1f0b6d"
                },
                "event": "payment.authorized",
                "status": "authorized",
                "psp_reference": "ocpay_8f14e45fceea467a95752c3b8e1f0b6d"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "payment.captured": {
      "post": {
        "operationId": "onPaymentCaptured",
        "summary": "payment.captured",
        "description": "The shopper paid. Mark the order as paid and ship it. For crypto and Card to Crypto paid to your own wallet, the payout is already on its way to it.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "examples": {
                "checkout": {
                  "summary": "A checkout payment",
                  "value": {
                    "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                    "type": "payment.captured",
                    "created": 1767225600,
                    "livemode": true,
                    "data": {
                      "session_id": "8b0f6f2e-4d1a-4c4e-9a52-6f3e1d2c7b11",
                      "order_id": "1001",
                      "reference": "order-1001",
                      "amount": 4900,
                      "currency": "USD",
                      "status": "captured",
                      "rail": "card",
                      "payment_reference": "ocpay_8b0f6f2e4d1a4c4e9a526f3e1d2c7b11"
                    },
                    "event": "payment.captured",
                    "status": "captured",
                    "psp_reference": "ocpay_8b0f6f2e4d1a4c4e9a526f3e1d2c7b11"
                  }
                },
                "wallet": {
                  "summary": "Card to Crypto paid to your wallet (plugin)",
                  "value": {
                    "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                    "type": "payment.captured",
                    "created": 1767225600,
                    "livemode": true,
                    "data": {
                      "payment_id": "3b1d6c2e-7f40-4a8e-9d51-6a2f0c9e1b74",
                      "payment_reference": "ocpay_3b1d6c2e7f404a8e9d516a2f0c9e1b74",
                      "session_id": null,
                      "order_id": "1043",
                      "reference": null,
                      "amount": 2500,
                      "currency": "USD",
                      "status": "captured",
                      "rail": "card_to_crypto",
                      "source": "plugin",
                      "method": "cashapp",
                      "coin": "USDC (Polygon)",
                      "coin_amount": "23.00",
                      "wallet": "0x2f1c…9a4e",
                      "payment_tx": null,
                      "payout_tx": "0x8b3e5d0c4f1a2b6e9d7c3a1f5e8b2d4c6a0e9f1b3d5c7a9e2f4b6d8c0a1e3f41c7"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "payment.under_review": {
      "post": {
        "operationId": "onPaymentUnderReview",
        "summary": "payment.under_review",
        "description": "A payment to your wallet arrived but does not match the order (for example a different amount), so check it before you ship.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "payment.under_review",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "payment_id": "3b1d6c2e-7f40-4a8e-9d51-6a2f0c9e1b74",
                  "payment_reference": "ocpay_3b1d6c2e7f404a8e9d516a2f0c9e1b74",
                  "session_id": null,
                  "order_id": "1043",
                  "reference": null,
                  "amount": 2500,
                  "currency": "USD",
                  "status": "under_review",
                  "rail": "card_to_crypto",
                  "source": "plugin",
                  "method": "cashapp",
                  "coin": "USDC (Polygon)",
                  "coin_amount": null,
                  "wallet": "0x2f1c…9a4e",
                  "payment_tx": null,
                  "payout_tx": null,
                  "reason": "The amount received does not match the order."
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "payment.refused": {
      "post": {
        "operationId": "onPaymentRefused",
        "summary": "payment.refused",
        "description": "The payment was declined. The order is not paid; the shopper can try again. When OnCharge refused it because the store reached a limit set on its account, `data.reason` is `limit_exceeded` and nothing was sent to the bank.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "payment.refused",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "session_id": "8f14e45f-ceea-467a-9575-2c3b8e1f0b6d",
                  "order_id": "1042",
                  "reference": "cart-1042",
                  "amount": 4900,
                  "currency": "USD",
                  "status": "refused",
                  "rail": "card",
                  "payment_reference": "ocpay_8f14e45fceea467a95752c3b8e1f0b6d"
                },
                "event": "payment.refused",
                "status": "refused",
                "psp_reference": "ocpay_8f14e45fceea467a95752c3b8e1f0b6d"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "payment.cancelled": {
      "post": {
        "operationId": "onPaymentCancelled",
        "summary": "payment.cancelled",
        "description": "The payment was cancelled before it was collected. Nothing was charged.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "payment.cancelled",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "session_id": "8f14e45f-ceea-467a-9575-2c3b8e1f0b6d",
                  "order_id": "1042",
                  "reference": "cart-1042",
                  "amount": 4900,
                  "currency": "USD",
                  "status": "cancelled",
                  "rail": "card",
                  "payment_reference": "ocpay_8f14e45fceea467a95752c3b8e1f0b6d"
                },
                "event": "payment.cancelled",
                "status": "cancelled",
                "psp_reference": "ocpay_8f14e45fceea467a95752c3b8e1f0b6d"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "payment.expired": {
      "post": {
        "operationId": "onPaymentExpired",
        "summary": "payment.expired",
        "description": "The shopper did not finish paying in time. Nothing was charged.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "examples": {
                "checkout": {
                  "summary": "A checkout payment",
                  "value": {
                    "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                    "type": "payment.expired",
                    "created": 1767225600,
                    "livemode": true,
                    "data": {
                      "session_id": "8f14e45f-ceea-467a-9575-2c3b8e1f0b6d",
                      "order_id": "1042",
                      "reference": "cart-1042",
                      "amount": 4900,
                      "currency": "USD",
                      "status": "expired",
                      "rail": "card",
                      "payment_reference": "ocpay_8f14e45fceea467a95752c3b8e1f0b6d"
                    },
                    "event": "payment.expired",
                    "status": "expired",
                    "psp_reference": "ocpay_8f14e45fceea467a95752c3b8e1f0b6d"
                  }
                },
                "wallet": {
                  "summary": "Card to Crypto (plugin)",
                  "value": {
                    "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                    "type": "payment.expired",
                    "created": 1767225600,
                    "livemode": true,
                    "data": {
                      "payment_id": "3b1d6c2e-7f40-4a8e-9d51-6a2f0c9e1b74",
                      "payment_reference": "ocpay_3b1d6c2e7f404a8e9d516a2f0c9e1b74",
                      "session_id": null,
                      "order_id": "1043",
                      "reference": null,
                      "amount": 2500,
                      "currency": "USD",
                      "status": "expired",
                      "rail": "card_to_crypto",
                      "source": "plugin",
                      "method": "cashapp",
                      "coin": "USDC (Polygon)",
                      "coin_amount": null,
                      "wallet": "0x2f1c…9a4e",
                      "payment_tx": null,
                      "payout_tx": null
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "payment.capture_failed": {
      "post": {
        "operationId": "onPaymentCaptureFailed",
        "summary": "payment.capture_failed",
        "description": "An approved payment could not be collected. The order is not paid.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "payment.capture_failed",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "session_id": "8f14e45f-ceea-467a-9575-2c3b8e1f0b6d",
                  "order_id": "1042",
                  "reference": "cart-1042",
                  "amount": 4900,
                  "currency": "USD",
                  "status": "capture_failed",
                  "rail": "card",
                  "payment_reference": "ocpay_8f14e45fceea467a95752c3b8e1f0b6d"
                },
                "event": "payment.capture_failed",
                "status": "capture_failed",
                "psp_reference": "ocpay_8f14e45fceea467a95752c3b8e1f0b6d"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "refund.succeeded": {
      "post": {
        "operationId": "onRefundSucceeded",
        "summary": "refund.succeeded",
        "description": "A refund went through. The amount is the total refunded on this order so far.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "refund.succeeded",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "session_id": "8f14e45f-ceea-467a-9575-2c3b8e1f0b6d",
                  "order_id": "1042",
                  "reference": "cart-1042",
                  "amount": 1500,
                  "currency": "USD",
                  "status": "refunded",
                  "rail": "card",
                  "payment_reference": "ocpay_8f14e45fceea467a95752c3b8e1f0b6d"
                },
                "event": "refund.succeeded",
                "status": "refunded",
                "psp_reference": "ocpay_8f14e45fceea467a95752c3b8e1f0b6d"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "refund.failed": {
      "post": {
        "operationId": "onRefundFailed",
        "summary": "refund.failed",
        "description": "A refund could not be sent. Nothing was taken from your balance.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "refund.failed",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "session_id": "8f14e45f-ceea-467a-9575-2c3b8e1f0b6d",
                  "order_id": "1042",
                  "reference": "cart-1042",
                  "amount": 1500,
                  "currency": "USD",
                  "status": "refund_failed",
                  "rail": "card",
                  "payment_reference": "ocpay_8f14e45fceea467a95752c3b8e1f0b6d"
                },
                "event": "refund.failed",
                "status": "refund_failed",
                "psp_reference": "ocpay_8f14e45fceea467a95752c3b8e1f0b6d"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "chargeback.opened": {
      "post": {
        "operationId": "onChargebackOpened",
        "summary": "chargeback.opened",
        "description": "The shopper asked their bank to reverse this payment. OnCharge helps you answer it.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "chargeback.opened",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "session_id": "8f14e45f-ceea-467a-9575-2c3b8e1f0b6d",
                  "order_id": "1042",
                  "reference": "cart-1042",
                  "amount": 4900,
                  "currency": "USD",
                  "status": "captured",
                  "rail": "card",
                  "payment_reference": "ocpay_8f14e45fceea467a95752c3b8e1f0b6d"
                },
                "event": "chargeback.opened",
                "status": "captured",
                "psp_reference": "ocpay_8f14e45fceea467a95752c3b8e1f0b6d"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "dispute.evidence_due": {
      "post": {
        "operationId": "onDisputeEvidenceDue",
        "summary": "dispute.evidence_due",
        "description": "A dispute needs its evidence by the date given. OnCharge answers for you where it can; the dispute page says what is still missing. Sent once per dispute and deadline.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "dispute.evidence_due",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "dispute_id": "ocdsp_4a7e2c9b1d3f4e5a8b6c0d2e4f6a8b0c",
                  "payment_reference": "ocpay_8f14e45fceea467a95752c3b8e1f0b6d",
                  "session_id": "8f14e45f-ceea-467a-9575-2c3b8e1f0b6d",
                  "order_id": "1042",
                  "amount": 4900,
                  "currency": "USD",
                  "reason": "the customer says they did not make the payment",
                  "evidence_due_by": "2026-12-15T23:59:59.000Z",
                  "rail": "card"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "chargeback.won": {
      "post": {
        "operationId": "onChargebackWon",
        "summary": "chargeback.won",
        "description": "The bank decided in your favour. You keep the money.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "chargeback.won",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "session_id": "8f14e45f-ceea-467a-9575-2c3b8e1f0b6d",
                  "order_id": "1042",
                  "reference": "cart-1042",
                  "amount": 4900,
                  "currency": "USD",
                  "status": "captured",
                  "rail": "card",
                  "payment_reference": "ocpay_8f14e45fceea467a95752c3b8e1f0b6d"
                },
                "event": "chargeback.won",
                "status": "captured",
                "psp_reference": "ocpay_8f14e45fceea467a95752c3b8e1f0b6d"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "chargeback.lost": {
      "post": {
        "operationId": "onChargebackLost",
        "summary": "chargeback.lost",
        "description": "The bank decided for the shopper. The payment is reversed.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "chargeback.lost",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "session_id": "8f14e45f-ceea-467a-9575-2c3b8e1f0b6d",
                  "order_id": "1042",
                  "reference": "cart-1042",
                  "amount": 4900,
                  "currency": "USD",
                  "status": "captured",
                  "rail": "card",
                  "payment_reference": "ocpay_8f14e45fceea467a95752c3b8e1f0b6d"
                },
                "event": "chargeback.lost",
                "status": "captured",
                "psp_reference": "ocpay_8f14e45fceea467a95752c3b8e1f0b6d"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "fraud_warning.received": {
      "post": {
        "operationId": "onFraudWarningReceived",
        "summary": "fraud_warning.received",
        "description": "The cardholder's bank reported this payment as fraud. Do not ship it yet: the payout is on hold, and OnCharge may refund it to stop a dispute.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "fraud_warning.received",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "warning_id": "6d0b2f4e-8a1c-4e3b-9f5d-7c2a4e6b8d0f",
                  "session_id": "8f14e45f-ceea-467a-9575-2c3b8e1f0b6d",
                  "payment_reference": "ocpay_8f14e45fceea467a95752c3b8e1f0b6d",
                  "order_id": "1042",
                  "amount": 4900,
                  "currency": "USD",
                  "reason": "The bank says the card was stolen.",
                  "rail": "card"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "delivery.confirmed": {
      "post": {
        "operationId": "onDeliveryConfirmed",
        "summary": "delivery.confirmed",
        "description": "Every package of the order was confirmed delivered by the carrier. Sent once per order.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "delivery.confirmed",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "session_id": "8f14e45f-ceea-467a-9575-2c3b8e1f0b6d",
                  "order_id": "1042",
                  "reference": "cart-1042",
                  "amount": 4900,
                  "currency": "USD",
                  "status": "captured",
                  "rail": "card",
                  "payment_reference": "ocpay_8f14e45fceea467a95752c3b8e1f0b6d"
                },
                "event": "delivery.confirmed",
                "status": "captured",
                "psp_reference": "ocpay_8f14e45fceea467a95752c3b8e1f0b6d"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "payout.paid": {
      "post": {
        "operationId": "onPayoutPaid",
        "summary": "payout.paid",
        "description": "A payout reached your bank, or (a debit card payout, `method` \"instant\") your debit card, with `fee` taken out. Payouts pay orders whose delivery was confirmed.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "payout.paid",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "payout_id": "ocpyt_7e1a3c5b9d2f4a6c8e0b1d3f5a7c9e2b",
                  "amount": 18240,
                  "currency": "USD",
                  "status": "paid",
                  "arrival_date": "2026-12-03T00:00:00.000Z",
                  "problem": null,
                  "method": "standard",
                  "fee": 0,
                  "rail": "card"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "payout.failed": {
      "post": {
        "operationId": "onPayoutFailed",
        "summary": "payout.failed",
        "description": "A payout could not be delivered to your bank. The money is safe and is sent again; the problem says whether your bank details need fixing. A debit card payout that fails goes to your bank instead, its fee refunded.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "payout.failed",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "payout_id": "ocpyt_7e1a3c5b9d2f4a6c8e0b1d3f5a7c9e2b",
                  "amount": 18240,
                  "currency": "USD",
                  "status": "failed",
                  "arrival_date": null,
                  "problem": {
                    "title": "This payout could not be delivered",
                    "reason": "The bank account number is not valid.",
                    "next": "Payouts are paused until working bank details are on file. The money is safe in your account and is sent again automatically once they are."
                  },
                  "method": "standard",
                  "fee": 0,
                  "rail": "card"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "payout.returned": {
      "post": {
        "operationId": "onPayoutReturned",
        "summary": "payout.returned",
        "description": "Your bank sent a payout back after it arrived. The money is sent again once working bank details are on file.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "payout.returned",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "payout_id": "ocpyt_7e1a3c5b9d2f4a6c8e0b1d3f5a7c9e2b",
                  "amount": 18240,
                  "currency": "USD",
                  "status": "returned",
                  "arrival_date": "2026-12-03T00:00:00.000Z",
                  "problem": {
                    "title": "Your bank returned this payout",
                    "reason": "The bank account is closed.",
                    "next": "Payouts are paused until working bank details are on file. The money is safe in your account and is sent again automatically once they are."
                  },
                  "method": "standard",
                  "fee": 0,
                  "rail": "card"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "account.updated": {
      "post": {
        "operationId": "onAccountUpdated",
        "summary": "account.updated",
        "description": "What your account can do changed: taking payments, receiving payouts, or what it needs from you.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "account.updated",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "account": {
                    "status": "action_required",
                    "payments_enabled": true,
                    "payouts_enabled": true,
                    "requirements_due": [
                      "Owner's date of birth"
                    ],
                    "deadline": "2026-12-20T00:00:00.000Z"
                  },
                  "changed": [
                    "status",
                    "requirements_due",
                    "deadline"
                  ],
                  "rail": "card"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "account.requirements_due": {
      "post": {
        "operationId": "onAccountRequirementsDue",
        "summary": "account.requirements_due",
        "description": "Your account needs more information by the deadline, or it stops taking payments. Provide it under Settings. Sent once per change.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "account.requirements_due",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "requirements": [
                    "Owner's date of birth",
                    "Business tax ID"
                  ],
                  "deadline": "2026-12-20T00:00:00.000Z",
                  "past_due": false,
                  "rail": "card"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "account.restricted": {
      "post": {
        "operationId": "onAccountRestricted",
        "summary": "account.restricted",
        "description": "Your account stopped taking payments or receiving payouts. The reason says what to do.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "account.restricted",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "payments_enabled": true,
                  "payouts_enabled": false,
                  "reason": "More information is needed to keep your account open.",
                  "rail": "card"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "swap.created": {
      "post": {
        "operationId": "onSwapCreated",
        "summary": "swap.created",
        "description": "A conversion was created and waits for the coins to arrive.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "swap.created",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "swap_id": "ocswp_41b9e2d07a6c4f1e8b3d5a7c9e1f2b4d",
                  "status": "waiting",
                  "from": {
                    "coin": "BTC",
                    "amount": "0.00051"
                  },
                  "to": {
                    "coin": "USDC",
                    "amount": null
                  },
                  "wallet": "0x2f1c…9a4e",
                  "payment_tx": null,
                  "payout_tx": null,
                  "reason": null,
                  "rail": "crypto"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "swap.completed": {
      "post": {
        "operationId": "onSwapCompleted",
        "summary": "swap.completed",
        "description": "A crypto payment was converted to the coin you are paid in and sent to your wallet.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "swap.completed",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "swap_id": "ocswp_41b9e2d07a6c4f1e8b3d5a7c9e1f2b4d",
                  "status": "completed",
                  "from": {
                    "coin": "BTC",
                    "amount": "0.00051"
                  },
                  "to": {
                    "coin": "USDC",
                    "amount": "48.71"
                  },
                  "wallet": "0x2f1c…9a4e",
                  "payment_tx": "9f2c4e6a8b0d1f3e5c7a9b1d3f5e7c9a0b2d4f6e8a0c2e4f6b8d0a2c4e6f8a0b",
                  "payout_tx": "0x8b3e5d0c4f1a2b6e9d7c3a1f5e8b2d4c6a0e9f1b3d5c7a9e2f4b6d8c0a1e3f41c7",
                  "reason": null,
                  "rail": "crypto"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "swap.failed": {
      "post": {
        "operationId": "onSwapFailed",
        "summary": "swap.failed",
        "description": "A crypto payment could not be converted. The coins go back to the sender, or OnCharge contacts you.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "swap.failed",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "swap_id": "ocswp_41b9e2d07a6c4f1e8b3d5a7c9e1f2b4d",
                  "status": "failed",
                  "from": {
                    "coin": "BTC",
                    "amount": "0.00051"
                  },
                  "to": {
                    "coin": "USDC",
                    "amount": null
                  },
                  "wallet": "0x2f1c…9a4e",
                  "payment_tx": null,
                  "payout_tx": null,
                  "reason": "The conversion could not be completed.",
                  "rail": "crypto"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "swap.refunded": {
      "post": {
        "operationId": "onSwapRefunded",
        "summary": "swap.refunded",
        "description": "A conversion could not finish, and the coins were sent back to the sender.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "swap.refunded",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "swap_id": "ocswp_41b9e2d07a6c4f1e8b3d5a7c9e1f2b4d",
                  "status": "refunded",
                  "from": {
                    "coin": "BTC",
                    "amount": "0.00051"
                  },
                  "to": {
                    "coin": "USDC",
                    "amount": null
                  },
                  "wallet": "0x2f1c…9a4e",
                  "payment_tx": null,
                  "payout_tx": null,
                  "reason": "The coins were sent back to the sender.",
                  "rail": "crypto"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "swap.expired": {
      "post": {
        "operationId": "onSwapExpired",
        "summary": "swap.expired",
        "description": "No coins arrived before the conversion's quote ran out. Nothing was converted.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "swap.expired",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "swap_id": "ocswp_41b9e2d07a6c4f1e8b3d5a7c9e1f2b4d",
                  "status": "expired",
                  "from": {
                    "coin": "BTC",
                    "amount": "0.00051"
                  },
                  "to": {
                    "coin": "USDC",
                    "amount": null
                  },
                  "wallet": "0x2f1c…9a4e",
                  "payment_tx": null,
                  "payout_tx": null,
                  "reason": "No coins arrived before the quote ran out.",
                  "rail": "crypto"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "support.conversation.created": {
      "post": {
        "operationId": "onSupportConversationCreated",
        "summary": "support.conversation.created",
        "description": "A customer started a conversation by email, chat or phone. Not sent yet: the sample shows what will arrive.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "support.conversation.created",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "conversation_id": "b6a1d2c3-4e5f-4a7b-8c9d-0e1f2a3b4c5d",
                  "channel": "email",
                  "status": "open",
                  "subject": "Where is my order?",
                  "customer": {
                    "name": "Ada Lovelace",
                    "email": "ada@example.com"
                  },
                  "rail": "card"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "support.message.received": {
      "post": {
        "operationId": "onSupportMessageReceived",
        "summary": "support.message.received",
        "description": "A customer wrote in an open conversation. Not sent yet: the sample shows what will arrive.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "support.message.received",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "conversation_id": "b6a1d2c3-4e5f-4a7b-8c9d-0e1f2a3b4c5d",
                  "message_id": "f0e1d2c3-b4a5-4968-8776-5a4b3c2d1e0f",
                  "channel": "chat",
                  "preview": "Hi, my parcel says delivered but I cannot find it.",
                  "rail": "card"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "support.conversation.closed": {
      "post": {
        "operationId": "onSupportConversationClosed",
        "summary": "support.conversation.closed",
        "description": "A conversation was marked as done by your team, an OnCharge rep or the AI assistant. Not sent yet: the sample shows what will arrive.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "support.conversation.closed",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "conversation_id": "b6a1d2c3-4e5f-4a7b-8c9d-0e1f2a3b4c5d",
                  "channel": "email",
                  "status": "closed",
                  "closed_by": "team",
                  "rail": "card"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "subscription.created": {
      "post": {
        "operationId": "onSubscriptionCreated",
        "summary": "subscription.created",
        "description": "A customer agreed to a subscription and it started: its trial began, or its first period was paid.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "subscription.created",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "subscription_id": "7e2f9a1c-3b4d-4e5f-8a6b-9c0d1e2f3a4b",
                  "customer_id": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
                  "status": "active",
                  "plan_id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
                  "plan_name": "Monthly box",
                  "amount": 3000,
                  "currency": "USD",
                  "interval": "month",
                  "interval_count": 1,
                  "quantity": 1,
                  "trial_end": null,
                  "current_period_start": "2026-12-01T00:00:00.000Z",
                  "current_period_end": "2027-01-01T00:00:00.000Z",
                  "cancel_at_period_end": false,
                  "canceled_at": null,
                  "cancel_reason": null,
                  "paused_at": null,
                  "resume_at": null,
                  "rail": "card"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "subscription.updated": {
      "post": {
        "operationId": "onSubscriptionUpdated",
        "summary": "subscription.updated",
        "description": "The plan, quantity, card, or a waiting cancellation or pause changed. `data.change` says what: `plan_changed` (with `prorated_charge` and `prorated_credit`), `change_scheduled` (with `pending_change`), `price_increase_notice` (the customer was emailed the notice of a price increase, with `price_increase`), `change_applied`, `payment_method`, `cancel_scheduled`, `pause_scheduled`, `kept` (a waiting cancellation or pause was called off), `trial_ended` or `payment_recovered`.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "subscription.updated",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "subscription_id": "7e2f9a1c-3b4d-4e5f-8a6b-9c0d1e2f3a4b",
                  "customer_id": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
                  "status": "active",
                  "plan_id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
                  "plan_name": "Monthly box",
                  "amount": 3000,
                  "currency": "USD",
                  "interval": "month",
                  "interval_count": 1,
                  "quantity": 1,
                  "trial_end": null,
                  "current_period_start": "2026-12-01T00:00:00.000Z",
                  "current_period_end": "2027-01-01T00:00:00.000Z",
                  "cancel_at_period_end": false,
                  "canceled_at": null,
                  "cancel_reason": null,
                  "paused_at": null,
                  "resume_at": null,
                  "rail": "card",
                  "change": "plan_changed",
                  "prorated_charge": 968,
                  "prorated_credit": 0
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "subscription.trial_will_end": {
      "post": {
        "operationId": "onSubscriptionTrialWillEnd",
        "summary": "subscription.trial_will_end",
        "description": "A trial ends soon and the customer was reminded: 7 days ahead for a trial of 14 days or more, 3 days for 7 to 13 days, 1 day for 3 to 6 days. Sent once per trial.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "subscription.trial_will_end",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "subscription_id": "7e2f9a1c-3b4d-4e5f-8a6b-9c0d1e2f3a4b",
                  "customer_id": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
                  "status": "trialing",
                  "plan_id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
                  "plan_name": "Monthly box",
                  "amount": 3000,
                  "currency": "USD",
                  "interval": "month",
                  "interval_count": 1,
                  "quantity": 1,
                  "trial_end": "2026-12-15T00:00:00.000Z",
                  "current_period_start": null,
                  "current_period_end": null,
                  "cancel_at_period_end": false,
                  "canceled_at": null,
                  "cancel_reason": null,
                  "paused_at": null,
                  "resume_at": null,
                  "rail": "card"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "subscription.past_due": {
      "post": {
        "operationId": "onSubscriptionPastDue",
        "summary": "subscription.past_due",
        "description": "A period's payment failed. OnCharge retries it 1, 3, 7 and 14 days after the first failure (unless it waits for the customer) and asked the customer to check their card.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "subscription.past_due",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "subscription_id": "7e2f9a1c-3b4d-4e5f-8a6b-9c0d1e2f3a4b",
                  "customer_id": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
                  "status": "past_due",
                  "plan_id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
                  "plan_name": "Monthly box",
                  "amount": 3000,
                  "currency": "USD",
                  "interval": "month",
                  "interval_count": 1,
                  "quantity": 1,
                  "trial_end": null,
                  "current_period_start": "2026-12-01T00:00:00.000Z",
                  "current_period_end": "2027-01-01T00:00:00.000Z",
                  "cancel_at_period_end": false,
                  "canceled_at": null,
                  "cancel_reason": null,
                  "paused_at": null,
                  "resume_at": null,
                  "rail": "card"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "subscription.paused": {
      "post": {
        "operationId": "onSubscriptionPaused",
        "summary": "subscription.paused",
        "description": "The subscription paused: nothing is charged or shipped until it resumes (`data.resume_at`, or when you resume it).",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "subscription.paused",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "subscription_id": "7e2f9a1c-3b4d-4e5f-8a6b-9c0d1e2f3a4b",
                  "customer_id": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
                  "status": "paused",
                  "plan_id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
                  "plan_name": "Monthly box",
                  "amount": 3000,
                  "currency": "USD",
                  "interval": "month",
                  "interval_count": 1,
                  "quantity": 1,
                  "trial_end": null,
                  "current_period_start": "2026-12-01T00:00:00.000Z",
                  "current_period_end": "2027-01-01T00:00:00.000Z",
                  "cancel_at_period_end": false,
                  "canceled_at": null,
                  "cancel_reason": null,
                  "paused_at": "2027-01-01T00:00:00.000Z",
                  "resume_at": "2027-03-01T00:00:00.000Z",
                  "rail": "card"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "subscription.resumed": {
      "post": {
        "operationId": "onSubscriptionResumed",
        "summary": "subscription.resumed",
        "description": "A paused subscription started again; a new period began and was charged.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "subscription.resumed",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "subscription_id": "7e2f9a1c-3b4d-4e5f-8a6b-9c0d1e2f3a4b",
                  "customer_id": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
                  "status": "active",
                  "plan_id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
                  "plan_name": "Monthly box",
                  "amount": 3000,
                  "currency": "USD",
                  "interval": "month",
                  "interval_count": 1,
                  "quantity": 1,
                  "trial_end": null,
                  "current_period_start": "2026-12-01T00:00:00.000Z",
                  "current_period_end": "2027-01-01T00:00:00.000Z",
                  "cancel_at_period_end": false,
                  "canceled_at": null,
                  "cancel_reason": null,
                  "paused_at": null,
                  "resume_at": null,
                  "rail": "card"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "subscription.canceled": {
      "post": {
        "operationId": "onSubscriptionCanceled",
        "summary": "subscription.canceled",
        "description": "The subscription ended: cancelled by you or the customer, or after its payment failed on every retry (`data.cancel_reason`).",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "subscription.canceled",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "subscription_id": "7e2f9a1c-3b4d-4e5f-8a6b-9c0d1e2f3a4b",
                  "customer_id": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
                  "status": "canceled",
                  "plan_id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
                  "plan_name": "Monthly box",
                  "amount": 3000,
                  "currency": "USD",
                  "interval": "month",
                  "interval_count": 1,
                  "quantity": 1,
                  "trial_end": null,
                  "current_period_start": "2026-12-01T00:00:00.000Z",
                  "current_period_end": "2027-01-01T00:00:00.000Z",
                  "cancel_at_period_end": false,
                  "canceled_at": "2026-12-20T00:00:00.000Z",
                  "cancel_reason": "customer",
                  "paused_at": null,
                  "resume_at": null,
                  "rail": "card"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "subscription.period.paid": {
      "post": {
        "operationId": "onSubscriptionPeriodPaid",
        "summary": "subscription.period.paid",
        "description": "A period (or a plan change) was paid. If it ships, ship it and report its tracking number with `data.session_id`: its payout is released on carrier-confirmed delivery, like any order.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "subscription.period.paid",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "subscription_id": "7e2f9a1c-3b4d-4e5f-8a6b-9c0d1e2f3a4b",
                  "billing_id": "2b3c4d5e-6f7a-4b8c-9d0e-1f2a3b4c5d6e",
                  "reason": "period",
                  "period_index": 1,
                  "period_start": "2027-01-01T00:00:00.000Z",
                  "period_end": "2027-02-01T00:00:00.000Z",
                  "amount": 3000,
                  "currency": "USD",
                  "invoice_id": "4d5e6f7a-8b9c-4d0e-8f1a-2b3c4d5e6f7a",
                  "invoice_number": "INV-0042",
                  "session_id": "8f14e45f-ceea-467a-9575-2c3b8e1f0b6d",
                  "payment_reference": "ocpay_8f14e45fceea467a95752c3b8e1f0b6d",
                  "attempt": 1,
                  "ships": true,
                  "failure": null,
                  "next_attempt_at": null,
                  "status": "paid",
                  "rail": "card"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    },
    "subscription.period.payment_failed": {
      "post": {
        "operationId": "onSubscriptionPeriodPaymentFailed",
        "summary": "subscription.period.payment_failed",
        "description": "A charge for a period failed. `data.failure` says why and `data.next_attempt_at` when it is tried again (null: it waits for the customer).",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEventId"
          },
          {
            "$ref": "#/components/parameters/WebhookSignature"
          },
          {
            "$ref": "#/components/parameters/LegacyWebhookSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_5f0c2a8e-1b7d-4c39-9e64-2d8f1a7b3c90",
                "type": "subscription.period.payment_failed",
                "created": 1767225600,
                "livemode": true,
                "data": {
                  "subscription_id": "7e2f9a1c-3b4d-4e5f-8a6b-9c0d1e2f3a4b",
                  "billing_id": "2b3c4d5e-6f7a-4b8c-9d0e-1f2a3b4c5d6e",
                  "reason": "period",
                  "period_index": 1,
                  "period_start": "2027-01-01T00:00:00.000Z",
                  "period_end": "2027-02-01T00:00:00.000Z",
                  "amount": 3000,
                  "currency": "USD",
                  "invoice_id": "4d5e6f7a-8b9c-4d0e-8f1a-2b3c4d5e6f7a",
                  "invoice_number": "INV-0042",
                  "session_id": null,
                  "payment_reference": null,
                  "attempt": 1,
                  "ships": true,
                  "failure": {
                    "reason": "declined",
                    "message": "The card was declined. It is retried on a schedule; the customer was asked to check their card."
                  },
                  "next_attempt_at": "2027-01-02T00:00:00.000Z",
                  "status": "failed",
                  "rail": "card"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx response within 8 seconds acknowledges the event. Other responses and timeouts\nare retried with backoff for up to 24 hours.\n"
          }
        },
        "security": []
      }
    }
  },
  "components": {
    "securitySchemes": {
      "OnChargeSignature": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Oncharge-Key",
        "description": "HMAC request signing. Every request carries three headers:\n\n| Header | Value |\n|---|---|\n| `X-Oncharge-Key` | Your API key (`oc_key_…`). |\n| `X-Oncharge-Timestamp` | Current Unix time in seconds. Must be within 300 seconds of OnCharge's clock. |\n| `X-Oncharge-Signature` | Lower-case hex HMAC-SHA256 described below. |\n\n1. `body_hash` = lower-case hex SHA-256 of the exact request body bytes (the empty string\n   for GET requests, empty-body POSTs and multipart uploads).\n2. `signing_string` = `{timestamp}.{METHOD}.{path}.{body_hash}` where `{timestamp}` is the\n   exact header value, `{METHOD}` is upper case and `{path}` is the URL path without the\n   query string, e.g. `/api/v1/checkout/sessions`.\n3. `signing_key` = lower-case hex SHA-256 of your API secret (`oc_sec_…`), used as a\n   64-character ASCII string (not decoded to bytes).\n4. `X-Oncharge-Signature` = lower-case hex HMAC-SHA256(`signing_key`, `signing_string`).\n\nTest vector: secret `oc_sec_example_secret_do_not_use`, timestamp `1767225600`,\n`POST /api/v1/checkout/sessions`, body\n`{\"amount\":4900,\"currency\":\"USD\",\"reference\":\"order-1001\",\"return_url\":\"https://shop.example.com/thanks\"}`\ngives signature `7b0e1f9370475ae2a926804c0c9927c5f391c8a3c2e09a8071d98891aa01fdc7`.\n",
        "x-oncharge-signing": {
          "algorithm": "HMAC-SHA256",
          "headers": {
            "key": "X-Oncharge-Key",
            "timestamp": "X-Oncharge-Timestamp",
            "signature": "X-Oncharge-Signature"
          },
          "signing_string": "{timestamp}.{METHOD}.{path}.{sha256_hex(raw_body)}",
          "signing_key": "sha256_hex(api_secret) used as an ASCII string",
          "path": "URL path only, no query string",
          "empty_body_hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
          "multipart_body_hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
          "timestamp_tolerance_seconds": 300,
          "encoding": "lower-case hex",
          "test_vector": {
            "api_secret": "oc_sec_example_secret_do_not_use",
            "timestamp": "1767225600",
            "method": "POST",
            "path": "/api/v1/checkout/sessions",
            "body": "{\"amount\":4900,\"currency\":\"USD\",\"reference\":\"order-1001\",\"return_url\":\"https://shop.example.com/thanks\"}",
            "body_hash": "5e52ceb9b1f344953c18661d556985d8cc6da177161aae0192a494cad909077b",
            "signing_key": "da99cc22bdd7ff7663935ccc2966a363e9b0fe1c4fc4b9803c7469ef2de84d54",
            "signature": "7b0e1f9370475ae2a926804c0c9927c5f391c8a3c2e09a8071d98891aa01fdc7"
          }
        }
      }
    },
    "parameters": {
      "Timestamp": {
        "name": "X-Oncharge-Timestamp",
        "in": "header",
        "required": true,
        "description": "Unix time in seconds, the same string used in the signing string.",
        "schema": {
          "type": "string",
          "pattern": "^[0-9]+$"
        },
        "example": "1767225600"
      },
      "Signature": {
        "name": "X-Oncharge-Signature",
        "in": "header",
        "required": true,
        "description": "Lower-case hex HMAC-SHA256 of the signing string. See the security scheme.",
        "schema": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        }
      },
      "StoreDomain": {
        "name": "X-Store-Domain",
        "in": "header",
        "required": false,
        "description": "Optional. Your store's host name (for example `shop.example.com`). If a request carries\n`Origin`, `Referer` or `X-Store-Domain`, at least one must match a registered store domain,\notherwise it is rejected with `domain_mismatch`.\n",
        "schema": {
          "type": "string"
        }
      },
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": false,
        "description": "A unique key (up to 255 characters is safe) that makes retries of this request safe.",
        "schema": {
          "type": "string",
          "maxLength": 255
        }
      },
      "SessionId": {
        "name": "session_id",
        "in": "path",
        "required": true,
        "description": "The checkout session ID returned when the session was created.",
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "DisputeId": {
        "name": "dispute_id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "WebhookEventId": {
        "name": "OnCharge-Event-Id",
        "in": "header",
        "required": true,
        "description": "Unique event ID (`evt_…`). Deduplicate on it; the same event may be delivered more than once.",
        "schema": {
          "type": "string"
        }
      },
      "WebhookSignature": {
        "name": "OnCharge-Signature",
        "in": "header",
        "required": true,
        "description": "`t=<unix seconds>,v1=<hex>` where `v1` = lower-case hex HMAC-SHA256(webhook signing secret,\n`\"<t>.<raw body>\"`). The key is your webhook signing secret (`oc_cbsec_…`) as given.\nCompare in constant time and reject events where `|now - t| > 300`.\n",
        "schema": {
          "type": "string"
        },
        "example": "t=1767225600,v1=84be083139c3b95201b3745caa34bf907aeef5ebb01d2ebca3241122086fc733"
      },
      "LegacyWebhookSignature": {
        "name": "X-Oncharge-Signature",
        "in": "header",
        "required": false,
        "deprecated": true,
        "description": "Legacy body-only signature kept for older plugins. Verify `OnCharge-Signature` instead.",
        "schema": {
          "type": "string"
        }
      },
      "EventId": {
        "name": "event_id",
        "in": "path",
        "required": true,
        "description": "An event id (`evt_…`).",
        "schema": {
          "type": "string"
        }
      },
      "InvoiceId": {
        "name": "invoice_id",
        "in": "path",
        "required": true,
        "description": "The invoice (or credit note) id.",
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "CustomerId": {
        "name": "customer_id",
        "in": "path",
        "required": true,
        "description": "An OnCharge customer ID of your store.",
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "PaymentMethodId": {
        "name": "payment_method_id",
        "in": "path",
        "required": true,
        "description": "A saved card's ID.",
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "PlanId": {
        "name": "plan_id",
        "in": "path",
        "required": true,
        "description": "A plan or add-on of your store.",
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "SubscriptionId": {
        "name": "subscription_id",
        "in": "path",
        "required": true,
        "description": "A subscription of your store.",
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "`validation_error` (the message lists each invalid field) or `invalid_json`.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "validation_error",
              "message": "amount: Invalid input: expected number, received string"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Authentication failed: `missing_auth`, `invalid_timestamp`, `timestamp_expired` (clock more\nthan 300 seconds off), `invalid_key` or `invalid_signature`.\n",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "invalid_signature",
              "message": "HMAC signature verification failed"
            }
          }
        }
      },
      "Forbidden": {
        "description": "`store_inactive` (the store is not active: a newly approved store stays `pending` until its processing account is open, and a suspended store is refused) or `domain_mismatch` (`Origin`, `Referer` or `X-Store-Domain` does not match a registered store domain).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "NotFound": {
        "description": "`not_found`: the object does not exist or belongs to another store.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "DisputeNotActionable": {
        "description": "`responded_by_oncharge`: the OnCharge team responds to this dispute for you; upload your evidence before the deadline instead. `missing_ref`: the dispute cannot be answered yet.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "responded_by_oncharge",
              "message": "Our team responds to this dispute for you. Upload your evidence (proof of delivery, messages with the customer, your policies) before the deadline."
            }
          }
        }
      },
      "RateLimited": {
        "description": "`rate_limited`: too many requests. Wait until `X-RateLimit-Reset` and retry.",
        "headers": {
          "X-RateLimit-Limit": {
            "description": "Requests allowed per window.",
            "schema": {
              "type": "integer"
            }
          },
          "X-RateLimit-Remaining": {
            "description": "Requests left in the current window.",
            "schema": {
              "type": "integer"
            }
          },
          "X-RateLimit-Reset": {
            "description": "Unix time (seconds) when the window resets.",
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "InternalError": {
        "description": "`internal_error`. Safe to retry with the same `Idempotency-Key`.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "ProviderError": {
        "description": "`provider_error` or `provider_unavailable`: the payment network did not accept the request. Retry later.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "ServiceUnavailable": {
        "description": "`config_error` or `service_unavailable`: temporarily unavailable. Retry with backoff.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "DisputeActionFailed": {
        "description": "`dispute_action_failed`: the action could not be completed right now. Retry later or contact support.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error",
          "message"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Machine-readable error code."
          },
          "message": {
            "type": "string",
            "description": "Human-readable explanation. Do not parse it."
          }
        }
      },
      "GlobalBanError": {
        "type": "object",
        "required": [
          "error",
          "message",
          "session_id"
        ],
        "properties": {
          "error": {
            "type": "string",
            "const": "global_ban"
          },
          "message": {
            "type": "string",
            "description": "A message you can show the shopper."
          },
          "session_id": {
            "type": "null"
          }
        }
      },
      "Amount": {
        "type": "integer",
        "minimum": 1,
        "description": "Amount in the currency's minor unit (cents for USD).",
        "examples": [
          4900
        ]
      },
      "Currency": {
        "type": "string",
        "minLength": 3,
        "maxLength": 3,
        "description": "ISO 4217 currency code.",
        "examples": [
          "USD"
        ]
      },
      "SessionStatus": {
        "type": "string",
        "enum": [
          "created",
          "pending",
          "authorized",
          "captured",
          "refused",
          "cancelled",
          "error",
          "expired"
        ],
        "description": "`created` (waiting for the shopper), `pending` (the shopper must complete a step),\n`authorized` (approved, not yet captured), `captured` (paid), `refused` (declined),\n`cancelled`, `error`, `expired` (not paid within 30 minutes).\n"
      },
      "ShippingAddress": {
        "type": "object",
        "description": "Where the order ships. OnCharge matches the carrier's delivery location against\n`postal_code` (US, first five digits) or `city` + `state`. Send at least `postal_code`\nor `city`.\n",
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 200
          },
          "line1": {
            "type": "string",
            "maxLength": 300
          },
          "line2": {
            "type": "string",
            "maxLength": 300
          },
          "city": {
            "type": "string",
            "maxLength": 120
          },
          "state": {
            "type": "string",
            "maxLength": 120
          },
          "postal_code": {
            "type": "string",
            "maxLength": 20
          },
          "country": {
            "type": "string",
            "maxLength": 60,
            "description": "ISO 3166-1 alpha-2 code recommended (`US`)."
          }
        }
      },
      "LineItem": {
        "type": "object",
        "required": [
          "description",
          "quantity",
          "amount_including_tax"
        ],
        "properties": {
          "description": {
            "type": "string"
          },
          "quantity": {
            "type": "integer",
            "minimum": 1
          },
          "amount_including_tax": {
            "type": "integer",
            "minimum": 0,
            "description": "Line amount in minor units, tax included."
          },
          "requires_shipping": {
            "type": "boolean",
            "description": "Whether this item is shipped. On a store that sells both shipped and unshipped things, an order with any shipped item is paid out after carrier-confirmed delivery; one whose items all say `false`, 7 days after payment. Without it, the order is decided by whether it has a shipping address."
          },
          "tax_category": {
            "$ref": "#/components/schemas/TaxCategory"
          }
        }
      },
      "CreateCheckoutSessionRequest": {
        "type": "object",
        "required": [
          "amount",
          "currency",
          "reference",
          "return_url"
        ],
        "properties": {
          "amount": {
            "$ref": "#/components/schemas/Amount"
          },
          "currency": {
            "$ref": "#/components/schemas/Currency"
          },
          "reference": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255,
            "description": "Your reference for this payment (order number or cart ID). Returned in webhooks."
          },
          "return_url": {
            "type": "string",
            "format": "uri",
            "description": "Where the shopper is sent after checkout. Must be on a registered store domain."
          },
          "order_id": {
            "type": "string",
            "maxLength": 255,
            "description": "Your order ID, if the order already exists. Otherwise attach it later."
          },
          "customer_email": {
            "type": "string",
            "format": "email"
          },
          "customer_phone": {
            "type": "string",
            "description": "E.164 format recommended (`+15551234567`)."
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true,
            "description": "Your own key-value data, stored with the session."
          },
          "shipping": {
            "$ref": "#/components/schemas/ShippingAddress"
          },
          "line_items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LineItem"
            }
          },
          "customer_id": {
            "type": "string",
            "format": "uuid",
            "description": "Your OnCharge customer (POST /api/v1/customers): the payment is theirs, and a card they choose to save is saved for them."
          },
          "save_card": {
            "type": "boolean",
            "default": false,
            "description": "Offer the shopper to save their card for your store: a box they must tick (card payments on stores with their own card account). Charge the saved card later with POST /api/v1/customers/{customer_id}/charges. Needs `customer_id` or `customer_email`."
          },
          "tax": {
            "$ref": "#/components/schemas/TaxRequest"
          }
        }
      },
      "CheckoutSession": {
        "type": "object",
        "required": [
          "session_id",
          "status",
          "iframe_url",
          "pay_token",
          "created_at",
          "expires_at"
        ],
        "properties": {
          "session_id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "$ref": "#/components/schemas/SessionStatus"
          },
          "iframe_url": {
            "type": "string",
            "description": "Path of the checkout page relative to `https://app.oncharge.io`, including the pay\ntoken. Prefix it with the API base URL to get the full checkout URL.\n"
          },
          "pay_token": {
            "type": "string",
            "description": "Short-lived token (30 minutes) that authorizes the checkout page. Already included in `iframe_url`."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "shipping_required": {
            "type": "boolean",
            "description": "Present (true) when the order ships by carrier and has no shipping address yet. Attach it with `POST /api/v1/checkout/sessions/{session_id}/order`; tracking is refused until it is on file."
          },
          "amount": {
            "type": "integer",
            "description": "With sales tax: what the shopper pays (the calculated total, once the address is known)."
          },
          "tax": {
            "$ref": "#/components/schemas/Tax"
          }
        }
      },
      "CheckoutSessionReplay": {
        "type": "object",
        "required": [
          "session_id",
          "status",
          "iframe_url",
          "pay_token"
        ],
        "properties": {
          "session_id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "$ref": "#/components/schemas/SessionStatus"
          },
          "iframe_url": {
            "type": "string"
          },
          "pay_token": {
            "type": "string"
          }
        }
      },
      "CheckoutSessionDetail": {
        "type": "object",
        "required": [
          "session_id",
          "store_id",
          "amount",
          "currency",
          "status",
          "created_at",
          "updated_at",
          "expires_at",
          "payment_reference"
        ],
        "properties": {
          "session_id": {
            "type": "string",
            "format": "uuid"
          },
          "store_id": {
            "type": "string",
            "format": "uuid"
          },
          "order_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "amount": {
            "$ref": "#/components/schemas/Amount"
          },
          "currency": {
            "$ref": "#/components/schemas/Currency"
          },
          "status": {
            "$ref": "#/components/schemas/SessionStatus"
          },
          "payment_reference": {
            "type": "string",
            "pattern": "^ocpay_[0-9a-f]{32}$",
            "description": "OnCharge's reference for the payment: `ocpay_` and the session id in lowercase hex without dashes, for every session. Never a payment processor id.",
            "example": "ocpay_3f2a9c1e0b7d4e6f8a1b2c3d4e5f6a7b"
          },
          "psp_reference": {
            "type": [
              "string",
              "null"
            ],
            "deprecated": true,
            "description": "Kept with its meaning for existing integrations: for a session created before the reference cutoff (2026-12-01T00:00:00Z by default; see the OnCharge references guide), its original payment reference (null before payment); for a session created at or after it, the same `ocpay_` reference as `payment_reference`. New integrations should read `payment_reference`."
          },
          "payment_method": {
            "$ref": "#/components/schemas/PaymentMethod"
          },
          "settlement": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "verify_deposits",
              "processing",
              "settled",
              null
            ],
            "description": "A bank debit's collection: `verify_deposits` while the shopper confirms their account with the test deposits, `processing` while the debit is collected (up to 4 business days), `settled` once it cleared. Null for every other method. Ship once `status` is `captured`."
          },
          "risk_decision": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "accept",
              "review",
              "reject",
              null
            ],
            "description": "Outcome of the checkout risk check."
          },
          "risk_score": {
            "type": [
              "number",
              "null"
            ],
            "description": "Risk score 0–100."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "tax": {
            "$ref": "#/components/schemas/Tax"
          }
        }
      },
      "AttachOrderRequest": {
        "type": "object",
        "properties": {
          "order_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "shipping": {
            "$ref": "#/components/schemas/ShippingAddress"
          }
        }
      },
      "AttachOrderResponse": {
        "type": "object",
        "required": [
          "session_id",
          "order_id",
          "shipping_recorded",
          "shipping_on_file"
        ],
        "properties": {
          "session_id": {
            "type": "string",
            "format": "uuid"
          },
          "order_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "shipping_recorded": {
            "type": "boolean",
            "description": "true if this call recorded the shipping address."
          },
          "shipping_on_file": {
            "type": "boolean",
            "description": "true if the session has a shipping destination (from this or an earlier call)."
          },
          "amount": {
            "type": "integer",
            "description": "With sales tax: the total now that the address is known."
          },
          "tax": {
            "$ref": "#/components/schemas/Tax"
          }
        }
      },
      "CancelResponse": {
        "type": "object",
        "required": [
          "session_id",
          "status"
        ],
        "properties": {
          "session_id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "const": "cancelled"
          },
          "psp_reference": {
            "type": "string",
            "description": "Opaque reference of the cancellation."
          }
        }
      },
      "CreateRefundRequest": {
        "type": "object",
        "required": [
          "session_id",
          "amount",
          "currency"
        ],
        "properties": {
          "session_id": {
            "type": "string",
            "format": "uuid"
          },
          "amount": {
            "$ref": "#/components/schemas/Amount"
          },
          "currency": {
            "$ref": "#/components/schemas/Currency"
          },
          "reference": {
            "type": "string",
            "maxLength": 255,
            "description": "Your reference for the refund."
          }
        }
      },
      "Refund": {
        "type": "object",
        "required": [
          "refund_id",
          "session_id",
          "status",
          "amount",
          "currency"
        ],
        "properties": {
          "refund_id": {
            "type": "string"
          },
          "session_id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "enum": [
              "refund_requested",
              "refunded"
            ],
            "description": "`refunded` if already complete, otherwise `refund_requested` until the `refund.succeeded` webhook."
          },
          "amount": {
            "$ref": "#/components/schemas/Amount"
          },
          "currency": {
            "$ref": "#/components/schemas/Currency"
          }
        }
      },
      "RefundReplay": {
        "type": "object",
        "required": [
          "refund_id",
          "session_id",
          "status",
          "idempotent"
        ],
        "properties": {
          "refund_id": {
            "type": "string"
          },
          "session_id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string"
          },
          "psp_reference": {
            "type": "string"
          },
          "idempotent": {
            "type": "boolean",
            "const": true
          }
        }
      },
      "Carrier": {
        "type": "string",
        "enum": [
          "usps",
          "ups",
          "fedex",
          "dhl_express"
        ],
        "description": "Normalized carrier. Common spellings are accepted on input (`USPS`, `United States Postal\nService`, `UPS`, `FedEx`, `FedEx Ground`, `DHL`, `DHL Express`, …).\n"
      },
      "ReportShipmentsRequest": {
        "type": "object",
        "required": [
          "shipments"
        ],
        "description": "Give `session_id` or `order_id`.",
        "properties": {
          "session_id": {
            "type": "string",
            "format": "uuid"
          },
          "order_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "shipments": {
            "type": "array",
            "minItems": 1,
            "maxItems": 10,
            "items": {
              "type": "object",
              "required": [
                "tracking_number"
              ],
              "properties": {
                "carrier": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "maxLength": 60,
                  "description": "USPS, UPS, FedEx or DHL Express, or a shipping tool's code for one. Optional when the tracking number format identifies the carrier."
                },
                "tracking_number": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 80,
                  "description": "Spaces and dashes are ignored; 8–40 letters and digits after normalization."
                },
                "replaces": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "maxLength": 80,
                  "description": "The tracking number (or shipment id) on this order that this one replaces."
                }
              }
            }
          }
        }
      },
      "ReportedShipment": {
        "type": "object",
        "required": [
          "tracking_number",
          "status"
        ],
        "properties": {
          "tracking_number": {
            "type": "string"
          },
          "carrier": {
            "$ref": "#/components/schemas/Carrier"
          },
          "status": {
            "type": "string",
            "enum": [
              "accepted",
              "rejected"
            ]
          },
          "error": {
            "type": "string",
            "enum": [
              "carrier_not_supported",
              "tracking_number_invalid",
              "carrier_mismatch",
              "tracking_number_in_use",
              "too_many_shipments",
              "replacement_not_found",
              "replacement_not_allowed"
            ]
          },
          "message": {
            "type": "string"
          },
          "replaced": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Tracking numbers this one replaced."
          }
        }
      },
      "DeliveryState": {
        "type": "string",
        "enum": [
          "not_tracked",
          "awaiting_shipment",
          "in_transit",
          "delivered",
          "on_hold",
          "refunded"
        ],
        "description": "`not_tracked` (no delivery tracking for this order, e.g. digital goods, or not paid yet),\n`awaiting_shipment`, `in_transit`, `delivered` (confirmed; payout released on schedule),\n`on_hold` (see `hold_reason`), `refunded`.\n"
      },
      "ReportShipmentsResponse": {
        "type": "object",
        "required": [
          "session_id",
          "shipments",
          "delivery"
        ],
        "properties": {
          "session_id": {
            "type": "string",
            "format": "uuid"
          },
          "shipments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ReportedShipment"
            }
          },
          "delivery": {
            "type": "object",
            "required": [
              "state",
              "hold_reason"
            ],
            "properties": {
              "state": {
                "$ref": "#/components/schemas/DeliveryState"
              },
              "hold_reason": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          }
        }
      },
      "Delivery": {
        "type": "object",
        "required": [
          "state",
          "hold_reason",
          "delivered_at",
          "shipments"
        ],
        "properties": {
          "state": {
            "$ref": "#/components/schemas/DeliveryState"
          },
          "hold_reason": {
            "type": [
              "string",
              "null"
            ],
            "description": "Plain-language reason when `state` is `on_hold`."
          },
          "delivered_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the last package was confirmed delivered."
          },
          "shipments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TrackedShipment"
            }
          },
          "action_required": {
            "type": [
              "string",
              "null"
            ],
            "description": "What to do now, if anything (add tracking, re-ship or refund)."
          },
          "auto_refund_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the shopper is refunded in full automatically if the order is still not confirmed delivered."
          },
          "can_add_tracking": {
            "type": "boolean"
          },
          "shipping_address_missing": {
            "type": "boolean"
          }
        }
      },
      "TrackedShipment": {
        "type": "object",
        "required": [
          "id",
          "carrier",
          "carrier_label",
          "tracking_number",
          "status",
          "result",
          "problems",
          "removable",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "carrier": {
            "$ref": "#/components/schemas/Carrier"
          },
          "carrier_label": {
            "type": "string",
            "examples": [
              "UPS"
            ]
          },
          "tracking_number": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "pre_transit",
              "in_transit",
              "out_for_delivery",
              "delivered",
              "available_for_pickup",
              "return_to_sender",
              "failure",
              "cancelled",
              "unknown"
            ],
            "description": "Latest carrier status."
          },
          "result": {
            "type": "string",
            "enum": [
              "checking",
              "confirmed",
              "problem",
              "replaced"
            ],
            "description": "`confirmed` when delivery to the order address is verified; `problem` lists reasons in `problems` (re-ship and replace the number, or refund); `replaced` when another number took its place."
          },
          "problems": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "delivered_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "delivered_to": {
            "type": [
              "string",
              "null"
            ],
            "description": "City, state and postal code the carrier reported."
          },
          "note": {
            "type": [
              "string",
              "null"
            ]
          },
          "removable": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "replaceable": {
            "type": "boolean"
          },
          "replaced_by": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          }
        }
      },
      "DeliveryStatusResponse": {
        "type": "object",
        "required": [
          "session_id",
          "delivery"
        ],
        "properties": {
          "session_id": {
            "type": "string",
            "format": "uuid"
          },
          "delivery": {
            "$ref": "#/components/schemas/Delivery"
          }
        }
      },
      "Dispute": {
        "type": "object",
        "description": "A dispute (chargeback) on one of your payments.",
        "required": [
          "id",
          "store_id",
          "session_id",
          "merchant_reference",
          "payment_reference",
          "original_amount",
          "dispute_amount",
          "currency",
          "reason",
          "reason_code",
          "status",
          "defense_deadline",
          "evidence_submitted_at",
          "closed_at",
          "responded_by",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "reference": {
            "type": "string",
            "pattern": "^ocdsp_[0-9a-f]{32}$",
            "description": "OnCharge's reference for the dispute (`ocdsp_` and its id in hex)."
          },
          "store_id": {
            "type": "string",
            "format": "uuid"
          },
          "session_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "description": "The checkout session of the disputed payment."
          },
          "merchant_reference": {
            "type": [
              "string",
              "null"
            ],
            "description": "Your own order reference."
          },
          "payment_reference": {
            "type": [
              "string",
              "null"
            ],
            "description": "Kept with its meaning for existing integrations: for a payment created before the reference cutoff (2026-12-01T00:00:00Z by default; see the OnCharge references guide), the payment reference this field always carried; for a payment created at or after it, the payment's `ocpay_` reference. New integrations should read `oncharge_payment_reference`."
          },
          "oncharge_payment_reference": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^ocpay_[0-9a-f]{32}$",
            "description": "The disputed payment's OnCharge reference (`ocpay_…`), for every dispute; the same as the checkout session's `payment_reference`. Null when no payment is linked."
          },
          "original_amount": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Amount of the original payment, minor units."
          },
          "dispute_amount": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Disputed amount, minor units."
          },
          "currency": {
            "type": [
              "string",
              "null"
            ]
          },
          "reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "reason_label": {
            "type": "string",
            "description": "The reason in plain words."
          },
          "reason_code": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "notification_of_chargeback",
              "chargeback",
              "second_chargeback",
              "prearbitration",
              "defense_pending",
              "defended",
              "accepted",
              "won",
              "lost"
            ]
          },
          "status_label": {
            "type": "string",
            "description": "The status in plain words."
          },
          "defense_deadline": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When evidence must be in."
          },
          "evidence_submitted_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "closed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "responded_by": {
            "type": "string",
            "enum": [
              "oncharge",
              "merchant"
            ],
            "description": "`oncharge`: the OnCharge team submits the response using the evidence you upload; defend, accept and auto-defend return `409 responded_by_oncharge`. `merchant`: you can defend or accept it through the API."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "DisputeEvidence": {
        "type": "object",
        "required": [
          "id",
          "doc_type",
          "filename",
          "uploaded_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "doc_type": {
            "type": "string"
          },
          "filename": {
            "type": [
              "string",
              "null"
            ]
          },
          "uploaded_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "AutoDefendResponse": {
        "type": "object",
        "required": [
          "dispute_id",
          "success"
        ],
        "properties": {
          "dispute_id": {
            "type": "string",
            "format": "uuid"
          },
          "success": {
            "type": "boolean"
          },
          "message": {
            "type": "string",
            "description": "`Defence submitted.` on success, otherwise a neutral explanation."
          },
          "evidence_count": {
            "type": "integer"
          },
          "defense_text_preview": {
            "type": "string"
          },
          "win_probability": {
            "type": [
              "number",
              "null"
            ]
          },
          "ai_recommendation": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "RiskDecisionValue": {
        "type": "string",
        "enum": [
          "allow",
          "deny",
          "review",
          "step_up"
        ]
      },
      "RiskReason": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "severity": {
            "type": "string",
            "enum": [
              "info",
              "warn",
              "block"
            ]
          },
          "explain": {
            "type": "string"
          }
        }
      },
      "RiskDecision": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "session_id": {
            "type": "string",
            "format": "uuid"
          },
          "decision": {
            "$ref": "#/components/schemas/RiskDecisionValue"
          },
          "score": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100
          },
          "actions": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Step-up actions, e.g. `require_sms_otp`, `require_terms`, `require_signature`, `force_3ds`."
          },
          "reasons": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RiskReason"
            }
          },
          "explain_short": {
            "type": [
              "string",
              "null"
            ]
          },
          "model_version": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "RiskDecisionDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/RiskDecision"
          },
          {
            "type": "object",
            "additionalProperties": true,
            "properties": {
              "feature_snapshot": {
                "type": "object",
                "additionalProperties": true
              },
              "policy_version": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "label": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "paid": {
                    "type": [
                      "boolean",
                      "null"
                    ]
                  },
                  "refunded": {
                    "type": [
                      "boolean",
                      "null"
                    ]
                  },
                  "chargeback": {
                    "type": [
                      "boolean",
                      "null"
                    ]
                  },
                  "dispute_opened": {
                    "type": [
                      "boolean",
                      "null"
                    ]
                  },
                  "label_source": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "occurred_at": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "date-time"
                  }
                }
              }
            }
          }
        ]
      },
      "BlockAction": {
        "type": "string",
        "enum": [
          "allow",
          "step_up",
          "deny"
        ]
      },
      "RiskPolicyUpdate": {
        "type": "object",
        "properties": {
          "mode": {
            "type": "string",
            "enum": [
              "monitor",
              "enforce"
            ]
          },
          "thresholds": {
            "type": "object",
            "required": [
              "score_allow",
              "score_review",
              "score_deny"
            ],
            "properties": {
              "score_allow": {
                "type": "integer",
                "minimum": 0,
                "maximum": 100
              },
              "score_review": {
                "type": "integer",
                "minimum": 0,
                "maximum": 100
              },
              "score_deny": {
                "type": "integer",
                "minimum": 0,
                "maximum": 100
              }
            }
          },
          "step_up_rules": {
            "type": "object",
            "required": [
              "require_otp_on_review",
              "require_signature",
              "require_terms",
              "force_3ds_above"
            ],
            "properties": {
              "require_otp_on_review": {
                "type": "boolean"
              },
              "require_signature": {
                "type": "boolean"
              },
              "require_terms": {
                "type": "boolean"
              },
              "force_3ds_above": {
                "type": "integer",
                "minimum": 0,
                "maximum": 100
              }
            }
          },
          "blocks": {
            "type": "object",
            "required": [
              "vpn_tor",
              "datacenter_asn",
              "disposable_email",
              "voip_phone",
              "high_risk_countries",
              "headless_browser"
            ],
            "properties": {
              "vpn_tor": {
                "$ref": "#/components/schemas/BlockAction"
              },
              "datacenter_asn": {
                "$ref": "#/components/schemas/BlockAction"
              },
              "disposable_email": {
                "$ref": "#/components/schemas/BlockAction"
              },
              "voip_phone": {
                "$ref": "#/components/schemas/BlockAction"
              },
              "high_risk_countries": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "ISO country codes."
              },
              "headless_browser": {
                "$ref": "#/components/schemas/BlockAction"
              }
            }
          },
          "velocity_limits": {
            "type": "object",
            "required": [
              "ip_5m",
              "ip_1h",
              "ip_24h",
              "email_5m",
              "email_1h",
              "email_24h"
            ],
            "properties": {
              "ip_5m": {
                "type": "integer",
                "minimum": 0
              },
              "ip_1h": {
                "type": "integer",
                "minimum": 0
              },
              "ip_24h": {
                "type": "integer",
                "minimum": 0
              },
              "email_5m": {
                "type": "integer",
                "minimum": 0
              },
              "email_1h": {
                "type": "integer",
                "minimum": 0
              },
              "email_24h": {
                "type": "integer",
                "minimum": 0
              }
            }
          }
        }
      },
      "RiskPolicy": {
        "allOf": [
          {
            "$ref": "#/components/schemas/RiskPolicyUpdate"
          },
          {
            "type": "object",
            "required": [
              "store_id",
              "is_default"
            ],
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "store_id": {
                "type": "string",
                "format": "uuid"
              },
              "is_default": {
                "type": "boolean",
                "description": "true when no policy has been saved and these are the defaults."
              },
              "created_at": {
                "type": "string",
                "format": "date-time"
              },
              "updated_at": {
                "type": "string",
                "format": "date-time"
              }
            }
          }
        ]
      },
      "StoredRiskPolicy": {
        "allOf": [
          {
            "$ref": "#/components/schemas/RiskPolicyUpdate"
          },
          {
            "type": "object",
            "additionalProperties": true,
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "store_id": {
                "type": "string",
                "format": "uuid"
              },
              "created_at": {
                "type": "string",
                "format": "date-time"
              },
              "updated_at": {
                "type": "string",
                "format": "date-time"
              }
            }
          }
        ]
      },
      "RiskSimulation": {
        "type": "object",
        "properties": {
          "simulation": {
            "type": "boolean",
            "const": true
          },
          "original": {
            "type": "object",
            "properties": {
              "decision": {
                "$ref": "#/components/schemas/RiskDecisionValue"
              },
              "score": {
                "type": "integer"
              },
              "explain_short": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "simulated": {
            "type": "object",
            "properties": {
              "decision": {
                "$ref": "#/components/schemas/RiskDecisionValue"
              },
              "score": {
                "type": "integer"
              },
              "actions": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "reasons": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/RiskReason"
                }
              },
              "explain_short": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "policy_tested": {
            "$ref": "#/components/schemas/RiskPolicyUpdate"
          }
        }
      },
      "WebhookEventType": {
        "type": "string",
        "enum": [
          "payment.pending",
          "payment.authorized",
          "payment.captured",
          "payment.under_review",
          "payment.refused",
          "payment.cancelled",
          "payment.expired",
          "payment.capture_failed",
          "refund.succeeded",
          "refund.failed",
          "chargeback.opened",
          "dispute.evidence_due",
          "chargeback.won",
          "chargeback.lost",
          "fraud_warning.received",
          "delivery.confirmed",
          "payout.paid",
          "payout.failed",
          "payout.returned",
          "account.updated",
          "account.requirements_due",
          "account.restricted",
          "swap.created",
          "swap.completed",
          "swap.failed",
          "swap.refunded",
          "swap.expired",
          "subscription.created",
          "subscription.updated",
          "subscription.trial_will_end",
          "subscription.past_due",
          "subscription.paused",
          "subscription.resumed",
          "subscription.canceled",
          "subscription.period.paid",
          "subscription.period.payment_failed",
          "support.conversation.created",
          "support.message.received",
          "support.conversation.closed"
        ],
        "description": "Every event type. Payments on every rail use the same payment.* types (data.rail says which). Handle the types you need and acknowledge (2xx) any others; new types may be added."
      },
      "WebhookEvent": {
        "type": "object",
        "required": [
          "id",
          "type",
          "created",
          "livemode",
          "data"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Event ID (`evt_…`), the same as the `OnCharge-Event-Id` header."
          },
          "type": {
            "$ref": "#/components/schemas/WebhookEventType"
          },
          "created": {
            "type": "integer",
            "description": "Unix time (seconds) the event was created."
          },
          "livemode": {
            "type": "boolean",
            "description": "false for events from test payments."
          },
          "data": {
            "type": "object",
            "required": [
              "rail"
            ],
            "properties": {
              "session_id": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The checkout session; null for a payment paid straight to your wallet."
              },
              "order_id": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Your order ID, if known."
              },
              "reference": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The `reference` you sent when creating the session."
              },
              "amount": {
                "type": [
                  "integer",
                  "null"
                ],
                "description": "Minor units. For `refund.succeeded`, the total refunded so far."
              },
              "currency": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "ISO 4217 code."
              },
              "status": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The order's payment status after the event (for example `captured`, `refunded`)."
              },
              "rail": {
                "$ref": "#/components/schemas/EventRail"
              },
              "payment_reference": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "OnCharge's reference for the payment (`ocpay_…`)."
              },
              "payment_link_id": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uuid",
                "description": "The payment link the checkout was made from (`/api/v1/payment-links`), or null."
              },
              "invoice_id": {
                "type": "string",
                "format": "uuid",
                "description": "Only on a payment for an OnCharge invoice: the invoice's id (see Invoices)."
              },
              "payment_method": {
                "$ref": "#/components/schemas/PaymentMethod"
              },
              "tax": {
                "$ref": "#/components/schemas/Tax",
                "description": "Sales tax on the payment, on payment, refund and chargeback events of a taxed payment only."
              },
              "reason": {
                "type": "string",
                "enum": [
                  "limit_exceeded"
                ],
                "description": "Only on `payment.refused` when OnCharge refused the payment itself: `limit_exceeded` (the store reached a limit OnCharge set on its account, such as a daily volume cap). Absent when the bank declined it."
              }
            },
            "description": "For payment events from a checkout, the fields below. Crypto and Card to Crypto paid to your wallet carry `session_id: null` with `payment_id`, `source`, `method`, `coin`, `coin_amount`, `wallet` and transaction hashes; every other event its own fields. All of them carry `rail`."
          },
          "event": {
            "$ref": "#/components/schemas/WebhookEventType",
            "deprecated": true,
            "description": "Same as `type`. Kept for older plugins; only on payment events from a checkout."
          },
          "status": {
            "type": [
              "string",
              "null"
            ],
            "deprecated": true,
            "description": "Same as `data.status`. Kept for older plugins; only on payment events from a checkout."
          },
          "psp_reference": {
            "type": [
              "string",
              "null"
            ],
            "deprecated": true,
            "description": "Kept for older plugins, which store it as the order's transaction id: a payment made before 2026-12-01 keeps its original value here; from 2026-12-01 on it is the payment's OnCharge reference (`ocpay_…`, the same as `data.payment_reference`). Only on payment events from a checkout."
          }
        },
        "description": "Every event: { id, type, created, livemode, data }, and data.rail on every event. Payment events from a checkout (payment.*, refund.*, chargeback.*, delivery.confirmed) also repeat three older top-level fields for existing plugins. Other events carry their own data (see each webhook)."
      },
      "CatalogExclusionReason": {
        "type": [
          "string",
          "null"
        ],
        "enum": [
          "merchant_excluded",
          "controlled_substance",
          "insecure_link",
          "missing_image",
          "zero_price",
          null
        ],
        "description": "Why the product is not advertised, or `null`. `merchant_excluded`: you sent `excluded: true`. `controlled_substance`: the product names a controlled substance (U.S. DEA schedules I to V), which is never sent to an ad platform. `insecure_link`: the link is not https. `missing_image`: no `image_link`. `zero_price`: `price_minor` is 0."
      },
      "CatalogItem": {
        "type": "object",
        "required": [
          "id",
          "title",
          "link",
          "price_minor",
          "currency"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 50,
            "description": "Your product ID (WooCommerce: the product or variation ID). Unique per store."
          },
          "item_group_id": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 50,
            "description": "Groups the variants of one product (WooCommerce: the parent product ID)."
          },
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1000,
            "description": "Product name. Stored cut to 150 characters."
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 20000,
            "description": "Plain text or HTML (tags and shortcodes are removed). Stored cut to 5,000 characters."
          },
          "link": {
            "type": "string",
            "format": "uri",
            "maxLength": 2048,
            "description": "Product page. Must be https; a product with an http link is rejected (or, if already stored, excluded)."
          },
          "image_link": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "maxLength": 2048,
            "description": "Main image. Products without one are stored but not advertised."
          },
          "additional_image_links": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri"
            },
            "maxItems": 20,
            "description": "More images; at most 10 are kept."
          },
          "price_minor": {
            "type": "integer",
            "minimum": 0,
            "description": "Regular price in minor units, as shown in your store."
          },
          "sale_price_minor": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "description": "Current sale price in minor units. Ignored unless lower than `price_minor`."
          },
          "currency": {
            "$ref": "#/components/schemas/Currency"
          },
          "availability": {
            "type": "string",
            "enum": [
              "in_stock",
              "out_of_stock",
              "preorder",
              "backorder"
            ],
            "default": "in_stock"
          },
          "condition": {
            "type": "string",
            "enum": [
              "new",
              "refurbished",
              "used"
            ],
            "default": "new"
          },
          "brand": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 200
          },
          "gtin": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 50,
            "description": "UPC, EAN, ISBN or ITF-14. Kept only when it is 8–14 digits."
          },
          "mpn": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 100
          },
          "google_product_category": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 500,
            "description": "Google's product category ID or path, if you know it."
          },
          "product_type": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 750,
            "description": "Your own category path, e.g. `Apparel > Shirts`."
          },
          "attributes": {
            "type": "object",
            "additionalProperties": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "description": "Variant attributes such as `{\"Color\": \"Blue\", \"Size\": \"M\"}`. At most 30."
          },
          "ruo": {
            "type": "boolean",
            "description": "`true` for research-use-only (RUO) products. A label only: the product is sent to the ad platforms like any other, and each platform reviews it against its own policies."
          },
          "excluded": {
            "type": "boolean",
            "description": "`true` to keep the product out of advertising."
          }
        }
      },
      "CatalogBatchRequest": {
        "type": "object",
        "description": "At least one product or delete, at most 500 together, each ID once.",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CatalogItem"
            },
            "maxItems": 500,
            "description": "Products to add or update."
          },
          "deletes": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 50
            },
            "maxItems": 500,
            "description": "IDs of products to remove."
          }
        }
      },
      "CatalogItemResult": {
        "type": "object",
        "required": [
          "id",
          "status"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "created",
              "updated",
              "unchanged",
              "deleted",
              "not_found",
              "rejected"
            ],
            "description": "`unchanged`: identical to what OnCharge already has (nothing written). `not_found`: a delete for an ID OnCharge never had."
          },
          "advertisable": {
            "type": "boolean",
            "description": "For stored products: may be sent to ad platforms."
          },
          "ruo": {
            "type": "boolean"
          },
          "excluded_reason": {
            "$ref": "#/components/schemas/CatalogExclusionReason"
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "title_truncated",
                "gtin_invalid",
                "sale_price_ignored",
                "additional_images_truncated",
                "link_not_stored"
              ]
            }
          },
          "error": {
            "type": "string",
            "description": "For `rejected`: the error code, e.g. `insecure_link`."
          },
          "message": {
            "type": "string"
          }
        }
      },
      "CatalogBatchResponse": {
        "type": "object",
        "required": [
          "results",
          "counts"
        ],
        "properties": {
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CatalogItemResult"
            },
            "description": "One per product, then one per delete, in request order."
          },
          "counts": {
            "type": "object",
            "required": [
              "created",
              "updated",
              "unchanged",
              "deleted",
              "not_found",
              "rejected"
            ],
            "properties": {
              "created": {
                "type": "integer"
              },
              "updated": {
                "type": "integer"
              },
              "unchanged": {
                "type": "integer"
              },
              "deleted": {
                "type": "integer"
              },
              "not_found": {
                "type": "integer"
              },
              "rejected": {
                "type": "integer"
              }
            }
          }
        }
      },
      "CatalogProduct": {
        "type": "object",
        "required": [
          "id",
          "title",
          "link",
          "price_minor",
          "currency",
          "availability",
          "ruo",
          "excluded_reason",
          "advertisable",
          "deleted",
          "content_hash",
          "updated_at"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "item_group_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "title": {
            "type": "string"
          },
          "link": {
            "type": "string",
            "format": "uri"
          },
          "image_link": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "price_minor": {
            "type": "integer"
          },
          "sale_price_minor": {
            "type": [
              "integer",
              "null"
            ]
          },
          "currency": {
            "$ref": "#/components/schemas/Currency"
          },
          "availability": {
            "type": "string",
            "enum": [
              "in_stock",
              "out_of_stock",
              "preorder",
              "backorder"
            ]
          },
          "ruo": {
            "type": "boolean"
          },
          "excluded_reason": {
            "$ref": "#/components/schemas/CatalogExclusionReason"
          },
          "advertisable": {
            "type": "boolean",
            "description": "Not removed and not excluded."
          },
          "deleted": {
            "type": "boolean",
            "description": "Removed (only listed with `include_deleted=true`)."
          },
          "content_hash": {
            "type": "string",
            "description": "Changes whenever anything OnCharge stores for the product changes."
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "EventRail": {
        "type": "string",
        "enum": [
          "card",
          "crypto",
          "card_to_crypto"
        ],
        "description": "The rail an event or payment is on: card checkout; crypto (crypto checkout, or a coin paid straight to your wallet through the plugin or the gateway API); or Card to Crypto (card, Cash App or Venmo paid out to your wallet in USDC)."
      },
      "MerchantEvent": {
        "allOf": [
          {
            "$ref": "#/components/schemas/WebhookEvent"
          }
        ],
        "description": "An event as your endpoints received it."
      },
      "Payment": {
        "type": "object",
        "description": "One entry of the activity ledger, on any rail. Amounts are minor units, signed from your side (a refund is negative).",
        "required": [
          "id",
          "reference",
          "kind",
          "rail",
          "status",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "OnCharge's id of the payment, refund, dispute or conversion."
          },
          "reference": {
            "type": "string",
            "description": "OnCharge's reference: `ocpay_…`, `ocrfd_…`, `ocdsp_…`, `ocswp_…`."
          },
          "kind": {
            "type": "string",
            "enum": [
              "payment",
              "refund",
              "dispute",
              "swap"
            ]
          },
          "rail": {
            "$ref": "#/components/schemas/EventRail"
          },
          "status": {
            "type": "string",
            "description": "paid, pending, authorized, review, refunded, partly_refunded, declined, failed, cancelled, expired, disputed, won, lost, completed…"
          },
          "status_label": {
            "type": "string"
          },
          "amount": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Null when only coin amounts are known."
          },
          "currency": {
            "type": [
              "string",
              "null"
            ]
          },
          "amount_text": {
            "type": [
              "string",
              "null"
            ],
            "description": "The coin amount as text when the amount in money is not known."
          },
          "fee": {
            "type": [
              "integer",
              "null"
            ]
          },
          "net": {
            "type": [
              "integer",
              "null"
            ]
          },
          "coin": {
            "type": [
              "string",
              "null"
            ]
          },
          "coin_amount": {
            "type": [
              "string",
              "null"
            ]
          },
          "coin_fee": {
            "type": [
              "string",
              "null"
            ]
          },
          "coin_net": {
            "type": [
              "string",
              "null"
            ]
          },
          "order_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "method": {
            "type": [
              "string",
              "null"
            ],
            "description": "Visa •••• 4242, Cash App, USDT (TRC20)…"
          },
          "customer_email": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "payment_reference": {
            "type": [
              "string",
              "null"
            ],
            "description": "The payment a refund or dispute belongs to."
          },
          "payout_reference": {
            "type": [
              "string",
              "null"
            ]
          },
          "payment_tx": {
            "type": [
              "string",
              "null"
            ],
            "description": "The paying transaction on a public chain."
          },
          "payout_tx": {
            "type": [
              "string",
              "null"
            ],
            "description": "The transaction that paid your wallet."
          },
          "refundable": {
            "type": "integer",
            "description": "Minor units that can still be refunded (0 when this entry cannot be)."
          },
          "signals": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "review",
                "fraud_warning",
                "disputed"
              ]
            }
          },
          "tax": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Sales tax inside `amount`, minor units, signed like it (a refund's share given back is negative); null when untaxed."
          }
        }
      },
      "Payout": {
        "type": "object",
        "required": [
          "id",
          "type",
          "status",
          "amount",
          "currency",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The payout id the payout.paid, payout.failed and payout.returned events carry."
          },
          "type": {
            "type": "string",
            "enum": [
              "payout",
              "bank_debit"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "paid",
              "on_its_way",
              "failed",
              "returned",
              "canceled"
            ]
          },
          "status_label": {
            "type": "string"
          },
          "amount": {
            "type": "integer",
            "description": "Minor units; negative for a bank debit."
          },
          "currency": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "arrival_date": {
            "type": [
              "string",
              "null"
            ]
          },
          "orders": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Orders it paid, once its statement exists."
          },
          "items": {
            "type": "integer"
          },
          "problem": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why it did not reach your bank (or, a debit card payout, your card), in plain words."
          },
          "method": {
            "type": "string",
            "enum": [
              "standard",
              "instant"
            ],
            "description": "`instant`: a debit card payout you asked for; `amount` is what reached the card."
          },
          "fee": {
            "type": "integer",
            "description": "OnCharge's fee taken out of a debit card payout, in minor units (0 for a standard payout, and for one that did not arrive)."
          }
        }
      },
      "Balance": {
        "type": "object",
        "additionalProperties": true,
        "description": "Where your money is, as the Balances page shows it: the card balance per currency (available and pending), what the store owes when below zero, card money by stage with the reserve and its release dates, why payouts are paused, the next payout and payouts on their way, and crypto paid straight to your wallet in the last 30 days (OnCharge holds none of it).",
        "required": [
          "as_of",
          "card"
        ],
        "properties": {
          "as_of": {
            "type": "string",
            "format": "date-time"
          },
          "card": {
            "type": "object"
          },
          "next_payouts": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "on_its_way": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "delivery": {
            "type": "object"
          },
          "wallet": {
            "type": [
              "object",
              "null"
            ]
          }
        }
      },
      "PayoutSummary": {
        "type": "object",
        "additionalProperties": true,
        "description": "Card payment totals for a period, per currency: gross volume, refunds, OnCharge's fees and what you keep, with your pricing and the newest payments with their fees.",
        "required": [
          "period",
          "totals"
        ],
        "properties": {
          "period": {
            "type": "object",
            "properties": {
              "from": {
                "type": "string",
                "format": "date"
              },
              "to": {
                "type": "string",
                "format": "date"
              }
            }
          },
          "totals": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "pricing": {
            "type": [
              "object",
              "null"
            ]
          },
          "fees": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "CreatePaymentLinkRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "title"
        ],
        "properties": {
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 500
          },
          "amount_type": {
            "type": "string",
            "enum": [
              "fixed",
              "customer_chosen"
            ],
            "default": "fixed",
            "description": "`fixed`: the customer pays `amount` per item. `customer_chosen`: they choose between `min_amount` and `max_amount`."
          },
          "amount": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "description": "Per item, for a fixed amount. Minor units (cents), at least 50."
          },
          "min_amount": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "description": "Customer-chosen amounts: the least they may pay (default 50)."
          },
          "max_amount": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "description": "Customer-chosen amounts: the most they may pay (default 1000000, $10,000)."
          },
          "preset_amount": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "description": "Customer-chosen amounts: where the amount field starts."
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Za-z]{3}$",
            "default": "USD",
            "description": "Card payments are USD only on stores paid out per delivered order."
          },
          "adjustable_quantity": {
            "type": "boolean",
            "default": false
          },
          "max_quantity": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "maximum": 99,
            "description": "Default 10 when `adjustable_quantity` is on."
          },
          "collect_shipping": {
            "type": "boolean",
            "default": false,
            "description": "Ask for a shipping address (required on stores that ship what they sell)."
          },
          "collect_phone": {
            "type": "boolean",
            "default": false
          },
          "success_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "description": "https, on one of the store's registered domains. Default: OnCharge's thank-you page."
          },
          "rails": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string",
              "enum": [
                "card",
                "crypto"
              ]
            },
            "minItems": 1,
            "description": "Ways to pay allowed on the link (default both); the store must have them on."
          },
          "expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "UpdatePaymentLinkRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 500
          },
          "amount_type": {
            "type": "string",
            "enum": [
              "fixed",
              "customer_chosen"
            ],
            "default": "fixed",
            "description": "`fixed`: the customer pays `amount` per item. `customer_chosen`: they choose between `min_amount` and `max_amount`."
          },
          "amount": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "description": "Per item, for a fixed amount. Minor units (cents), at least 50."
          },
          "min_amount": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "description": "Customer-chosen amounts: the least they may pay (default 50)."
          },
          "max_amount": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "description": "Customer-chosen amounts: the most they may pay (default 1000000, $10,000)."
          },
          "preset_amount": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "description": "Customer-chosen amounts: where the amount field starts."
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Za-z]{3}$",
            "default": "USD",
            "description": "Card payments are USD only on stores paid out per delivered order."
          },
          "adjustable_quantity": {
            "type": "boolean",
            "default": false
          },
          "max_quantity": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "maximum": 99,
            "description": "Default 10 when `adjustable_quantity` is on."
          },
          "collect_shipping": {
            "type": "boolean",
            "default": false,
            "description": "Ask for a shipping address (required on stores that ship what they sell)."
          },
          "collect_phone": {
            "type": "boolean",
            "default": false
          },
          "success_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "description": "https, on one of the store's registered domains. Default: OnCharge's thank-you page."
          },
          "rails": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string",
              "enum": [
                "card",
                "crypto"
              ]
            },
            "minItems": 1,
            "description": "Ways to pay allowed on the link (default both); the store must have them on."
          },
          "expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "active": {
            "type": "boolean",
            "description": "Turn the link off (`false`) or back on (`true`)."
          }
        }
      },
      "PaymentLink": {
        "type": "object",
        "required": [
          "id",
          "object",
          "store_id",
          "code",
          "url",
          "title",
          "amount_type",
          "currency",
          "active",
          "status",
          "created_at",
          "stats"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "object": {
            "type": "string",
            "const": "payment_link"
          },
          "store_id": {
            "type": "string",
            "format": "uuid"
          },
          "code": {
            "type": "string",
            "pattern": "^[A-Za-z0-9]{8,32}$"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "The link to share: `https://app.oncharge.io/l/<code>`."
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "amount_type": {
            "type": "string",
            "enum": [
              "fixed",
              "customer_chosen"
            ]
          },
          "amount": {
            "type": [
              "integer",
              "null"
            ]
          },
          "min_amount": {
            "type": [
              "integer",
              "null"
            ]
          },
          "max_amount": {
            "type": [
              "integer",
              "null"
            ]
          },
          "preset_amount": {
            "type": [
              "integer",
              "null"
            ]
          },
          "currency": {
            "type": "string"
          },
          "adjustable_quantity": {
            "type": "boolean"
          },
          "max_quantity": {
            "type": "integer"
          },
          "collect_shipping": {
            "type": "boolean"
          },
          "collect_phone": {
            "type": "boolean"
          },
          "success_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "rails": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "card",
                "crypto"
              ]
            }
          },
          "active": {
            "type": "boolean"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "inactive",
              "expired"
            ],
            "description": "`active`: takes payments; `inactive`: turned off; `expired`: past `expires_at`."
          },
          "expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "deactivated_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "created_via": {
            "type": "string",
            "enum": [
              "dashboard",
              "api"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "stats": {
            "type": "object",
            "required": [
              "views",
              "checkouts",
              "payments",
              "revenue",
              "refunded"
            ],
            "properties": {
              "views": {
                "type": "integer",
                "description": "Visits of the link page while it was active."
              },
              "checkouts": {
                "type": "integer",
                "description": "Checkouts started from the link."
              },
              "payments": {
                "type": "integer",
                "description": "Paid checkouts (captured, or refunded afterwards)."
              },
              "revenue": {
                "type": "integer",
                "description": "What the paid checkouts came to before refunds, minor units of the link's currency."
              },
              "refunded": {
                "type": "integer",
                "description": "What was refunded of them."
              }
            }
          },
          "qr_code": {
            "type": [
              "string",
              "null"
            ],
            "description": "An SVG QR code of `url` as a data URI (single-link responses)."
          }
        }
      },
      "PaymentLinkList": {
        "type": "object",
        "required": [
          "object",
          "data",
          "has_more",
          "next_before"
        ],
        "properties": {
          "object": {
            "type": "string",
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PaymentLink"
            }
          },
          "has_more": {
            "type": "boolean"
          },
          "next_before": {
            "type": [
              "string",
              "null"
            ],
            "description": "Pass as `before` for the next page."
          }
        }
      },
      "InvoiceAddress": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "line1": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 300
          },
          "line2": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 300
          },
          "city": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 120
          },
          "state": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 120
          },
          "postal_code": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 20
          },
          "country": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 60
          }
        }
      },
      "InvoiceLineInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "description",
          "quantity",
          "unit_amount"
        ],
        "properties": {
          "description": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "quantity": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100000
          },
          "unit_amount": {
            "type": "integer",
            "minimum": -10000000000,
            "maximum": 10000000000,
            "description": "Minor units of the invoice currency; negative for a discount line. quantity x unit_amount may be at most 10000000000 either way."
          },
          "tax_rate": {
            "type": [
              "number",
              "string"
            ],
            "description": "A percent from 0 to 100 with up to three decimals, e.g. `8.875`. Tax is rounded half away from zero per line."
          },
          "requires_shipping": {
            "type": "boolean",
            "default": false,
            "description": "A shipped item. Card payments for it are paid out after the carrier confirms delivery to `shipping_address`, as for any order."
          }
        }
      },
      "InvoiceUpdateRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "currency": {
            "type": "string",
            "enum": [
              "USD",
              "EUR",
              "GBP",
              "CAD",
              "AUD",
              "NZD",
              "CHF",
              "JPY"
            ],
            "default": "USD",
            "description": "Amounts are in this currency's minor units (JPY has none). Card payments on stores paid out per delivered order are USD only."
          },
          "customer": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "name": {
                "type": [
                  "string",
                  "null"
                ],
                "maxLength": 200,
                "description": "Required to finalize."
              },
              "email": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "email",
                "description": "Required to send."
              },
              "address": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/InvoiceAddress"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            }
          },
          "shipping_address": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/InvoiceAddress"
              },
              {
                "type": "null"
              }
            ],
            "description": "Needed when a line ships and the store's card payments are paid out on delivery."
          },
          "lines": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/InvoiceLineInput"
            },
            "description": "On update, replaces every line."
          },
          "memo": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2000
          },
          "footer": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 1000
          },
          "reply_to": {
            "type": [
              "string",
              "null"
            ],
            "format": "email",
            "description": "Where the customer's replies to invoice emails go."
          },
          "days_until_due": {
            "type": "integer",
            "minimum": 0,
            "maximum": 365,
            "default": 30
          },
          "due_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "A date (`YYYY-MM-DD`, end of that day UTC) or an ISO 8601 time. Overrides `days_until_due`; must not be in the past when finalizing."
          },
          "send_reminders": {
            "type": "boolean",
            "default": true,
            "description": "Email the customer 1, 7 and 14 days after the due date while it is unpaid."
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "maxLength": 500
            },
            "maxProperties": 20
          }
        }
      },
      "CreateInvoiceRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "currency": {
            "type": "string",
            "enum": [
              "USD",
              "EUR",
              "GBP",
              "CAD",
              "AUD",
              "NZD",
              "CHF",
              "JPY"
            ],
            "default": "USD",
            "description": "Amounts are in this currency's minor units (JPY has none). Card payments on stores paid out per delivered order are USD only."
          },
          "customer": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "name": {
                "type": [
                  "string",
                  "null"
                ],
                "maxLength": 200,
                "description": "Required to finalize."
              },
              "email": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "email",
                "description": "Required to send."
              },
              "address": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/InvoiceAddress"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            }
          },
          "shipping_address": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/InvoiceAddress"
              },
              {
                "type": "null"
              }
            ],
            "description": "Needed when a line ships and the store's card payments are paid out on delivery."
          },
          "lines": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/InvoiceLineInput"
            },
            "description": "On update, replaces every line."
          },
          "memo": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2000
          },
          "footer": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 1000
          },
          "reply_to": {
            "type": [
              "string",
              "null"
            ],
            "format": "email",
            "description": "Where the customer's replies to invoice emails go."
          },
          "days_until_due": {
            "type": "integer",
            "minimum": 0,
            "maximum": 365,
            "default": 30
          },
          "due_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "A date (`YYYY-MM-DD`, end of that day UTC) or an ISO 8601 time. Overrides `days_until_due`; must not be in the past when finalizing."
          },
          "send_reminders": {
            "type": "boolean",
            "default": true,
            "description": "Email the customer 1, 7 and 14 days after the due date while it is unpaid."
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "maxLength": 500
            },
            "maxProperties": 20
          },
          "finalize": {
            "type": "boolean",
            "description": "Finalize it straight away."
          },
          "send": {
            "type": "boolean",
            "description": "Finalize it and email it to the customer."
          }
        }
      },
      "InvoiceLine": {
        "type": "object",
        "properties": {
          "description": {
            "type": "string"
          },
          "quantity": {
            "type": "integer"
          },
          "unit_amount": {
            "type": "integer"
          },
          "tax_rate": {
            "type": "number"
          },
          "amount": {
            "type": "integer"
          },
          "tax_amount": {
            "type": "integer"
          },
          "requires_shipping": {
            "type": "boolean"
          }
        }
      },
      "Invoice": {
        "type": "object",
        "required": [
          "id",
          "object",
          "status",
          "currency",
          "lines",
          "total",
          "amount_remaining"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "object": {
            "type": "string",
            "enum": [
              "invoice",
              "credit_note"
            ]
          },
          "store_id": {
            "type": "string",
            "format": "uuid"
          },
          "number": {
            "type": [
              "string",
              "null"
            ],
            "description": "`INV-0001` (credit notes `CN-0001`), per store, given at finalize; null on a draft."
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "open",
              "paid",
              "void",
              "issued"
            ],
            "description": "`issued` is a credit note's."
          },
          "display_status": {
            "type": "string",
            "enum": [
              "draft",
              "open",
              "overdue",
              "paid",
              "void",
              "issued"
            ]
          },
          "status_label": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "currency_digits": {
            "type": "integer"
          },
          "customer": {
            "type": "object",
            "properties": {
              "name": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "email": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "address": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/InvoiceAddress"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            }
          },
          "shipping_address": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/InvoiceAddress"
              },
              {
                "type": "null"
              }
            ]
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoiceLine"
            }
          },
          "subtotal": {
            "type": "integer"
          },
          "tax": {
            "type": "integer"
          },
          "total": {
            "type": "integer"
          },
          "amount_paid": {
            "type": "integer"
          },
          "amount_credited": {
            "type": "integer"
          },
          "amount_remaining": {
            "type": "integer"
          },
          "memo": {
            "type": [
              "string",
              "null"
            ]
          },
          "footer": {
            "type": [
              "string",
              "null"
            ]
          },
          "reply_to": {
            "type": [
              "string",
              "null"
            ]
          },
          "days_until_due": {
            "type": "integer"
          },
          "due_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "send_reminders": {
            "type": "boolean"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "hosted_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "The hosted invoice page the customer pays on (once finalized)."
          },
          "paid_out_of_band": {
            "type": "boolean"
          },
          "payment_reference": {
            "type": [
              "string",
              "null"
            ],
            "description": "The OnCharge reference (`ocpay_…`) of the payment that paid it."
          },
          "credit_note_for": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "number": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "credit_reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "source": {
            "type": "string",
            "enum": [
              "dashboard",
              "api"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "finalized_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "sent_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "paid_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "voided_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "actions": {
            "type": "object",
            "description": "What can be done now.",
            "additionalProperties": {
              "type": "boolean"
            }
          },
          "events": {
            "type": "array",
            "description": "History (detail only).",
            "items": {
              "type": "object"
            }
          },
          "payments": {
            "type": "array",
            "description": "Payments made for it, by OnCharge reference (detail only).",
            "items": {
              "type": "object",
              "properties": {
                "payment_reference": {
                  "type": "string"
                },
                "session_id": {
                  "type": "string"
                },
                "amount": {
                  "type": "integer"
                },
                "currency": {
                  "type": "string"
                },
                "status": {
                  "type": "string"
                },
                "rail": {
                  "type": "string",
                  "enum": [
                    "card",
                    "crypto"
                  ]
                }
              }
            }
          },
          "credit_notes": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Credit notes issued against it (detail only)."
          },
          "payment_options": {
            "type": "array",
            "description": "How the customer can pay it now, and why a rail is off (detail only).",
            "items": {
              "type": "object",
              "properties": {
                "rail": {
                  "type": "string"
                },
                "available": {
                  "type": "boolean"
                },
                "reason": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              }
            }
          },
          "idempotent": {
            "type": "boolean"
          },
          "email_error": {
            "type": "string",
            "description": "Finalized, but the email could not be sent."
          }
        }
      },
      "InvoiceList": {
        "type": "object",
        "required": [
          "invoices",
          "next_cursor"
        ],
        "properties": {
          "invoices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Invoice"
            }
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "Pass back as `cursor`; null on the last page."
          }
        }
      },
      "CreditNoteRequest": {
        "type": "object",
        "additionalProperties": false,
        "description": "Send `amount` or `lines`.",
        "properties": {
          "amount": {
            "type": "integer",
            "minimum": 1,
            "description": "One credit line of this many minor units."
          },
          "lines": {
            "type": "array",
            "minItems": 1,
            "maxItems": 100,
            "items": {
              "type": "object",
              "required": [
                "description",
                "unit_amount"
              ],
              "properties": {
                "description": {
                  "type": "string"
                },
                "quantity": {
                  "type": "integer",
                  "default": 1
                },
                "unit_amount": {
                  "type": "integer",
                  "minimum": 1
                },
                "tax_rate": {
                  "type": [
                    "number",
                    "string"
                  ]
                }
              }
            }
          },
          "reason": {
            "type": "string",
            "enum": [
              "duplicate",
              "fraudulent",
              "order_change",
              "product_unsatisfactory",
              "other"
            ],
            "default": "other"
          },
          "memo": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2000
          },
          "refund": {
            "type": "boolean",
            "default": false,
            "description": "On an invoice paid through OnCharge, also refund the credit to the customer's payment."
          }
        }
      },
      "Money": {
        "type": "object",
        "required": [
          "currency",
          "amount"
        ],
        "properties": {
          "currency": {
            "$ref": "#/components/schemas/Currency"
          },
          "amount": {
            "type": "integer",
            "description": "Minor units."
          }
        }
      },
      "SavedCard": {
        "type": "object",
        "description": "A saved card: brand, last 4 and expiry only. Never a card number, and never usable by another store.",
        "required": [
          "id",
          "object",
          "type",
          "brand",
          "last4",
          "exp_month",
          "exp_year",
          "is_default",
          "status",
          "expired",
          "saved_via",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "object": {
            "type": "string",
            "const": "payment_method"
          },
          "type": {
            "type": "string",
            "const": "card"
          },
          "brand": {
            "type": "string",
            "example": "Visa"
          },
          "last4": {
            "type": "string",
            "pattern": "^[0-9]{4}$"
          },
          "exp_month": {
            "type": "integer",
            "minimum": 1,
            "maximum": 12
          },
          "exp_year": {
            "type": "integer"
          },
          "funding": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "credit",
              "debit",
              "prepaid",
              "unknown",
              null
            ]
          },
          "country": {
            "type": [
              "string",
              "null"
            ]
          },
          "wallet": {
            "type": [
              "string",
              "null"
            ],
            "description": "Apple Pay or Google Pay when the card was saved from one."
          },
          "is_default": {
            "type": "boolean"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "removed"
            ]
          },
          "expired": {
            "type": "boolean"
          },
          "saved_via": {
            "type": "string",
            "enum": [
              "checkout",
              "save_card_page"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "last_used_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "updated_by_card_network_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the card network last sent new details for this card (a renewed or replaced card)."
          },
          "removed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "CustomerTotals": {
        "type": "object",
        "required": [
          "payments",
          "lifetime_value",
          "refunded",
          "disputes",
          "last_payment_at"
        ],
        "properties": {
          "payments": {
            "type": "integer",
            "description": "Paid payments."
          },
          "lifetime_value": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Money"
            },
            "description": "What the customer paid, less refunds, per currency."
          },
          "refunded": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Money"
            }
          },
          "disputes": {
            "type": "integer"
          },
          "last_payment_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "Customer": {
        "type": "object",
        "description": "A customer of one store. One email, and one reference, is one customer of a store; the same shopper at another store is another customer.",
        "required": [
          "id",
          "object",
          "store_id",
          "email",
          "name",
          "phone",
          "reference",
          "metadata",
          "source",
          "created_at",
          "totals"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "object": {
            "type": "string",
            "const": "customer"
          },
          "store_id": {
            "type": "string",
            "format": "uuid"
          },
          "email": {
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          },
          "phone": {
            "type": [
              "string",
              "null"
            ]
          },
          "reference": {
            "type": [
              "string",
              "null"
            ],
            "description": "Your own ID for this customer."
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "source": {
            "type": "string",
            "description": "How OnCharge first met the customer, in plain words."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "totals": {
            "$ref": "#/components/schemas/CustomerTotals"
          },
          "payment_methods": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SavedCard"
            },
            "description": "On a single customer: the saved cards that can be charged."
          },
          "saved_cards": {
            "type": "integer",
            "description": "In lists: how many saved cards the customer has."
          }
        }
      },
      "CreateCustomerRequest": {
        "type": "object",
        "additionalProperties": false,
        "description": "At least an email, a name or a reference.",
        "properties": {
          "email": {
            "type": "string",
            "format": "email",
            "maxLength": 320
          },
          "name": {
            "type": "string",
            "maxLength": 200
          },
          "phone": {
            "type": "string",
            "maxLength": 40
          },
          "reference": {
            "type": "string",
            "maxLength": 255
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "maxLength": 500
            },
            "maxProperties": 50
          }
        }
      },
      "CustomerList": {
        "type": "object",
        "required": [
          "object",
          "data",
          "next_cursor"
        ],
        "properties": {
          "object": {
            "type": "string",
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Customer"
            }
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "SavedCardList": {
        "type": "object",
        "required": [
          "object",
          "data"
        ],
        "properties": {
          "object": {
            "type": "string",
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SavedCard"
            }
          }
        }
      },
      "CreateSetupSessionRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "return_url": {
            "type": "string",
            "format": "uri",
            "description": "https, on one of your store's domains: where the customer returns once the card is saved."
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "maxLength": 500
            },
            "maxProperties": 50
          },
          "expires_in_hours": {
            "type": "integer",
            "minimum": 1,
            "maximum": 72,
            "default": 24
          }
        }
      },
      "SetupSession": {
        "type": "object",
        "description": "A save-card page OnCharge hosts for one customer. It shows the consent text first and the card form only after the customer agrees; the card is saved for your store only.",
        "required": [
          "id",
          "object",
          "customer_id",
          "status",
          "url",
          "expires_at",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "object": {
            "type": "string",
            "const": "setup_session"
          },
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "succeeded",
              "failed",
              "expired"
            ]
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Send the customer here."
          },
          "return_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "payment_method_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "description": "The card saved, once the customer saved one."
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreateCustomerChargeRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "amount",
          "currency"
        ],
        "properties": {
          "amount": {
            "$ref": "#/components/schemas/Amount"
          },
          "currency": {
            "$ref": "#/components/schemas/Currency"
          },
          "payment_method_id": {
            "type": "string",
            "format": "uuid",
            "description": "A saved card of this customer. The default card when omitted."
          },
          "reference": {
            "type": "string",
            "maxLength": 255
          },
          "order_id": {
            "type": "string",
            "maxLength": 255
          },
          "description": {
            "type": "string",
            "maxLength": 500
          },
          "shipping": {
            "$ref": "#/components/schemas/ShippingAddress"
          },
          "line_items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LineItem"
            },
            "maxItems": 500
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "maxLength": 500
            },
            "maxProperties": 50
          },
          "tax": {
            "$ref": "#/components/schemas/TaxRequest"
          }
        }
      },
      "CustomerCharge": {
        "type": "object",
        "required": [
          "id",
          "object",
          "session_id",
          "payment_reference",
          "status",
          "amount",
          "currency",
          "customer_id",
          "payment_method_id",
          "created_at",
          "decline",
          "authentication"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "object": {
            "type": "string",
            "const": "charge"
          },
          "session_id": {
            "type": "string",
            "format": "uuid",
            "description": "The payment, as for a checkout session: refunds, shipments and webhooks use it."
          },
          "payment_reference": {
            "type": "string",
            "pattern": "^ocpay_[0-9a-f]{32}$"
          },
          "status": {
            "type": "string",
            "enum": [
              "succeeded",
              "processing",
              "requires_authentication",
              "declined",
              "failed"
            ],
            "description": "`succeeded`: paid. `processing`: the bank has not answered yet; a payment webhook follows. `requires_authentication`: the customer's bank wants them to confirm it; OnCharge emailed them a link to confirm it (`authentication.emailed`). `declined`: see `decline`."
          },
          "amount": {
            "type": "integer"
          },
          "currency": {
            "type": "string"
          },
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "payment_method_id": {
            "type": "string",
            "format": "uuid"
          },
          "order_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "decline": {
            "type": [
              "object",
              "null"
            ],
            "required": [
              "reason",
              "message"
            ],
            "properties": {
              "reason": {
                "type": "string",
                "enum": [
                  "insufficient_funds",
                  "expired_card",
                  "incorrect_details",
                  "authentication_required",
                  "card_not_supported",
                  "try_again_later",
                  "suspected_fraud",
                  "card_declined",
                  "limit_exceeded"
                ]
              },
              "message": {
                "type": "string",
                "description": "What happened and what to do, in plain words."
              }
            }
          },
          "authentication": {
            "type": [
              "object",
              "null"
            ],
            "required": [
              "emailed"
            ],
            "properties": {
              "emailed": {
                "type": "boolean",
                "description": "OnCharge emailed the customer a link to its page where they confirm the payment (valid 7 days). `false` when the customer has no email: ask them to pay through checkout instead. The link goes to the customer only, so the cardholder confirms it."
              }
            }
          },
          "shipping_required": {
            "type": "boolean",
            "const": true,
            "description": "The order ships by carrier and has no address yet: attach it with POST /api/v1/checkout/sessions/{session_id}/order."
          },
          "idempotent": {
            "type": "boolean",
            "const": true,
            "description": "A retry with the same Idempotency-Key returned the first charge."
          },
          "tax": {
            "$ref": "#/components/schemas/Tax"
          }
        }
      },
      "TaxRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "enabled"
        ],
        "description": "Sales tax for this payment, when your store has it on (Settings → Sales tax). With `enabled`, `amount` is the order as you list it (before tax, unless your store lists prices with tax included); line items (`amount_including_tax` is then each line's total as listed) and `shipping_amount` must add up to it. Tax is calculated for the shipping address, or `billing_address` when nothing ships. See /docs/sales-tax.",
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "Calculate sales tax. Store plugins that already add their platform's tax should leave this off."
          },
          "shipping_amount": {
            "type": "integer",
            "minimum": 0,
            "description": "The shipping charge inside `amount`, minor units: taxed as shipping."
          },
          "billing_address": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "postal_code"
            ],
            "properties": {
              "line1": {
                "type": "string",
                "maxLength": 300
              },
              "line2": {
                "type": "string",
                "maxLength": 300
              },
              "city": {
                "type": "string",
                "maxLength": 120
              },
              "state": {
                "type": "string",
                "maxLength": 120,
                "description": "Two-letter US state (or its name)."
              },
              "postal_code": {
                "type": "string",
                "maxLength": 20,
                "description": "Five-digit US ZIP code (ZIP+4 accepted)."
              },
              "country": {
                "type": "string",
                "maxLength": 60,
                "description": "US only for now. Defaults to US."
              }
            }
          }
        }
      },
      "TaxCategory": {
        "type": "string",
        "description": "An OnCharge product tax category.",
        "enum": [
          "general_goods",
          "nontaxable",
          "services",
          "electronic_services",
          "clothing",
          "software_download",
          "saas",
          "books",
          "ebooks",
          "music_download",
          "dietary_supplements",
          "otc_drugs",
          "cosmetics",
          "candy",
          "groceries",
          "prepared_food",
          "pet_food",
          "gift_cards"
        ]
      },
      "Tax": {
        "type": [
          "object",
          "null"
        ],
        "description": "Sales tax on a payment; null when it is not taxed.",
        "required": [
          "status",
          "inclusive",
          "currency",
          "subtotal",
          "amount",
          "total",
          "shipping",
          "jurisdictions",
          "refunded",
          "error"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "awaiting_address",
              "calculated",
              "pending",
              "failed",
              "collected",
              "partly_refunded",
              "refunded"
            ],
            "description": "`awaiting_address`: no address yet, the payment waits. `calculated`: not paid yet. `pending`: tax included, charged while the calculation was unavailable; worked out shortly. `failed`: the calculation failed (`error`), the payment waits. `collected`, `partly_refunded`, `refunded`: paid, and how much of the tax was given back."
          },
          "inclusive": {
            "type": "boolean",
            "description": "true when the listed prices include the tax."
          },
          "currency": {
            "type": [
              "string",
              "null"
            ]
          },
          "subtotal": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Before tax, minor units."
          },
          "amount": {
            "type": [
              "integer",
              "null"
            ],
            "description": "The tax, minor units."
          },
          "total": {
            "type": [
              "integer",
              "null"
            ],
            "description": "What the customer pays, minor units."
          },
          "shipping": {
            "type": "integer",
            "description": "The shipping charge inside the total, minor units."
          },
          "jurisdictions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "state": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "rate": {
                  "type": "string",
                  "description": "Combined percent, e.g. \"8.25\"."
                },
                "amount": {
                  "type": "integer"
                }
              }
            }
          },
          "refunded": {
            "type": "integer",
            "description": "Tax given back so far with refunds and lost disputes, minor units."
          },
          "error": {
            "type": [
              "string",
              "null"
            ],
            "description": "`tax_address_invalid` or `tax_unavailable` when `status` is `failed`."
          }
        }
      },
      "InstantPayoutBlock": {
        "type": "object",
        "required": [
          "code",
          "message",
          "until",
          "action"
        ],
        "description": "Why a debit card payout cannot be made now.",
        "properties": {
          "code": {
            "type": "string",
            "enum": [
              "not_available",
              "not_set_up",
              "not_available_for_program",
              "payouts_not_enabled",
              "payouts_paused",
              "negative_balance",
              "dispute_rate",
              "first_payout_pending",
              "no_card",
              "card_cooling_off",
              "card_not_instant",
              "daily_limit",
              "nothing_payable",
              "busy",
              "unavailable"
            ]
          },
          "message": {
            "type": "string",
            "description": "In plain words, for your customer-facing staff."
          },
          "until": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it lifts by itself, if it does."
          },
          "action": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "label": {
                "type": "string"
              },
              "href": {
                "type": "string",
                "description": "A dashboard path."
              }
            }
          }
        }
      },
      "InstantPayoutQuote": {
        "type": "object",
        "required": [
          "store_id",
          "available",
          "block",
          "amount",
          "fee",
          "total",
          "currency",
          "arrival",
          "card",
          "fee_rule",
          "limits"
        ],
        "description": "What could reach your debit card now (money already released for delivered orders only), or why nothing can.",
        "properties": {
          "store_id": {
            "type": "string",
            "format": "uuid"
          },
          "available": {
            "type": "boolean"
          },
          "block": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/InstantPayoutBlock"
              },
              {
                "type": "null"
              }
            ]
          },
          "amount": {
            "type": "integer",
            "description": "What would reach the card, in minor units."
          },
          "fee": {
            "type": "integer",
            "description": "OnCharge's fee, in minor units: 1.5% of the total, at least 0.50."
          },
          "total": {
            "type": "integer",
            "description": "What would leave your balance: amount + fee."
          },
          "currency": {
            "type": "string",
            "enum": [
              "USD"
            ]
          },
          "arrival": {
            "type": "object",
            "properties": {
              "text": {
                "type": "string",
                "example": "Usually within 30 minutes"
              },
              "minutes": {
                "type": "integer"
              },
              "estimate": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            }
          },
          "card": {
            "type": [
              "object",
              "null"
            ],
            "description": "The debit card on file, masked. Added in the dashboard only.",
            "properties": {
              "brand": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "last4": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "exp_month": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "exp_year": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "status": {
                "type": "string",
                "enum": [
                  "cooling_off",
                  "ready"
                ]
              },
              "usable_from": {
                "type": "string",
                "format": "date-time"
              },
              "added_at": {
                "type": "string",
                "format": "date-time"
              }
            }
          },
          "fee_rule": {
            "type": "object",
            "properties": {
              "percent": {
                "type": "number"
              },
              "minimum": {
                "type": "integer"
              }
            }
          },
          "limits": {
            "type": "object",
            "properties": {
              "min": {
                "type": "integer"
              },
              "per_payout_max": {
                "type": "integer"
              },
              "daily_remaining_amount": {
                "type": "integer"
              },
              "daily_remaining_count": {
                "type": "integer"
              }
            }
          }
        }
      },
      "InstantPayout": {
        "type": "object",
        "required": [
          "id",
          "method",
          "status",
          "amount",
          "fee",
          "total",
          "currency",
          "created_at",
          "arrival"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The id the payouts list and the payout.paid / payout.failed events carry."
          },
          "method": {
            "type": "string",
            "enum": [
              "instant"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "paid",
              "on_its_way",
              "failed",
              "returned",
              "canceled"
            ]
          },
          "amount": {
            "type": "integer",
            "description": "What reaches the card."
          },
          "fee": {
            "type": "integer"
          },
          "total": {
            "type": "integer",
            "description": "What left your balance."
          },
          "currency": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "arrival": {
            "type": "object",
            "properties": {
              "text": {
                "type": "string"
              },
              "estimate": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            }
          }
        }
      },
      "PaymentMethod": {
        "type": [
          "string",
          "null"
        ],
        "enum": [
          "card",
          "bank_debit",
          "cash_app_pay",
          "klarna",
          "affirm",
          "afterpay",
          null
        ],
        "description": "How the shopper paid: `card`, or a way to pay beyond cards the store turned on (bank debit, Cash App Pay, Klarna, Affirm, Afterpay; see the Payment methods guide). Null for crypto."
      },
      "PaymentMethodStatus": {
        "type": "object",
        "required": [
          "method",
          "label",
          "summary",
          "enabled",
          "state",
          "status_text",
          "needs"
        ],
        "properties": {
          "method": {
            "type": "string",
            "enum": [
              "bank_debit",
              "cash_app_pay",
              "klarna",
              "affirm",
              "afterpay"
            ]
          },
          "label": {
            "type": "string",
            "example": "Bank debit (ACH)"
          },
          "summary": {
            "type": "string",
            "description": "What the method does for your store, in one or two sentences."
          },
          "enabled": {
            "type": "boolean",
            "description": "Whether the store turned it on (owners and admins, in the portal under Settings → Payment setup)."
          },
          "state": {
            "type": "string",
            "enum": [
              "off",
              "not_available",
              "requesting",
              "reviewing",
              "needs_information",
              "inactive",
              "active"
            ],
            "description": "`active`: shoppers see it at checkout. `not_available`: not offered to this store's business."
          },
          "status_text": {
            "type": "string",
            "description": "The state in plain words."
          },
          "needs": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "What is still needed before it can be approved, in words."
          }
        }
      },
      "PaymentMethodList": {
        "type": "object",
        "required": [
          "store_id",
          "methods"
        ],
        "properties": {
          "store_id": {
            "type": "string",
            "format": "uuid"
          },
          "methods": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PaymentMethodStatus"
            },
            "description": "Only the methods OnCharge offers today."
          }
        }
      },
      "PlanInterval": {
        "type": "string",
        "enum": [
          "day",
          "week",
          "month",
          "year"
        ],
        "description": "How long a period is, with `interval_count`."
      },
      "PlanIntro": {
        "type": "object",
        "description": "A lower price for the first periods of a plan.",
        "required": [
          "amount",
          "periods"
        ],
        "additionalProperties": false,
        "properties": {
          "amount": {
            "type": "integer",
            "minimum": 1,
            "maximum": 99999999,
            "description": "The plan's price per period while the intro lasts, minor units. Lower than the plan's `amount`."
          },
          "periods": {
            "type": "integer",
            "minimum": 1,
            "maximum": 24,
            "description": "How many periods it lasts."
          }
        }
      },
      "CreatePlanRequest": {
        "type": "object",
        "required": [
          "name",
          "amount"
        ],
        "additionalProperties": false,
        "description": "A plan, or an add-on (`kind: \"addon\"`) billed with a plan in its periods. A plan's price and terms never change once created: create another plan instead.",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "plan",
              "addon"
            ],
            "default": "plan",
            "description": "`addon`: no interval, trial or intro of its own; it is billed with the plan it is added to."
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 1000
          },
          "amount": {
            "type": "integer",
            "minimum": 1,
            "maximum": 99999999,
            "description": "Per period (per unit), minor units."
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Za-z]{3}$",
            "default": "USD",
            "description": "ISO 4217. Add-ons must be in their plan's currency."
          },
          "interval": {
            "$ref": "#/components/schemas/PlanInterval",
            "description": "Required for a plan."
          },
          "interval_count": {
            "type": "integer",
            "minimum": 1,
            "maximum": 365,
            "default": 1,
            "description": "Intervals per period, up to one year: at most 365 days, 52 weeks, 12 months or 1 year."
          },
          "trial_days": {
            "type": "integer",
            "minimum": 0,
            "maximum": 365,
            "default": 0,
            "description": "A free trial before the first charge: 0 (none) or at least 7 days, so the customer can be reminded 7 days before it ends. Plans only."
          },
          "intro": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PlanIntro"
              },
              {
                "type": "null"
              }
            ],
            "description": "A lower price for the first periods: `{ \"amount\": 1500, \"periods\": 2 }`. Plans only."
          },
          "requires_shipping": {
            "type": "boolean",
            "default": false,
            "description": "Each period ships, needs a shipping address and is paid out after carrier-confirmed delivery. On a store that ships physical goods every period ships anyway."
          },
          "metadata": {
            "$ref": "#/components/schemas/SubscriptionMetadata"
          }
        }
      },
      "UpdatePlanRequest": {
        "type": "object",
        "additionalProperties": false,
        "description": "Only these change. The price and terms of a plan are fixed once created.",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 1000
          },
          "active": {
            "type": "boolean",
            "description": "`false` archives the plan: it takes no new subscriptions, and those already on it go on. `true` brings it back."
          },
          "metadata": {
            "$ref": "#/components/schemas/SubscriptionMetadata"
          }
        }
      },
      "Plan": {
        "type": "object",
        "description": "A plan or an add-on.",
        "required": [
          "id",
          "object",
          "store_id",
          "name",
          "description",
          "amount",
          "currency",
          "interval",
          "interval_count",
          "interval_text",
          "trial_days",
          "intro",
          "requires_shipping",
          "active",
          "metadata",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "object": {
            "type": "string",
            "enum": [
              "plan",
              "addon"
            ]
          },
          "store_id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "amount": {
            "type": "integer",
            "description": "Per period (per unit), minor units."
          },
          "currency": {
            "type": "string"
          },
          "interval": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PlanInterval"
              },
              {
                "type": "null"
              }
            ],
            "description": "Null for an add-on."
          },
          "interval_count": {
            "type": [
              "integer",
              "null"
            ]
          },
          "interval_text": {
            "type": [
              "string",
              "null"
            ],
            "description": "The period in words: `month`, `3 months`. Null for an add-on."
          },
          "trial_days": {
            "type": "integer"
          },
          "intro": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PlanIntro"
              },
              {
                "type": "null"
              }
            ],
            "description": "The intro price per period (`amount`) for the first `periods` periods."
          },
          "requires_shipping": {
            "type": "boolean"
          },
          "active": {
            "type": "boolean",
            "description": "False once archived."
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "example": {
          "id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
          "object": "plan",
          "store_id": "0f1e2d3c-4b5a-4968-8776-655443322110",
          "name": "Monthly box",
          "description": "A box of our best sellers, every month.",
          "amount": 3000,
          "currency": "USD",
          "interval": "month",
          "interval_count": 1,
          "interval_text": "month",
          "trial_days": 14,
          "intro": {
            "amount": 1500,
            "periods": 2
          },
          "requires_shipping": true,
          "active": true,
          "metadata": {},
          "created_at": "2026-12-01T00:00:00.000Z"
        }
      },
      "PlanList": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Plan"
            },
            "description": "Newest first, at most 200."
          }
        }
      },
      "PlanPaymentLink": {
        "type": "object",
        "description": "A payment link that signs shoppers up to the plan. It is one of your payment links (/api/v1/payment-links), and turned off the same way.",
        "required": [
          "id",
          "code",
          "url",
          "plan_id"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "code": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "description": "The link to share: https://app.oncharge.io/l/<code>."
          },
          "plan_id": {
            "type": "string",
            "format": "uuid"
          }
        }
      },
      "SubscriptionMetadata": {
        "type": "object",
        "description": "Your own key-value pairs: at most 20 keys of letters, digits, `_`, `.` and `-` (up to 40 characters), each value up to 500 characters.",
        "maxProperties": 20,
        "propertyNames": {
          "pattern": "^[A-Za-z0-9_.-]{1,40}$"
        },
        "additionalProperties": {
          "type": "string",
          "maxLength": 500
        }
      },
      "SubscriptionStatus": {
        "type": "string",
        "enum": [
          "incomplete",
          "incomplete_expired",
          "trialing",
          "active",
          "past_due",
          "paused",
          "canceled"
        ],
        "description": "`incomplete`: waiting for the customer to sign up. `incomplete_expired`: they did not in time. `trialing`: in its free trial. `active`: paid up. `past_due`: a payment failed and is being retried. `paused`: nothing is charged or shipped. `canceled`: ended."
      },
      "SubscriptionAddress": {
        "type": "object",
        "description": "Where each period ships.",
        "required": [
          "name",
          "line1",
          "city",
          "postal_code",
          "country"
        ],
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "line1": {
            "type": "string",
            "minLength": 1,
            "maxLength": 300
          },
          "line2": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 300
          },
          "city": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "state": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 120
          },
          "postal_code": {
            "type": "string",
            "minLength": 1,
            "maxLength": 20
          },
          "country": {
            "type": "string",
            "pattern": "^[A-Za-z]{2}$",
            "description": "Two-letter code (`US`)."
          }
        }
      },
      "SubscriptionAddonInput": {
        "type": "object",
        "required": [
          "plan_id"
        ],
        "additionalProperties": false,
        "properties": {
          "plan_id": {
            "type": "string",
            "format": "uuid",
            "description": "An add-on of your store (`kind: \"addon\"`), in the plan's currency."
          },
          "quantity": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000,
            "default": 1
          }
        }
      },
      "CreateSubscriptionRequest": {
        "type": "object",
        "required": [
          "customer_id",
          "plan_id"
        ],
        "additionalProperties": false,
        "properties": {
          "customer_id": {
            "type": "string",
            "format": "uuid",
            "description": "An existing customer of your store. They need an email address: OnCharge emails them the link to confirm."
          },
          "plan_id": {
            "type": "string",
            "format": "uuid",
            "description": "An active plan of your store."
          },
          "quantity": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000,
            "default": 1
          },
          "addons": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SubscriptionAddonInput"
            },
            "maxItems": 20,
            "description": "Each add-on listed once."
          },
          "shipping": {
            "$ref": "#/components/schemas/SubscriptionAddress",
            "description": "Required when the subscription ships."
          },
          "metadata": {
            "$ref": "#/components/schemas/SubscriptionMetadata"
          }
        }
      },
      "CreateSubscriptionCheckoutRequest": {
        "type": "object",
        "required": [
          "plan_id"
        ],
        "additionalProperties": false,
        "description": "Give `customer_id` or `customer_email`.",
        "properties": {
          "plan_id": {
            "type": "string",
            "format": "uuid",
            "description": "An active plan of your store."
          },
          "quantity": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000,
            "default": 1
          },
          "addons": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SubscriptionAddonInput"
            },
            "maxItems": 20,
            "description": "Each add-on listed once."
          },
          "customer_id": {
            "type": "string",
            "format": "uuid",
            "description": "An existing customer of your store."
          },
          "customer_email": {
            "type": "string",
            "format": "email",
            "maxLength": 254,
            "description": "The customer is found by email, or added to your store."
          },
          "customer_name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200,
            "description": "Saved on the customer if they have no name yet."
          },
          "shipping": {
            "$ref": "#/components/schemas/SubscriptionAddress",
            "description": "Required when the subscription ships."
          },
          "success_url": {
            "type": "string",
            "format": "uri",
            "maxLength": 2048,
            "description": "An `https` page the customer goes to after signing up. Kept in the subscription's `metadata` as `success_url`."
          },
          "metadata": {
            "$ref": "#/components/schemas/SubscriptionMetadata"
          }
        }
      },
      "UpdateSubscriptionRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "payment_method_id": {
            "type": "string",
            "format": "uuid",
            "description": "Another active saved card of the same customer at your store. The customer is emailed a link to switch to it themselves (`202`); the subscription keeps its card, and nothing is charged to this one, until they do. Not on an `incomplete` subscription: the customer chooses the card when they sign up."
          },
          "shipping": {
            "$ref": "#/components/schemas/SubscriptionAddress",
            "description": "Where the next periods ship."
          },
          "metadata": {
            "$ref": "#/components/schemas/SubscriptionMetadata",
            "description": "Replaces the metadata."
          }
        }
      },
      "CancelSubscriptionRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "at_period_end": {
            "type": "boolean",
            "default": true,
            "description": "`true`: an active or trialing subscription ends when its current period (or trial) ends; any other status ends now. `false`: it ends now and anything unpaid is voided."
          }
        }
      },
      "PauseSubscriptionRequest": {
        "type": "object",
        "additionalProperties": false,
        "description": "The pause starts at the end of the current period. Give `periods` or `resume_at`, not both; with neither, it lasts until you resume it.",
        "properties": {
          "periods": {
            "type": "integer",
            "minimum": 1,
            "maximum": 12,
            "description": "Pause for this many periods."
          },
          "resume_at": {
            "type": "string",
            "format": "date-time",
            "description": "Resume then: after the end of the current period."
          }
        }
      },
      "ChangeSubscriptionRequest": {
        "type": "object",
        "additionalProperties": false,
        "description": "Give at least one of `plan_id`, `quantity` or `addons`.",
        "properties": {
          "plan_id": {
            "type": "string",
            "format": "uuid",
            "description": "Another plan of your store, in the same currency. A new plan drops any intro price left."
          },
          "quantity": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000
          },
          "addons": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SubscriptionAddonInput"
            },
            "maxItems": 20,
            "description": "Replaces every add-on (`[]` removes them)."
          },
          "proration": {
            "type": "string",
            "enum": [
              "now",
              "next_period"
            ],
            "description": "`now`: applied at once; the rest of the period is prorated (a lower price is a credit on the next bills). A change that raises the price is never applied now (`409 price_increase_needs_notice`). `next_period`: applied at the renewal, or for a price increase from the first period at least 7 days after the customer's emailed notice. Left out: `now`, unless the change raises the price (then scheduled with the notice). A shipped subscription, or a plan with another interval, changes at the next period only (`409 change_at_next_period` otherwise); a paused one always does."
          }
        }
      },
      "Subscription": {
        "type": "object",
        "description": "A subscription. Cards are masked (brand, last 4, expiry) and payments carry OnCharge references.",
        "required": [
          "id",
          "object",
          "store_id",
          "customer_id",
          "customer",
          "status",
          "status_text",
          "plan",
          "quantity",
          "addons",
          "intro",
          "payment_method",
          "trial_end",
          "current_period",
          "next_billing_at",
          "credit_balance",
          "pending_change",
          "cancel_at_period_end",
          "canceled_at",
          "ended_at",
          "cancel_reason",
          "pause",
          "shipping",
          "source",
          "payment_link_id",
          "sign_up_expires_at",
          "metadata",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "object": {
            "type": "string",
            "const": "subscription"
          },
          "store_id": {
            "type": "string",
            "format": "uuid"
          },
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "customer": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "email": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "name": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "status": {
            "$ref": "#/components/schemas/SubscriptionStatus"
          },
          "status_text": {
            "type": "string",
            "description": "The status in plain words (`Waiting for customer`, `Past due`, …)."
          },
          "plan": {
            "type": "object",
            "required": [
              "id"
            ],
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "name": {
                "type": "string"
              },
              "amount": {
                "type": "integer"
              },
              "currency": {
                "type": "string"
              },
              "interval": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/PlanInterval"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "interval_count": {
                "type": [
                  "integer",
                  "null"
                ]
              }
            }
          },
          "quantity": {
            "type": "integer"
          },
          "addons": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "plan_id": {
                  "type": "string",
                  "format": "uuid"
                },
                "name": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "amount": {
                  "type": [
                    "integer",
                    "null"
                  ]
                },
                "quantity": {
                  "type": "integer"
                }
              }
            }
          },
          "intro": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PlanIntro"
              },
              {
                "type": "null"
              }
            ],
            "description": "The intro price this subscription has, taken from its plan when it was created."
          },
          "payment_method": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/SavedCard"
              },
              {
                "type": "null"
              }
            ],
            "description": "The saved card it is charged to. Null until the customer signs up."
          },
          "trial_end": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the free trial ends (the first charge)."
          },
          "current_period": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "index": {
                "type": "integer",
                "description": "0 for the first period."
              },
              "start": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "end": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "amount": {
                "type": [
                  "integer",
                  "null"
                ],
                "description": "What this period was billed, minor units."
              }
            }
          },
          "next_billing_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it is charged next, or resumes; null once ended."
          },
          "credit_balance": {
            "type": "integer",
            "description": "Credit from downgrades, taken off the next bills (minor units)."
          },
          "pending_change": {
            "type": [
              "object",
              "null"
            ],
            "description": "A change that applies at the next period (a price increase: from `increase.effective_at`).",
            "properties": {
              "change_id": {
                "type": "string",
                "format": "uuid",
                "description": "This change: its notice is for it alone; a newer change is always told again."
              },
              "plan_id": {
                "type": "string",
                "format": "uuid"
              },
              "increase": {
                "type": [
                  "object",
                  "null"
                ],
                "description": "Set when the change raises the price: a bigger charge, or a higher price per day when the interval changes. It applies only to the period starting `effective_at`, with the customer's notice confirmed sent 7 to 30 days before that date. Its date follows the subscription's real schedule (after a pause, from the day it resumes); when that schedule moves, the date moves (`version` goes up) and the customer is told again.",
                "properties": {
                  "from": {
                    "type": "integer",
                    "description": "The price per period before, minor units (per `from_every`)."
                  },
                  "to": {
                    "type": "integer",
                    "description": "The price per period after, minor units (per `to_every`)."
                  },
                  "from_every": {
                    "type": "string",
                    "description": "The period before, in words: `every month`."
                  },
                  "to_every": {
                    "type": "string",
                    "description": "The period after, in words: `every week`."
                  },
                  "currency": {
                    "type": "string"
                  },
                  "effective_index": {
                    "type": [
                      "integer",
                      "null"
                    ],
                    "description": "The period it applies from (0 is the first); null while unknown (paused with no end date)."
                  },
                  "effective_at": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "date-time",
                    "description": "When that period starts: the first charge at the new price; null while unknown."
                  },
                  "notice_sent_at": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "date-time",
                    "description": "When the email service accepted the notice; null until then (it goes 30 days before `effective_at`, and is tried again if it did not go)."
                  },
                  "version": {
                    "type": "integer",
                    "description": "Which notice: goes up each time the date moves, so a notice for an earlier date never counts again."
                  }
                }
              },
              "quantity": {
                "type": "integer"
              },
              "addons": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "plan_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "quantity": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "cancel_at_period_end": {
            "type": "boolean",
            "description": "It ends when the current period ends."
          },
          "canceled_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was cancelled (for a cancellation at the period's end, when it was asked for)."
          },
          "ended_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "cancel_reason": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "merchant",
              "customer",
              "api",
              "dunning",
              "store_closed",
              "reminder_undeliverable",
              null
            ],
            "description": "`dunning`: its payment failed on every retry. `reminder_undeliverable`: the reminder required 7 days before the first charge after a trial could not be emailed for 72 hours, so it ended without being charged."
          },
          "pause": {
            "type": [
              "object",
              "null"
            ],
            "description": "A pause waiting for the period's end (`at_period_end: true`), or under way.",
            "properties": {
              "at_period_end": {
                "type": "boolean"
              },
              "paused_at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "resume_at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time",
                "description": "When it starts again by itself; null: when you (or the customer) resume it."
              },
              "reason": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "merchant",
                  "customer",
                  "api",
                  "dunning",
                  null
                ]
              }
            }
          },
          "shipping": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "name": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "address": {
                "type": "object",
                "properties": {
                  "line1": {
                    "type": "string"
                  },
                  "line2": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "city": {
                    "type": "string"
                  },
                  "state": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "postal_code": {
                    "type": "string"
                  },
                  "country": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "source": {
            "type": "string",
            "enum": [
              "dashboard",
              "api",
              "payment_link",
              "checkout"
            ],
            "description": "How it was started."
          },
          "payment_link_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "description": "The plan payment link the customer signed up through."
          },
          "sign_up_expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "While `incomplete`: when the sign-up link stops working."
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "example": {
          "id": "7e2f9a1c-3b4d-4e5f-8a6b-9c0d1e2f3a4b",
          "object": "subscription",
          "store_id": "0f1e2d3c-4b5a-4968-8776-655443322110",
          "customer_id": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
          "customer": {
            "email": "ada@example.com",
            "name": "Ada Lovelace"
          },
          "plan": {
            "id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
            "name": "Monthly box",
            "amount": 3000,
            "currency": "USD",
            "interval": "month",
            "interval_count": 1
          },
          "quantity": 1,
          "addons": [],
          "intro": {
            "amount": 1500,
            "periods": 2
          },
          "credit_balance": 0,
          "pending_change": null,
          "cancel_at_period_end": false,
          "canceled_at": null,
          "ended_at": null,
          "cancel_reason": null,
          "pause": null,
          "shipping": {
            "name": "Ada Lovelace",
            "address": {
              "line1": "1 Main St",
              "line2": null,
              "city": "Austin",
              "state": "TX",
              "postal_code": "78701",
              "country": "US"
            }
          },
          "payment_link_id": null,
          "metadata": {},
          "created_at": "2026-12-01T00:00:00.000Z",
          "status": "active",
          "status_text": "Active",
          "payment_method": {
            "id": "5b6c7d8e-9f0a-4b1c-8d2e-3f4a5b6c7d8e",
            "object": "payment_method",
            "type": "card",
            "brand": "Visa",
            "last4": "4242",
            "exp_month": 12,
            "exp_year": 2029,
            "funding": "credit",
            "country": "US",
            "wallet": null,
            "is_default": true,
            "status": "active",
            "expired": false,
            "saved_via": "save_card_page",
            "created_at": "2026-12-01T00:00:00.000Z",
            "last_used_at": "2026-12-15T00:00:00.000Z",
            "updated_by_card_network_at": null,
            "removed_at": null
          },
          "trial_end": "2026-12-15T00:00:00.000Z",
          "current_period": {
            "index": 0,
            "start": "2026-12-15T00:00:00.000Z",
            "end": "2027-01-15T00:00:00.000Z",
            "amount": 1500
          },
          "next_billing_at": "2027-01-15T00:00:00.000Z",
          "source": "api",
          "sign_up_expires_at": null
        }
      },
      "SubscriptionBilling": {
        "type": "object",
        "description": "One bill: a period, or a plan change in the middle of a period. Each has its own OnCharge invoice and is charged to the subscription's card through an ordinary checkout session.",
        "required": [
          "id",
          "object",
          "subscription_id",
          "reason",
          "period_index",
          "period_start",
          "period_end",
          "lines",
          "subtotal",
          "credit_applied",
          "amount_due",
          "ships",
          "status",
          "invoice",
          "attempts",
          "next_attempt_at",
          "failure",
          "paid_at",
          "payment_reference",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "object": {
            "type": "string",
            "const": "subscription_billing"
          },
          "subscription_id": {
            "type": "string",
            "format": "uuid"
          },
          "reason": {
            "type": "string",
            "enum": [
              "period",
              "proration"
            ],
            "description": "`proration`: the prorated charge of a plan change applied now."
          },
          "period_index": {
            "type": "integer",
            "description": "0 for the first period."
          },
          "period_start": {
            "type": "string",
            "format": "date-time"
          },
          "period_end": {
            "type": "string",
            "format": "date-time"
          },
          "lines": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "description": {
                  "type": "string"
                },
                "quantity": {
                  "type": "integer"
                },
                "unit_amount": {
                  "type": "integer"
                },
                "requires_shipping": {
                  "type": "boolean"
                }
              }
            }
          },
          "subtotal": {
            "type": "integer"
          },
          "credit_applied": {
            "type": "integer",
            "description": "Credit from earlier downgrades taken off this bill."
          },
          "amount_due": {
            "type": "integer"
          },
          "ships": {
            "type": "boolean",
            "description": "This period's order ships: it is paid out after carrier-confirmed delivery."
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "paid",
              "uncollectible",
              "void"
            ]
          },
          "invoice": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "number": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "`INV-0042`."
              }
            }
          },
          "attempts": {
            "type": "integer",
            "description": "Charge attempts so far."
          },
          "next_attempt_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "While open: when it is charged again; null when it waits for the customer."
          },
          "failure": {
            "type": [
              "object",
              "null"
            ],
            "description": "Why the last charge failed, while unpaid.",
            "properties": {
              "reason": {
                "type": "string",
                "enum": [
                  "declined",
                  "authentication_required",
                  "unusable_card",
                  "error",
                  "store_unavailable",
                  "store_limit"
                ]
              },
              "message": {
                "type": "string",
                "description": "What happened and what OnCharge does next, in plain words."
              },
              "waits_for_customer": {
                "type": "boolean",
                "description": "No automatic retry: the customer has to confirm the payment with their bank or add another card."
              }
            }
          },
          "paid_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "payment_reference": {
            "type": [
              "string",
              "null"
            ],
            "description": "OnCharge's reference for the payment that paid it (`ocpay_…`)."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "example": {
          "id": "2b3c4d5e-6f7a-4b8c-9d0e-1f2a3b4c5d6e",
          "object": "subscription_billing",
          "subscription_id": "7e2f9a1c-3b4d-4e5f-8a6b-9c0d1e2f3a4b",
          "reason": "period",
          "period_index": 0,
          "period_start": "2026-12-15T00:00:00.000Z",
          "period_end": "2027-01-15T00:00:00.000Z",
          "lines": [
            {
              "description": "Monthly box (introductory price)",
              "quantity": 1,
              "unit_amount": 1500,
              "requires_shipping": true
            }
          ],
          "subtotal": 1500,
          "credit_applied": 0,
          "amount_due": 1500,
          "ships": true,
          "status": "paid",
          "invoice": {
            "id": "4d5e6f7a-8b9c-4d0e-8f1a-2b3c4d5e6f7a",
            "number": "INV-0042"
          },
          "attempts": 1,
          "next_attempt_at": null,
          "failure": null,
          "paid_at": "2026-12-15T00:05:00.000Z",
          "payment_reference": "ocpay_8f14e45fceea467a95752c3b8e1f0b6d",
          "created_at": "2026-12-15T00:00:00.000Z"
        }
      },
      "SubscriptionDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Subscription"
          },
          {
            "type": "object",
            "required": [
              "billings",
              "history"
            ],
            "properties": {
              "billings": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/SubscriptionBilling"
                },
                "description": "Every bill, newest first."
              },
              "history": {
                "type": "array",
                "description": "What happened, newest first (at most 100).",
                "items": {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string"
                    },
                    "actor": {
                      "type": "string",
                      "enum": [
                        "merchant",
                        "api",
                        "customer",
                        "system"
                      ]
                    },
                    "data": {
                      "type": "object"
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          }
        ],
        "description": "A subscription with its bills and history."
      },
      "SubscriptionCheckout": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Subscription"
          },
          {
            "type": "object",
            "required": [
              "url"
            ],
            "properties": {
              "url": {
                "type": "string",
                "description": "The customer's sign-up page on OnCharge. It works until `sign_up_expires_at` (24 hours). It never offers the customer's saved cards."
              }
            }
          }
        ],
        "description": "A subscription waiting for the customer (`incomplete`), with the page to send them to."
      },
      "SubscriptionChangeResult": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Subscription"
          },
          {
            "type": "object",
            "properties": {
              "proration": {
                "type": "object",
                "description": "Only for a change applied now.",
                "properties": {
                  "charge": {
                    "type": "integer",
                    "description": "Charged now for the rest of the period, minor units. Always 0 since a price increase never applies at once (kept for compatibility)."
                  },
                  "credit": {
                    "type": "integer",
                    "description": "Credited to the next bills (a downgrade), minor units."
                  },
                  "outcome": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "enum": [
                      "paid",
                      "processing",
                      "failed",
                      "resume_later",
                      "not_charged",
                      null
                    ],
                    "description": "How the charge went; null when nothing was charged."
                  }
                }
              }
            }
          }
        ]
      },
      "SubscriptionRetryResult": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Subscription"
          },
          {
            "type": "object",
            "required": [
              "retry"
            ],
            "properties": {
              "retry": {
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": [
                    "paid",
                    "processing",
                    "failed",
                    "resume_later",
                    "not_charged"
                  ]
                },
                "description": "How each unpaid bill's charge went, oldest first."
              }
            }
          }
        ]
      },
      "SubscriptionList": {
        "type": "object",
        "required": [
          "data",
          "has_more"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Subscription"
            }
          },
          "has_more": {
            "type": "boolean",
            "description": "More follow: pass the last `id` as `starting_after`."
          }
        }
      }
    }
  }
}
