{
  "openapi": "3.1.0",
  "info": {
    "title": "Payments.lk API",
    "version": "v1",
    "description": "The Payments.lk REST API: checkouts, payments, refunds, payment links, saved cards, events and your account. JSON over HTTPS, with your key as a bearer token. Amounts are integer cents of LKR. Every write takes an Idempotency-Key, remembered for 24 hours per mode. Every error is explained at https://payments.lk/developers/errors. There is no version header: everything is under /v1. Read it with examples at https://payments.lk/developers/api.",
    "contact": {
      "name": "Payments.lk",
      "url": "https://payments.lk/developers/api",
      "email": "hello@payments.lk"
    }
  },
  "servers": [
    {
      "url": "https://api.payments.lk",
      "description": "Test and live keys both use this address; the key decides the mode."
    }
  ],
  "externalDocs": {
    "description": "The API reference, with examples",
    "url": "https://payments.lk/developers/api"
  },
  "tags": [
    {
      "name": "Checkouts",
      "description": "A payment and the hosted page that takes it. Most integrations need only this."
    },
    {
      "name": "Payments",
      "description": "Every payment, however it was made: a checkout, a payment link, a checkout page or a saved card."
    },
    {
      "name": "Refunds",
      "description": "Money back to the customer's card, in full or in part. The outcome arrives as a webhook."
    },
    {
      "name": "Payment links",
      "description": "A fixed amount link you can send anywhere, with no website of your own."
    },
    {
      "name": "Saved cards",
      "description": "Cards customers kept on file at a checkout, charged later without them present."
    },
    {
      "name": "Events",
      "description": "The events your webhooks receive, readable here too, in the same shape."
    },
    {
      "name": "Subscriptions",
      "description": "Customers, recurring prices, subscriptions and their invoices. We renew, charge the card on file, retry and email the customer; you react to the events."
    },
    {
      "name": "Account",
      "description": "The merchant account behind the key."
    },
    {
      "name": "Reference",
      "description": "This document."
    }
  ],
  "security": [
    {
      "secretKey": []
    }
  ],
  "paths": {
    "/v1/checkouts": {
      "post": {
        "operationId": "createCheckout",
        "tags": [
          "Checkouts"
        ],
        "summary": "Create a checkout",
        "description": "Creates a payment and the hosted page that takes it. Send amountCents and a description, or lineItems and the total is worked out from them; never both. Send the customer to url. The checkout expires 30 minutes after it is made. The mode comes from the key, never from the body: a sandbox key makes a sandbox checkout on Payable's sandbox. When the customer has paid you receive payment.succeeded; fulfil the order from that webhook, not from the browser's return to successUrl.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "examples": {
              "default": {
                "value": "order-8891"
              },
              "lineItems": {
                "value": "order-8892"
              }
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCheckoutRequest"
              },
              "examples": {
                "default": {
                  "summary": "With an amount",
                  "value": {
                    "amountCents": 350000,
                    "description": "Two kottu and a milk tea",
                    "reference": "order-8891",
                    "customer": {
                      "name": "Nimali Perera",
                      "email": "nimali@example.lk",
                      "phone": "0771234567"
                    },
                    "successUrl": "https://yourshop.lk/orders/8891",
                    "cancelUrl": "https://yourshop.lk/cart"
                  }
                },
                "lineItems": {
                  "summary": "With line items, in Sinhala",
                  "value": {
                    "lineItems": [
                      {
                        "name": "Chicken kottu",
                        "unitAmountCents": 145000,
                        "quantity": 2
                      },
                      {
                        "name": "Milk tea",
                        "description": "Hot, with sugar",
                        "unitAmountCents": 30000,
                        "quantity": 2
                      }
                    ],
                    "reference": "order-8892",
                    "locale": "si",
                    "successUrl": "https://yourshop.lk/orders/8892",
                    "cancelUrl": "https://yourshop.lk/cart"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Checkout"
                },
                "examples": {
                  "default": {
                    "summary": "With an amount",
                    "value": {
                      "object": "checkout",
                      "id": "chk_z6zf7gkx4fcwy3402kmwrm3w",
                      "mode": "test",
                      "status": "open",
                      "url": "https://payments.lk/checkout/chk_z6zf7gkx4fcwy3402kmwrm3w",
                      "expiresAt": "2026-09-18T09:44:05.000Z",
                      "payment": {
                        "object": "payment",
                        "id": "pay_x1n31wnp8nkbjkkhymtqd6zs",
                        "mode": "test",
                        "status": "requires_payment_method",
                        "amountCents": 350000,
                        "currency": "LKR",
                        "description": "Two kottu and a milk tea",
                        "reference": "order-8891",
                        "customer": {
                          "name": "Nimali Perera",
                          "email": "nimali@example.lk",
                          "phone": "0771234567"
                        },
                        "card": null,
                        "cardSave": "not_requested",
                        "feeCents": null,
                        "netCents": null,
                        "refundedCents": 0,
                        "failureMessage": null,
                        "paymentLinkId": null,
                        "savedCardId": null,
                        "invoiceId": null,
                        "checkoutId": "chk_z6zf7gkx4fcwy3402kmwrm3w",
                        "checkoutPageId": null,
                        "order": null,
                        "delivery": null,
                        "customFields": null,
                        "customerTaxId": null,
                        "termsAcceptedAt": null,
                        "createdAt": "2026-09-18T09:14:05.000Z",
                        "succeededAt": null
                      }
                    }
                  },
                  "lineItems": {
                    "summary": "With line items, in Sinhala",
                    "value": {
                      "object": "checkout",
                      "id": "chk_7h2mq8v4d1x9k3r6t0ya5wnp",
                      "mode": "test",
                      "status": "open",
                      "url": "https://payments.lk/si/checkout/chk_7h2mq8v4d1x9k3r6t0ya5wnp",
                      "expiresAt": "2026-09-18T09:44:05.000Z",
                      "payment": {
                        "object": "payment",
                        "id": "pay_3c9k2x7m1v8q4r6h0tdy5bnw",
                        "mode": "test",
                        "status": "requires_payment_method",
                        "amountCents": 350000,
                        "currency": "LKR",
                        "description": "Colombo Kottu House, 4 items",
                        "reference": "order-8892",
                        "customer": null,
                        "card": null,
                        "cardSave": "not_requested",
                        "feeCents": null,
                        "netCents": null,
                        "refundedCents": 0,
                        "failureMessage": null,
                        "paymentLinkId": null,
                        "savedCardId": null,
                        "invoiceId": null,
                        "checkoutId": "chk_7h2mq8v4d1x9k3r6t0ya5wnp",
                        "checkoutPageId": null,
                        "order": {
                          "lines": [
                            {
                              "id": "line-1",
                              "name": "Chicken kottu",
                              "quantity": 2,
                              "unitAmountCents": 145000,
                              "amountCents": 290000,
                              "suggested": false
                            },
                            {
                              "id": "line-2",
                              "name": "Milk tea",
                              "description": "Hot, with sugar",
                              "quantity": 2,
                              "unitAmountCents": 30000,
                              "amountCents": 60000,
                              "suggested": false
                            }
                          ],
                          "subtotalCents": 350000,
                          "discount": null,
                          "shipping": null,
                          "tax": null,
                          "totalCents": 350000
                        },
                        "delivery": null,
                        "customFields": null,
                        "customerTaxId": null,
                        "termsAcceptedAt": null,
                        "createdAt": "2026-09-18T09:14:05.000Z",
                        "succeededAt": null
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. The line items add up to less or more than one payment may be. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              },
              {
                "reason": "amount",
                "docUrl": "https://payments.lk/developers/errors#amount"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. A live key before the account is activated, an account that cannot take payments, saveCard on a live checkout before saved cards are switched on, or an amount that would take this month past the plan's monthly limit. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              },
              {
                "reason": "merchant_not_live",
                "docUrl": "https://payments.lk/developers/errors#merchant_not_live"
              },
              {
                "reason": "merchant_unavailable",
                "docUrl": "https://payments.lk/developers/errors#merchant_unavailable"
              },
              {
                "reason": "saved_cards_off",
                "docUrl": "https://payments.lk/developers/errors#saved_cards_off"
              },
              {
                "reason": "monthly_limit_reached",
                "docUrl": "https://payments.lk/developers/errors#monthly_limit_reached"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "publishableKey": []
          }
        ],
        "x-permission": "checkouts:create",
        "x-key-kinds": [
          "publishable",
          "secret"
        ],
        "x-idempotency-key": "required"
      }
    },
    "/v1/checkouts/{id}": {
      "get": {
        "operationId": "retrieveCheckout",
        "tags": [
          "Checkouts"
        ],
        "summary": "Retrieve a checkout",
        "description": "A checkout and its payment. Read it to confirm an order when your webhook has not arrived; the browser's return proves nothing.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The checkout's id, chk_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "chk_z6zf7gkx4fcwy3402kmwrm3w"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Checkout"
                },
                "example": {
                  "object": "checkout",
                  "id": "chk_z6zf7gkx4fcwy3402kmwrm3w",
                  "mode": "test",
                  "status": "completed",
                  "url": "https://payments.lk/checkout/chk_z6zf7gkx4fcwy3402kmwrm3w",
                  "expiresAt": "2026-09-18T09:44:05.000Z",
                  "payment": {
                    "object": "payment",
                    "id": "pay_x1n31wnp8nkbjkkhymtqd6zs",
                    "mode": "test",
                    "status": "succeeded",
                    "amountCents": 350000,
                    "currency": "LKR",
                    "description": "Two kottu and a milk tea",
                    "reference": "order-8891",
                    "customer": {
                      "name": "Nimali Perera",
                      "email": "nimali@example.lk",
                      "phone": "0771234567"
                    },
                    "card": {
                      "scheme": "VISA",
                      "last4": "4242"
                    },
                    "cardSave": "not_requested",
                    "feeCents": 8015,
                    "netCents": 341985,
                    "refundedCents": 0,
                    "failureMessage": null,
                    "paymentLinkId": null,
                    "savedCardId": null,
                    "invoiceId": null,
                    "checkoutId": "chk_z6zf7gkx4fcwy3402kmwrm3w",
                    "checkoutPageId": null,
                    "order": null,
                    "delivery": null,
                    "customFields": null,
                    "customerTaxId": null,
                    "termsAcceptedAt": null,
                    "createdAt": "2026-09-18T09:14:05.000Z",
                    "succeededAt": "2026-09-18T09:16:41.000Z"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No checkout with this id for this key; mode_mismatch when it exists in the other mode. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found",
            "x-error-reasons": [
              {
                "reason": "mode_mismatch",
                "docUrl": "https://payments.lk/developers/errors#mode_mismatch"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "payments:read",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/payments": {
      "get": {
        "operationId": "listPayments",
        "tags": [
          "Payments"
        ],
        "summary": "List payments",
        "description": "Your payments in this key's mode, newest first. Filter by status and page with limit and cursor.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "How many to return, 1 to 100. Defaults to 25.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            },
            "example": 1
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "The nextCursor of the page before. Leave it out for the first page.",
            "schema": {
              "type": "string",
              "pattern": "^[a-z]{2,8}_[0-9a-z]{20,32}$"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Only payments in this status.",
            "schema": {
              "type": "string",
              "enum": [
                "requires_payment_method",
                "processing",
                "succeeded",
                "failed",
                "canceled",
                "partially_refunded",
                "refunded",
                "disputed"
              ]
            },
            "example": "succeeded"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "object": "payment",
                      "id": "pay_x1n31wnp8nkbjkkhymtqd6zs",
                      "mode": "test",
                      "status": "succeeded",
                      "amountCents": 350000,
                      "currency": "LKR",
                      "description": "Two kottu and a milk tea",
                      "reference": "order-8891",
                      "customer": {
                        "name": "Nimali Perera",
                        "email": "nimali@example.lk",
                        "phone": "0771234567"
                      },
                      "card": {
                        "scheme": "VISA",
                        "last4": "4242"
                      },
                      "cardSave": "not_requested",
                      "feeCents": 8015,
                      "netCents": 341985,
                      "refundedCents": 0,
                      "failureMessage": null,
                      "paymentLinkId": null,
                      "savedCardId": null,
                      "invoiceId": null,
                      "checkoutId": "chk_z6zf7gkx4fcwy3402kmwrm3w",
                      "checkoutPageId": null,
                      "order": null,
                      "delivery": null,
                      "customFields": null,
                      "customerTaxId": null,
                      "termsAcceptedAt": null,
                      "createdAt": "2026-09-18T09:14:05.000Z",
                      "succeededAt": "2026-09-18T09:16:41.000Z"
                    }
                  ],
                  "hasMore": true,
                  "nextCursor": "pay_x1n31wnp8nkbjkkhymtqd6zs"
                }
              }
            }
          },
          "400": {
            "description": "A query parameter is not valid; fields names each one. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed"
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "payments:read",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/payments/{id}": {
      "get": {
        "operationId": "retrievePayment",
        "tags": [
          "Payments"
        ],
        "summary": "Retrieve a payment",
        "description": "One payment.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The payment's id, pay_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "pay_x1n31wnp8nkbjkkhymtqd6zs"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Payment"
                },
                "example": {
                  "object": "payment",
                  "id": "pay_x1n31wnp8nkbjkkhymtqd6zs",
                  "mode": "test",
                  "status": "succeeded",
                  "amountCents": 350000,
                  "currency": "LKR",
                  "description": "Two kottu and a milk tea",
                  "reference": "order-8891",
                  "customer": {
                    "name": "Nimali Perera",
                    "email": "nimali@example.lk",
                    "phone": "0771234567"
                  },
                  "card": {
                    "scheme": "VISA",
                    "last4": "4242"
                  },
                  "cardSave": "not_requested",
                  "feeCents": 8015,
                  "netCents": 341985,
                  "refundedCents": 0,
                  "failureMessage": null,
                  "paymentLinkId": null,
                  "savedCardId": null,
                  "invoiceId": null,
                  "checkoutId": "chk_z6zf7gkx4fcwy3402kmwrm3w",
                  "checkoutPageId": null,
                  "order": null,
                  "delivery": null,
                  "customFields": null,
                  "customerTaxId": null,
                  "termsAcceptedAt": null,
                  "createdAt": "2026-09-18T09:14:05.000Z",
                  "succeededAt": "2026-09-18T09:16:41.000Z"
                }
              }
            }
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No payment with this id for this key; mode_mismatch when it exists in the other mode. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found",
            "x-error-reasons": [
              {
                "reason": "mode_mismatch",
                "docUrl": "https://payments.lk/developers/errors#mode_mismatch"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "payments:read",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/refunds": {
      "post": {
        "operationId": "createRefund",
        "tags": [
          "Refunds"
        ],
        "summary": "Create a refund",
        "description": "Refunds a payment in full or in part. The refund is recorded as pending and sent to Payable, which refunds only a settled payment, so a live refund goes out from the next bank working day. The outcome arrives as refund.succeeded or refund.failed. Refunds on one payment never add up to more than was paid.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "example": "refund-order-8891-tea"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateRefundRequest"
              },
              "example": {
                "paymentId": "pay_x1n31wnp8nkbjkkhymtqd6zs",
                "amountCents": 50000,
                "reason": "The milk tea was not available"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refund"
                },
                "example": {
                  "object": "refund",
                  "id": "re_sbca5jeftvf7acqsx5rvdzk3",
                  "mode": "test",
                  "paymentId": "pay_x1n31wnp8nkbjkkhymtqd6zs",
                  "status": "pending",
                  "amountCents": 50000,
                  "currency": "LKR",
                  "reason": "The milk tea was not available",
                  "failureMessage": null,
                  "createdAt": "2026-09-19T10:02:17.000Z",
                  "succeededAt": null
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. The amount is more than is left to refund on the payment. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              },
              {
                "reason": "amount",
                "docUrl": "https://payments.lk/developers/errors#amount"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No payment with this id for this key; mode_mismatch when it exists in the other mode. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found",
            "x-error-reasons": [
              {
                "reason": "mode_mismatch",
                "docUrl": "https://payments.lk/developers/errors#mode_mismatch"
              }
            ]
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. The payment has not succeeded, so there is nothing to refund. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              },
              {
                "reason": "not_refundable",
                "docUrl": "https://payments.lk/developers/errors#not_refundable"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "refunds:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      },
      "get": {
        "operationId": "listRefunds",
        "tags": [
          "Refunds"
        ],
        "summary": "List refunds",
        "description": "Your refunds in this key's mode, newest first. Filter by payment and page with limit and cursor.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "How many to return, 1 to 100. Defaults to 25.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "The nextCursor of the page before. Leave it out for the first page.",
            "schema": {
              "type": "string",
              "pattern": "^[a-z]{2,8}_[0-9a-z]{20,32}$"
            }
          },
          {
            "name": "paymentId",
            "in": "query",
            "required": false,
            "description": "Only refunds of this payment.",
            "schema": {
              "type": "string",
              "pattern": "^pay_[0-9a-z]{24}$"
            },
            "example": "pay_x1n31wnp8nkbjkkhymtqd6zs"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RefundList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "object": "refund",
                      "id": "re_sbca5jeftvf7acqsx5rvdzk3",
                      "mode": "test",
                      "paymentId": "pay_x1n31wnp8nkbjkkhymtqd6zs",
                      "status": "succeeded",
                      "amountCents": 50000,
                      "currency": "LKR",
                      "reason": "The milk tea was not available",
                      "failureMessage": null,
                      "createdAt": "2026-09-19T10:02:17.000Z",
                      "succeededAt": "2026-09-19T10:05:52.000Z"
                    }
                  ],
                  "hasMore": false,
                  "nextCursor": null
                }
              }
            }
          },
          "400": {
            "description": "A query parameter is not valid; fields names each one. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed"
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "payments:read",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/refunds/{id}": {
      "get": {
        "operationId": "retrieveRefund",
        "tags": [
          "Refunds"
        ],
        "summary": "Retrieve a refund",
        "description": "One refund.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The refund's id, re_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "re_sbca5jeftvf7acqsx5rvdzk3"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refund"
                },
                "example": {
                  "object": "refund",
                  "id": "re_sbca5jeftvf7acqsx5rvdzk3",
                  "mode": "test",
                  "paymentId": "pay_x1n31wnp8nkbjkkhymtqd6zs",
                  "status": "succeeded",
                  "amountCents": 50000,
                  "currency": "LKR",
                  "reason": "The milk tea was not available",
                  "failureMessage": null,
                  "createdAt": "2026-09-19T10:02:17.000Z",
                  "succeededAt": "2026-09-19T10:05:52.000Z"
                }
              }
            }
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No refund with this id for this key; mode_mismatch when it exists in the other mode. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found",
            "x-error-reasons": [
              {
                "reason": "mode_mismatch",
                "docUrl": "https://payments.lk/developers/errors#mode_mismatch"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "payments:read",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/payment_links": {
      "post": {
        "operationId": "createPaymentLink",
        "tags": [
          "Payment links"
        ],
        "summary": "Create a payment link",
        "description": "A link for a fixed amount that you can send anywhere. Each payer who opens it gets a checkout and a payment of their own.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "example": "cake-link-2026-09-18"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreatePaymentLinkRequest"
              },
              "example": {
                "title": "Chocolate cake, 1 kg",
                "description": "Collect from the shop on Saturday",
                "amountCents": 450000
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentLink"
                },
                "example": {
                  "object": "payment_link",
                  "id": "plink_6fn2qx9v9dk3ppj0n9dky5hz",
                  "mode": "test",
                  "title": "Chocolate cake, 1 kg",
                  "description": "Collect from the shop on Saturday",
                  "amountCents": 450000,
                  "url": "https://payments.lk/l/5oR6p1BQk5dFDfFpu7MZ5I",
                  "active": true,
                  "paidCount": 0,
                  "createdAt": "2026-09-18T11:20:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. A live key before the account is activated, or an account that cannot take payments. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              },
              {
                "reason": "merchant_not_live",
                "docUrl": "https://payments.lk/developers/errors#merchant_not_live"
              },
              {
                "reason": "merchant_unavailable",
                "docUrl": "https://payments.lk/developers/errors#merchant_unavailable"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "links:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      },
      "get": {
        "operationId": "listPaymentLinks",
        "tags": [
          "Payment links"
        ],
        "summary": "List payment links",
        "description": "Your 200 newest payment links in this key's mode, retired ones included, with how many payments each has taken. Not paginated.",
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentLinkList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "object": "payment_link",
                      "id": "plink_6fn2qx9v9dk3ppj0n9dky5hz",
                      "mode": "test",
                      "title": "Chocolate cake, 1 kg",
                      "description": "Collect from the shop on Saturday",
                      "amountCents": 450000,
                      "url": "https://payments.lk/l/5oR6p1BQk5dFDfFpu7MZ5I",
                      "active": true,
                      "paidCount": 3,
                      "createdAt": "2026-09-18T11:20:00.000Z"
                    }
                  ],
                  "hasMore": false,
                  "nextCursor": null
                }
              }
            }
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "payments:read",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/payment_links/{id}": {
      "delete": {
        "operationId": "retirePaymentLink",
        "tags": [
          "Payment links"
        ],
        "summary": "Retire a payment link",
        "description": "Turns a link off: it takes no more payments. Payments already made are unaffected. Retiring a link that is already retired answers the same.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The payment link's id, plink_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "plink_6fn2qx9v9dk3ppj0n9dky5hz"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentLink"
                },
                "example": {
                  "object": "payment_link",
                  "id": "plink_6fn2qx9v9dk3ppj0n9dky5hz",
                  "mode": "test",
                  "title": "Chocolate cake, 1 kg",
                  "description": "Collect from the shop on Saturday",
                  "amountCents": 450000,
                  "url": "https://payments.lk/l/5oR6p1BQk5dFDfFpu7MZ5I",
                  "active": false,
                  "paidCount": 0,
                  "createdAt": "2026-09-18T11:20:00.000Z"
                }
              }
            }
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No payment link with this id for this key; mode_mismatch when it exists in the other mode. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found",
            "x-error-reasons": [
              {
                "reason": "mode_mismatch",
                "docUrl": "https://payments.lk/developers/errors#mode_mismatch"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "links:write",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/cards": {
      "get": {
        "operationId": "listSavedCards",
        "tags": [
          "Saved cards"
        ],
        "summary": "List saved cards",
        "description": "The cards your customers kept on file in this key's mode that have not been deleted, newest first. Filter by the customer's email and page with limit and cursor.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "How many to return, 1 to 100. Defaults to 25.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            },
            "example": 1
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "The nextCursor of the page before. Leave it out for the first page.",
            "schema": {
              "type": "string",
              "pattern": "^card_[0-9a-z]{20,32}$"
            }
          },
          {
            "name": "customerEmail",
            "in": "query",
            "required": false,
            "description": "Only the cards kept by this customer, matched on the address they gave at checkout.",
            "schema": {
              "type": "string",
              "minLength": 3,
              "maxLength": 254,
              "pattern": "^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$"
            },
            "example": "ruwan@example.lk"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SavedCardList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "object": "saved_card",
                      "id": "card_g2a1rex14ff7qh2dc6j6qzmq",
                      "mode": "test",
                      "customerEmail": "ruwan@example.lk",
                      "scheme": "VISA",
                      "last4": "4242",
                      "expiry": {
                        "month": 11,
                        "year": 2029
                      },
                      "paymentId": "pay_x1n31wnp8nkbjkkhymtqd6zs",
                      "consent": {
                        "agreedAt": "2026-09-02T07:30:41.000Z",
                        "locale": "en",
                        "wording": "checkoutPage.saveCard@1"
                      },
                      "active": true,
                      "createdAt": "2026-09-02T07:30:44.000Z",
                      "retiredAt": null
                    }
                  ],
                  "hasMore": false,
                  "nextCursor": null
                }
              }
            }
          },
          "400": {
            "description": "A query parameter is not valid; fields names each one. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed"
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "cards:read",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/cards/{id}": {
      "get": {
        "operationId": "retrieveSavedCard",
        "tags": [
          "Saved cards"
        ],
        "summary": "Retrieve a saved card",
        "description": "One saved card, deleted ones included, so you can still say why a charge stopped. It carries the card's expiry month and the consent the customer gave when they kept it.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The saved card's id, card_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "card_g2a1rex14ff7qh2dc6j6qzmq"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SavedCard"
                },
                "example": {
                  "object": "saved_card",
                  "id": "card_g2a1rex14ff7qh2dc6j6qzmq",
                  "mode": "test",
                  "customerEmail": "ruwan@example.lk",
                  "scheme": "VISA",
                  "last4": "4242",
                  "expiry": {
                    "month": 11,
                    "year": 2029
                  },
                  "paymentId": "pay_x1n31wnp8nkbjkkhymtqd6zs",
                  "consent": {
                    "agreedAt": "2026-09-02T07:30:41.000Z",
                    "locale": "en",
                    "wording": "checkoutPage.saveCard@1"
                  },
                  "active": true,
                  "createdAt": "2026-09-02T07:30:44.000Z",
                  "retiredAt": null
                }
              }
            }
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No saved card with this id for this key; mode_mismatch when it exists in the other mode. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found",
            "x-error-reasons": [
              {
                "reason": "mode_mismatch",
                "docUrl": "https://payments.lk/developers/errors#mode_mismatch"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "cards:read",
        "x-key-kinds": [
          "secret"
        ]
      },
      "delete": {
        "operationId": "deleteSavedCard",
        "tags": [
          "Saved cards"
        ],
        "summary": "Delete a saved card",
        "description": "Deletes the card here and its token at the processor. Do it when the customer asks or cancels. Deleting a card that is already deleted answers the same card, so a retry is safe.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The saved card's id, card_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "card_g2a1rex14ff7qh2dc6j6qzmq"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SavedCard"
                },
                "example": {
                  "object": "saved_card",
                  "id": "card_g2a1rex14ff7qh2dc6j6qzmq",
                  "mode": "test",
                  "customerEmail": "ruwan@example.lk",
                  "scheme": "VISA",
                  "last4": "4242",
                  "expiry": {
                    "month": 11,
                    "year": 2029
                  },
                  "paymentId": "pay_x1n31wnp8nkbjkkhymtqd6zs",
                  "consent": {
                    "agreedAt": "2026-09-02T07:30:41.000Z",
                    "locale": "en",
                    "wording": "checkoutPage.saveCard@1"
                  },
                  "active": false,
                  "createdAt": "2026-09-02T07:30:44.000Z",
                  "retiredAt": "2026-10-04T11:09:52.000Z"
                }
              }
            }
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No saved card with this id for this key; mode_mismatch when it exists in the other mode. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found",
            "x-error-reasons": [
              {
                "reason": "mode_mismatch",
                "docUrl": "https://payments.lk/developers/errors#mode_mismatch"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "cards:charge",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/cards/{id}/charge": {
      "post": {
        "operationId": "chargeSavedCard",
        "tags": [
          "Saved cards"
        ],
        "summary": "Charge a saved card",
        "description": "Takes a payment on a saved card without the customer present. The answer is the payment, usually processing: the outcome arrives as payment.succeeded or payment.failed. A charge the processor refuses at once comes back as failed. Charge only what the customer agreed to, with one Idempotency-Key per billing period.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The saved card's id, card_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "card_g2a1rex14ff7qh2dc6j6qzmq"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "example": "sub-1042-2026-10"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChargeSavedCardRequest"
              },
              "example": {
                "amountCents": 250000,
                "description": "October coffee subscription",
                "reference": "sub-1042-2026-10"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Payment"
                },
                "example": {
                  "object": "payment",
                  "id": "pay_41j10awqfww0v3p1gjndpbv4",
                  "mode": "test",
                  "status": "processing",
                  "amountCents": 250000,
                  "currency": "LKR",
                  "description": "October coffee subscription",
                  "reference": "sub-1042-2026-10",
                  "customer": {
                    "name": null,
                    "email": "ruwan@example.lk",
                    "phone": null
                  },
                  "card": {
                    "scheme": "VISA",
                    "last4": "4242"
                  },
                  "cardSave": "not_requested",
                  "feeCents": null,
                  "netCents": null,
                  "refundedCents": 0,
                  "failureMessage": null,
                  "paymentLinkId": null,
                  "savedCardId": "card_g2a1rex14ff7qh2dc6j6qzmq",
                  "invoiceId": null,
                  "checkoutId": null,
                  "checkoutPageId": null,
                  "order": null,
                  "delivery": null,
                  "customFields": null,
                  "customerTaxId": null,
                  "termsAcceptedAt": null,
                  "createdAt": "2026-10-01T06:00:03.000Z",
                  "succeededAt": null
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No saved card with this id for this key; mode_mismatch when it exists in the other mode. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found",
            "x-error-reasons": [
              {
                "reason": "mode_mismatch",
                "docUrl": "https://payments.lk/developers/errors#mode_mismatch"
              }
            ]
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. A live key before the account is activated, a card that cannot be charged again (ask the customer to save it at a new checkout), or an amount that would take this month past the plan's monthly limit. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              },
              {
                "reason": "merchant_not_live",
                "docUrl": "https://payments.lk/developers/errors#merchant_not_live"
              },
              {
                "reason": "card_not_reusable",
                "docUrl": "https://payments.lk/developers/errors#card_not_reusable"
              },
              {
                "reason": "monthly_limit_reached",
                "docUrl": "https://payments.lk/developers/errors#monthly_limit_reached"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "cards:charge",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      }
    },
    "/v1/events": {
      "get": {
        "operationId": "listEvents",
        "tags": [
          "Events"
        ],
        "summary": "List events",
        "description": "The public events in this key's mode, newest first, in exactly the shape a webhook delivers them. Use it to catch up on anything your endpoint missed. Filter by type and time; page with limit and cursor.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "How many to return, 1 to 100. Defaults to 25.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            },
            "example": 1
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "The nextCursor of the page before. Leave it out for the first page.",
            "schema": {
              "type": "string",
              "pattern": "^evt_[0-9a-z]{20,32}$"
            }
          },
          {
            "name": "type",
            "in": "query",
            "required": false,
            "description": "Only events of this type.",
            "schema": {
              "type": "string",
              "enum": [
                "payment.succeeded",
                "payment.failed",
                "checkout.expired",
                "card.saved",
                "card.save_failed",
                "card.expiring",
                "billing.alert.triggered",
                "subscription_schedule.created",
                "subscription_schedule.completed",
                "subscription_schedule.released",
                "subscription_schedule.canceled",
                "refund.succeeded",
                "refund.failed",
                "account.limit.approaching",
                "account.limit.reached",
                "account.limit.reset",
                "customer.subscription.created",
                "customer.subscription.updated",
                "customer.subscription.deleted",
                "customer.subscription.trial_will_end",
                "customer.subscription.paused",
                "customer.subscription.resumed",
                "invoice.created",
                "invoice.finalized",
                "invoice.sent",
                "invoice.overdue",
                "credit_note.created",
                "entitlements.active_entitlement_summary.updated",
                "invoice.paid",
                "invoice.payment_failed",
                "invoice.upcoming",
                "invoice.voided",
                "invoice.marked_uncollectible"
              ]
            },
            "example": "payment.succeeded"
          },
          {
            "name": "since",
            "in": "query",
            "required": false,
            "description": "Only events created at or after this moment, ISO 8601, such as 2026-09-18T00:00:00Z.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EventList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "id": "evt_ev85ebwj9yqjq81vwf5qwz9m",
                      "object": "event",
                      "type": "payment.succeeded",
                      "mode": "test",
                      "created": "2026-09-18T09:16:41.000Z",
                      "data": {
                        "object": "payment",
                        "id": "pay_x1n31wnp8nkbjkkhymtqd6zs",
                        "mode": "test",
                        "status": "succeeded",
                        "amountCents": 350000,
                        "currency": "LKR",
                        "description": "Two kottu and a milk tea",
                        "reference": "order-8891",
                        "customer": {
                          "name": "Nimali Perera",
                          "email": "nimali@example.lk",
                          "phone": "0771234567"
                        },
                        "card": {
                          "scheme": "VISA",
                          "last4": "4242"
                        },
                        "cardSave": "not_requested",
                        "feeCents": 8015,
                        "netCents": 341985,
                        "refundedCents": 0,
                        "failureMessage": null,
                        "paymentLinkId": null,
                        "savedCardId": null,
                        "invoiceId": null,
                        "checkoutId": "chk_z6zf7gkx4fcwy3402kmwrm3w",
                        "checkoutPageId": null,
                        "order": null,
                        "delivery": null,
                        "customFields": null,
                        "customerTaxId": null,
                        "termsAcceptedAt": null,
                        "createdAt": "2026-09-18T09:14:05.000Z",
                        "succeededAt": "2026-09-18T09:16:41.000Z"
                      }
                    }
                  ],
                  "hasMore": false,
                  "nextCursor": null
                }
              }
            }
          },
          "400": {
            "description": "A query parameter is not valid; fields names each one. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed"
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "events:read",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/events/{id}": {
      "get": {
        "operationId": "retrieveEvent",
        "tags": [
          "Events"
        ],
        "summary": "Retrieve an event",
        "description": "One event, in the shape a webhook delivers it.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The event's id, evt_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "evt_ev85ebwj9yqjq81vwf5qwz9m"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Event"
                },
                "example": {
                  "id": "evt_ev85ebwj9yqjq81vwf5qwz9m",
                  "object": "event",
                  "type": "payment.succeeded",
                  "mode": "test",
                  "created": "2026-09-18T09:16:41.000Z",
                  "data": {
                    "object": "payment",
                    "id": "pay_x1n31wnp8nkbjkkhymtqd6zs",
                    "mode": "test",
                    "status": "succeeded",
                    "amountCents": 350000,
                    "currency": "LKR",
                    "description": "Two kottu and a milk tea",
                    "reference": "order-8891",
                    "customer": {
                      "name": "Nimali Perera",
                      "email": "nimali@example.lk",
                      "phone": "0771234567"
                    },
                    "card": {
                      "scheme": "VISA",
                      "last4": "4242"
                    },
                    "cardSave": "not_requested",
                    "feeCents": 8015,
                    "netCents": 341985,
                    "refundedCents": 0,
                    "failureMessage": null,
                    "paymentLinkId": null,
                    "savedCardId": null,
                    "invoiceId": null,
                    "checkoutId": "chk_z6zf7gkx4fcwy3402kmwrm3w",
                    "checkoutPageId": null,
                    "order": null,
                    "delivery": null,
                    "customFields": null,
                    "customerTaxId": null,
                    "termsAcceptedAt": null,
                    "createdAt": "2026-09-18T09:14:05.000Z",
                    "succeededAt": "2026-09-18T09:16:41.000Z"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No public event with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "events:read",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/account": {
      "get": {
        "operationId": "retrieveAccount",
        "tags": [
          "Account"
        ],
        "summary": "Retrieve your account",
        "description": "The merchant behind the key: status, plan, this month's usage against the plan's monthly limit in the key's mode, and whether live payments are open. A payment that would take the month past the limit is refused with monthly_limit_reached; usage says how close the month is.",
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Account"
                },
                "example": {
                  "id": "mer_yb1xzmzqdza69g0p3hpeaew6",
                  "tradingName": "Colombo Kottu House",
                  "status": "activated",
                  "applicationStatus": "approved",
                  "clearance": {
                    "tier": "starter",
                    "monthlyCapCents": 10000000
                  },
                  "pricingPlan": "standard",
                  "plan": "starter",
                  "usage": {
                    "month": "2026-09",
                    "mode": "test",
                    "plan": "starter",
                    "capCents": 10000000,
                    "settledCents": 6340000,
                    "reservedCents": 0,
                    "percent": 63,
                    "resetsAt": "2026-09-30T18:30:00.000Z",
                    "refusedCount": 0,
                    "refusedCents": 0
                  },
                  "locale": "en",
                  "liveEnabled": true,
                  "phase1Position": null
                }
              }
            }
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "account:read",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/customers": {
      "post": {
        "operationId": "createCustomer",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Create a customer",
        "description": "Someone you bill. One customer per email in each mode: sending an email you already have answers that customer, with any new details filled in.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "example": "member-1042"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCustomerRequest"
              },
              "example": {
                "email": "nimali@example.com",
                "name": "Nimali Perera",
                "phone": "0771234567",
                "locale": "si"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Customer"
                },
                "example": {
                  "object": "customer",
                  "id": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "mode": "test",
                  "email": "nimali@example.com",
                  "name": "Nimali Perera",
                  "phone": "+94771234567",
                  "locale": "si",
                  "defaultCardId": "card_g2a1rex14ff7qh2dc6j6qzmq",
                  "creditBalanceCents": 0,
                  "createdAt": "2026-10-01T04:12:30.000Z"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      },
      "get": {
        "operationId": "listCustomers",
        "tags": [
          "Subscriptions"
        ],
        "summary": "List customers",
        "description": "Your customers in this key's mode, newest first. Filter by email; page with limit and cursor.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "How many to return, 1 to 100. Defaults to 25.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "The nextCursor of the page before. Leave it out for the first page.",
            "schema": {
              "type": "string",
              "pattern": "^cus_[0-9a-z]{20,32}$"
            }
          },
          {
            "name": "email",
            "in": "query",
            "required": false,
            "description": "Only the customer with this email.",
            "schema": {
              "type": "string",
              "minLength": 3,
              "maxLength": 254,
              "pattern": "^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$"
            },
            "example": "nimali@example.com"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "object": "customer",
                      "id": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                      "mode": "test",
                      "email": "nimali@example.com",
                      "name": "Nimali Perera",
                      "phone": "+94771234567",
                      "locale": "si",
                      "defaultCardId": "card_g2a1rex14ff7qh2dc6j6qzmq",
                      "creditBalanceCents": 0,
                      "createdAt": "2026-10-01T04:12:30.000Z"
                    }
                  ],
                  "hasMore": false,
                  "nextCursor": null
                }
              }
            }
          },
          "400": {
            "description": "A query parameter is not valid; fields names each one. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed"
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:read",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/customers/{id}": {
      "get": {
        "operationId": "retrieveCustomer",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Retrieve a customer",
        "description": "One customer.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The customer's id, cus_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "cus_q8w3n5v1x7c2m9r4t6ya0kzp"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Customer"
                },
                "example": {
                  "object": "customer",
                  "id": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "mode": "test",
                  "email": "nimali@example.com",
                  "name": "Nimali Perera",
                  "phone": "+94771234567",
                  "locale": "si",
                  "defaultCardId": "card_g2a1rex14ff7qh2dc6j6qzmq",
                  "creditBalanceCents": 0,
                  "createdAt": "2026-10-01T04:12:30.000Z"
                }
              }
            }
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No customer with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:read",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/prices": {
      "post": {
        "operationId": "createPrice",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Create a price",
        "description": "A recurring price: an amount every day, week, month or year, on a product you name here or made before. Prices are never edited; make a new one and archive the old in the dashboard.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "examples": {
              "default": {
                "value": "price-gym-monthly"
              },
              "metered": {
                "value": "price-sms-usage"
              }
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreatePriceRequest"
              },
              "examples": {
                "default": {
                  "summary": "A monthly price",
                  "value": {
                    "product": {
                      "name": "Gym membership",
                      "description": "Unlimited visits, both branches"
                    },
                    "unitAmountCents": 450000,
                    "interval": "month"
                  }
                },
                "metered": {
                  "summary": "Usage, tiered: messages sent",
                  "value": {
                    "product": {
                      "name": "SMS gateway"
                    },
                    "interval": "month",
                    "billingScheme": "tiered",
                    "tiersMode": "graduated",
                    "tiers": [
                      {
                        "upTo": 1000,
                        "unitAmountCents": 150
                      },
                      {
                        "upTo": null,
                        "unitAmountCents": 100
                      }
                    ],
                    "usageType": "metered",
                    "meterId": "mtr_a4c8v2x9q1m7k3r6t0yhwn5z"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Price"
                },
                "examples": {
                  "default": {
                    "summary": "A monthly price",
                    "value": {
                      "object": "price",
                      "id": "price_m3v8q1x6c9k2r5t7y0wn4hzp",
                      "mode": "test",
                      "product": {
                        "id": "prod_h2k9m4q7v1x8c3r6t0ynwz5p",
                        "name": "Gym membership",
                        "description": "Unlimited visits, both branches"
                      },
                      "unitAmountCents": 450000,
                      "currency": "LKR",
                      "interval": "month",
                      "intervalCount": 1,
                      "nickname": null,
                      "active": true,
                      "billingScheme": "per_unit",
                      "tiersMode": null,
                      "tiers": null,
                      "packageSize": null,
                      "usageType": "licensed",
                      "meterId": null,
                      "createdAt": "2026-10-01T04:00:00.000Z"
                    }
                  },
                  "metered": {
                    "summary": "Usage, tiered: messages sent",
                    "value": {
                      "object": "price",
                      "id": "price_u6s2v9x1c8q4m7k3r0tnhw5y",
                      "mode": "test",
                      "product": {
                        "id": "prod_h2k9m4q7v1x8c3r6t0ynwz5p",
                        "name": "SMS gateway",
                        "description": null
                      },
                      "unitAmountCents": 0,
                      "currency": "LKR",
                      "interval": "month",
                      "intervalCount": 1,
                      "nickname": null,
                      "active": true,
                      "billingScheme": "tiered",
                      "tiersMode": "graduated",
                      "tiers": [
                        {
                          "upTo": 1000,
                          "unitAmountCents": 150,
                          "flatAmountCents": 0
                        },
                        {
                          "upTo": null,
                          "unitAmountCents": 100,
                          "flatAmountCents": 0
                        }
                      ],
                      "packageSize": null,
                      "usageType": "metered",
                      "meterId": "mtr_a4c8v2x9q1m7k3r6t0yhwn5z",
                      "createdAt": "2026-10-01T04:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. A metered price names no active meter of yours, or the tiers cannot price anything. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              },
              {
                "reason": "meter_invalid",
                "docUrl": "https://payments.lk/developers/errors#meter_invalid"
              },
              {
                "reason": "price_invalid",
                "docUrl": "https://payments.lk/developers/errors#price_invalid"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No product with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      },
      "get": {
        "operationId": "listPrices",
        "tags": [
          "Subscriptions"
        ],
        "summary": "List prices",
        "description": "Your prices in this key's mode, newest first, with their products. Filter by active.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "How many to return, 1 to 100. Defaults to 25.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "The nextCursor of the page before. Leave it out for the first page.",
            "schema": {
              "type": "string",
              "pattern": "^price_[0-9a-z]{20,32}$"
            }
          },
          {
            "name": "active",
            "in": "query",
            "required": false,
            "description": "true for prices taking new subscriptions, false for archived ones.",
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            },
            "example": "true"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PriceList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "object": "price",
                      "id": "price_m3v8q1x6c9k2r5t7y0wn4hzp",
                      "mode": "test",
                      "product": {
                        "id": "prod_h2k9m4q7v1x8c3r6t0ynwz5p",
                        "name": "Gym membership",
                        "description": "Unlimited visits, both branches"
                      },
                      "unitAmountCents": 450000,
                      "currency": "LKR",
                      "interval": "month",
                      "intervalCount": 1,
                      "nickname": null,
                      "active": true,
                      "billingScheme": "per_unit",
                      "tiersMode": null,
                      "tiers": null,
                      "packageSize": null,
                      "usageType": "licensed",
                      "meterId": null,
                      "createdAt": "2026-10-01T04:00:00.000Z"
                    }
                  ],
                  "hasMore": false,
                  "nextCursor": null
                }
              }
            }
          },
          "400": {
            "description": "A query parameter is not valid; fields names each one. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed"
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:read",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/prices/{id}": {
      "get": {
        "operationId": "retrievePrice",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Retrieve a price",
        "description": "One price, with its product.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The price's id, price_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "price_m3v8q1x6c9k2r5t7y0wn4hzp"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Price"
                },
                "example": {
                  "object": "price",
                  "id": "price_m3v8q1x6c9k2r5t7y0wn4hzp",
                  "mode": "test",
                  "product": {
                    "id": "prod_h2k9m4q7v1x8c3r6t0ynwz5p",
                    "name": "Gym membership",
                    "description": "Unlimited visits, both branches"
                  },
                  "unitAmountCents": 450000,
                  "currency": "LKR",
                  "interval": "month",
                  "intervalCount": 1,
                  "nickname": null,
                  "active": true,
                  "billingScheme": "per_unit",
                  "tiersMode": null,
                  "tiers": null,
                  "packageSize": null,
                  "usageType": "licensed",
                  "meterId": null,
                  "createdAt": "2026-10-01T04:00:00.000Z"
                }
              }
            }
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No price with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:read",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/subscriptions": {
      "post": {
        "operationId": "createSubscription",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Create a subscription",
        "description": "Starts a subscription on a price for a customer, by id or by details. It is incomplete, with its first invoice open, until that invoice is paid. With a card the customer saved with you (cardId, or the customer's default card) the invoice is charged within a minute. Without one, send the customer to checkoutUrl: they pay on Payable's page and agree to keep the card for the renewals. Unpaid after 23 hours, the subscription expires. From then on we renew each period, charge the card, retry a decline on days 1, 3, 7 and 14, email the customer, and send you the events. Live subscriptions need saved cards switched on.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "example": "member-1042-gym"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateSubscriptionRequest"
              },
              "example": {
                "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                "priceId": "price_m3v8q1x6c9k2r5t7y0wn4hzp",
                "reference": "member-1042",
                "successUrl": "https://gym.example/welcome"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Subscription"
                },
                "example": {
                  "object": "subscription",
                  "id": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "mode": "test",
                  "status": "incomplete",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "price": {
                    "id": "price_m3v8q1x6c9k2r5t7y0wn4hzp",
                    "productName": "Gym membership",
                    "unitAmountCents": 450000,
                    "interval": "month",
                    "intervalCount": 1
                  },
                  "quantity": 1,
                  "items": [
                    {
                      "id": "si_t4c9v2x7q1m6k8r3y0wnhz5p",
                      "price": {
                        "id": "price_m3v8q1x6c9k2r5t7y0wn4hzp",
                        "productName": "Gym membership",
                        "unitAmountCents": 450000,
                        "interval": "month",
                        "intervalCount": 1
                      },
                      "quantity": 1
                    }
                  ],
                  "currentPeriodStart": "2026-10-01T04:12:31.000Z",
                  "currentPeriodEnd": "2026-11-01T04:12:31.000Z",
                  "billingCycleAnchor": "2026-10-01T04:12:31.000Z",
                  "cancelAtPeriodEnd": false,
                  "cancelAt": null,
                  "canceledAt": null,
                  "endedAt": null,
                  "cancelReason": null,
                  "cancellationDetails": {
                    "reason": null,
                    "feedback": null,
                    "comment": null
                  },
                  "trialStart": null,
                  "trialEnd": null,
                  "trialEndBehavior": "create_invoice",
                  "pauseCollection": null,
                  "discount": null,
                  "taxRateIds": [],
                  "subscriptionLinkId": null,
                  "collectionMethod": "charge_automatically",
                  "daysUntilDue": null,
                  "pendingUpdate": null,
                  "cardId": null,
                  "cardMissingSince": null,
                  "latestInvoiceId": "in_c4v9x2q7m1k8r3t6y0wnzhp5",
                  "checkoutUrl": "https://payments.lk/checkout/chk_r8v2x6c1q9m4k7t3y0wnzh5p",
                  "reference": "member-1042",
                  "createdAt": "2026-10-01T04:12:31.000Z"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. trialEnd or cancelAt is in the past or more than two years away. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              },
              {
                "reason": "billing_date_invalid",
                "docUrl": "https://payments.lk/developers/errors#billing_date_invalid"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No customer with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. An archived price, a card that is not this customer's, a coupon or tax rate that cannot be used, live saved cards not switched on, the monthly limit, or an account that cannot take payments. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              },
              {
                "reason": "price_unavailable",
                "docUrl": "https://payments.lk/developers/errors#price_unavailable"
              },
              {
                "reason": "card_not_reusable",
                "docUrl": "https://payments.lk/developers/errors#card_not_reusable"
              },
              {
                "reason": "coupon_invalid",
                "docUrl": "https://payments.lk/developers/errors#coupon_invalid"
              },
              {
                "reason": "tax_rate_invalid",
                "docUrl": "https://payments.lk/developers/errors#tax_rate_invalid"
              },
              {
                "reason": "saved_cards_off",
                "docUrl": "https://payments.lk/developers/errors#saved_cards_off"
              },
              {
                "reason": "monthly_limit_reached",
                "docUrl": "https://payments.lk/developers/errors#monthly_limit_reached"
              },
              {
                "reason": "merchant_not_live",
                "docUrl": "https://payments.lk/developers/errors#merchant_not_live"
              },
              {
                "reason": "merchant_unavailable",
                "docUrl": "https://payments.lk/developers/errors#merchant_unavailable"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      },
      "get": {
        "operationId": "listSubscriptions",
        "tags": [
          "Subscriptions"
        ],
        "summary": "List subscriptions",
        "description": "Your subscriptions in this key's mode, newest first. Filter by customer and status.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "How many to return, 1 to 100. Defaults to 25.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "The nextCursor of the page before. Leave it out for the first page.",
            "schema": {
              "type": "string",
              "pattern": "^sub_[0-9a-z]{20,32}$"
            }
          },
          {
            "name": "customerId",
            "in": "query",
            "required": false,
            "description": "Only this customer's subscriptions.",
            "schema": {
              "type": "string",
              "pattern": "^cus_[0-9a-z]{20,32}$"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Only subscriptions in this status.",
            "schema": {
              "type": "string",
              "enum": [
                "incomplete",
                "incomplete_expired",
                "trialing",
                "active",
                "past_due",
                "unpaid",
                "paused",
                "canceled"
              ]
            },
            "example": "active"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubscriptionList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "object": "subscription",
                      "id": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                      "mode": "test",
                      "status": "active",
                      "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                      "price": {
                        "id": "price_m3v8q1x6c9k2r5t7y0wn4hzp",
                        "productName": "Gym membership",
                        "unitAmountCents": 450000,
                        "interval": "month",
                        "intervalCount": 1
                      },
                      "quantity": 1,
                      "items": [
                        {
                          "id": "si_t4c9v2x7q1m6k8r3y0wnhz5p",
                          "price": {
                            "id": "price_m3v8q1x6c9k2r5t7y0wn4hzp",
                            "productName": "Gym membership",
                            "unitAmountCents": 450000,
                            "interval": "month",
                            "intervalCount": 1
                          },
                          "quantity": 1
                        }
                      ],
                      "currentPeriodStart": "2026-10-01T04:12:31.000Z",
                      "currentPeriodEnd": "2026-11-01T04:12:31.000Z",
                      "billingCycleAnchor": "2026-10-01T04:12:31.000Z",
                      "cancelAtPeriodEnd": false,
                      "cancelAt": null,
                      "canceledAt": null,
                      "endedAt": null,
                      "cancelReason": null,
                      "cancellationDetails": {
                        "reason": null,
                        "feedback": null,
                        "comment": null
                      },
                      "trialStart": null,
                      "trialEnd": null,
                      "trialEndBehavior": "create_invoice",
                      "pauseCollection": null,
                      "discount": null,
                      "taxRateIds": [],
                      "subscriptionLinkId": null,
                      "collectionMethod": "charge_automatically",
                      "daysUntilDue": null,
                      "pendingUpdate": null,
                      "cardId": "card_g2a1rex14ff7qh2dc6j6qzmq",
                      "cardMissingSince": null,
                      "latestInvoiceId": "in_c4v9x2q7m1k8r3t6y0wnzhp5",
                      "checkoutUrl": null,
                      "reference": "member-1042",
                      "createdAt": "2026-10-01T04:12:31.000Z"
                    }
                  ],
                  "hasMore": false,
                  "nextCursor": null
                }
              }
            }
          },
          "400": {
            "description": "A query parameter is not valid; fields names each one. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed"
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:read",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/subscriptions/{id}": {
      "get": {
        "operationId": "retrieveSubscription",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Retrieve a subscription",
        "description": "One subscription.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The subscription's id, sub_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "sub_p6x1c8v3q9m2k7r4t0yhwz5n"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Subscription"
                },
                "example": {
                  "object": "subscription",
                  "id": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "mode": "test",
                  "status": "active",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "price": {
                    "id": "price_m3v8q1x6c9k2r5t7y0wn4hzp",
                    "productName": "Gym membership",
                    "unitAmountCents": 450000,
                    "interval": "month",
                    "intervalCount": 1
                  },
                  "quantity": 1,
                  "items": [
                    {
                      "id": "si_t4c9v2x7q1m6k8r3y0wnhz5p",
                      "price": {
                        "id": "price_m3v8q1x6c9k2r5t7y0wn4hzp",
                        "productName": "Gym membership",
                        "unitAmountCents": 450000,
                        "interval": "month",
                        "intervalCount": 1
                      },
                      "quantity": 1
                    }
                  ],
                  "currentPeriodStart": "2026-10-01T04:12:31.000Z",
                  "currentPeriodEnd": "2026-11-01T04:12:31.000Z",
                  "billingCycleAnchor": "2026-10-01T04:12:31.000Z",
                  "cancelAtPeriodEnd": false,
                  "cancelAt": null,
                  "canceledAt": null,
                  "endedAt": null,
                  "cancelReason": null,
                  "cancellationDetails": {
                    "reason": null,
                    "feedback": null,
                    "comment": null
                  },
                  "trialStart": null,
                  "trialEnd": null,
                  "trialEndBehavior": "create_invoice",
                  "pauseCollection": null,
                  "discount": null,
                  "taxRateIds": [],
                  "subscriptionLinkId": null,
                  "collectionMethod": "charge_automatically",
                  "daysUntilDue": null,
                  "pendingUpdate": null,
                  "cardId": "card_g2a1rex14ff7qh2dc6j6qzmq",
                  "cardMissingSince": null,
                  "latestInvoiceId": "in_c4v9x2q7m1k8r3t6y0wnzhp5",
                  "checkoutUrl": null,
                  "reference": "member-1042",
                  "createdAt": "2026-10-01T04:12:31.000Z"
                }
              }
            }
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No subscription with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:read",
        "x-key-kinds": [
          "secret"
        ]
      },
      "post": {
        "operationId": "updateSubscription",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Update a subscription",
        "description": "Changes what a subscription bills (items, or priceId and quantity for one item) and how the part of the period already begun is billed (prorationBehavior), when it ends (cancelAtPeriodEnd, cancelAt), pauses or resumes collection (pauseCollection), ends or moves a trial (trialEnd), and sets the card renewals are charged to, the cancellation details, the coupon, the tax rates and your reference. Only the fields you send change. A change of interval starts a new period at once, invoiced now with the unused time credited. With paymentBehavior pending_if_incomplete a change that costs more waits in pendingUpdate until its invoice is paid. Preview a change with POST /v1/invoices/preview. customer.subscription.updated is sent.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The subscription's id, sub_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "sub_p6x1c8v3q9m2k7r4t0yhwz5n"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "examples": {
              "default": {
                "value": "upgrade-member-1042-pool"
              },
              "pause": {
                "value": "pause-member-1042-holidays"
              }
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "items": {
                    "description": "Changes to its items, up to 10: an existing one by id (a new priceId, a new quantity, or deleted true), or a new one by priceId.",
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "description": "The item to change, from the subscription's items.",
                          "type": "string",
                          "pattern": "^si_[0-9a-z]{20,32}$"
                        },
                        "priceId": {
                          "description": "Its new price, or the price of a new item. Active, and on the subscription's interval unless every item changes to a new one together.",
                          "type": "string",
                          "pattern": "^price_[0-9a-z]{20,32}$"
                        },
                        "quantity": {
                          "description": "Its new quantity, 1 to 10000.",
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 10000
                        },
                        "deleted": {
                          "description": "True removes the item. A subscription keeps at least one.",
                          "type": "boolean",
                          "const": true
                        }
                      },
                      "additionalProperties": false
                    },
                    "minItems": 1,
                    "maxItems": 10
                  },
                  "priceId": {
                    "description": "For a subscription of one item: its new price. Send this and quantity, or items.",
                    "type": "string",
                    "pattern": "^price_[0-9a-z]{20,32}$"
                  },
                  "quantity": {
                    "description": "For a subscription of one item: its new quantity, 1 to 10000.",
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 10000
                  },
                  "prorationBehavior": {
                    "description": "How the part of the period already begun is billed: create_prorations (the default: a credit for the unused time and a charge for the rest of the period wait for the next invoice), always_invoice (the same, invoiced and charged now) or none. A change of interval starts a new period at once, invoiced now.",
                    "type": "string",
                    "enum": [
                      "create_prorations",
                      "always_invoice",
                      "none"
                    ]
                  },
                  "prorationDate": {
                    "description": "Price the change as at this time, ISO 8601: inside the current period and not after now. Send the time a preview used so the charge matches it.",
                    "type": "string",
                    "format": "date-time"
                  },
                  "paymentBehavior": {
                    "description": "allow_incomplete (the default: the change applies at once) or pending_if_incomplete (a change that costs more waits for its invoice to be paid; see pendingUpdate).",
                    "type": "string",
                    "enum": [
                      "allow_incomplete",
                      "pending_if_incomplete"
                    ]
                  },
                  "cancelAtPeriodEnd": {
                    "description": "True ends it when the period that is paid for runs out; false takes that back.",
                    "type": "boolean"
                  },
                  "cancelAt": {
                    "description": "Ends it at this time, ISO 8601, within two years; the last period is billed only up to it. Null takes the date back.",
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "date-time"
                  },
                  "pauseCollection": {
                    "description": "Pauses collection: invoices are still made but not charged, until resumesAt or until you send null.",
                    "type": [
                      "object",
                      "null"
                    ],
                    "properties": {
                      "behavior": {
                        "description": "keep_as_draft, mark_uncollectible or void: what happens to each invoice made while paused.",
                        "type": "string",
                        "enum": [
                          "keep_as_draft",
                          "mark_uncollectible",
                          "void"
                        ]
                      },
                      "resumesAt": {
                        "description": "When collection resumes by itself, ISO 8601, within two years.",
                        "type": "string",
                        "format": "date-time"
                      }
                    },
                    "required": [
                      "behavior"
                    ],
                    "additionalProperties": false
                  },
                  "trialEnd": {
                    "description": "Ends a trialing subscription's trial: \"now\", or a new time within two years.",
                    "anyOf": [
                      {
                        "type": "string",
                        "const": "now"
                      },
                      {
                        "type": "string",
                        "format": "date-time"
                      }
                    ]
                  },
                  "trialEndBehavior": {
                    "description": "create_invoice, pause or cancel: what happens if the trial ends with no card on file.",
                    "type": "string",
                    "enum": [
                      "create_invoice",
                      "pause",
                      "cancel"
                    ]
                  },
                  "cardId": {
                    "description": "A card this customer kept with you, charged for the renewals from now on.",
                    "type": "string",
                    "pattern": "^card_[0-9a-z]{20,32}$"
                  },
                  "cancellationDetails": {
                    "description": "Why it is being cancelled, kept on the subscription.",
                    "type": "object",
                    "properties": {
                      "feedback": {
                        "description": "customer_service, low_quality, missing_features, other, switched_service, too_complex, too_expensive or unused.",
                        "type": "string",
                        "enum": [
                          "customer_service",
                          "low_quality",
                          "missing_features",
                          "other",
                          "switched_service",
                          "too_complex",
                          "too_expensive",
                          "unused"
                        ]
                      },
                      "comment": {
                        "description": "A comment on why, up to 500 characters.",
                        "type": "string",
                        "maxLength": 500
                      }
                    },
                    "additionalProperties": false
                  },
                  "reference": {
                    "description": "Your own reference, up to 120 characters, or null to clear it.",
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 120
                  },
                  "couponId": {
                    "description": "A coupon to discount its invoices from now, or null to take the discount off.",
                    "type": [
                      "string",
                      "null"
                    ],
                    "pattern": "^cpn_[0-9a-z]{20,32}$"
                  },
                  "taxRateIds": {
                    "description": "The tax rates for its invoices from now; an empty list stops taxing them.",
                    "type": "array",
                    "items": {
                      "type": "string",
                      "pattern": "^txr_[0-9a-z]{20,32}$"
                    },
                    "maxItems": 5
                  },
                  "collectionMethod": {
                    "description": "How its invoices are collected from the next one: charge_automatically or send_invoice.",
                    "type": "string",
                    "enum": [
                      "charge_automatically",
                      "send_invoice"
                    ]
                  },
                  "daysUntilDue": {
                    "description": "For send_invoice: days from an invoice being sent to its due date, 0 to 365.",
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 365
                  }
                },
                "additionalProperties": false
              },
              "examples": {
                "default": {
                  "summary": "Move to another plan, invoiced now",
                  "value": {
                    "priceId": "price_w7k2x9c4q1m8v3r6t0ynhz5p",
                    "prorationBehavior": "always_invoice",
                    "prorationDate": "2026-10-16T04:12:31.000Z"
                  }
                },
                "pause": {
                  "summary": "Pause collection over the holidays",
                  "value": {
                    "pauseCollection": {
                      "behavior": "keep_as_draft",
                      "resumesAt": "2027-01-05T00:00:00.000Z"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Subscription"
                },
                "examples": {
                  "default": {
                    "summary": "Move to another plan, invoiced now",
                    "value": {
                      "object": "subscription",
                      "id": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                      "mode": "test",
                      "status": "active",
                      "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                      "price": {
                        "id": "price_w7k2x9c4q1m8v3r6t0ynhz5p",
                        "productName": "Gym and pool",
                        "unitAmountCents": 600000,
                        "interval": "month",
                        "intervalCount": 1
                      },
                      "quantity": 1,
                      "items": [
                        {
                          "id": "si_t4c9v2x7q1m6k8r3y0wnhz5p",
                          "price": {
                            "id": "price_w7k2x9c4q1m8v3r6t0ynhz5p",
                            "productName": "Gym and pool",
                            "unitAmountCents": 600000,
                            "interval": "month",
                            "intervalCount": 1
                          },
                          "quantity": 1
                        }
                      ],
                      "currentPeriodStart": "2026-10-01T04:12:31.000Z",
                      "currentPeriodEnd": "2026-11-01T04:12:31.000Z",
                      "billingCycleAnchor": "2026-10-01T04:12:31.000Z",
                      "cancelAtPeriodEnd": false,
                      "cancelAt": null,
                      "canceledAt": null,
                      "endedAt": null,
                      "cancelReason": null,
                      "cancellationDetails": {
                        "reason": null,
                        "feedback": null,
                        "comment": null
                      },
                      "trialStart": null,
                      "trialEnd": null,
                      "trialEndBehavior": "create_invoice",
                      "pauseCollection": null,
                      "discount": null,
                      "taxRateIds": [],
                      "subscriptionLinkId": null,
                      "collectionMethod": "charge_automatically",
                      "daysUntilDue": null,
                      "pendingUpdate": null,
                      "cardId": "card_g2a1rex14ff7qh2dc6j6qzmq",
                      "cardMissingSince": null,
                      "latestInvoiceId": "in_c4v9x2q7m1k8r3t6y0wnzhp5",
                      "checkoutUrl": null,
                      "reference": "member-1042",
                      "createdAt": "2026-10-01T04:12:31.000Z"
                    }
                  },
                  "pause": {
                    "summary": "Pause collection over the holidays",
                    "value": {
                      "object": "subscription",
                      "id": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                      "mode": "test",
                      "status": "active",
                      "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                      "price": {
                        "id": "price_m3v8q1x6c9k2r5t7y0wn4hzp",
                        "productName": "Gym membership",
                        "unitAmountCents": 450000,
                        "interval": "month",
                        "intervalCount": 1
                      },
                      "quantity": 1,
                      "items": [
                        {
                          "id": "si_t4c9v2x7q1m6k8r3y0wnhz5p",
                          "price": {
                            "id": "price_m3v8q1x6c9k2r5t7y0wn4hzp",
                            "productName": "Gym membership",
                            "unitAmountCents": 450000,
                            "interval": "month",
                            "intervalCount": 1
                          },
                          "quantity": 1
                        }
                      ],
                      "currentPeriodStart": "2026-10-01T04:12:31.000Z",
                      "currentPeriodEnd": "2026-11-01T04:12:31.000Z",
                      "billingCycleAnchor": "2026-10-01T04:12:31.000Z",
                      "cancelAtPeriodEnd": false,
                      "cancelAt": null,
                      "canceledAt": null,
                      "endedAt": null,
                      "cancelReason": null,
                      "cancellationDetails": {
                        "reason": null,
                        "feedback": null,
                        "comment": null
                      },
                      "trialStart": null,
                      "trialEnd": null,
                      "trialEndBehavior": "create_invoice",
                      "pauseCollection": {
                        "behavior": "keep_as_draft",
                        "resumesAt": "2027-01-05T00:00:00.000Z"
                      },
                      "discount": null,
                      "taxRateIds": [],
                      "subscriptionLinkId": null,
                      "collectionMethod": "charge_automatically",
                      "daysUntilDue": null,
                      "pendingUpdate": null,
                      "cardId": "card_g2a1rex14ff7qh2dc6j6qzmq",
                      "cardMissingSince": null,
                      "latestInvoiceId": "in_c4v9x2q7m1k8r3t6y0wnzhp5",
                      "checkoutUrl": null,
                      "reference": "member-1042",
                      "createdAt": "2026-10-01T04:12:31.000Z"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. A date is out of range, or the items would not go together: an unknown item, a price twice, two intervals, or none left. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              },
              {
                "reason": "billing_date_invalid",
                "docUrl": "https://payments.lk/developers/errors#billing_date_invalid"
              },
              {
                "reason": "items_invalid",
                "docUrl": "https://payments.lk/developers/errors#items_invalid"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No subscription with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. The subscription has ended, the change does not apply in its status (or a change already waits for its invoice), the card is not this customer's, a price is archived or in the other mode, or a coupon or tax rate cannot be used. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              },
              {
                "reason": "subscription_ended",
                "docUrl": "https://payments.lk/developers/errors#subscription_ended"
              },
              {
                "reason": "subscription_change_refused",
                "docUrl": "https://payments.lk/developers/errors#subscription_change_refused"
              },
              {
                "reason": "card_not_reusable",
                "docUrl": "https://payments.lk/developers/errors#card_not_reusable"
              },
              {
                "reason": "price_unavailable",
                "docUrl": "https://payments.lk/developers/errors#price_unavailable"
              },
              {
                "reason": "coupon_invalid",
                "docUrl": "https://payments.lk/developers/errors#coupon_invalid"
              },
              {
                "reason": "tax_rate_invalid",
                "docUrl": "https://payments.lk/developers/errors#tax_rate_invalid"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      }
    },
    "/v1/subscriptions/{id}/cancel": {
      "post": {
        "operationId": "cancelSubscription",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Cancel a subscription",
        "description": "Ends a subscription now (atPeriodEnd false, the default): its open invoices are voided and retries stop. Or at the end of the period that is paid for (atPeriodEnd true), which you can take back with resume until then. The customer is emailed when it ends.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The subscription's id, sub_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "sub_p6x1c8v3q9m2k7r4t0yhwz5n"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "example": "cancel-member-1042"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CancelSubscriptionRequest"
              },
              "example": {
                "atPeriodEnd": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Subscription"
                },
                "example": {
                  "object": "subscription",
                  "id": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "mode": "test",
                  "status": "canceled",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "price": {
                    "id": "price_m3v8q1x6c9k2r5t7y0wn4hzp",
                    "productName": "Gym membership",
                    "unitAmountCents": 450000,
                    "interval": "month",
                    "intervalCount": 1
                  },
                  "quantity": 1,
                  "items": [
                    {
                      "id": "si_t4c9v2x7q1m6k8r3y0wnhz5p",
                      "price": {
                        "id": "price_m3v8q1x6c9k2r5t7y0wn4hzp",
                        "productName": "Gym membership",
                        "unitAmountCents": 450000,
                        "interval": "month",
                        "intervalCount": 1
                      },
                      "quantity": 1
                    }
                  ],
                  "currentPeriodStart": "2026-10-01T04:12:31.000Z",
                  "currentPeriodEnd": "2026-11-01T04:12:31.000Z",
                  "billingCycleAnchor": "2026-10-01T04:12:31.000Z",
                  "cancelAtPeriodEnd": false,
                  "cancelAt": null,
                  "canceledAt": "2026-10-20T08:00:00.000Z",
                  "endedAt": "2026-10-20T08:00:00.000Z",
                  "cancelReason": "requested_by_merchant",
                  "cancellationDetails": {
                    "reason": "requested_by_merchant",
                    "feedback": "too_expensive",
                    "comment": "Moving to the branch closer to home."
                  },
                  "trialStart": null,
                  "trialEnd": null,
                  "trialEndBehavior": "create_invoice",
                  "pauseCollection": null,
                  "discount": null,
                  "taxRateIds": [],
                  "subscriptionLinkId": null,
                  "collectionMethod": "charge_automatically",
                  "daysUntilDue": null,
                  "pendingUpdate": null,
                  "cardId": "card_g2a1rex14ff7qh2dc6j6qzmq",
                  "cardMissingSince": null,
                  "latestInvoiceId": "in_c4v9x2q7m1k8r3t6y0wnzhp5",
                  "checkoutUrl": null,
                  "reference": "member-1042",
                  "createdAt": "2026-10-01T04:12:31.000Z"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No subscription with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. The subscription has already ended. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              },
              {
                "reason": "subscription_ended",
                "docUrl": "https://payments.lk/developers/errors#subscription_ended"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      }
    },
    "/v1/subscriptions/{id}/resume": {
      "post": {
        "operationId": "resumeSubscription",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Resume a subscription",
        "description": "Withdraws a cancellation set for the period's end or for a date, while it is still running. A paused subscription (its trial ended with no card) starts again with a new period from now, billed at once to the card now on file, and customer.subscription.resumed is sent. A subscription with neither is answered as it is.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The subscription's id, sub_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "sub_p6x1c8v3q9m2k7r4t0yhwz5n"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "example": "resume-member-1042"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Subscription"
                },
                "example": {
                  "object": "subscription",
                  "id": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "mode": "test",
                  "status": "active",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "price": {
                    "id": "price_m3v8q1x6c9k2r5t7y0wn4hzp",
                    "productName": "Gym membership",
                    "unitAmountCents": 450000,
                    "interval": "month",
                    "intervalCount": 1
                  },
                  "quantity": 1,
                  "items": [
                    {
                      "id": "si_t4c9v2x7q1m6k8r3y0wnhz5p",
                      "price": {
                        "id": "price_m3v8q1x6c9k2r5t7y0wn4hzp",
                        "productName": "Gym membership",
                        "unitAmountCents": 450000,
                        "interval": "month",
                        "intervalCount": 1
                      },
                      "quantity": 1
                    }
                  ],
                  "currentPeriodStart": "2026-10-01T04:12:31.000Z",
                  "currentPeriodEnd": "2026-11-01T04:12:31.000Z",
                  "billingCycleAnchor": "2026-10-01T04:12:31.000Z",
                  "cancelAtPeriodEnd": false,
                  "cancelAt": null,
                  "canceledAt": null,
                  "endedAt": null,
                  "cancelReason": null,
                  "cancellationDetails": {
                    "reason": null,
                    "feedback": null,
                    "comment": null
                  },
                  "trialStart": null,
                  "trialEnd": null,
                  "trialEndBehavior": "create_invoice",
                  "pauseCollection": null,
                  "discount": null,
                  "taxRateIds": [],
                  "subscriptionLinkId": null,
                  "collectionMethod": "charge_automatically",
                  "daysUntilDue": null,
                  "pendingUpdate": null,
                  "cardId": "card_g2a1rex14ff7qh2dc6j6qzmq",
                  "cardMissingSince": null,
                  "latestInvoiceId": "in_c4v9x2q7m1k8r3t6y0wnzhp5",
                  "checkoutUrl": null,
                  "reference": "member-1042",
                  "createdAt": "2026-10-01T04:12:31.000Z"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No subscription with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. The subscription has already ended, or it is paused and there is no card on file. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              },
              {
                "reason": "subscription_ended",
                "docUrl": "https://payments.lk/developers/errors#subscription_ended"
              },
              {
                "reason": "subscription_change_refused",
                "docUrl": "https://payments.lk/developers/errors#subscription_change_refused"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      }
    },
    "/v1/invoices": {
      "get": {
        "operationId": "listInvoices",
        "tags": [
          "Subscriptions"
        ],
        "summary": "List invoices",
        "description": "Your invoices in this key's mode, newest first. Filter by subscription, customer and status.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "How many to return, 1 to 100. Defaults to 25.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "The nextCursor of the page before. Leave it out for the first page.",
            "schema": {
              "type": "string",
              "pattern": "^in_[0-9a-z]{20,32}$"
            }
          },
          {
            "name": "subscriptionId",
            "in": "query",
            "required": false,
            "description": "Only this subscription's invoices.",
            "schema": {
              "type": "string",
              "pattern": "^sub_[0-9a-z]{20,32}$"
            },
            "example": "sub_p6x1c8v3q9m2k7r4t0yhwz5n"
          },
          {
            "name": "customerId",
            "in": "query",
            "required": false,
            "description": "Only this customer's invoices.",
            "schema": {
              "type": "string",
              "pattern": "^cus_[0-9a-z]{20,32}$"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Only invoices in this status.",
            "schema": {
              "type": "string",
              "enum": [
                "draft",
                "open",
                "paid",
                "void",
                "uncollectible"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "object": "invoice",
                      "id": "in_x7c2v9q4m1k6r8t3y0hwnzp5",
                      "mode": "test",
                      "number": "INV-000002",
                      "status": "open",
                      "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                      "subscriptionId": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                      "billingReason": "subscription_cycle",
                      "periodStart": "2026-11-01T04:12:31.000Z",
                      "periodEnd": "2026-12-01T04:12:31.000Z",
                      "lines": [
                        {
                          "description": "Gym membership, every month",
                          "quantity": 1,
                          "unitAmountCents": 450000,
                          "amountCents": 450000,
                          "periodStart": "2026-11-01T04:12:31.000Z",
                          "periodEnd": "2026-12-01T04:12:31.000Z",
                          "proration": false
                        }
                      ],
                      "subtotalCents": 450000,
                      "discountCents": 0,
                      "couponId": null,
                      "taxCents": 0,
                      "taxes": [],
                      "totalCents": 450000,
                      "creditAppliedCents": 0,
                      "amountDueCents": 450000,
                      "amountPaidCents": 0,
                      "creditNotesCents": 0,
                      "collectionMethod": "charge_automatically",
                      "dueDate": null,
                      "memo": null,
                      "currency": "LKR",
                      "attemptCount": 1,
                      "nextAttemptAt": "2026-11-02T03:30:00.000Z",
                      "lastFailure": "The processor refused the charge.",
                      "paidAt": null,
                      "hostedInvoiceUrl": "https://payments.lk/invoice/b3Nq8Zt2Xv6Lm1Kc9Rw4Hy7Pd5Gs0Jf2Ae4Uo7Ik9Mx",
                      "createdAt": "2026-11-01T04:13:00.000Z"
                    },
                    {
                      "object": "invoice",
                      "id": "in_c4v9x2q7m1k8r3t6y0wnzhp5",
                      "mode": "test",
                      "number": "INV-000001",
                      "status": "paid",
                      "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                      "subscriptionId": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                      "billingReason": "subscription_create",
                      "periodStart": "2026-10-01T04:12:31.000Z",
                      "periodEnd": "2026-11-01T04:12:31.000Z",
                      "lines": [
                        {
                          "description": "Gym membership, every month",
                          "quantity": 1,
                          "unitAmountCents": 450000,
                          "amountCents": 450000,
                          "periodStart": "2026-10-01T04:12:31.000Z",
                          "periodEnd": "2026-11-01T04:12:31.000Z",
                          "proration": false
                        }
                      ],
                      "subtotalCents": 450000,
                      "discountCents": 0,
                      "couponId": null,
                      "taxCents": 0,
                      "taxes": [],
                      "totalCents": 450000,
                      "creditAppliedCents": 0,
                      "amountDueCents": 450000,
                      "amountPaidCents": 450000,
                      "creditNotesCents": 0,
                      "collectionMethod": "charge_automatically",
                      "dueDate": null,
                      "memo": null,
                      "currency": "LKR",
                      "attemptCount": 0,
                      "nextAttemptAt": null,
                      "lastFailure": null,
                      "paidAt": "2026-10-01T04:15:02.000Z",
                      "hostedInvoiceUrl": "https://payments.lk/invoice/q7Vd2x9Kc4mZt1Wn8Rb5Hy3Lp6Gs0Jf2Ae4Uo7Ik9Nx",
                      "createdAt": "2026-10-01T04:12:31.000Z"
                    }
                  ],
                  "hasMore": false,
                  "nextCursor": null
                }
              }
            }
          },
          "400": {
            "description": "A query parameter is not valid; fields names each one. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed"
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:read",
        "x-key-kinds": [
          "secret"
        ]
      },
      "post": {
        "operationId": "createInvoice",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Create an invoice",
        "description": "A standalone invoice for a customer, not tied to a subscription: a draft whose lines are the customer's pending invoice items (make them with POST /v1/invoice_items first, or add them to the draft with its invoiceId). Finalise it with POST /v1/invoices/{id}/finalize: send_invoice (the default) numbers it and emails the customer its page, to pay by the due date; charge_automatically charges the card on file.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "example": "term-3-nimali"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customerId": {
                    "description": "The customer, one of yours in this key's mode. Their pending invoice items not for a subscription become its lines.",
                    "type": "string",
                    "pattern": "^cus_[0-9a-z]{20,32}$"
                  },
                  "collectionMethod": {
                    "description": "send_invoice (the default: emailed when finalised, to pay by its due date) or charge_automatically (the card on file is charged when finalised).",
                    "type": "string",
                    "enum": [
                      "charge_automatically",
                      "send_invoice"
                    ],
                    "default": "send_invoice"
                  },
                  "daysUntilDue": {
                    "description": "For send_invoice: days from sending to the due date, 0 to 365. Defaults to 30.",
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 365
                  },
                  "memo": {
                    "description": "A note printed on it, up to 500 characters.",
                    "type": "string",
                    "maxLength": 500
                  }
                },
                "required": [
                  "customerId"
                ],
                "additionalProperties": false
              },
              "example": {
                "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                "collectionMethod": "send_invoice",
                "daysUntilDue": 30,
                "memo": "Third term, grade 10"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Invoice"
                },
                "example": {
                  "object": "invoice",
                  "id": "in_s5v1x8c3q9m2k7r4t0yhwn6z",
                  "mode": "test",
                  "number": null,
                  "status": "draft",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "subscriptionId": null,
                  "billingReason": "manual",
                  "periodStart": null,
                  "periodEnd": null,
                  "lines": [
                    {
                      "description": "Grade 10 maths, third term",
                      "quantity": 1,
                      "unitAmountCents": 1800000,
                      "amountCents": 1800000,
                      "periodStart": null,
                      "periodEnd": null,
                      "proration": false
                    }
                  ],
                  "subtotalCents": 1800000,
                  "discountCents": 0,
                  "couponId": null,
                  "taxCents": 0,
                  "taxes": [],
                  "totalCents": 1800000,
                  "creditAppliedCents": 0,
                  "amountDueCents": 1800000,
                  "amountPaidCents": 0,
                  "creditNotesCents": 0,
                  "collectionMethod": "send_invoice",
                  "dueDate": null,
                  "memo": "Third term, grade 10",
                  "currency": "LKR",
                  "attemptCount": 0,
                  "nextAttemptAt": null,
                  "lastFailure": null,
                  "paidAt": null,
                  "hostedInvoiceUrl": null,
                  "createdAt": "2026-10-01T08:00:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No customer with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      }
    },
    "/v1/invoices/{id}": {
      "get": {
        "operationId": "retrieveInvoice",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Retrieve an invoice",
        "description": "One invoice, with its lines and where its collection stands.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The invoice's id, in_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "in_c4v9x2q7m1k8r3t6y0wnzhp5"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Invoice"
                },
                "example": {
                  "object": "invoice",
                  "id": "in_c4v9x2q7m1k8r3t6y0wnzhp5",
                  "mode": "test",
                  "number": "INV-000001",
                  "status": "paid",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "subscriptionId": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "billingReason": "subscription_create",
                  "periodStart": "2026-10-01T04:12:31.000Z",
                  "periodEnd": "2026-11-01T04:12:31.000Z",
                  "lines": [
                    {
                      "description": "Gym membership, every month",
                      "quantity": 1,
                      "unitAmountCents": 450000,
                      "amountCents": 450000,
                      "periodStart": "2026-10-01T04:12:31.000Z",
                      "periodEnd": "2026-11-01T04:12:31.000Z",
                      "proration": false
                    }
                  ],
                  "subtotalCents": 450000,
                  "discountCents": 0,
                  "couponId": null,
                  "taxCents": 0,
                  "taxes": [],
                  "totalCents": 450000,
                  "creditAppliedCents": 0,
                  "amountDueCents": 450000,
                  "amountPaidCents": 450000,
                  "creditNotesCents": 0,
                  "collectionMethod": "charge_automatically",
                  "dueDate": null,
                  "memo": null,
                  "currency": "LKR",
                  "attemptCount": 0,
                  "nextAttemptAt": null,
                  "lastFailure": null,
                  "paidAt": "2026-10-01T04:15:02.000Z",
                  "hostedInvoiceUrl": "https://payments.lk/invoice/q7Vd2x9Kc4mZt1Wn8Rb5Hy3Lp6Gs0Jf2Ae4Uo7Ik9Nx",
                  "createdAt": "2026-10-01T04:12:31.000Z"
                }
              }
            }
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No invoice with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:read",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/invoices/upcoming": {
      "get": {
        "operationId": "upcomingInvoice",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Preview the next invoice",
        "description": "The invoice a subscription's next renewal will make, as it stands now: its period and its lines. Nothing is written, and the preview has no id of its own. Not found for a subscription that will not renew.",
        "parameters": [
          {
            "name": "subscriptionId",
            "in": "query",
            "required": true,
            "description": "The subscription whose next invoice to preview.",
            "schema": {
              "type": "string",
              "pattern": "^sub_[0-9a-z]{20,32}$"
            },
            "example": "sub_p6x1c8v3q9m2k7r4t0yhwz5n"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Invoice"
                },
                "example": {
                  "object": "invoice",
                  "id": "upcoming_sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "mode": "test",
                  "number": null,
                  "status": "draft",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "subscriptionId": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "billingReason": "subscription_cycle",
                  "periodStart": "2026-11-01T04:12:31.000Z",
                  "periodEnd": "2026-12-01T04:12:31.000Z",
                  "lines": [
                    {
                      "description": "Gym membership, every month",
                      "quantity": 1,
                      "unitAmountCents": 450000,
                      "amountCents": 450000,
                      "periodStart": "2026-11-01T04:12:31.000Z",
                      "periodEnd": "2026-12-01T04:12:31.000Z",
                      "proration": false
                    }
                  ],
                  "subtotalCents": 450000,
                  "discountCents": 0,
                  "couponId": null,
                  "taxCents": 0,
                  "taxes": [],
                  "totalCents": 450000,
                  "creditAppliedCents": 0,
                  "amountDueCents": 450000,
                  "amountPaidCents": 0,
                  "creditNotesCents": 0,
                  "collectionMethod": "charge_automatically",
                  "dueDate": null,
                  "memo": null,
                  "currency": "LKR",
                  "attemptCount": 0,
                  "nextAttemptAt": null,
                  "lastFailure": null,
                  "paidAt": null,
                  "hostedInvoiceUrl": null,
                  "createdAt": "2026-10-29T04:13:00.000Z"
                }
              }
            }
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No subscription with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:read",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/invoices/preview": {
      "post": {
        "operationId": "previewInvoice",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Preview a change",
        "description": "The invoice a change to a subscription would make, without making it: with always_invoice (or a change of interval) the invoice made at once, with its proration lines; otherwise the next renewal with the new items and the prorations it would carry. Send the same prorationDate with the update so the amounts match. Nothing is written, and the preview has no id of its own. A read: no Idempotency-Key.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "subscriptionId": {
                    "description": "The subscription the change is for.",
                    "type": "string",
                    "pattern": "^sub_[0-9a-z]{20,32}$"
                  },
                  "items": {
                    "description": "The item changes to preview, as the update takes them.",
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "description": "The item to change, from the subscription's items.",
                          "type": "string",
                          "pattern": "^si_[0-9a-z]{20,32}$"
                        },
                        "priceId": {
                          "description": "Its new price, or the price of a new item.",
                          "type": "string",
                          "pattern": "^price_[0-9a-z]{20,32}$"
                        },
                        "quantity": {
                          "description": "Its new quantity, 1 to 10000.",
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 10000
                        },
                        "deleted": {
                          "description": "True removes the item.",
                          "type": "boolean",
                          "const": true
                        }
                      },
                      "additionalProperties": false
                    },
                    "minItems": 1,
                    "maxItems": 10
                  },
                  "priceId": {
                    "description": "For a subscription of one item: its new price.",
                    "type": "string",
                    "pattern": "^price_[0-9a-z]{20,32}$"
                  },
                  "quantity": {
                    "description": "For a subscription of one item: its new quantity, 1 to 10000.",
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 10000
                  },
                  "prorationBehavior": {
                    "description": "create_prorations (the default), always_invoice or none, as the update will send it.",
                    "type": "string",
                    "enum": [
                      "create_prorations",
                      "always_invoice",
                      "none"
                    ]
                  },
                  "prorationDate": {
                    "description": "Price the change as at this time, ISO 8601; defaults to now. Send the same time with the update.",
                    "type": "string",
                    "format": "date-time"
                  }
                },
                "required": [
                  "subscriptionId"
                ],
                "additionalProperties": false
              },
              "example": {
                "subscriptionId": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                "priceId": "price_w7k2x9c4q1m8v3r6t0ynhz5p",
                "prorationBehavior": "always_invoice",
                "prorationDate": "2026-10-16T04:12:31.000Z"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Invoice"
                },
                "example": {
                  "object": "invoice",
                  "id": "upcoming_sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "mode": "test",
                  "number": null,
                  "status": "draft",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "subscriptionId": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "billingReason": "subscription_update",
                  "periodStart": "2026-10-16T04:12:31.000Z",
                  "periodEnd": "2026-11-01T04:12:31.000Z",
                  "lines": [
                    {
                      "description": "Unused time on Gym membership from 16 October",
                      "quantity": 1,
                      "unitAmountCents": -239063,
                      "amountCents": -239063,
                      "periodStart": "2026-10-16T04:12:31.000Z",
                      "periodEnd": "2026-11-01T04:12:31.000Z",
                      "proration": true
                    },
                    {
                      "description": "Remaining time on Gym and pool from 16 October",
                      "quantity": 1,
                      "unitAmountCents": 318750,
                      "amountCents": 318750,
                      "periodStart": "2026-10-16T04:12:31.000Z",
                      "periodEnd": "2026-11-01T04:12:31.000Z",
                      "proration": true
                    }
                  ],
                  "subtotalCents": 79687,
                  "discountCents": 0,
                  "couponId": null,
                  "taxCents": 0,
                  "taxes": [],
                  "totalCents": 79687,
                  "creditAppliedCents": 0,
                  "amountDueCents": 79687,
                  "amountPaidCents": 0,
                  "creditNotesCents": 0,
                  "collectionMethod": "charge_automatically",
                  "dueDate": null,
                  "memo": null,
                  "currency": "LKR",
                  "attemptCount": 0,
                  "nextAttemptAt": null,
                  "lastFailure": null,
                  "paidAt": null,
                  "hostedInvoiceUrl": null,
                  "createdAt": "2026-10-16T04:12:31.000Z"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The proration date is outside the period, or the items would not go together. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "billing_date_invalid",
                "docUrl": "https://payments.lk/developers/errors#billing_date_invalid"
              },
              {
                "reason": "items_invalid",
                "docUrl": "https://payments.lk/developers/errors#items_invalid"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No subscription with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "409": {
            "description": "The subscription has ended, or a price is archived or in the other mode. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "subscription_ended",
                "docUrl": "https://payments.lk/developers/errors#subscription_ended"
              },
              {
                "reason": "price_unavailable",
                "docUrl": "https://payments.lk/developers/errors#price_unavailable"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:read",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/invoices/{id}/send": {
      "post": {
        "operationId": "sendInvoice",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Send an invoice again",
        "description": "Emails an open invoice collected by sending it to the customer again, with its page to pay on. invoice.sent is sent. Reminders go out by themselves three days before the due date and when it passes.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The invoice's id, in_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "in_s5v1x8c3q9m2k7r4t0yhwn6z"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "example": "term-3-nimali-resend"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Invoice"
                },
                "example": {
                  "object": "invoice",
                  "id": "in_s5v1x8c3q9m2k7r4t0yhwn6z",
                  "mode": "test",
                  "number": "INV-000014",
                  "status": "open",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "subscriptionId": null,
                  "billingReason": "manual",
                  "periodStart": null,
                  "periodEnd": null,
                  "lines": [
                    {
                      "description": "Grade 10 maths, third term",
                      "quantity": 1,
                      "unitAmountCents": 1800000,
                      "amountCents": 1800000,
                      "periodStart": null,
                      "periodEnd": null,
                      "proration": false
                    }
                  ],
                  "subtotalCents": 1800000,
                  "discountCents": 0,
                  "couponId": null,
                  "taxCents": 0,
                  "taxes": [],
                  "totalCents": 1800000,
                  "creditAppliedCents": 0,
                  "amountDueCents": 1800000,
                  "amountPaidCents": 0,
                  "creditNotesCents": 0,
                  "collectionMethod": "send_invoice",
                  "dueDate": "2026-10-31T18:29:59.000Z",
                  "memo": "Third term, grade 10",
                  "currency": "LKR",
                  "attemptCount": 0,
                  "nextAttemptAt": null,
                  "lastFailure": null,
                  "paidAt": null,
                  "hostedInvoiceUrl": "https://payments.lk/invoice/r2Vd9x4Kc7mZt3Wn1Rb8Hy6Lp5Gs0Jf4Ae2Uo9Ik7Nx",
                  "createdAt": "2026-10-01T08:00:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No invoice with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. The invoice is not open, or it is charged to the card on file rather than sent. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              },
              {
                "reason": "invoice_not_open",
                "docUrl": "https://payments.lk/developers/errors#invoice_not_open"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      }
    },
    "/v1/credit_notes": {
      "post": {
        "operationId": "createCreditNote",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Create a credit note",
        "description": "Takes an amount off an invoice, as Stripe's credit notes. On an open invoice it lowers what is due (all of it pays the invoice). On a paid one it is refunded to the card the invoice was paid with (refund true), or added to the customer's credit balance for their next invoices. Numbered CN-000001 in your own sequence; credit_note.created is sent.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "example": "cn-october-closure"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "invoiceId": {
                    "description": "The invoice, open or paid.",
                    "type": "string",
                    "pattern": "^in_[0-9a-z]{20,32}$"
                  },
                  "amountCents": {
                    "description": "How much, in cents: at most what is due on an open invoice, or what was paid and not yet credited on a paid one.",
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100000000
                  },
                  "reason": {
                    "description": "duplicate, fraudulent, order_change or product_unsatisfactory.",
                    "type": "string",
                    "enum": [
                      "duplicate",
                      "fraudulent",
                      "order_change",
                      "product_unsatisfactory"
                    ]
                  },
                  "memo": {
                    "description": "A note, up to 500 characters.",
                    "type": "string",
                    "maxLength": 500
                  },
                  "refund": {
                    "description": "On a paid invoice: true refunds the amount to the card it was paid with; false (the default) adds it to the customer's credit balance for their next invoices.",
                    "type": "boolean",
                    "default": false
                  }
                },
                "required": [
                  "invoiceId",
                  "amountCents"
                ],
                "additionalProperties": false
              },
              "example": {
                "invoiceId": "in_c4v9x2q7m1k8r3t6y0wnzhp5",
                "amountCents": 150000,
                "reason": "order_change",
                "memo": "Closed for a week in October"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreditNote"
                },
                "example": {
                  "object": "credit_note",
                  "id": "cn_r7v2x9c4q1m8k3t6y0wnhz5p",
                  "mode": "test",
                  "invoiceId": "in_c4v9x2q7m1k8r3t6y0wnzhp5",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "number": "CN-000001",
                  "amountCents": 150000,
                  "reason": "order_change",
                  "memo": "Closed for a week in October",
                  "amountDueReducedCents": 0,
                  "refundedCents": 0,
                  "creditedToBalanceCents": 150000,
                  "refundId": null,
                  "createdAt": "2026-10-20T08:00:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. More than the invoice still has to give. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              },
              {
                "reason": "amount",
                "docUrl": "https://payments.lk/developers/errors#amount"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No invoice with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. The invoice is neither open nor paid, or it was not paid by card here and a refund was asked for. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              },
              {
                "reason": "invoice_not_open",
                "docUrl": "https://payments.lk/developers/errors#invoice_not_open"
              },
              {
                "reason": "not_refundable",
                "docUrl": "https://payments.lk/developers/errors#not_refundable"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      },
      "get": {
        "operationId": "listCreditNotes",
        "tags": [
          "Subscriptions"
        ],
        "summary": "List credit notes",
        "description": "Your credit notes in this key's mode, newest first. Filter by invoice.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "How many to return, 1 to 100. Defaults to 25.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "The nextCursor of the page before. Leave it out for the first page.",
            "schema": {
              "type": "string",
              "pattern": "^cn_[0-9a-z]{20,32}$"
            }
          },
          {
            "name": "invoiceId",
            "in": "query",
            "required": false,
            "description": "Only this invoice's credit notes.",
            "schema": {
              "type": "string",
              "pattern": "^in_[0-9a-z]{20,32}$"
            },
            "example": "in_c4v9x2q7m1k8r3t6y0wnzhp5"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreditNoteList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "object": "credit_note",
                      "id": "cn_r7v2x9c4q1m8k3t6y0wnhz5p",
                      "mode": "test",
                      "invoiceId": "in_c4v9x2q7m1k8r3t6y0wnzhp5",
                      "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                      "number": "CN-000001",
                      "amountCents": 150000,
                      "reason": "order_change",
                      "memo": "Closed for a week in October",
                      "amountDueReducedCents": 0,
                      "refundedCents": 0,
                      "creditedToBalanceCents": 150000,
                      "refundId": null,
                      "createdAt": "2026-10-20T08:00:00.000Z"
                    }
                  ],
                  "hasMore": false,
                  "nextCursor": null
                }
              }
            }
          },
          "400": {
            "description": "A query parameter is not valid; fields names each one. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed"
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:read",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/credit_notes/{id}": {
      "get": {
        "operationId": "retrieveCreditNote",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Retrieve a credit note",
        "description": "One credit note.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The credit note's id, cn_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "cn_r7v2x9c4q1m8k3t6y0wnhz5p"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreditNote"
                },
                "example": {
                  "object": "credit_note",
                  "id": "cn_r7v2x9c4q1m8k3t6y0wnhz5p",
                  "mode": "test",
                  "invoiceId": "in_c4v9x2q7m1k8r3t6y0wnzhp5",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "number": "CN-000001",
                  "amountCents": 150000,
                  "reason": "order_change",
                  "memo": "Closed for a week in October",
                  "amountDueReducedCents": 0,
                  "refundedCents": 0,
                  "creditedToBalanceCents": 150000,
                  "refundId": null,
                  "createdAt": "2026-10-20T08:00:00.000Z"
                }
              }
            }
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No credit note with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:read",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/invoices/{id}/pay": {
      "post": {
        "operationId": "payInvoice",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Charge an invoice now",
        "description": "Charges an open invoice to the card on file (the subscription's, or the customer's default) on the worker's next pass, within a minute, whatever the retry schedule says. The outcome arrives as invoice.paid or invoice.payment_failed. A customer without a card pays on the invoice's hostedInvoiceUrl instead.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The invoice's id, in_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "in_x7c2v9q4m1k6r8t3y0hwnzp5"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "example": "pay-inv-000002"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Invoice"
                },
                "example": {
                  "object": "invoice",
                  "id": "in_x7c2v9q4m1k6r8t3y0hwnzp5",
                  "mode": "test",
                  "number": "INV-000002",
                  "status": "open",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "subscriptionId": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "billingReason": "subscription_cycle",
                  "periodStart": "2026-11-01T04:12:31.000Z",
                  "periodEnd": "2026-12-01T04:12:31.000Z",
                  "lines": [
                    {
                      "description": "Gym membership, every month",
                      "quantity": 1,
                      "unitAmountCents": 450000,
                      "amountCents": 450000,
                      "periodStart": "2026-11-01T04:12:31.000Z",
                      "periodEnd": "2026-12-01T04:12:31.000Z",
                      "proration": false
                    }
                  ],
                  "subtotalCents": 450000,
                  "discountCents": 0,
                  "couponId": null,
                  "taxCents": 0,
                  "taxes": [],
                  "totalCents": 450000,
                  "creditAppliedCents": 0,
                  "amountDueCents": 450000,
                  "amountPaidCents": 0,
                  "creditNotesCents": 0,
                  "collectionMethod": "charge_automatically",
                  "dueDate": null,
                  "memo": null,
                  "currency": "LKR",
                  "attemptCount": 1,
                  "nextAttemptAt": "2026-11-01T09:40:00.000Z",
                  "lastFailure": "The processor refused the charge.",
                  "paidAt": null,
                  "hostedInvoiceUrl": "https://payments.lk/invoice/b3Nq8Zt2Xv6Lm1Kc9Rw4Hy7Pd5Gs0Jf2Ae4Uo7Ik9Mx",
                  "createdAt": "2026-11-01T04:13:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No invoice with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. The invoice is not open, a charge of it is still with the processor, or there is no card to charge. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              },
              {
                "reason": "invoice_not_open",
                "docUrl": "https://payments.lk/developers/errors#invoice_not_open"
              },
              {
                "reason": "invoice_payment_pending",
                "docUrl": "https://payments.lk/developers/errors#invoice_payment_pending"
              },
              {
                "reason": "no_card_on_file",
                "docUrl": "https://payments.lk/developers/errors#no_card_on_file"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      }
    },
    "/v1/invoices/{id}/finalize": {
      "post": {
        "operationId": "finalizeInvoice",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Finalise a draft now",
        "description": "Ends a renewal's draft window early: the invoice is numbered, gets its hosted page, and is charged to the card on file on the worker's next pass (an unpaid subscription's invoice is left for the customer to pay).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The invoice's id, in_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "in_x7c2v9q4m1k6r8t3y0hwnzp5"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "example": "finalize-inv-draft"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Invoice"
                },
                "example": {
                  "object": "invoice",
                  "id": "in_x7c2v9q4m1k6r8t3y0hwnzp5",
                  "mode": "test",
                  "number": "INV-000002",
                  "status": "open",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "subscriptionId": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "billingReason": "subscription_cycle",
                  "periodStart": "2026-11-01T04:12:31.000Z",
                  "periodEnd": "2026-12-01T04:12:31.000Z",
                  "lines": [
                    {
                      "description": "Gym membership, every month",
                      "quantity": 1,
                      "unitAmountCents": 450000,
                      "amountCents": 450000,
                      "periodStart": "2026-11-01T04:12:31.000Z",
                      "periodEnd": "2026-12-01T04:12:31.000Z",
                      "proration": false
                    }
                  ],
                  "subtotalCents": 450000,
                  "discountCents": 0,
                  "couponId": null,
                  "taxCents": 0,
                  "taxes": [],
                  "totalCents": 450000,
                  "creditAppliedCents": 0,
                  "amountDueCents": 450000,
                  "amountPaidCents": 0,
                  "creditNotesCents": 0,
                  "collectionMethod": "charge_automatically",
                  "dueDate": null,
                  "memo": null,
                  "currency": "LKR",
                  "attemptCount": 0,
                  "nextAttemptAt": "2026-11-01T04:20:00.000Z",
                  "lastFailure": null,
                  "paidAt": null,
                  "hostedInvoiceUrl": "https://payments.lk/invoice/b3Nq8Zt2Xv6Lm1Kc9Rw4Hy7Pd5Gs0Jf2Ae4Uo7Ik9Mx",
                  "createdAt": "2026-11-01T04:13:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No invoice with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. The invoice is not a draft. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              },
              {
                "reason": "invoice_not_open",
                "docUrl": "https://payments.lk/developers/errors#invoice_not_open"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      }
    },
    "/v1/invoices/{id}/void": {
      "post": {
        "operationId": "voidInvoice",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Void an invoice",
        "description": "Cancels a draft or open invoice: nothing is owed on it and nothing more is tried. A past due or unpaid subscription with nothing else open is active again. Voiding a subscription's first invoice before it is paid ends the subscription as incomplete_expired.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The invoice's id, in_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "in_x7c2v9q4m1k6r8t3y0hwnzp5"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "example": "void-inv-000002"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Invoice"
                },
                "example": {
                  "object": "invoice",
                  "id": "in_x7c2v9q4m1k6r8t3y0hwnzp5",
                  "mode": "test",
                  "number": "INV-000002",
                  "status": "void",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "subscriptionId": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "billingReason": "subscription_cycle",
                  "periodStart": "2026-11-01T04:12:31.000Z",
                  "periodEnd": "2026-12-01T04:12:31.000Z",
                  "lines": [
                    {
                      "description": "Gym membership, every month",
                      "quantity": 1,
                      "unitAmountCents": 450000,
                      "amountCents": 450000,
                      "periodStart": "2026-11-01T04:12:31.000Z",
                      "periodEnd": "2026-12-01T04:12:31.000Z",
                      "proration": false
                    }
                  ],
                  "subtotalCents": 450000,
                  "discountCents": 0,
                  "couponId": null,
                  "taxCents": 0,
                  "taxes": [],
                  "totalCents": 450000,
                  "creditAppliedCents": 0,
                  "amountDueCents": 450000,
                  "amountPaidCents": 0,
                  "creditNotesCents": 0,
                  "collectionMethod": "charge_automatically",
                  "dueDate": null,
                  "memo": null,
                  "currency": "LKR",
                  "attemptCount": 1,
                  "nextAttemptAt": null,
                  "lastFailure": "The processor refused the charge.",
                  "paidAt": null,
                  "hostedInvoiceUrl": "https://payments.lk/invoice/b3Nq8Zt2Xv6Lm1Kc9Rw4Hy7Pd5Gs0Jf2Ae4Uo7Ik9Mx",
                  "createdAt": "2026-11-01T04:13:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No invoice with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. The invoice is paid, void or uncollectible already, or a charge of it is still with the processor. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              },
              {
                "reason": "invoice_not_open",
                "docUrl": "https://payments.lk/developers/errors#invoice_not_open"
              },
              {
                "reason": "invoice_payment_pending",
                "docUrl": "https://payments.lk/developers/errors#invoice_payment_pending"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      }
    },
    "/v1/invoices/{id}/mark_uncollectible": {
      "post": {
        "operationId": "markInvoiceUncollectible",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Write an invoice off",
        "description": "Marks an open invoice uncollectible: it was owed, and will never be tried again. A past due or unpaid subscription with nothing else open is active again.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The invoice's id, in_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "in_x7c2v9q4m1k6r8t3y0hwnzp5"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "example": "writeoff-inv-000002"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Invoice"
                },
                "example": {
                  "object": "invoice",
                  "id": "in_x7c2v9q4m1k6r8t3y0hwnzp5",
                  "mode": "test",
                  "number": "INV-000002",
                  "status": "uncollectible",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "subscriptionId": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "billingReason": "subscription_cycle",
                  "periodStart": "2026-11-01T04:12:31.000Z",
                  "periodEnd": "2026-12-01T04:12:31.000Z",
                  "lines": [
                    {
                      "description": "Gym membership, every month",
                      "quantity": 1,
                      "unitAmountCents": 450000,
                      "amountCents": 450000,
                      "periodStart": "2026-11-01T04:12:31.000Z",
                      "periodEnd": "2026-12-01T04:12:31.000Z",
                      "proration": false
                    }
                  ],
                  "subtotalCents": 450000,
                  "discountCents": 0,
                  "couponId": null,
                  "taxCents": 0,
                  "taxes": [],
                  "totalCents": 450000,
                  "creditAppliedCents": 0,
                  "amountDueCents": 450000,
                  "amountPaidCents": 0,
                  "creditNotesCents": 0,
                  "collectionMethod": "charge_automatically",
                  "dueDate": null,
                  "memo": null,
                  "currency": "LKR",
                  "attemptCount": 1,
                  "nextAttemptAt": null,
                  "lastFailure": "The processor refused the charge.",
                  "paidAt": null,
                  "hostedInvoiceUrl": "https://payments.lk/invoice/b3Nq8Zt2Xv6Lm1Kc9Rw4Hy7Pd5Gs0Jf2Ae4Uo7Ik9Mx",
                  "createdAt": "2026-11-01T04:13:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No invoice with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. The invoice is not open, or a charge of it is still with the processor. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              },
              {
                "reason": "invoice_not_open",
                "docUrl": "https://payments.lk/developers/errors#invoice_not_open"
              },
              {
                "reason": "invoice_payment_pending",
                "docUrl": "https://payments.lk/developers/errors#invoice_payment_pending"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      }
    },
    "/v1/coupons": {
      "post": {
        "operationId": "createCoupon",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Create a coupon",
        "description": "A discount for subscriptions: percent or amount off, for their next invoice (once), some months (repeating) or for as long as they run (forever). Put it on a subscription with couponId.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "example": "coupon-new-year-2027"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "description": "Its name, 1 to 80 characters.",
                    "type": "string",
                    "maxLength": 80,
                    "minLength": 1
                  },
                  "percentOffBps": {
                    "description": "Basis points off, 1 to 10000 (2000 is 20%). Send this or amountOffCents.",
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 10000
                  },
                  "amountOffCents": {
                    "description": "Cents off each invoice it discounts, from 100. Send this or percentOffBps.",
                    "type": "integer",
                    "minimum": 100,
                    "maximum": 100000000
                  },
                  "duration": {
                    "description": "once, repeating or forever.",
                    "type": "string",
                    "enum": [
                      "once",
                      "repeating",
                      "forever"
                    ]
                  },
                  "durationInMonths": {
                    "description": "For repeating: how many months, 1 to 36.",
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 36
                  },
                  "maxRedemptions": {
                    "description": "How many subscriptions may take it.",
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 1000000
                  },
                  "redeemBy": {
                    "description": "The last time a subscription may take it, ISO 8601.",
                    "type": "string",
                    "format": "date-time"
                  },
                  "code": {
                    "description": "A code customers type on a subscription link, or in the customer portal where you allow it, to take this coupon: 3 to 24 letters, digits, dashes or underscores, kept in upper case, unique in the mode.",
                    "type": "string",
                    "pattern": "^[A-Z0-9_-]{3,24}$"
                  }
                },
                "required": [
                  "name",
                  "duration"
                ],
                "additionalProperties": false
              },
              "example": {
                "name": "New year, 20% off for 3 months",
                "percentOffBps": 2000,
                "duration": "repeating",
                "durationInMonths": 3,
                "maxRedemptions": 100,
                "redeemBy": "2027-01-31T18:30:00.000Z"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Coupon"
                },
                "example": {
                  "object": "coupon",
                  "id": "cpn_n5v2x8c1q7m3k9r4t0yhwz6p",
                  "mode": "test",
                  "name": "New year, 20% off for 3 months",
                  "percentOffBps": 2000,
                  "amountOffCents": null,
                  "duration": "repeating",
                  "durationInMonths": 3,
                  "maxRedemptions": 100,
                  "timesRedeemed": 0,
                  "redeemBy": "2027-01-31T18:30:00.000Z",
                  "active": true,
                  "code": "NEWYEAR20",
                  "createdAt": "2026-09-25T08:00:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. redeemBy has passed. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              },
              {
                "reason": "billing_date_invalid",
                "docUrl": "https://payments.lk/developers/errors#billing_date_invalid"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      },
      "get": {
        "operationId": "listCoupons",
        "tags": [
          "Subscriptions"
        ],
        "summary": "List coupons",
        "description": "Your coupons in this key's mode, newest first.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "How many to return, 1 to 100. Defaults to 25.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "The nextCursor of the page before. Leave it out for the first page.",
            "schema": {
              "type": "string",
              "pattern": "^cpn_[0-9a-z]{20,32}$"
            }
          },
          {
            "name": "active",
            "in": "query",
            "required": false,
            "description": "true for coupons taking new subscriptions, false for archived ones.",
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            },
            "example": "true"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CouponList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "object": "coupon",
                      "id": "cpn_n5v2x8c1q7m3k9r4t0yhwz6p",
                      "mode": "test",
                      "name": "New year, 20% off for 3 months",
                      "percentOffBps": 2000,
                      "amountOffCents": null,
                      "duration": "repeating",
                      "durationInMonths": 3,
                      "maxRedemptions": 100,
                      "timesRedeemed": 1,
                      "redeemBy": "2027-01-31T18:30:00.000Z",
                      "active": true,
                      "code": "NEWYEAR20",
                      "createdAt": "2026-09-25T08:00:00.000Z"
                    }
                  ],
                  "hasMore": false,
                  "nextCursor": null
                }
              }
            }
          },
          "400": {
            "description": "A query parameter is not valid; fields names each one. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed"
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:read",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/coupons/{id}": {
      "get": {
        "operationId": "retrieveCoupon",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Retrieve a coupon",
        "description": "One coupon, with how many subscriptions have taken it.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The coupon's id, cpn_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "cpn_n5v2x8c1q7m3k9r4t0yhwz6p"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Coupon"
                },
                "example": {
                  "object": "coupon",
                  "id": "cpn_n5v2x8c1q7m3k9r4t0yhwz6p",
                  "mode": "test",
                  "name": "New year, 20% off for 3 months",
                  "percentOffBps": 2000,
                  "amountOffCents": null,
                  "duration": "repeating",
                  "durationInMonths": 3,
                  "maxRedemptions": 100,
                  "timesRedeemed": 1,
                  "redeemBy": "2027-01-31T18:30:00.000Z",
                  "active": true,
                  "code": "NEWYEAR20",
                  "createdAt": "2026-09-25T08:00:00.000Z"
                }
              }
            }
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No coupon with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:read",
        "x-key-kinds": [
          "secret"
        ]
      },
      "delete": {
        "operationId": "archiveCoupon",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Archive a coupon",
        "description": "Stops new subscriptions taking it. Subscriptions that have it keep their discount, as Stripe's do.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The coupon's id, cpn_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "cpn_n5v2x8c1q7m3k9r4t0yhwz6p"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Coupon"
                },
                "example": {
                  "object": "coupon",
                  "id": "cpn_n5v2x8c1q7m3k9r4t0yhwz6p",
                  "mode": "test",
                  "name": "New year, 20% off for 3 months",
                  "percentOffBps": 2000,
                  "amountOffCents": null,
                  "duration": "repeating",
                  "durationInMonths": 3,
                  "maxRedemptions": 100,
                  "timesRedeemed": 1,
                  "redeemBy": "2027-01-31T18:30:00.000Z",
                  "active": false,
                  "code": "NEWYEAR20",
                  "createdAt": "2026-09-25T08:00:00.000Z"
                }
              }
            }
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No coupon with this id for this key; mode_mismatch when it exists in the other mode. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found",
            "x-error-reasons": [
              {
                "reason": "mode_mismatch",
                "docUrl": "https://payments.lk/developers/errors#mode_mismatch"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/tax_rates": {
      "post": {
        "operationId": "createTaxRate",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Create a tax rate",
        "description": "A tax you charge on invoices, such as VAT 18% or SSCL 2.5%, added on top or included in your prices. Put it on a subscription with taxRateIds.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "example": "tax-vat-18"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "displayName": {
                    "description": "Its name on invoices, 1 to 40 characters, such as VAT.",
                    "type": "string",
                    "maxLength": 40,
                    "minLength": 1
                  },
                  "description": {
                    "description": "A line about it, up to 120 characters.",
                    "type": "string",
                    "maxLength": 120
                  },
                  "percentageBps": {
                    "description": "The rate in basis points, 0 to 5000: 1800 is 18%.",
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 5000
                  },
                  "inclusive": {
                    "description": "True when your prices already include it. Defaults to false: added on top.",
                    "type": "boolean",
                    "default": false
                  }
                },
                "required": [
                  "displayName",
                  "percentageBps"
                ],
                "additionalProperties": false
              },
              "example": {
                "displayName": "VAT",
                "description": "Value added tax",
                "percentageBps": 1800,
                "inclusive": false
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaxRate"
                },
                "example": {
                  "object": "tax_rate",
                  "id": "txr_v1x8c3q6m2k9r5t7y0wnhz4p",
                  "mode": "test",
                  "displayName": "VAT",
                  "description": "Value added tax",
                  "percentageBps": 1800,
                  "inclusive": false,
                  "active": true,
                  "createdAt": "2026-09-25T08:00:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      },
      "get": {
        "operationId": "listTaxRates",
        "tags": [
          "Subscriptions"
        ],
        "summary": "List tax rates",
        "description": "Your tax rates in this key's mode, newest first.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "How many to return, 1 to 100. Defaults to 25.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "The nextCursor of the page before. Leave it out for the first page.",
            "schema": {
              "type": "string",
              "pattern": "^txr_[0-9a-z]{20,32}$"
            }
          },
          {
            "name": "active",
            "in": "query",
            "required": false,
            "description": "true for rates taking new subscriptions, false for archived ones.",
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            },
            "example": "true"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaxRateList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "object": "tax_rate",
                      "id": "txr_v1x8c3q6m2k9r5t7y0wnhz4p",
                      "mode": "test",
                      "displayName": "VAT",
                      "description": "Value added tax",
                      "percentageBps": 1800,
                      "inclusive": false,
                      "active": true,
                      "createdAt": "2026-09-25T08:00:00.000Z"
                    }
                  ],
                  "hasMore": false,
                  "nextCursor": null
                }
              }
            }
          },
          "400": {
            "description": "A query parameter is not valid; fields names each one. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed"
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:read",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/tax_rates/{id}": {
      "get": {
        "operationId": "retrieveTaxRate",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Retrieve a tax rate",
        "description": "One tax rate.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The tax rate's id, txr_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "txr_v1x8c3q6m2k9r5t7y0wnhz4p"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaxRate"
                },
                "example": {
                  "object": "tax_rate",
                  "id": "txr_v1x8c3q6m2k9r5t7y0wnhz4p",
                  "mode": "test",
                  "displayName": "VAT",
                  "description": "Value added tax",
                  "percentageBps": 1800,
                  "inclusive": false,
                  "active": true,
                  "createdAt": "2026-09-25T08:00:00.000Z"
                }
              }
            }
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No tax rate with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:read",
        "x-key-kinds": [
          "secret"
        ]
      },
      "post": {
        "operationId": "updateTaxRate",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Update a tax rate",
        "description": "Its name or description, or active false to archive it: no new subscription takes it, those that have it keep it. Its percentage never changes; for a new rate, create a new tax rate.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The tax rate's id, txr_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "txr_v1x8c3q6m2k9r5t7y0wnhz4p"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "example": "archive-vat-18"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "displayName": {
                    "description": "A new name.",
                    "type": "string",
                    "maxLength": 40,
                    "minLength": 1
                  },
                  "description": {
                    "description": "A new line about it, or null.",
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 120
                  },
                  "active": {
                    "description": "False archives it: no new subscription takes it.",
                    "type": "boolean"
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "active": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaxRate"
                },
                "example": {
                  "object": "tax_rate",
                  "id": "txr_v1x8c3q6m2k9r5t7y0wnhz4p",
                  "mode": "test",
                  "displayName": "VAT",
                  "description": "Value added tax",
                  "percentageBps": 1800,
                  "inclusive": false,
                  "active": false,
                  "createdAt": "2026-09-25T08:00:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No tax rate with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      }
    },
    "/v1/invoice_items": {
      "post": {
        "operationId": "createInvoiceItem",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Add an invoice item",
        "description": "A one-off line, such as a setup fee or an add-on (a negative amount is a credit): it waits for the customer's next invoice, or the named subscription's, and joins a draft at once when you name one during its draft window.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "example": "joining-fee-member-1042"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "description": {
                    "description": "The line as the customer reads it, 1 to 200 characters.",
                    "type": "string",
                    "maxLength": 200,
                    "minLength": 1
                  },
                  "unitAmountCents": {
                    "description": "Per unit, in cents; negative for a credit.",
                    "type": "integer",
                    "minimum": -100000000,
                    "maximum": 100000000
                  },
                  "quantity": {
                    "description": "How many units, 1 to 10000. Defaults to 1.",
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 10000,
                    "default": 1
                  },
                  "discountable": {
                    "description": "Whether a coupon discounts it. Defaults to true.",
                    "type": "boolean",
                    "default": true
                  },
                  "customerId": {
                    "description": "The customer it bills.",
                    "type": "string",
                    "pattern": "^cus_[0-9a-z]{20,32}$"
                  },
                  "subscriptionId": {
                    "description": "Only this subscription's next invoice takes it. Without it, the customer's next invoice does.",
                    "type": "string",
                    "pattern": "^sub_[0-9a-z]{20,32}$"
                  },
                  "invoiceId": {
                    "description": "A draft invoice to add it to now, during its draft window.",
                    "type": "string",
                    "pattern": "^in_[0-9a-z]{20,32}$"
                  }
                },
                "required": [
                  "description",
                  "unitAmountCents",
                  "customerId"
                ],
                "additionalProperties": false
              },
              "example": {
                "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                "subscriptionId": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                "description": "Joining fee",
                "unitAmountCents": 250000,
                "discountable": false
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceItem"
                },
                "example": {
                  "object": "invoice_item",
                  "id": "ii_f3v7x2c9q1m8k4r6t0yhzw5n",
                  "mode": "test",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "subscriptionId": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "invoiceId": null,
                  "description": "Joining fee",
                  "quantity": 1,
                  "unitAmountCents": 250000,
                  "amountCents": 250000,
                  "proration": false,
                  "discountable": false,
                  "createdAt": "2026-10-01T04:12:31.000Z"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No customer, subscription or invoice with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. The invoice is not a draft, or the subscription has ended. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              },
              {
                "reason": "invoice_not_open",
                "docUrl": "https://payments.lk/developers/errors#invoice_not_open"
              },
              {
                "reason": "subscription_ended",
                "docUrl": "https://payments.lk/developers/errors#subscription_ended"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      },
      "get": {
        "operationId": "listInvoiceItems",
        "tags": [
          "Subscriptions"
        ],
        "summary": "List invoice items",
        "description": "Your invoice items in this key's mode, newest first. Filter by customer, and by whether an invoice has taken them.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "How many to return, 1 to 100. Defaults to 25.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "The nextCursor of the page before. Leave it out for the first page.",
            "schema": {
              "type": "string",
              "pattern": "^ii_[0-9a-z]{20,32}$"
            }
          },
          {
            "name": "customerId",
            "in": "query",
            "required": false,
            "description": "Only this customer's items.",
            "schema": {
              "type": "string",
              "pattern": "^cus_[0-9a-z]{20,32}$"
            },
            "example": "cus_q8w3n5v1x7c2m9r4t6ya0kzp"
          },
          {
            "name": "pending",
            "in": "query",
            "required": false,
            "description": "true for items no invoice has taken yet, false for the ones taken.",
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            },
            "example": "true"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceItemList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "object": "invoice_item",
                      "id": "ii_f3v7x2c9q1m8k4r6t0yhzw5n",
                      "mode": "test",
                      "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                      "subscriptionId": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                      "invoiceId": null,
                      "description": "Joining fee",
                      "quantity": 1,
                      "unitAmountCents": 250000,
                      "amountCents": 250000,
                      "proration": false,
                      "discountable": false,
                      "createdAt": "2026-10-01T04:12:31.000Z"
                    }
                  ],
                  "hasMore": false,
                  "nextCursor": null
                }
              }
            }
          },
          "400": {
            "description": "A query parameter is not valid; fields names each one. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed"
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:read",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/invoice_items/{id}": {
      "delete": {
        "operationId": "deleteInvoiceItem",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Delete an invoice item",
        "description": "Deletes an item no invoice has taken yet. One an invoice took stays as that invoice's record.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The invoice item's id, ii_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "ii_f3v7x2c9q1m8k4r6t0yhzw5n"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeletedInvoiceItem"
                },
                "example": {
                  "object": "invoice_item",
                  "id": "ii_f3v7x2c9q1m8k4r6t0yhzw5n",
                  "mode": "test",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "subscriptionId": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "invoiceId": null,
                  "description": "Joining fee",
                  "quantity": 1,
                  "unitAmountCents": 250000,
                  "amountCents": 250000,
                  "proration": false,
                  "discountable": false,
                  "createdAt": "2026-10-01T04:12:31.000Z",
                  "deleted": true
                }
              }
            }
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No invoice item with this id for this key; mode_mismatch when it exists in the other mode. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found",
            "x-error-reasons": [
              {
                "reason": "mode_mismatch",
                "docUrl": "https://payments.lk/developers/errors#mode_mismatch"
              }
            ]
          },
          "409": {
            "description": "An invoice has taken it. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "invoice_not_open",
                "docUrl": "https://payments.lk/developers/errors#invoice_not_open"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/customers/{id}/balance_transactions": {
      "post": {
        "operationId": "createBalanceTransaction",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Adjust a customer's credit",
        "description": "Adds credit to the customer's balance (positive) or takes it away (negative, never below zero). Credit is taken off their next invoices before the card is charged.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The customer's id, cus_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "cus_q8w3n5v1x7c2m9r4t6ya0kzp"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "example": "credit-pool-week"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "amountCents": {
                    "description": "Positive adds credit to the customer's balance; negative takes it away, never below zero.",
                    "type": "integer",
                    "minimum": -100000000,
                    "maximum": 100000000
                  },
                  "description": {
                    "description": "Why, up to 200 characters.",
                    "type": "string",
                    "maxLength": 200
                  }
                },
                "required": [
                  "amountCents"
                ],
                "additionalProperties": false
              },
              "example": {
                "amountCents": 150000,
                "description": "Goodwill credit for the closed pool week"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerBalanceTransaction"
                },
                "example": {
                  "object": "customer_balance_transaction",
                  "id": "cbtx_b4x9v2c7q3m1k8r5t0nwhz6y",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "amountCents": 150000,
                  "endingBalanceCents": 150000,
                  "type": "adjustment",
                  "invoiceId": null,
                  "description": "Goodwill credit for the closed pool week",
                  "createdAt": "2026-10-12T09:00:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. It would take the balance below zero. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              },
              {
                "reason": "amount",
                "docUrl": "https://payments.lk/developers/errors#amount"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No customer with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      },
      "get": {
        "operationId": "listBalanceTransactions",
        "tags": [
          "Subscriptions"
        ],
        "summary": "List a customer's credit changes",
        "description": "Every change to the customer's credit balance, newest first, each with the balance after it.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The customer's id, cus_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "cus_q8w3n5v1x7c2m9r4t6ya0kzp"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "How many to return, 1 to 100. Defaults to 25.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "The nextCursor of the page before. Leave it out for the first page.",
            "schema": {
              "type": "string",
              "pattern": "^cbtx_[0-9a-z]{20,32}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerBalanceTransactionList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "object": "customer_balance_transaction",
                      "id": "cbtx_b4x9v2c7q3m1k8r5t0nwhz6y",
                      "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                      "amountCents": 150000,
                      "endingBalanceCents": 150000,
                      "type": "adjustment",
                      "invoiceId": null,
                      "description": "Goodwill credit for the closed pool week",
                      "createdAt": "2026-10-12T09:00:00.000Z"
                    }
                  ],
                  "hasMore": false,
                  "nextCursor": null
                }
              }
            }
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No customer with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:read",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/test_clocks/advance": {
      "post": {
        "operationId": "advanceTestClock",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Move a subscription's time forward",
        "description": "Sandbox only. Runs one subscription's clock forward by up to a year, so you can watch the upcoming notice, the renewal, the charge, a retry and a cancellation in minutes instead of months. The worker catches up within a minute of each call.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "example": "clock-member-1042-1"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AdvanceTestClockRequest"
              },
              "example": {
                "subscriptionId": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                "seconds": 2678400
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TestClock"
                },
                "example": {
                  "object": "test_clock",
                  "subscriptionId": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "frozenTime": "2026-11-01T04:20:00.000Z",
                  "offsetSeconds": 2678400
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No subscription with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. A live key where real money moves, or a subscription that has ended. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              },
              {
                "reason": "test_clock_unavailable",
                "docUrl": "https://payments.lk/developers/errors#test_clock_unavailable"
              },
              {
                "reason": "subscription_ended",
                "docUrl": "https://payments.lk/developers/errors#subscription_ended"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      }
    },
    "/v1/subscription_schedules": {
      "post": {
        "operationId": "createSubscriptionSchedule",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Create a subscription schedule",
        "description": "Phases a subscription moves through, each its prices for a number of billing periods: a discounted first year and then the full price, or installments. The subscription starts on startDate (now by default), charged as any new subscription is: the card on file, or the first invoice's hostedInvoiceUrl. At the renewal where a phase ends it moves to the next phase's prices, with no proration. After the last phase it carries on (endBehavior release) or ends (cancel). Installments: one phase of the installment price with iterations set to the number of payments, and endBehavior cancel.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "example": "diploma-nimali-installments"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customerId": {
                    "description": "The customer, one of yours in this key's mode.",
                    "type": "string",
                    "pattern": "^cus_[0-9a-z]{20,32}$"
                  },
                  "startDate": {
                    "description": "\"now\" (the default) starts the subscription at once, charged as any new subscription is; a time within two years starts it then.",
                    "anyOf": [
                      {
                        "type": "string",
                        "const": "now"
                      },
                      {
                        "type": "string",
                        "format": "date-time"
                      }
                    ],
                    "default": "now"
                  },
                  "endBehavior": {
                    "description": "After the last phase: release (the default: the subscription carries on at the last phase's prices) or cancel (it ends: installments).",
                    "type": "string",
                    "enum": [
                      "release",
                      "cancel"
                    ],
                    "default": "release"
                  },
                  "phases": {
                    "description": "1 to 10 phases, in order.",
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "items": {
                          "description": "The phase's prices, 1 to 10, each once, all on one interval.",
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "priceId": {
                                "description": "An active price of yours.",
                                "type": "string",
                                "pattern": "^price_[0-9a-z]{20,32}$"
                              },
                              "quantity": {
                                "description": "How many units, 1 to 10000. Defaults to 1.",
                                "type": "integer",
                                "minimum": 1,
                                "maximum": 10000,
                                "default": 1
                              }
                            },
                            "required": [
                              "priceId"
                            ],
                            "additionalProperties": false
                          },
                          "minItems": 1,
                          "maxItems": 10
                        },
                        "iterations": {
                          "description": "How many billing periods the phase lasts, 1 to 120. Every phase but the last has it; give the last one too for endBehavior cancel.",
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 120
                        },
                        "trialDays": {
                          "description": "A free trial at the start of the first phase, 1 to 730 days.",
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 730
                        },
                        "couponId": {
                          "description": "A coupon of yours put on the subscription when the phase starts.",
                          "type": "string",
                          "pattern": "^cpn_[0-9a-z]{20,32}$"
                        }
                      },
                      "required": [
                        "items"
                      ],
                      "additionalProperties": false
                    },
                    "minItems": 1,
                    "maxItems": 10
                  },
                  "reference": {
                    "description": "Your own reference, up to 120 characters.",
                    "type": "string",
                    "maxLength": 120
                  }
                },
                "required": [
                  "customerId",
                  "phases"
                ],
                "additionalProperties": false
              },
              "example": {
                "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                "startDate": "now",
                "endBehavior": "cancel",
                "phases": [
                  {
                    "items": [
                      {
                        "priceId": "price_i7c3v9x2q8m1k6r4t0ynwh5z",
                        "quantity": 1
                      }
                    ],
                    "iterations": 12
                  }
                ],
                "reference": "Diploma, 12 installments"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubscriptionSchedule"
                },
                "example": {
                  "object": "subscription_schedule",
                  "id": "sched_c6v2x9q1m8k4r7t3y0hwnz5p",
                  "mode": "test",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "subscriptionId": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "status": "active",
                  "endBehavior": "cancel",
                  "startDate": "2026-10-01T04:12:31.000Z",
                  "phases": [
                    {
                      "items": [
                        {
                          "priceId": "price_i7c3v9x2q8m1k6r4t0ynwh5z",
                          "quantity": 1
                        }
                      ],
                      "iterations": 12,
                      "trialDays": null,
                      "couponId": null
                    }
                  ],
                  "currentPhase": 0,
                  "currentPhaseEndsAt": "2027-10-01T04:12:31.000Z",
                  "reference": "Diploma, 12 installments",
                  "completedAt": null,
                  "releasedAt": null,
                  "canceledAt": null,
                  "createdAt": "2026-10-01T04:12:31.000Z"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. A phase's prices bill on different intervals, or the start date is out of range. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              },
              {
                "reason": "items_invalid",
                "docUrl": "https://payments.lk/developers/errors#items_invalid"
              },
              {
                "reason": "billing_date_invalid",
                "docUrl": "https://payments.lk/developers/errors#billing_date_invalid"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No customer with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. A price is archived or in the other mode, or a coupon cannot be used. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              },
              {
                "reason": "price_unavailable",
                "docUrl": "https://payments.lk/developers/errors#price_unavailable"
              },
              {
                "reason": "coupon_invalid",
                "docUrl": "https://payments.lk/developers/errors#coupon_invalid"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      },
      "get": {
        "operationId": "listSubscriptionSchedules",
        "tags": [
          "Subscriptions"
        ],
        "summary": "List subscription schedules",
        "description": "Your subscription schedules in this key's mode, newest first. Filter by customer and status.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "How many to return, 1 to 100. Defaults to 25.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "The nextCursor of the page before. Leave it out for the first page.",
            "schema": {
              "type": "string",
              "pattern": "^sched_[0-9a-z]{20,32}$"
            }
          },
          {
            "name": "customerId",
            "in": "query",
            "required": false,
            "description": "Only this customer's schedules.",
            "schema": {
              "type": "string",
              "pattern": "^cus_[0-9a-z]{20,32}$"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Only schedules with this status.",
            "schema": {
              "type": "string",
              "enum": [
                "not_started",
                "active",
                "completed",
                "released",
                "canceled"
              ]
            },
            "example": "active"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubscriptionScheduleList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "object": "subscription_schedule",
                      "id": "sched_c6v2x9q1m8k4r7t3y0hwnz5p",
                      "mode": "test",
                      "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                      "subscriptionId": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                      "status": "active",
                      "endBehavior": "cancel",
                      "startDate": "2026-10-01T04:12:31.000Z",
                      "phases": [
                        {
                          "items": [
                            {
                              "priceId": "price_i7c3v9x2q8m1k6r4t0ynwh5z",
                              "quantity": 1
                            }
                          ],
                          "iterations": 12,
                          "trialDays": null,
                          "couponId": null
                        }
                      ],
                      "currentPhase": 0,
                      "currentPhaseEndsAt": "2027-10-01T04:12:31.000Z",
                      "reference": "Diploma, 12 installments",
                      "completedAt": null,
                      "releasedAt": null,
                      "canceledAt": null,
                      "createdAt": "2026-10-01T04:12:31.000Z"
                    }
                  ],
                  "hasMore": false,
                  "nextCursor": null
                }
              }
            }
          },
          "400": {
            "description": "A query parameter is not valid; fields names each one. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed"
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:read",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/subscription_schedules/{id}": {
      "get": {
        "operationId": "retrieveSubscriptionSchedule",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Retrieve a subscription schedule",
        "description": "One schedule, with the phase now running and when it ends.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The subscription schedule's id, sched_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "sched_c6v2x9q1m8k4r7t3y0hwnz5p"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubscriptionSchedule"
                },
                "example": {
                  "object": "subscription_schedule",
                  "id": "sched_c6v2x9q1m8k4r7t3y0hwnz5p",
                  "mode": "test",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "subscriptionId": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "status": "active",
                  "endBehavior": "cancel",
                  "startDate": "2026-10-01T04:12:31.000Z",
                  "phases": [
                    {
                      "items": [
                        {
                          "priceId": "price_i7c3v9x2q8m1k6r4t0ynwh5z",
                          "quantity": 1
                        }
                      ],
                      "iterations": 12,
                      "trialDays": null,
                      "couponId": null
                    }
                  ],
                  "currentPhase": 0,
                  "currentPhaseEndsAt": "2027-10-01T04:12:31.000Z",
                  "reference": "Diploma, 12 installments",
                  "completedAt": null,
                  "releasedAt": null,
                  "canceledAt": null,
                  "createdAt": "2026-10-01T04:12:31.000Z"
                }
              }
            }
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No subscription schedule with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:read",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/subscription_schedules/{id}/cancel": {
      "post": {
        "operationId": "cancelSubscriptionSchedule",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Cancel a subscription schedule",
        "description": "A schedule not started never starts; one running cancels its subscription now, as a cancellation from the API does.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The subscription schedule's id, sched_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "sched_c6v2x9q1m8k4r7t3y0hwnz5p"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "example": "diploma-nimali-cancel"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubscriptionSchedule"
                },
                "example": {
                  "object": "subscription_schedule",
                  "id": "sched_c6v2x9q1m8k4r7t3y0hwnz5p",
                  "mode": "test",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "subscriptionId": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "status": "canceled",
                  "endBehavior": "cancel",
                  "startDate": "2026-10-01T04:12:31.000Z",
                  "phases": [
                    {
                      "items": [
                        {
                          "priceId": "price_i7c3v9x2q8m1k6r4t0ynwh5z",
                          "quantity": 1
                        }
                      ],
                      "iterations": 12,
                      "trialDays": null,
                      "couponId": null
                    }
                  ],
                  "currentPhase": 0,
                  "currentPhaseEndsAt": null,
                  "reference": "Diploma, 12 installments",
                  "completedAt": null,
                  "releasedAt": null,
                  "canceledAt": "2027-02-01T04:12:31.000Z",
                  "createdAt": "2026-10-01T04:12:31.000Z"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No subscription schedule with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. The schedule has already finished. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              },
              {
                "reason": "subscription_change_refused",
                "docUrl": "https://payments.lk/developers/errors#subscription_change_refused"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      }
    },
    "/v1/subscription_schedules/{id}/release": {
      "post": {
        "operationId": "releaseSubscriptionSchedule",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Release a subscription schedule",
        "description": "Lets go of the subscription, which carries on at the prices it has now, with no more phases. A schedule not started never starts.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The subscription schedule's id, sched_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "sched_c6v2x9q1m8k4r7t3y0hwnz5p"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "example": "diploma-nimali-release"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubscriptionSchedule"
                },
                "example": {
                  "object": "subscription_schedule",
                  "id": "sched_c6v2x9q1m8k4r7t3y0hwnz5p",
                  "mode": "test",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "subscriptionId": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "status": "released",
                  "endBehavior": "cancel",
                  "startDate": "2026-10-01T04:12:31.000Z",
                  "phases": [
                    {
                      "items": [
                        {
                          "priceId": "price_i7c3v9x2q8m1k6r4t0ynwh5z",
                          "quantity": 1
                        }
                      ],
                      "iterations": 12,
                      "trialDays": null,
                      "couponId": null
                    }
                  ],
                  "currentPhase": 0,
                  "currentPhaseEndsAt": null,
                  "reference": "Diploma, 12 installments",
                  "completedAt": null,
                  "releasedAt": "2027-02-01T04:12:31.000Z",
                  "canceledAt": null,
                  "createdAt": "2026-10-01T04:12:31.000Z"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No subscription schedule with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. The schedule has already finished. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              },
              {
                "reason": "subscription_change_refused",
                "docUrl": "https://payments.lk/developers/errors#subscription_change_refused"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      }
    },
    "/v1/entitlements/features": {
      "post": {
        "operationId": "createFeature",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Create a feature",
        "description": "A feature customers get with a product, as Stripe's entitlements: give it to products with POST /v1/products/{id}/features, and check a customer's features in your app by lookup key. entitlements.active_entitlement_summary.updated tells you when a customer's features change.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "example": "feature-pool"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "description": "Its name, 1 to 80 characters.",
                    "type": "string",
                    "maxLength": 80,
                    "minLength": 1
                  },
                  "lookupKey": {
                    "description": "The key your app checks: lower case letters, digits, dots, dashes and underscores, up to 80, unique in the mode.",
                    "type": "string",
                    "pattern": "^[a-z0-9][a-z0-9_.-]{0,79}$"
                  }
                },
                "required": [
                  "name",
                  "lookupKey"
                ],
                "additionalProperties": false
              },
              "example": {
                "name": "Swimming pool",
                "lookupKey": "pool"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Feature"
                },
                "example": {
                  "object": "entitlements.feature",
                  "id": "feat_p3v8x1c6q9m2k7r4t0ynhw5z",
                  "mode": "test",
                  "name": "Swimming pool",
                  "lookupKey": "pool",
                  "active": true,
                  "createdAt": "2026-09-25T08:00:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. Another feature in this mode already has that lookup key. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              },
              {
                "reason": "feature_exists",
                "docUrl": "https://payments.lk/developers/errors#feature_exists"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      },
      "get": {
        "operationId": "listFeatures",
        "tags": [
          "Subscriptions"
        ],
        "summary": "List features",
        "description": "Your features in this key's mode, newest first.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "How many to return, 1 to 100. Defaults to 25.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "The nextCursor of the page before. Leave it out for the first page.",
            "schema": {
              "type": "string",
              "pattern": "^feat_[0-9a-z]{20,32}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FeatureList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "object": "entitlements.feature",
                      "id": "feat_p3v8x1c6q9m2k7r4t0ynhw5z",
                      "mode": "test",
                      "name": "Swimming pool",
                      "lookupKey": "pool",
                      "active": true,
                      "createdAt": "2026-09-25T08:00:00.000Z"
                    }
                  ],
                  "hasMore": false,
                  "nextCursor": null
                }
              }
            }
          },
          "400": {
            "description": "A query parameter is not valid; fields names each one. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed"
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:read",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/entitlements/active_entitlements": {
      "get": {
        "operationId": "activeEntitlements",
        "tags": [
          "Subscriptions"
        ],
        "summary": "List a customer's features",
        "description": "The features a customer has now: those of the products on their active, trialing and past due subscriptions, each once. Check one by lookup key before letting them use it.",
        "parameters": [
          {
            "name": "customerId",
            "in": "query",
            "required": true,
            "description": "The customer.",
            "schema": {
              "type": "string",
              "pattern": "^cus_[0-9a-z]{20,32}$"
            },
            "example": "cus_q8w3n5v1x7c2m9r4t6ya0kzp"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ActiveEntitlementList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "object": "entitlements.active_entitlement",
                      "featureId": "feat_g2v7x9c5q1m8k3r6t0hwnz4y",
                      "lookupKey": "gym"
                    },
                    {
                      "object": "entitlements.active_entitlement",
                      "featureId": "feat_p3v8x1c6q9m2k7r4t0ynhw5z",
                      "lookupKey": "pool"
                    }
                  ],
                  "hasMore": false,
                  "nextCursor": null
                }
              }
            }
          },
          "400": {
            "description": "A query parameter is not valid; fields names each one. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed"
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No customer with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:read",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/products/{id}/features": {
      "post": {
        "operationId": "attachProductFeature",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Give a product a feature",
        "description": "Every running subscription to the product now gives its customer the feature; their summaries are sent. A feature already on the product is answered as it is.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The product's id, prod_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "prod_h2k9m4q7v1x8c3r6t0ynwz5p"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "example": "gym-pool-feature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "featureId": {
                    "description": "The feature to give with the product.",
                    "type": "string",
                    "pattern": "^feat_[0-9a-z]{20,32}$"
                  }
                },
                "required": [
                  "featureId"
                ],
                "additionalProperties": false
              },
              "example": {
                "featureId": "feat_p3v8x1c6q9m2k7r4t0ynhw5z"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProductFeature"
                },
                "example": {
                  "object": "product_feature",
                  "id": "pfeat_q4v9x2c7m1k8r3t6y0wnhz5p",
                  "productId": "prod_h2k9m4q7v1x8c3r6t0ynwz5p",
                  "featureId": "feat_p3v8x1c6q9m2k7r4t0ynhw5z",
                  "lookupKey": "pool",
                  "createdAt": "2026-09-25T08:05:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No product with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      },
      "get": {
        "operationId": "listProductFeatures",
        "tags": [
          "Subscriptions"
        ],
        "summary": "List a product's features",
        "description": "The features given with a product, oldest first.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The product's id, prod_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "prod_h2k9m4q7v1x8c3r6t0ynwz5p"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProductFeatureList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "object": "product_feature",
                      "id": "pfeat_q4v9x2c7m1k8r3t6y0wnhz5p",
                      "productId": "prod_h2k9m4q7v1x8c3r6t0ynwz5p",
                      "featureId": "feat_p3v8x1c6q9m2k7r4t0ynhw5z",
                      "lookupKey": "pool",
                      "createdAt": "2026-09-25T08:05:00.000Z"
                    }
                  ],
                  "hasMore": false,
                  "nextCursor": null
                }
              }
            }
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No product with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:read",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/products/{id}/features/{featureId}": {
      "delete": {
        "operationId": "detachProductFeature",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Take a feature off a product",
        "description": "Customers with the product lose the feature, unless another of their products gives it; their summaries are sent.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The product's id, prod_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "prod_h2k9m4q7v1x8c3r6t0ynwz5p"
          },
          {
            "name": "featureId",
            "in": "path",
            "required": true,
            "description": "The feature's id, feat_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "feat_p3v8x1c6q9m2k7r4t0ynhw5z"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeletedProductFeature"
                },
                "example": {
                  "object": "product_feature",
                  "productId": "prod_h2k9m4q7v1x8c3r6t0ynwz5p",
                  "featureId": "feat_p3v8x1c6q9m2k7r4t0ynhw5z",
                  "deleted": true
                }
              }
            }
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No product feature with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/meters": {
      "post": {
        "operationId": "createMeter",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Create a meter",
        "description": "What you count for usage based billing: API calls, messages, kilowatt hours. Report each use with POST /v1/meter_events under its eventName; a metered price on the meter bills a customer's usage at the end of each period, by the price's billing scheme.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "example": "meter-sms"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "description": "Its name, 1 to 80 characters, as invoice lines show the usage.",
                    "type": "string",
                    "maxLength": 80,
                    "minLength": 1
                  },
                  "eventName": {
                    "description": "The name your meter events will carry: lower case letters, digits, dots, dashes and underscores, up to 100, unique in the mode.",
                    "type": "string",
                    "pattern": "^[a-z0-9][a-z0-9_.-]{0,99}$"
                  },
                  "aggregation": {
                    "description": "sum (the default), count or last.",
                    "type": "string",
                    "enum": [
                      "sum",
                      "count",
                      "last"
                    ],
                    "default": "sum"
                  }
                },
                "required": [
                  "name",
                  "eventName"
                ],
                "additionalProperties": false
              },
              "example": {
                "name": "SMS sent",
                "eventName": "sms.sent",
                "aggregation": "sum"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Meter"
                },
                "example": {
                  "object": "meter",
                  "id": "mtr_a4c8v2x9q1m7k3r6t0yhwn5z",
                  "mode": "test",
                  "name": "SMS sent",
                  "eventName": "sms.sent",
                  "aggregation": "sum",
                  "active": true,
                  "createdAt": "2026-10-01T04:00:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. Another meter in this mode already counts that eventName. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              },
              {
                "reason": "meter_exists",
                "docUrl": "https://payments.lk/developers/errors#meter_exists"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      },
      "get": {
        "operationId": "listMeters",
        "tags": [
          "Subscriptions"
        ],
        "summary": "List meters",
        "description": "Your meters in this key's mode, newest first.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "How many to return, 1 to 100. Defaults to 25.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "The nextCursor of the page before. Leave it out for the first page.",
            "schema": {
              "type": "string",
              "pattern": "^mtr_[0-9a-z]{20,32}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MeterList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "object": "meter",
                      "id": "mtr_a4c8v2x9q1m7k3r6t0yhwn5z",
                      "mode": "test",
                      "name": "SMS sent",
                      "eventName": "sms.sent",
                      "aggregation": "sum",
                      "active": true,
                      "createdAt": "2026-10-01T04:00:00.000Z"
                    }
                  ],
                  "hasMore": false,
                  "nextCursor": null
                }
              }
            }
          },
          "400": {
            "description": "A query parameter is not valid; fields names each one. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed"
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:read",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/meters/{id}": {
      "get": {
        "operationId": "retrieveMeter",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Retrieve a meter",
        "description": "One meter.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The meter's id, mtr_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "mtr_a4c8v2x9q1m7k3r6t0yhwn5z"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Meter"
                },
                "example": {
                  "object": "meter",
                  "id": "mtr_a4c8v2x9q1m7k3r6t0yhwn5z",
                  "mode": "test",
                  "name": "SMS sent",
                  "eventName": "sms.sent",
                  "aggregation": "sum",
                  "active": true,
                  "createdAt": "2026-10-01T04:00:00.000Z"
                }
              }
            }
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No meter with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:read",
        "x-key-kinds": [
          "secret"
        ]
      },
      "post": {
        "operationId": "updateMeter",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Update a meter",
        "description": "Renames a meter, or turns it off (active false: its events are refused, and its prices bill what it counted) or back on.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The meter's id, mtr_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "mtr_a4c8v2x9q1m7k3r6t0yhwn5z"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "example": "meter-sms-rename"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "description": "Its new name.",
                    "type": "string",
                    "maxLength": 80,
                    "minLength": 1
                  },
                  "active": {
                    "description": "False turns it off: its events are refused. True turns it back on.",
                    "type": "boolean"
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "name": "Messages sent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Meter"
                },
                "example": {
                  "object": "meter",
                  "id": "mtr_a4c8v2x9q1m7k3r6t0yhwn5z",
                  "mode": "test",
                  "name": "Messages sent",
                  "eventName": "sms.sent",
                  "aggregation": "sum",
                  "active": true,
                  "createdAt": "2026-10-01T04:00:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No meter with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      }
    },
    "/v1/meters/{id}/event_summaries": {
      "get": {
        "operationId": "meterEventSummaries",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Summarise a customer's usage",
        "description": "A customer's usage on the meter between two times, as the meter adds it up: what a metered price would bill for that span.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The meter's id, mtr_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "mtr_a4c8v2x9q1m7k3r6t0yhwn5z"
          },
          {
            "name": "customerId",
            "in": "query",
            "required": true,
            "description": "The customer.",
            "schema": {
              "type": "string",
              "pattern": "^cus_[0-9a-z]{20,32}$"
            },
            "example": "cus_q8w3n5v1x7c2m9r4t6ya0kzp"
          },
          {
            "name": "start",
            "in": "query",
            "required": true,
            "description": "From this time, ISO 8601.",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "example": "2026-10-01T04:12:31.000Z"
          },
          {
            "name": "end",
            "in": "query",
            "required": true,
            "description": "Up to (not including) this time, ISO 8601, after start.",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "example": "2026-11-01T04:12:31.000Z"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MeterEventSummary"
                },
                "example": {
                  "object": "meter_event_summary",
                  "meterId": "mtr_a4c8v2x9q1m7k3r6t0yhwn5z",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "start": "2026-10-01T04:12:31.000Z",
                  "end": "2026-11-01T04:12:31.000Z",
                  "aggregatedValue": 12480
                }
              }
            }
          },
          "400": {
            "description": "A query parameter is not valid; fields names each one. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed"
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No meter with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:read",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/meter_events": {
      "post": {
        "operationId": "createMeterEvent",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Report usage",
        "description": "One use of a customer's, counted by the active meter whose eventName it carries, dated when it happened (within the last 35 days). Send your own identifier so a retry never counts twice: the same identifier answers with the event already kept. Usage alerts the customer's usage now reaches fire as billing.alert.triggered.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "example": "usage-msg-88412"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "eventName": {
                    "description": "The eventName of an active meter of yours in this mode.",
                    "type": "string",
                    "pattern": "^[a-z0-9][a-z0-9_.-]{0,99}$"
                  },
                  "customerId": {
                    "description": "The customer whose usage it is.",
                    "type": "string",
                    "pattern": "^cus_[0-9a-z]{20,32}$"
                  },
                  "value": {
                    "description": "How much, a whole number from 0. Defaults to 1.",
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 1000000000,
                    "default": 1
                  },
                  "timestamp": {
                    "description": "When it happened, ISO 8601: within the last 35 days, and not ahead of now. Defaults to now.",
                    "type": "string",
                    "format": "date-time"
                  },
                  "identifier": {
                    "description": "Your own id for it, up to 100 characters: sending it again returns the event already kept.",
                    "type": "string",
                    "maxLength": 100
                  }
                },
                "required": [
                  "eventName",
                  "customerId"
                ],
                "additionalProperties": false
              },
              "example": {
                "eventName": "sms.sent",
                "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                "value": 3,
                "timestamp": "2026-10-18T06:40:12.000Z",
                "identifier": "msg-88412"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MeterEvent"
                },
                "example": {
                  "object": "meter_event",
                  "id": "mev_e2x7v1c9q4m8k3r6t0ynhw5p",
                  "mode": "test",
                  "meterId": "mtr_a4c8v2x9q1m7k3r6t0yhwn5z",
                  "eventName": "sms.sent",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "value": 3,
                  "timestamp": "2026-10-18T06:40:12.000Z",
                  "identifier": "msg-88412",
                  "createdAt": "2026-10-18T06:40:12.000Z"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. No active meter counts that eventName, or the timestamp is out of range. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              },
              {
                "reason": "meter_invalid",
                "docUrl": "https://payments.lk/developers/errors#meter_invalid"
              },
              {
                "reason": "billing_date_invalid",
                "docUrl": "https://payments.lk/developers/errors#billing_date_invalid"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No customer with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      }
    },
    "/v1/usage_alerts": {
      "post": {
        "operationId": "createUsageAlert",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Create a usage alert",
        "description": "Sends billing.alert.triggered once a customer's usage on the meter in their current period reaches the threshold, once per customer: for one customer, or for every customer.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "example": "alert-sms-10k"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "meterId": {
                    "description": "The meter to watch.",
                    "type": "string",
                    "pattern": "^mtr_[0-9a-z]{20,32}$"
                  },
                  "customerId": {
                    "description": "One customer to watch. Leave it out to watch every customer.",
                    "type": "string",
                    "pattern": "^cus_[0-9a-z]{20,32}$"
                  },
                  "title": {
                    "description": "Its name, 1 to 80 characters, sent with the event.",
                    "type": "string",
                    "maxLength": 80,
                    "minLength": 1
                  },
                  "threshold": {
                    "description": "The usage in a customer's current period that fires it, from 1.",
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 1000000000
                  }
                },
                "required": [
                  "meterId",
                  "title",
                  "threshold"
                ],
                "additionalProperties": false
              },
              "example": {
                "meterId": "mtr_a4c8v2x9q1m7k3r6t0yhwn5z",
                "title": "10,000 messages",
                "threshold": 10000
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UsageAlert"
                },
                "example": {
                  "object": "usage_alert",
                  "id": "ual_t3v9x1c7q2m8k4r6y0wnhz5p",
                  "mode": "test",
                  "meterId": "mtr_a4c8v2x9q1m7k3r6t0yhwn5z",
                  "customerId": null,
                  "title": "10,000 messages",
                  "threshold": 10000,
                  "active": true,
                  "createdAt": "2026-10-01T04:05:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. The meter is not one of yours in this mode. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              },
              {
                "reason": "meter_invalid",
                "docUrl": "https://payments.lk/developers/errors#meter_invalid"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No customer with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      },
      "get": {
        "operationId": "listUsageAlerts",
        "tags": [
          "Subscriptions"
        ],
        "summary": "List usage alerts",
        "description": "Your usage alerts in this key's mode, newest first. Filter by meter.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "How many to return, 1 to 100. Defaults to 25.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "The nextCursor of the page before. Leave it out for the first page.",
            "schema": {
              "type": "string",
              "pattern": "^ual_[0-9a-z]{20,32}$"
            }
          },
          {
            "name": "meterId",
            "in": "query",
            "required": false,
            "description": "Only the alerts watching this meter.",
            "schema": {
              "type": "string",
              "pattern": "^mtr_[0-9a-z]{20,32}$"
            },
            "example": "mtr_a4c8v2x9q1m7k3r6t0yhwn5z"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UsageAlertList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "object": "usage_alert",
                      "id": "ual_t3v9x1c7q2m8k4r6y0wnhz5p",
                      "mode": "test",
                      "meterId": "mtr_a4c8v2x9q1m7k3r6t0yhwn5z",
                      "customerId": null,
                      "title": "10,000 messages",
                      "threshold": 10000,
                      "active": true,
                      "createdAt": "2026-10-01T04:05:00.000Z"
                    }
                  ],
                  "hasMore": false,
                  "nextCursor": null
                }
              }
            }
          },
          "400": {
            "description": "A query parameter is not valid; fields names each one. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed"
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:read",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/usage_alerts/{id}/archive": {
      "post": {
        "operationId": "archiveUsageAlert",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Archive a usage alert",
        "description": "Stops the alert firing for anyone new. Those it fired for stay recorded.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The usage alert's id, ual_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "ual_t3v9x1c7q2m8k4r6y0wnhz5p"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "example": "alert-sms-10k-off"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UsageAlert"
                },
                "example": {
                  "object": "usage_alert",
                  "id": "ual_t3v9x1c7q2m8k4r6y0wnhz5p",
                  "mode": "test",
                  "meterId": "mtr_a4c8v2x9q1m7k3r6t0yhwn5z",
                  "customerId": null,
                  "title": "10,000 messages",
                  "threshold": 10000,
                  "active": false,
                  "createdAt": "2026-10-01T04:05:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No usage alert with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      }
    },
    "/v1/subscription_links": {
      "post": {
        "operationId": "createSubscriptionLink",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Create a subscription link",
        "description": "A public link to subscribe, with no website of your own: the customer chooses one of up to six prices (monthly and yearly side by side), gives their email, and pays the first period at a checkout that keeps the card. With trialDays nothing is paid; the card is checked with Rs. 10, refunded at once, and charged when the trial ends. With allowPromotionCodes the page takes a code matched to your coupons' codes. A link never charges a card already on file and never changes an existing customer's details. Subscriptions made through it carry subscriptionLinkId.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "example": "link-membership-2026"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "description": "Its name, for you, 1 to 80 characters.",
                    "type": "string",
                    "maxLength": 80,
                    "minLength": 1
                  },
                  "priceIds": {
                    "description": "One to six active prices of yours, each once, in the order the page shows them. Mix monthly and yearly to let customers choose.",
                    "type": "array",
                    "items": {
                      "type": "string",
                      "pattern": "^price_[0-9a-z]{20,32}$"
                    },
                    "minItems": 1,
                    "maxItems": 6
                  },
                  "trialDays": {
                    "description": "A free trial of 1 to 730 days for everyone who subscribes through it. Their card is checked with Rs. 10, refunded at once, and charged when the trial ends.",
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 730
                  },
                  "allowPromotionCodes": {
                    "description": "True shows a field for a code, matched to your coupons' codes. Defaults to false.",
                    "type": "boolean",
                    "default": false
                  },
                  "successUrl": {
                    "description": "Where customers land after subscribing: https, or your app's scheme. Without it, the link's own thank you page.",
                    "type": "string",
                    "maxLength": 2000
                  }
                },
                "required": [
                  "name",
                  "priceIds"
                ],
                "additionalProperties": false
              },
              "example": {
                "name": "Membership, monthly or yearly",
                "priceIds": [
                  "price_m3v8q1x6c9k2r5t7y0wn4hzp",
                  "price_y5c1v8x3q9m2k7r4t0hwnz6p"
                ],
                "trialDays": 7,
                "allowPromotionCodes": true,
                "successUrl": "https://gym.example/welcome"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubscriptionLink"
                },
                "example": {
                  "object": "subscription_link",
                  "id": "slk_g4v8x2c9q1m7k3r6t0ynwh5z",
                  "mode": "test",
                  "url": "https://payments.lk/s/4fQ9kZ2mR7xW1pL8vN3bT6",
                  "name": "Membership, monthly or yearly",
                  "prices": [
                    {
                      "id": "price_m3v8q1x6c9k2r5t7y0wn4hzp",
                      "productName": "Gym membership",
                      "nickname": null,
                      "unitAmountCents": 450000,
                      "interval": "month",
                      "intervalCount": 1,
                      "active": true
                    },
                    {
                      "id": "price_y5c1v8x3q9m2k7r4t0hwnz6p",
                      "productName": "Gym membership",
                      "nickname": "Yearly, two months free",
                      "unitAmountCents": 4500000,
                      "interval": "year",
                      "intervalCount": 1,
                      "active": true
                    }
                  ],
                  "trialDays": 7,
                  "allowPromotionCodes": true,
                  "successUrl": "https://gym.example/welcome",
                  "active": true,
                  "createdAt": "2026-09-25T08:30:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. A price is archived or in the other mode. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              },
              {
                "reason": "price_unavailable",
                "docUrl": "https://payments.lk/developers/errors#price_unavailable"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      },
      "get": {
        "operationId": "listSubscriptionLinks",
        "tags": [
          "Subscriptions"
        ],
        "summary": "List subscription links",
        "description": "Your subscription links in this key's mode, newest first.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "How many to return, 1 to 100. Defaults to 25.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "The nextCursor of the page before. Leave it out for the first page.",
            "schema": {
              "type": "string",
              "pattern": "^slk_[0-9a-z]{20,32}$"
            }
          },
          {
            "name": "active",
            "in": "query",
            "required": false,
            "description": "true for links that work, false for ones turned off.",
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            },
            "example": "true"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubscriptionLinkList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "object": "subscription_link",
                      "id": "slk_g4v8x2c9q1m7k3r6t0ynwh5z",
                      "mode": "test",
                      "url": "https://payments.lk/s/4fQ9kZ2mR7xW1pL8vN3bT6",
                      "name": "Membership, monthly or yearly",
                      "prices": [
                        {
                          "id": "price_m3v8q1x6c9k2r5t7y0wn4hzp",
                          "productName": "Gym membership",
                          "nickname": null,
                          "unitAmountCents": 450000,
                          "interval": "month",
                          "intervalCount": 1,
                          "active": true
                        },
                        {
                          "id": "price_y5c1v8x3q9m2k7r4t0hwnz6p",
                          "productName": "Gym membership",
                          "nickname": "Yearly, two months free",
                          "unitAmountCents": 4500000,
                          "interval": "year",
                          "intervalCount": 1,
                          "active": true
                        }
                      ],
                      "trialDays": 7,
                      "allowPromotionCodes": true,
                      "successUrl": "https://gym.example/welcome",
                      "active": true,
                      "createdAt": "2026-09-25T08:30:00.000Z"
                    }
                  ],
                  "hasMore": false,
                  "nextCursor": null
                }
              }
            }
          },
          "400": {
            "description": "A query parameter is not valid; fields names each one. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed"
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:read",
        "x-key-kinds": [
          "secret"
        ]
      }
    },
    "/v1/subscription_links/{id}": {
      "get": {
        "operationId": "retrieveSubscriptionLink",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Retrieve a subscription link",
        "description": "One subscription link.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The subscription link's id, slk_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "slk_g4v8x2c9q1m7k3r6t0ynwh5z"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubscriptionLink"
                },
                "example": {
                  "object": "subscription_link",
                  "id": "slk_g4v8x2c9q1m7k3r6t0ynwh5z",
                  "mode": "test",
                  "url": "https://payments.lk/s/4fQ9kZ2mR7xW1pL8vN3bT6",
                  "name": "Membership, monthly or yearly",
                  "prices": [
                    {
                      "id": "price_m3v8q1x6c9k2r5t7y0wn4hzp",
                      "productName": "Gym membership",
                      "nickname": null,
                      "unitAmountCents": 450000,
                      "interval": "month",
                      "intervalCount": 1,
                      "active": true
                    },
                    {
                      "id": "price_y5c1v8x3q9m2k7r4t0hwnz6p",
                      "productName": "Gym membership",
                      "nickname": "Yearly, two months free",
                      "unitAmountCents": 4500000,
                      "interval": "year",
                      "intervalCount": 1,
                      "active": true
                    }
                  ],
                  "trialDays": 7,
                  "allowPromotionCodes": true,
                  "successUrl": "https://gym.example/welcome",
                  "active": true,
                  "createdAt": "2026-09-25T08:30:00.000Z"
                }
              }
            }
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No subscription link with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:read",
        "x-key-kinds": [
          "secret"
        ]
      },
      "post": {
        "operationId": "updateSubscriptionLink",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Update a subscription link",
        "description": "Changes its name, trial, codes or landing page, or turns it off (active false) so its page says the link does not work, or back on. Its prices stay as they were: make a new link for other prices.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The subscription link's id, slk_ followed by 24 characters.",
            "schema": {
              "type": "string"
            },
            "example": "slk_g4v8x2c9q1m7k3r6t0ynwh5z"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "example": "link-membership-off"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "description": "Its new name.",
                    "type": "string",
                    "maxLength": 80,
                    "minLength": 1
                  },
                  "active": {
                    "description": "False turns the link off; true turns it back on.",
                    "type": "boolean"
                  },
                  "trialDays": {
                    "description": "A new free trial length, or null to take the trial away.",
                    "type": [
                      "integer",
                      "null"
                    ],
                    "minimum": 1,
                    "maximum": 730
                  },
                  "allowPromotionCodes": {
                    "description": "Whether the page takes a code.",
                    "type": "boolean"
                  },
                  "successUrl": {
                    "description": "A new landing page, or null for the link's own.",
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 2000
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "active": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubscriptionLink"
                },
                "example": {
                  "object": "subscription_link",
                  "id": "slk_g4v8x2c9q1m7k3r6t0ynwh5z",
                  "mode": "test",
                  "url": "https://payments.lk/s/4fQ9kZ2mR7xW1pL8vN3bT6",
                  "name": "Membership, monthly or yearly",
                  "prices": [
                    {
                      "id": "price_m3v8q1x6c9k2r5t7y0wn4hzp",
                      "productName": "Gym membership",
                      "nickname": null,
                      "unitAmountCents": 450000,
                      "interval": "month",
                      "intervalCount": 1,
                      "active": true
                    },
                    {
                      "id": "price_y5c1v8x3q9m2k7r4t0hwnz6p",
                      "productName": "Gym membership",
                      "nickname": "Yearly, two months free",
                      "unitAmountCents": 4500000,
                      "interval": "year",
                      "intervalCount": 1,
                      "active": true
                    }
                  ],
                  "trialDays": 7,
                  "allowPromotionCodes": true,
                  "successUrl": "https://gym.example/welcome",
                  "active": false,
                  "createdAt": "2026-09-25T08:30:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No subscription link with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      }
    },
    "/v1/billing_portal/sessions": {
      "post": {
        "operationId": "createBillingPortalSession",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Open the customer portal",
        "description": "A customer's way into the customer portal, where they see their subscriptions and invoices, change their card, and, as your billing settings allow, switch plan or cancel. Send the customer to url straight away: it works for an hour. Make one each time a signed in customer asks to manage their subscription. A new card is taken by a Rs. 10 check that is refunded at once.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Makes the write safe to retry. A key is remembered for 24 hours, separately for test and live keys: within that time the same key with the same body gets the first answer back instead of making a second one, and after it the key counts as new. Use a new key for every new write. 8 to 255 letters, digits, dashes, underscores, colons or dots.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,255}$"
            },
            "example": "portal-member-1042-20261016"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customerId": {
                    "description": "The customer, one of yours in this key's mode.",
                    "type": "string",
                    "pattern": "^cus_[0-9a-z]{20,32}$"
                  },
                  "returnUrl": {
                    "description": "Where the portal's back link takes the customer: https, or your app's scheme.",
                    "type": "string",
                    "maxLength": 2000
                  }
                },
                "required": [
                  "customerId"
                ],
                "additionalProperties": false
              },
              "example": {
                "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                "returnUrl": "https://gym.example/account"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingPortalSession"
                },
                "example": {
                  "object": "billing_portal.session",
                  "id": "bps_k3v8x1c6q9m2r5t7y0wn4hzp",
                  "mode": "test",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "url": "https://payments.lk/billing/Xq7d2V9kC4mZt1Wn8Rb5Hy3Lp6Gs0Jf2Ae4Uo7Ik9Nx",
                  "returnUrl": "https://gym.example/account",
                  "expiresAt": "2026-10-16T05:12:31.000Z",
                  "createdAt": "2026-10-16T04:12:31.000Z"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or not valid, fields names each one; or the body is not JSON. The Idempotency-Key header is missing, or is not 8 to 255 letters, digits, dashes, underscores, colons or dots. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "json_required",
                "docUrl": "https://payments.lk/developers/errors#json_required"
              },
              {
                "reason": "invalid_json",
                "docUrl": "https://payments.lk/developers/errors#invalid_json"
              },
              {
                "reason": "idempotency_key_missing",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_missing"
              }
            ]
          },
          "401": {
            "description": "The key is missing, malformed, or not a live key: revoked, expired or never issued. Explained at https://payments.lk/developers/errors#unauthenticated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "UNAUTHENTICATED",
            "x-doc-url": "https://payments.lk/developers/errors#unauthenticated",
            "x-error-reasons": [
              {
                "reason": "missing_api_key",
                "docUrl": "https://payments.lk/developers/errors#missing_api_key"
              },
              {
                "reason": "malformed_api_key",
                "docUrl": "https://payments.lk/developers/errors#malformed_api_key"
              },
              {
                "reason": "unknown_api_key",
                "docUrl": "https://payments.lk/developers/errors#unknown_api_key"
              }
            ]
          },
          "403": {
            "description": "This kind of key cannot do this: a publishable key may only create checkouts, and an agent key opens no REST endpoint. Explained at https://payments.lk/developers/errors#forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "FORBIDDEN",
            "x-doc-url": "https://payments.lk/developers/errors#forbidden",
            "x-error-reasons": [
              {
                "reason": "key_not_permitted",
                "docUrl": "https://payments.lk/developers/errors#key_not_permitted"
              }
            ]
          },
          "404": {
            "description": "No customer with this id for this key. Explained at https://payments.lk/developers/errors#not_found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "NOT_FOUND",
            "x-doc-url": "https://payments.lk/developers/errors#not_found"
          },
          "409": {
            "description": "The Idempotency-Key was already used with a different request, or the first request with it is still running. Explained at https://payments.lk/developers/errors#conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "CONFLICT",
            "x-doc-url": "https://payments.lk/developers/errors#conflict",
            "x-error-reasons": [
              {
                "reason": "idempotency_key_reused",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_reused"
              },
              {
                "reason": "idempotency_key_in_progress",
                "docUrl": "https://payments.lk/developers/errors#idempotency_key_in_progress"
              }
            ]
          },
          "413": {
            "description": "The body is larger than the API reads. Explained at https://payments.lk/developers/errors#validation_failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "VALIDATION_FAILED",
            "x-doc-url": "https://payments.lk/developers/errors#validation_failed",
            "x-error-reasons": [
              {
                "reason": "body_too_large",
                "docUrl": "https://payments.lk/developers/errors#body_too_large"
              }
            ]
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "x-permission": "billing:write",
        "x-key-kinds": [
          "secret"
        ],
        "x-idempotency-key": "required"
      }
    },
    "/v1/openapi.json": {
      "get": {
        "operationId": "getOpenApiDocument",
        "tags": [
          "Reference"
        ],
        "summary": "This document",
        "description": "The OpenAPI 3.1 description of this API, generated from the same schemas the API validates with. No key needed; any origin may read it.",
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "x-trace-id": {
                "$ref": "#/components/headers/x-trace-id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "openapi": {
                      "type": "string",
                      "const": "3.1.0"
                    },
                    "info": {
                      "type": "object",
                      "properties": {
                        "title": {
                          "type": "string"
                        },
                        "version": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "title",
                        "version"
                      ]
                    }
                  },
                  "required": [
                    "openapi",
                    "info"
                  ]
                },
                "example": {
                  "openapi": "3.1.0",
                  "info": {
                    "title": "Payments.lk API",
                    "version": "v1"
                  }
                }
              }
            }
          },
          "429": {
            "description": "More than 120 requests a minute from one address to this endpoint. Wait for Retry-After seconds. Explained at https://payments.lk/developers/errors#rate_limited.",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "RATE_LIMITED",
            "x-doc-url": "https://payments.lk/developers/errors#rate_limited"
          },
          "500": {
            "description": "Something failed on our side. Retry, with the same Idempotency-Key for a write. Explained at https://payments.lk/developers/errors#internal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "x-error-code": "INTERNAL",
            "x-doc-url": "https://payments.lk/developers/errors#internal"
          }
        },
        "security": []
      }
    }
  },
  "webhooks": {
    "payment.succeeded": {
      "post": {
        "operationId": "webhook_payment_succeeded",
        "summary": "payment.succeeded",
        "description": "The card was authorised and the payment succeeded. data is the payment, with its fee. Fulfil the order from this event.",
        "parameters": [
          {
            "name": "Payments-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> under the endpoint's signing secret (whsec_). While a rotated secret is kept, one v1 for each secret, the new one last: accept the delivery if any v1 matches. Refuse a delivery whose t is more than 300 seconds from your clock.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Payments-Event-Id",
            "in": "header",
            "required": true,
            "description": "The event's id, the same as id in the body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PaymentSucceededEvent"
              },
              "example": {
                "id": "evt_ev85ebwj9yqjq81vwf5qwz9m",
                "object": "event",
                "type": "payment.succeeded",
                "mode": "test",
                "created": "2026-09-18T09:16:41.000Z",
                "data": {
                  "object": "payment",
                  "id": "pay_x1n31wnp8nkbjkkhymtqd6zs",
                  "mode": "test",
                  "status": "succeeded",
                  "amountCents": 350000,
                  "currency": "LKR",
                  "description": "Two kottu and a milk tea",
                  "reference": "order-8891",
                  "customer": {
                    "name": "Nimali Perera",
                    "email": "nimali@example.lk",
                    "phone": "0771234567"
                  },
                  "card": {
                    "scheme": "VISA",
                    "last4": "4242"
                  },
                  "cardSave": "not_requested",
                  "feeCents": 8015,
                  "netCents": 341985,
                  "refundedCents": 0,
                  "failureMessage": null,
                  "paymentLinkId": null,
                  "savedCardId": null,
                  "invoiceId": null,
                  "checkoutId": "chk_z6zf7gkx4fcwy3402kmwrm3w",
                  "checkoutPageId": null,
                  "order": null,
                  "delivery": null,
                  "customFields": null,
                  "customerTaxId": null,
                  "termsAcceptedAt": null,
                  "createdAt": "2026-09-18T09:14:05.000Z",
                  "succeededAt": "2026-09-18T09:16:41.000Z"
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx answer marks the delivery done. Anything else, or no answer within the timeout, is retried."
          }
        }
      }
    },
    "payment.failed": {
      "post": {
        "operationId": "webhook_payment_failed",
        "summary": "payment.failed",
        "description": "The card was declined or the payment was not completed. data is the payment, with failureMessage.",
        "parameters": [
          {
            "name": "Payments-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> under the endpoint's signing secret (whsec_). While a rotated secret is kept, one v1 for each secret, the new one last: accept the delivery if any v1 matches. Refuse a delivery whose t is more than 300 seconds from your clock.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Payments-Event-Id",
            "in": "header",
            "required": true,
            "description": "The event's id, the same as id in the body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PaymentFailedEvent"
              },
              "example": {
                "id": "evt_wxb2ycr0s580brjpes23aw67",
                "object": "event",
                "type": "payment.failed",
                "mode": "test",
                "created": "2026-09-17T18:42:30.000Z",
                "data": {
                  "object": "payment",
                  "id": "pay_hj31hwy2mavtcbrfb2b2zz3n",
                  "mode": "test",
                  "status": "failed",
                  "amountCents": 520000,
                  "currency": "LKR",
                  "description": "Lamprais for four",
                  "reference": "order-8874",
                  "customer": {
                    "name": "Nimali Perera",
                    "email": "nimali@example.lk",
                    "phone": "0771234567"
                  },
                  "card": {
                    "scheme": "MASTERCARD",
                    "last4": "5100"
                  },
                  "cardSave": "not_requested",
                  "feeCents": null,
                  "netCents": null,
                  "refundedCents": 0,
                  "failureMessage": "The card was declined.",
                  "paymentLinkId": null,
                  "savedCardId": null,
                  "invoiceId": null,
                  "checkoutId": "chk_4ne3cpz1r2a8g5vq7xk0m9dt",
                  "checkoutPageId": null,
                  "order": null,
                  "delivery": null,
                  "customFields": null,
                  "customerTaxId": null,
                  "termsAcceptedAt": null,
                  "createdAt": "2026-09-17T18:40:12.000Z",
                  "succeededAt": null
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx answer marks the delivery done. Anything else, or no answer within the timeout, is retried."
          }
        }
      }
    },
    "checkout.expired": {
      "post": {
        "operationId": "webhook_checkout_expired",
        "summary": "checkout.expired",
        "description": "Nobody paid the checkout before it expired. data names the checkout and its payment, which is now canceled.",
        "parameters": [
          {
            "name": "Payments-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> under the endpoint's signing secret (whsec_). While a rotated secret is kept, one v1 for each secret, the new one last: accept the delivery if any v1 matches. Refuse a delivery whose t is more than 300 seconds from your clock.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Payments-Event-Id",
            "in": "header",
            "required": true,
            "description": "The event's id, the same as id in the body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CheckoutExpiredEvent"
              },
              "example": {
                "id": "evt_r0my8wv91rgsx5fjb848aqpp",
                "object": "event",
                "type": "checkout.expired",
                "mode": "test",
                "created": "2026-09-18T10:31:00.000Z",
                "data": {
                  "object": "checkout",
                  "id": "chk_wnqa1fax67k19rt7td9cc3j2",
                  "paymentId": "pay_xsrps207y12k0c1y5f85jbvz"
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx answer marks the delivery done. Anything else, or no answer within the timeout, is retried."
          }
        }
      }
    },
    "card.saved": {
      "post": {
        "operationId": "webhook_card_saved",
        "summary": "card.saved",
        "description": "The customer kept their card on file. data is the saved card; keep its id to charge it later.",
        "parameters": [
          {
            "name": "Payments-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> under the endpoint's signing secret (whsec_). While a rotated secret is kept, one v1 for each secret, the new one last: accept the delivery if any v1 matches. Refuse a delivery whose t is more than 300 seconds from your clock.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Payments-Event-Id",
            "in": "header",
            "required": true,
            "description": "The event's id, the same as id in the body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CardSavedEvent"
              },
              "example": {
                "id": "evt_w2fx9rtd0sa7fx2kt2vhbh9a",
                "object": "event",
                "type": "card.saved",
                "mode": "test",
                "created": "2026-09-02T07:30:44.000Z",
                "data": {
                  "object": "saved_card",
                  "id": "card_g2a1rex14ff7qh2dc6j6qzmq",
                  "mode": "test",
                  "customerEmail": "ruwan@example.lk",
                  "scheme": "VISA",
                  "last4": "4242",
                  "expiry": {
                    "month": 11,
                    "year": 2029
                  },
                  "paymentId": "pay_x1n31wnp8nkbjkkhymtqd6zs",
                  "consent": {
                    "agreedAt": "2026-09-02T07:30:41.000Z",
                    "locale": "en",
                    "wording": "checkoutPage.saveCard@1"
                  },
                  "active": true,
                  "createdAt": "2026-09-02T07:30:44.000Z",
                  "retiredAt": null
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx answer marks the delivery done. Anything else, or no answer within the timeout, is retried."
          }
        }
      }
    },
    "card.save_failed": {
      "post": {
        "operationId": "webhook_card_save_failed",
        "summary": "card.save_failed",
        "description": "A payment that was to keep the customer's card succeeded, but the card was not kept: Payable did not tokenise it, or its answer carried no token. data is the payment, whose cardSave is failed; no card.saved follows. Ask the customer to add the card again. A subscription it was for, left with no card, shows cardMissingSince, and its renewals are emailed to the customer to pay, with a link to add a card.",
        "parameters": [
          {
            "name": "Payments-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> under the endpoint's signing secret (whsec_). While a rotated secret is kept, one v1 for each secret, the new one last: accept the delivery if any v1 matches. Refuse a delivery whose t is more than 300 seconds from your clock.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Payments-Event-Id",
            "in": "header",
            "required": true,
            "description": "The event's id, the same as id in the body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CardSaveFailedEvent"
              },
              "example": {
                "id": "evt_c8f3v1x6q9m2k5r7t0ynhw4z",
                "object": "event",
                "type": "card.save_failed",
                "mode": "test",
                "created": "2026-09-18T09:16:41.000Z",
                "data": {
                  "object": "payment",
                  "id": "pay_x1n31wnp8nkbjkkhymtqd6zs",
                  "mode": "test",
                  "status": "succeeded",
                  "amountCents": 350000,
                  "currency": "LKR",
                  "description": "Two kottu and a milk tea",
                  "reference": "order-8891",
                  "customer": {
                    "name": "Nimali Perera",
                    "email": "nimali@example.lk",
                    "phone": "0771234567"
                  },
                  "card": {
                    "scheme": "VISA",
                    "last4": "4242"
                  },
                  "cardSave": "failed",
                  "feeCents": 8015,
                  "netCents": 341985,
                  "refundedCents": 0,
                  "failureMessage": null,
                  "paymentLinkId": null,
                  "savedCardId": null,
                  "invoiceId": null,
                  "checkoutId": "chk_z6zf7gkx4fcwy3402kmwrm3w",
                  "checkoutPageId": null,
                  "order": null,
                  "delivery": null,
                  "customFields": null,
                  "customerTaxId": null,
                  "termsAcceptedAt": null,
                  "createdAt": "2026-09-18T09:14:05.000Z",
                  "succeededAt": "2026-09-18T09:16:41.000Z"
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx answer marks the delivery done. Anything else, or no answer within the timeout, is retried."
          }
        }
      }
    },
    "card.expiring": {
      "post": {
        "operationId": "webhook_card_expiring",
        "summary": "card.expiring",
        "description": "A saved card that a running subscription is charged to expires at the end of this month. data is the saved card; the customer is emailed a link to the customer portal to change it.",
        "parameters": [
          {
            "name": "Payments-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> under the endpoint's signing secret (whsec_). While a rotated secret is kept, one v1 for each secret, the new one last: accept the delivery if any v1 matches. Refuse a delivery whose t is more than 300 seconds from your clock.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Payments-Event-Id",
            "in": "header",
            "required": true,
            "description": "The event's id, the same as id in the body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CardExpiringEvent"
              },
              "example": {
                "id": "evt_c7x2v9k1q4m8e3r6t0ynhz5w",
                "object": "event",
                "type": "card.expiring",
                "mode": "test",
                "created": "2026-11-15T09:30:00.000Z",
                "data": {
                  "object": "saved_card",
                  "id": "card_g2a1rex14ff7qh2dc6j6qzmq",
                  "mode": "test",
                  "customerEmail": "ruwan@example.lk",
                  "scheme": "VISA",
                  "last4": "4242",
                  "expiry": {
                    "month": 11,
                    "year": 2029
                  },
                  "paymentId": "pay_x1n31wnp8nkbjkkhymtqd6zs",
                  "consent": {
                    "agreedAt": "2026-09-02T07:30:41.000Z",
                    "locale": "en",
                    "wording": "checkoutPage.saveCard@1"
                  },
                  "active": true,
                  "createdAt": "2026-09-02T07:30:44.000Z",
                  "retiredAt": null
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx answer marks the delivery done. Anything else, or no answer within the timeout, is retried."
          }
        }
      }
    },
    "billing.alert.triggered": {
      "post": {
        "operationId": "webhook_billing_alert_triggered",
        "summary": "billing.alert.triggered",
        "description": "A customer's usage on a meter in their current period reached a usage alert's threshold. data is the alert, the customer and the usage; it is sent once per alert and customer.",
        "parameters": [
          {
            "name": "Payments-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> under the endpoint's signing secret (whsec_). While a rotated secret is kept, one v1 for each secret, the new one last: accept the delivery if any v1 matches. Refuse a delivery whose t is more than 300 seconds from your clock.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Payments-Event-Id",
            "in": "header",
            "required": true,
            "description": "The event's id, the same as id in the body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BillingAlertTriggeredEvent"
              },
              "example": {
                "id": "evt_b8a2v7x1c9q4m3k6r0tnhw5z",
                "object": "event",
                "type": "billing.alert.triggered",
                "mode": "test",
                "created": "2026-11-15T09:30:00.000Z",
                "data": {
                  "object": "usage_alert_trigger",
                  "alertId": "ual_t3v9x1c7q2m8k4r6y0wnhz5p",
                  "title": "10,000 API calls",
                  "meterId": "mtr_a4c8v2x9q1m7k3r6t0yhwn5z",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "threshold": 10000,
                  "value": 10012,
                  "triggeredAt": "2026-10-18T06:40:12.000Z"
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx answer marks the delivery done. Anything else, or no answer within the timeout, is retried."
          }
        }
      }
    },
    "subscription_schedule.created": {
      "post": {
        "operationId": "webhook_subscription_schedule_created",
        "summary": "subscription_schedule.created",
        "description": "A subscription schedule was made. data is the schedule; its subscription starts on startDate.",
        "parameters": [
          {
            "name": "Payments-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> under the endpoint's signing secret (whsec_). While a rotated secret is kept, one v1 for each secret, the new one last: accept the delivery if any v1 matches. Refuse a delivery whose t is more than 300 seconds from your clock.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Payments-Event-Id",
            "in": "header",
            "required": true,
            "description": "The event's id, the same as id in the body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubscriptionScheduleCreatedEvent"
              },
              "example": {
                "id": "evt_d1s8v3x7c2q9m4k6r0tnhw5y",
                "object": "event",
                "type": "subscription_schedule.created",
                "mode": "test",
                "created": "2026-11-15T09:30:00.000Z",
                "data": {
                  "object": "subscription_schedule",
                  "id": "sched_c6v2x9q1m8k4r7t3y0hwnz5p",
                  "mode": "test",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "subscriptionId": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "status": "active",
                  "endBehavior": "cancel",
                  "startDate": "2026-10-01T04:12:31.000Z",
                  "phases": [
                    {
                      "items": [
                        {
                          "priceId": "price_i7c3v9x2q8m1k6r4t0ynwh5z",
                          "quantity": 1
                        }
                      ],
                      "iterations": 12,
                      "trialDays": null,
                      "couponId": null
                    }
                  ],
                  "currentPhase": 0,
                  "currentPhaseEndsAt": "2027-10-01T04:12:31.000Z",
                  "reference": "Diploma, 12 installments",
                  "completedAt": null,
                  "releasedAt": null,
                  "canceledAt": null,
                  "createdAt": "2026-10-01T04:12:31.000Z"
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx answer marks the delivery done. Anything else, or no answer within the timeout, is retried."
          }
        }
      }
    },
    "subscription_schedule.completed": {
      "post": {
        "operationId": "webhook_subscription_schedule_completed",
        "summary": "subscription_schedule.completed",
        "description": "A schedule's last phase ended and, as its endBehavior is cancel, so did its subscription. data is the schedule.",
        "parameters": [
          {
            "name": "Payments-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> under the endpoint's signing secret (whsec_). While a rotated secret is kept, one v1 for each secret, the new one last: accept the delivery if any v1 matches. Refuse a delivery whose t is more than 300 seconds from your clock.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Payments-Event-Id",
            "in": "header",
            "required": true,
            "description": "The event's id, the same as id in the body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubscriptionScheduleCompletedEvent"
              },
              "example": {
                "id": "evt_d2s9v4x8c3q1m5k7r0ynhw6z",
                "object": "event",
                "type": "subscription_schedule.completed",
                "mode": "test",
                "created": "2026-11-15T09:30:00.000Z",
                "data": {
                  "object": "subscription_schedule",
                  "id": "sched_c6v2x9q1m8k4r7t3y0hwnz5p",
                  "mode": "test",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "subscriptionId": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "status": "completed",
                  "endBehavior": "cancel",
                  "startDate": "2026-10-01T04:12:31.000Z",
                  "phases": [
                    {
                      "items": [
                        {
                          "priceId": "price_i7c3v9x2q8m1k6r4t0ynwh5z",
                          "quantity": 1
                        }
                      ],
                      "iterations": 12,
                      "trialDays": null,
                      "couponId": null
                    }
                  ],
                  "currentPhase": 0,
                  "currentPhaseEndsAt": null,
                  "reference": "Diploma, 12 installments",
                  "completedAt": "2027-10-01T04:12:31.000Z",
                  "releasedAt": null,
                  "canceledAt": null,
                  "createdAt": "2026-10-01T04:12:31.000Z"
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx answer marks the delivery done. Anything else, or no answer within the timeout, is retried."
          }
        }
      }
    },
    "subscription_schedule.released": {
      "post": {
        "operationId": "webhook_subscription_schedule_released",
        "summary": "subscription_schedule.released",
        "description": "A schedule let go of its subscription, which carries on as it is: after its last phase with endBehavior release, or released by you. data is the schedule.",
        "parameters": [
          {
            "name": "Payments-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> under the endpoint's signing secret (whsec_). While a rotated secret is kept, one v1 for each secret, the new one last: accept the delivery if any v1 matches. Refuse a delivery whose t is more than 300 seconds from your clock.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Payments-Event-Id",
            "in": "header",
            "required": true,
            "description": "The event's id, the same as id in the body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubscriptionScheduleReleasedEvent"
              },
              "example": {
                "id": "evt_d3s1v5x9c4q2m6k8r0hwnz7y",
                "object": "event",
                "type": "subscription_schedule.released",
                "mode": "test",
                "created": "2026-11-15T09:30:00.000Z",
                "data": {
                  "object": "subscription_schedule",
                  "id": "sched_c6v2x9q1m8k4r7t3y0hwnz5p",
                  "mode": "test",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "subscriptionId": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "status": "released",
                  "endBehavior": "release",
                  "startDate": "2026-10-01T04:12:31.000Z",
                  "phases": [
                    {
                      "items": [
                        {
                          "priceId": "price_i7c3v9x2q8m1k6r4t0ynwh5z",
                          "quantity": 1
                        }
                      ],
                      "iterations": 12,
                      "trialDays": null,
                      "couponId": null
                    }
                  ],
                  "currentPhase": 0,
                  "currentPhaseEndsAt": null,
                  "reference": "Diploma, 12 installments",
                  "completedAt": null,
                  "releasedAt": "2027-10-01T04:12:31.000Z",
                  "canceledAt": null,
                  "createdAt": "2026-10-01T04:12:31.000Z"
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx answer marks the delivery done. Anything else, or no answer within the timeout, is retried."
          }
        }
      }
    },
    "subscription_schedule.canceled": {
      "post": {
        "operationId": "webhook_subscription_schedule_canceled",
        "summary": "subscription_schedule.canceled",
        "description": "A schedule was canceled, by you or because its subscription ended some other way. data is the schedule.",
        "parameters": [
          {
            "name": "Payments-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> under the endpoint's signing secret (whsec_). While a rotated secret is kept, one v1 for each secret, the new one last: accept the delivery if any v1 matches. Refuse a delivery whose t is more than 300 seconds from your clock.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Payments-Event-Id",
            "in": "header",
            "required": true,
            "description": "The event's id, the same as id in the body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubscriptionScheduleCanceledEvent"
              },
              "example": {
                "id": "evt_d4s2v6x1c5q3m7k9r0wnhy8z",
                "object": "event",
                "type": "subscription_schedule.canceled",
                "mode": "test",
                "created": "2026-11-15T09:30:00.000Z",
                "data": {
                  "object": "subscription_schedule",
                  "id": "sched_c6v2x9q1m8k4r7t3y0hwnz5p",
                  "mode": "test",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "subscriptionId": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "status": "canceled",
                  "endBehavior": "cancel",
                  "startDate": "2026-10-01T04:12:31.000Z",
                  "phases": [
                    {
                      "items": [
                        {
                          "priceId": "price_i7c3v9x2q8m1k6r4t0ynwh5z",
                          "quantity": 1
                        }
                      ],
                      "iterations": 12,
                      "trialDays": null,
                      "couponId": null
                    }
                  ],
                  "currentPhase": 0,
                  "currentPhaseEndsAt": null,
                  "reference": "Diploma, 12 installments",
                  "completedAt": null,
                  "releasedAt": null,
                  "canceledAt": "2027-02-01T04:12:31.000Z",
                  "createdAt": "2026-10-01T04:12:31.000Z"
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx answer marks the delivery done. Anything else, or no answer within the timeout, is retried."
          }
        }
      }
    },
    "refund.succeeded": {
      "post": {
        "operationId": "webhook_refund_succeeded",
        "summary": "refund.succeeded",
        "description": "The refund went through. data is the refund, with the payment as it stands after it.",
        "parameters": [
          {
            "name": "Payments-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> under the endpoint's signing secret (whsec_). While a rotated secret is kept, one v1 for each secret, the new one last: accept the delivery if any v1 matches. Refuse a delivery whose t is more than 300 seconds from your clock.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Payments-Event-Id",
            "in": "header",
            "required": true,
            "description": "The event's id, the same as id in the body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RefundSucceededEvent"
              },
              "example": {
                "id": "evt_np6d7c5k65jryr0jdgmavejf",
                "object": "event",
                "type": "refund.succeeded",
                "mode": "test",
                "created": "2026-09-19T10:05:52.000Z",
                "data": {
                  "object": "refund",
                  "id": "re_sbca5jeftvf7acqsx5rvdzk3",
                  "mode": "test",
                  "paymentId": "pay_x1n31wnp8nkbjkkhymtqd6zs",
                  "status": "succeeded",
                  "amountCents": 50000,
                  "currency": "LKR",
                  "reason": "The milk tea was not available",
                  "failureMessage": null,
                  "createdAt": "2026-09-19T10:02:17.000Z",
                  "succeededAt": "2026-09-19T10:05:52.000Z",
                  "payment": {
                    "object": "payment",
                    "id": "pay_x1n31wnp8nkbjkkhymtqd6zs",
                    "mode": "test",
                    "status": "partially_refunded",
                    "amountCents": 350000,
                    "currency": "LKR",
                    "description": "Two kottu and a milk tea",
                    "reference": "order-8891",
                    "customer": {
                      "name": "Nimali Perera",
                      "email": "nimali@example.lk",
                      "phone": "0771234567"
                    },
                    "card": {
                      "scheme": "VISA",
                      "last4": "4242"
                    },
                    "cardSave": "not_requested",
                    "feeCents": 8015,
                    "netCents": 341985,
                    "refundedCents": 50000,
                    "failureMessage": null,
                    "paymentLinkId": null,
                    "savedCardId": null,
                    "invoiceId": null,
                    "checkoutId": null,
                    "checkoutPageId": null,
                    "order": null,
                    "delivery": null,
                    "customFields": null,
                    "customerTaxId": null,
                    "termsAcceptedAt": null,
                    "createdAt": "2026-09-18T09:14:05.000Z",
                    "succeededAt": "2026-09-18T09:16:41.000Z"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx answer marks the delivery done. Anything else, or no answer within the timeout, is retried."
          }
        }
      }
    },
    "refund.failed": {
      "post": {
        "operationId": "webhook_refund_failed",
        "summary": "refund.failed",
        "description": "The refund could not be made. data is the refund, with failureMessage, and the payment it was for.",
        "parameters": [
          {
            "name": "Payments-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> under the endpoint's signing secret (whsec_). While a rotated secret is kept, one v1 for each secret, the new one last: accept the delivery if any v1 matches. Refuse a delivery whose t is more than 300 seconds from your clock.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Payments-Event-Id",
            "in": "header",
            "required": true,
            "description": "The event's id, the same as id in the body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RefundFailedEvent"
              },
              "example": {
                "id": "evt_v2z2cg8qe8w2mcqxbs7s7btd",
                "object": "event",
                "type": "refund.failed",
                "mode": "test",
                "created": "2026-09-19T10:05:52.000Z",
                "data": {
                  "object": "refund",
                  "id": "re_sbca5jeftvf7acqsx5rvdzk3",
                  "mode": "test",
                  "paymentId": "pay_x1n31wnp8nkbjkkhymtqd6zs",
                  "status": "failed",
                  "amountCents": 50000,
                  "currency": "LKR",
                  "reason": "The milk tea was not available",
                  "failureMessage": "The refund could not be processed.",
                  "createdAt": "2026-09-19T10:02:17.000Z",
                  "succeededAt": null,
                  "payment": {
                    "object": "payment",
                    "id": "pay_x1n31wnp8nkbjkkhymtqd6zs",
                    "mode": "test",
                    "status": "succeeded",
                    "amountCents": 350000,
                    "currency": "LKR",
                    "description": "Two kottu and a milk tea",
                    "reference": "order-8891",
                    "customer": {
                      "name": "Nimali Perera",
                      "email": "nimali@example.lk",
                      "phone": "0771234567"
                    },
                    "card": {
                      "scheme": "VISA",
                      "last4": "4242"
                    },
                    "cardSave": "not_requested",
                    "feeCents": 8015,
                    "netCents": 341985,
                    "refundedCents": 0,
                    "failureMessage": null,
                    "paymentLinkId": null,
                    "savedCardId": null,
                    "invoiceId": null,
                    "checkoutId": null,
                    "checkoutPageId": null,
                    "order": null,
                    "delivery": null,
                    "customFields": null,
                    "customerTaxId": null,
                    "termsAcceptedAt": null,
                    "createdAt": "2026-09-18T09:14:05.000Z",
                    "succeededAt": "2026-09-18T09:16:41.000Z"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx answer marks the delivery done. Anything else, or no answer within the timeout, is retried."
          }
        }
      }
    },
    "account.limit.approaching": {
      "post": {
        "operationId": "webhook_account_limit_approaching",
        "summary": "account.limit.approaching",
        "description": "This month's live card payments reached 60, 70, 80 or 90 percent of your plan's monthly limit; threshold says which. Sent once a month per threshold. data is the month's usage, with projectedAt when the pace says when the limit will be reached.",
        "parameters": [
          {
            "name": "Payments-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> under the endpoint's signing secret (whsec_). While a rotated secret is kept, one v1 for each secret, the new one last: accept the delivery if any v1 matches. Refuse a delivery whose t is more than 300 seconds from your clock.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Payments-Event-Id",
            "in": "header",
            "required": true,
            "description": "The event's id, the same as id in the body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountLimitApproachingEvent"
              },
              "example": {
                "id": "evt_k7m2q9x4v1c8r3t6y0wz5hnd",
                "object": "event",
                "type": "account.limit.approaching",
                "mode": "live",
                "created": "2026-09-19T11:40:00.000Z",
                "data": {
                  "object": "account_usage",
                  "month": "2026-09",
                  "plan": "starter",
                  "capCents": 10000000,
                  "settledCents": 8120000,
                  "percent": 81,
                  "threshold": 80,
                  "refusedCount": 0,
                  "refusedCents": 0,
                  "resetsAt": "2026-09-30T18:30:00.000Z",
                  "projectedAt": "2026-09-24T09:12:00.000Z"
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx answer marks the delivery done. Anything else, or no answer within the timeout, is retried."
          }
        }
      }
    },
    "account.limit.reached": {
      "post": {
        "operationId": "webhook_account_limit_reached",
        "summary": "account.limit.reached",
        "description": "Your plan's monthly limit now stands in the way of live card payments: the month reached it, or a payment that would pass it was refused. Payments that would pass the limit are refused until you upgrade or the month resets on the 1st. data is the month's usage.",
        "parameters": [
          {
            "name": "Payments-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> under the endpoint's signing secret (whsec_). While a rotated secret is kept, one v1 for each secret, the new one last: accept the delivery if any v1 matches. Refuse a delivery whose t is more than 300 seconds from your clock.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Payments-Event-Id",
            "in": "header",
            "required": true,
            "description": "The event's id, the same as id in the body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountLimitReachedEvent"
              },
              "example": {
                "id": "evt_p3v8n1x6c9m2q5r7t0yk4hwz",
                "object": "event",
                "type": "account.limit.reached",
                "mode": "live",
                "created": "2026-09-24T09:15:00.000Z",
                "data": {
                  "object": "account_usage",
                  "month": "2026-09",
                  "plan": "starter",
                  "capCents": 10000000,
                  "settledCents": 9750000,
                  "percent": 97,
                  "threshold": 100,
                  "refusedCount": 1,
                  "refusedCents": 450000,
                  "resetsAt": "2026-09-30T18:30:00.000Z",
                  "projectedAt": null
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx answer marks the delivery done. Anything else, or no answer within the timeout, is retried."
          }
        }
      }
    },
    "account.limit.reset": {
      "post": {
        "operationId": "webhook_account_limit_reset",
        "summary": "account.limit.reset",
        "description": "A new month began after one that reached the limit. data is the finished month's usage, with how many payments the limit refused and what they came to.",
        "parameters": [
          {
            "name": "Payments-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> under the endpoint's signing secret (whsec_). While a rotated secret is kept, one v1 for each secret, the new one last: accept the delivery if any v1 matches. Refuse a delivery whose t is more than 300 seconds from your clock.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Payments-Event-Id",
            "in": "header",
            "required": true,
            "description": "The event's id, the same as id in the body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountLimitResetEvent"
              },
              "example": {
                "id": "evt_z9c4m7q2x8v1n5r3t6yh0kwp",
                "object": "event",
                "type": "account.limit.reset",
                "mode": "live",
                "created": "2026-09-30T18:31:00.000Z",
                "data": {
                  "object": "account_usage",
                  "month": "2026-09",
                  "plan": "starter",
                  "capCents": 10000000,
                  "settledCents": 9750000,
                  "percent": 97,
                  "threshold": 100,
                  "refusedCount": 3,
                  "refusedCents": 1280000,
                  "resetsAt": "2026-09-30T18:30:00.000Z",
                  "projectedAt": null
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx answer marks the delivery done. Anything else, or no answer within the timeout, is retried."
          }
        }
      }
    },
    "customer.subscription.created": {
      "post": {
        "operationId": "webhook_customer_subscription_created",
        "summary": "customer.subscription.created",
        "description": "A subscription was made. It is incomplete until its first invoice is paid. data is the subscription.",
        "parameters": [
          {
            "name": "Payments-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> under the endpoint's signing secret (whsec_). While a rotated secret is kept, one v1 for each secret, the new one last: accept the delivery if any v1 matches. Refuse a delivery whose t is more than 300 seconds from your clock.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Payments-Event-Id",
            "in": "header",
            "required": true,
            "description": "The event's id, the same as id in the body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubscriptionCreatedEvent"
              },
              "example": {
                "id": "evt_s1c8v2x7q4m9k3r6t0yhwn5z",
                "object": "event",
                "type": "customer.subscription.created",
                "mode": "test",
                "created": "2026-10-01T04:12:31.000Z",
                "data": {
                  "object": "subscription",
                  "id": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "mode": "test",
                  "status": "incomplete",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "price": {
                    "id": "price_m3v8q1x6c9k2r5t7y0wn4hzp",
                    "productName": "Gym membership",
                    "unitAmountCents": 450000,
                    "interval": "month",
                    "intervalCount": 1
                  },
                  "quantity": 1,
                  "items": [
                    {
                      "id": "si_t4c9v2x7q1m6k8r3y0wnhz5p",
                      "price": {
                        "id": "price_m3v8q1x6c9k2r5t7y0wn4hzp",
                        "productName": "Gym membership",
                        "unitAmountCents": 450000,
                        "interval": "month",
                        "intervalCount": 1
                      },
                      "quantity": 1
                    }
                  ],
                  "currentPeriodStart": "2026-10-01T04:12:31.000Z",
                  "currentPeriodEnd": "2026-11-01T04:12:31.000Z",
                  "billingCycleAnchor": "2026-10-01T04:12:31.000Z",
                  "cancelAtPeriodEnd": false,
                  "cancelAt": null,
                  "canceledAt": null,
                  "endedAt": null,
                  "cancelReason": null,
                  "cancellationDetails": {
                    "reason": null,
                    "feedback": null,
                    "comment": null
                  },
                  "trialStart": null,
                  "trialEnd": null,
                  "trialEndBehavior": "create_invoice",
                  "pauseCollection": null,
                  "discount": null,
                  "taxRateIds": [],
                  "subscriptionLinkId": null,
                  "collectionMethod": "charge_automatically",
                  "daysUntilDue": null,
                  "pendingUpdate": null,
                  "cardId": null,
                  "cardMissingSince": null,
                  "latestInvoiceId": "in_c4v9x2q7m1k8r3t6y0wnzhp5",
                  "checkoutUrl": "https://payments.lk/checkout/chk_r8v2x6c1q9m4k7t3y0wnzh5p",
                  "reference": "member-1042",
                  "createdAt": "2026-10-01T04:12:31.000Z"
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx answer marks the delivery done. Anything else, or no answer within the timeout, is retried."
          }
        }
      }
    },
    "customer.subscription.updated": {
      "post": {
        "operationId": "webhook_customer_subscription_updated",
        "summary": "customer.subscription.updated",
        "description": "A subscription changed: it turned active, past_due or unpaid, moved to its next period, was set to cancel at period end, or expired unpaid. data is the subscription as it stands.",
        "parameters": [
          {
            "name": "Payments-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> under the endpoint's signing secret (whsec_). While a rotated secret is kept, one v1 for each secret, the new one last: accept the delivery if any v1 matches. Refuse a delivery whose t is more than 300 seconds from your clock.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Payments-Event-Id",
            "in": "header",
            "required": true,
            "description": "The event's id, the same as id in the body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubscriptionUpdatedEvent"
              },
              "example": {
                "id": "evt_s2v9x3c8q1m6k4r7t0ynhw5z",
                "object": "event",
                "type": "customer.subscription.updated",
                "mode": "test",
                "created": "2026-10-01T04:15:02.000Z",
                "data": {
                  "object": "subscription",
                  "id": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "mode": "test",
                  "status": "active",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "price": {
                    "id": "price_m3v8q1x6c9k2r5t7y0wn4hzp",
                    "productName": "Gym membership",
                    "unitAmountCents": 450000,
                    "interval": "month",
                    "intervalCount": 1
                  },
                  "quantity": 1,
                  "items": [
                    {
                      "id": "si_t4c9v2x7q1m6k8r3y0wnhz5p",
                      "price": {
                        "id": "price_m3v8q1x6c9k2r5t7y0wn4hzp",
                        "productName": "Gym membership",
                        "unitAmountCents": 450000,
                        "interval": "month",
                        "intervalCount": 1
                      },
                      "quantity": 1
                    }
                  ],
                  "currentPeriodStart": "2026-10-01T04:12:31.000Z",
                  "currentPeriodEnd": "2026-11-01T04:12:31.000Z",
                  "billingCycleAnchor": "2026-10-01T04:12:31.000Z",
                  "cancelAtPeriodEnd": false,
                  "cancelAt": null,
                  "canceledAt": null,
                  "endedAt": null,
                  "cancelReason": null,
                  "cancellationDetails": {
                    "reason": null,
                    "feedback": null,
                    "comment": null
                  },
                  "trialStart": null,
                  "trialEnd": null,
                  "trialEndBehavior": "create_invoice",
                  "pauseCollection": null,
                  "discount": null,
                  "taxRateIds": [],
                  "subscriptionLinkId": null,
                  "collectionMethod": "charge_automatically",
                  "daysUntilDue": null,
                  "pendingUpdate": null,
                  "cardId": "card_g2a1rex14ff7qh2dc6j6qzmq",
                  "cardMissingSince": null,
                  "latestInvoiceId": "in_c4v9x2q7m1k8r3t6y0wnzhp5",
                  "checkoutUrl": null,
                  "reference": "member-1042",
                  "createdAt": "2026-10-01T04:12:31.000Z"
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx answer marks the delivery done. Anything else, or no answer within the timeout, is retried."
          }
        }
      }
    },
    "customer.subscription.deleted": {
      "post": {
        "operationId": "webhook_customer_subscription_deleted",
        "summary": "customer.subscription.deleted",
        "description": "A subscription ended: canceled now, at the end of its period, or for non-payment after the last retry and the grace days. data is the subscription. Revoke access.",
        "parameters": [
          {
            "name": "Payments-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> under the endpoint's signing secret (whsec_). While a rotated secret is kept, one v1 for each secret, the new one last: accept the delivery if any v1 matches. Refuse a delivery whose t is more than 300 seconds from your clock.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Payments-Event-Id",
            "in": "header",
            "required": true,
            "description": "The event's id, the same as id in the body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubscriptionDeletedEvent"
              },
              "example": {
                "id": "evt_s3x1v6c9q2m8k5r4t0zyhw7n",
                "object": "event",
                "type": "customer.subscription.deleted",
                "mode": "test",
                "created": "2026-10-20T08:00:00.000Z",
                "data": {
                  "object": "subscription",
                  "id": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "mode": "test",
                  "status": "canceled",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "price": {
                    "id": "price_m3v8q1x6c9k2r5t7y0wn4hzp",
                    "productName": "Gym membership",
                    "unitAmountCents": 450000,
                    "interval": "month",
                    "intervalCount": 1
                  },
                  "quantity": 1,
                  "items": [
                    {
                      "id": "si_t4c9v2x7q1m6k8r3y0wnhz5p",
                      "price": {
                        "id": "price_m3v8q1x6c9k2r5t7y0wn4hzp",
                        "productName": "Gym membership",
                        "unitAmountCents": 450000,
                        "interval": "month",
                        "intervalCount": 1
                      },
                      "quantity": 1
                    }
                  ],
                  "currentPeriodStart": "2026-10-01T04:12:31.000Z",
                  "currentPeriodEnd": "2026-11-01T04:12:31.000Z",
                  "billingCycleAnchor": "2026-10-01T04:12:31.000Z",
                  "cancelAtPeriodEnd": false,
                  "cancelAt": null,
                  "canceledAt": "2026-10-20T08:00:00.000Z",
                  "endedAt": "2026-10-20T08:00:00.000Z",
                  "cancelReason": "requested_by_merchant",
                  "cancellationDetails": {
                    "reason": "requested_by_merchant",
                    "feedback": "too_expensive",
                    "comment": "Moving to the branch closer to home."
                  },
                  "trialStart": null,
                  "trialEnd": null,
                  "trialEndBehavior": "create_invoice",
                  "pauseCollection": null,
                  "discount": null,
                  "taxRateIds": [],
                  "subscriptionLinkId": null,
                  "collectionMethod": "charge_automatically",
                  "daysUntilDue": null,
                  "pendingUpdate": null,
                  "cardId": "card_g2a1rex14ff7qh2dc6j6qzmq",
                  "cardMissingSince": null,
                  "latestInvoiceId": "in_c4v9x2q7m1k8r3t6y0wnzhp5",
                  "checkoutUrl": null,
                  "reference": "member-1042",
                  "createdAt": "2026-10-01T04:12:31.000Z"
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx answer marks the delivery done. Anything else, or no answer within the timeout, is retried."
          }
        }
      }
    },
    "customer.subscription.trial_will_end": {
      "post": {
        "operationId": "webhook_customer_subscription_trial_will_end",
        "summary": "customer.subscription.trial_will_end",
        "description": "A subscription's trial ends in three days. The customer has been emailed what happens next. data is the subscription.",
        "parameters": [
          {
            "name": "Payments-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> under the endpoint's signing secret (whsec_). While a rotated secret is kept, one v1 for each secret, the new one last: accept the delivery if any v1 matches. Refuse a delivery whose t is more than 300 seconds from your clock.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Payments-Event-Id",
            "in": "header",
            "required": true,
            "description": "The event's id, the same as id in the body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubscriptionTrialWillEndEvent"
              },
              "example": {
                "id": "evt_s4t8v1x2c9q3m7k5r0yhwn6z",
                "object": "event",
                "type": "customer.subscription.trial_will_end",
                "mode": "test",
                "created": "2026-11-15T09:30:00.000Z",
                "data": {
                  "object": "subscription",
                  "id": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "mode": "test",
                  "status": "trialing",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "price": {
                    "id": "price_m3v8q1x6c9k2r5t7y0wn4hzp",
                    "productName": "Gym membership",
                    "unitAmountCents": 450000,
                    "interval": "month",
                    "intervalCount": 1
                  },
                  "quantity": 1,
                  "items": [
                    {
                      "id": "si_t4c9v2x7q1m6k8r3y0wnhz5p",
                      "price": {
                        "id": "price_m3v8q1x6c9k2r5t7y0wn4hzp",
                        "productName": "Gym membership",
                        "unitAmountCents": 450000,
                        "interval": "month",
                        "intervalCount": 1
                      },
                      "quantity": 1
                    }
                  ],
                  "currentPeriodStart": "2026-10-01T04:12:31.000Z",
                  "currentPeriodEnd": "2026-10-15T04:12:31.000Z",
                  "billingCycleAnchor": "2026-10-01T04:12:31.000Z",
                  "cancelAtPeriodEnd": false,
                  "cancelAt": null,
                  "canceledAt": null,
                  "endedAt": null,
                  "cancelReason": null,
                  "cancellationDetails": {
                    "reason": null,
                    "feedback": null,
                    "comment": null
                  },
                  "trialStart": "2026-10-01T04:12:31.000Z",
                  "trialEnd": "2026-10-15T04:12:31.000Z",
                  "trialEndBehavior": "create_invoice",
                  "pauseCollection": null,
                  "discount": null,
                  "taxRateIds": [],
                  "subscriptionLinkId": null,
                  "collectionMethod": "charge_automatically",
                  "daysUntilDue": null,
                  "pendingUpdate": null,
                  "cardId": "card_g2a1rex14ff7qh2dc6j6qzmq",
                  "cardMissingSince": null,
                  "latestInvoiceId": "in_c4v9x2q7m1k8r3t6y0wnzhp5",
                  "checkoutUrl": null,
                  "reference": "member-1042",
                  "createdAt": "2026-10-01T04:12:31.000Z"
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx answer marks the delivery done. Anything else, or no answer within the timeout, is retried."
          }
        }
      }
    },
    "customer.subscription.paused": {
      "post": {
        "operationId": "webhook_customer_subscription_paused",
        "summary": "customer.subscription.paused",
        "description": "A subscription was paused because its trial ended without a card on file and you chose to pause such subscriptions. Nothing is billed until it is resumed. data is the subscription.",
        "parameters": [
          {
            "name": "Payments-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> under the endpoint's signing secret (whsec_). While a rotated secret is kept, one v1 for each secret, the new one last: accept the delivery if any v1 matches. Refuse a delivery whose t is more than 300 seconds from your clock.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Payments-Event-Id",
            "in": "header",
            "required": true,
            "description": "The event's id, the same as id in the body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubscriptionPausedEvent"
              },
              "example": {
                "id": "evt_s5p2v7x1c8q4m9k3r0zyhw6n",
                "object": "event",
                "type": "customer.subscription.paused",
                "mode": "test",
                "created": "2026-11-15T09:30:00.000Z",
                "data": {
                  "object": "subscription",
                  "id": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "mode": "test",
                  "status": "paused",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "price": {
                    "id": "price_m3v8q1x6c9k2r5t7y0wn4hzp",
                    "productName": "Gym membership",
                    "unitAmountCents": 450000,
                    "interval": "month",
                    "intervalCount": 1
                  },
                  "quantity": 1,
                  "items": [
                    {
                      "id": "si_t4c9v2x7q1m6k8r3y0wnhz5p",
                      "price": {
                        "id": "price_m3v8q1x6c9k2r5t7y0wn4hzp",
                        "productName": "Gym membership",
                        "unitAmountCents": 450000,
                        "interval": "month",
                        "intervalCount": 1
                      },
                      "quantity": 1
                    }
                  ],
                  "currentPeriodStart": "2026-10-01T04:12:31.000Z",
                  "currentPeriodEnd": "2026-10-15T04:12:31.000Z",
                  "billingCycleAnchor": "2026-10-01T04:12:31.000Z",
                  "cancelAtPeriodEnd": false,
                  "cancelAt": null,
                  "canceledAt": null,
                  "endedAt": null,
                  "cancelReason": null,
                  "cancellationDetails": {
                    "reason": null,
                    "feedback": null,
                    "comment": null
                  },
                  "trialStart": "2026-10-01T04:12:31.000Z",
                  "trialEnd": "2026-10-15T04:12:31.000Z",
                  "trialEndBehavior": "create_invoice",
                  "pauseCollection": null,
                  "discount": null,
                  "taxRateIds": [],
                  "subscriptionLinkId": null,
                  "collectionMethod": "charge_automatically",
                  "daysUntilDue": null,
                  "pendingUpdate": null,
                  "cardId": null,
                  "cardMissingSince": null,
                  "latestInvoiceId": "in_c4v9x2q7m1k8r3t6y0wnzhp5",
                  "checkoutUrl": null,
                  "reference": "member-1042",
                  "createdAt": "2026-10-01T04:12:31.000Z"
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx answer marks the delivery done. Anything else, or no answer within the timeout, is retried."
          }
        }
      }
    },
    "customer.subscription.resumed": {
      "post": {
        "operationId": "webhook_customer_subscription_resumed",
        "summary": "customer.subscription.resumed",
        "description": "A paused subscription was resumed: a new period started and its invoice is charged to the card now on file. data is the subscription.",
        "parameters": [
          {
            "name": "Payments-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> under the endpoint's signing secret (whsec_). While a rotated secret is kept, one v1 for each secret, the new one last: accept the delivery if any v1 matches. Refuse a delivery whose t is more than 300 seconds from your clock.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Payments-Event-Id",
            "in": "header",
            "required": true,
            "description": "The event's id, the same as id in the body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubscriptionResumedEvent"
              },
              "example": {
                "id": "evt_s6r1v8x3c2q7m4k9t0nwhz5y",
                "object": "event",
                "type": "customer.subscription.resumed",
                "mode": "test",
                "created": "2026-11-15T09:30:00.000Z",
                "data": {
                  "object": "subscription",
                  "id": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "mode": "test",
                  "status": "active",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "price": {
                    "id": "price_m3v8q1x6c9k2r5t7y0wn4hzp",
                    "productName": "Gym membership",
                    "unitAmountCents": 450000,
                    "interval": "month",
                    "intervalCount": 1
                  },
                  "quantity": 1,
                  "items": [
                    {
                      "id": "si_t4c9v2x7q1m6k8r3y0wnhz5p",
                      "price": {
                        "id": "price_m3v8q1x6c9k2r5t7y0wn4hzp",
                        "productName": "Gym membership",
                        "unitAmountCents": 450000,
                        "interval": "month",
                        "intervalCount": 1
                      },
                      "quantity": 1
                    }
                  ],
                  "currentPeriodStart": "2026-10-01T04:12:31.000Z",
                  "currentPeriodEnd": "2026-11-01T04:12:31.000Z",
                  "billingCycleAnchor": "2026-10-01T04:12:31.000Z",
                  "cancelAtPeriodEnd": false,
                  "cancelAt": null,
                  "canceledAt": null,
                  "endedAt": null,
                  "cancelReason": null,
                  "cancellationDetails": {
                    "reason": null,
                    "feedback": null,
                    "comment": null
                  },
                  "trialStart": null,
                  "trialEnd": null,
                  "trialEndBehavior": "create_invoice",
                  "pauseCollection": null,
                  "discount": null,
                  "taxRateIds": [],
                  "subscriptionLinkId": null,
                  "collectionMethod": "charge_automatically",
                  "daysUntilDue": null,
                  "pendingUpdate": null,
                  "cardId": "card_g2a1rex14ff7qh2dc6j6qzmq",
                  "cardMissingSince": null,
                  "latestInvoiceId": "in_c4v9x2q7m1k8r3t6y0wnzhp5",
                  "checkoutUrl": null,
                  "reference": "member-1042",
                  "createdAt": "2026-10-01T04:12:31.000Z"
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx answer marks the delivery done. Anything else, or no answer within the timeout, is retried."
          }
        }
      }
    },
    "invoice.created": {
      "post": {
        "operationId": "webhook_invoice_created",
        "summary": "invoice.created",
        "description": "An invoice was made: a subscription's first, or a renewal's draft, which is finalised and charged after the draft window. data is the invoice.",
        "parameters": [
          {
            "name": "Payments-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> under the endpoint's signing secret (whsec_). While a rotated secret is kept, one v1 for each secret, the new one last: accept the delivery if any v1 matches. Refuse a delivery whose t is more than 300 seconds from your clock.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Payments-Event-Id",
            "in": "header",
            "required": true,
            "description": "The event's id, the same as id in the body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoiceCreatedEvent"
              },
              "example": {
                "id": "evt_i1c9v3x8q2m7k4r6t0ywnh5z",
                "object": "event",
                "type": "invoice.created",
                "mode": "test",
                "created": "2026-11-01T04:13:00.000Z",
                "data": {
                  "object": "invoice",
                  "id": "in_x7c2v9q4m1k6r8t3y0hwnzp5",
                  "mode": "test",
                  "number": null,
                  "status": "draft",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "subscriptionId": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "billingReason": "subscription_cycle",
                  "periodStart": "2026-11-01T04:12:31.000Z",
                  "periodEnd": "2026-12-01T04:12:31.000Z",
                  "lines": [
                    {
                      "description": "Gym membership, every month",
                      "quantity": 1,
                      "unitAmountCents": 450000,
                      "amountCents": 450000,
                      "periodStart": "2026-11-01T04:12:31.000Z",
                      "periodEnd": "2026-12-01T04:12:31.000Z",
                      "proration": false
                    }
                  ],
                  "subtotalCents": 450000,
                  "discountCents": 0,
                  "couponId": null,
                  "taxCents": 0,
                  "taxes": [],
                  "totalCents": 450000,
                  "creditAppliedCents": 0,
                  "amountDueCents": 450000,
                  "amountPaidCents": 0,
                  "creditNotesCents": 0,
                  "collectionMethod": "charge_automatically",
                  "dueDate": null,
                  "memo": null,
                  "currency": "LKR",
                  "attemptCount": 0,
                  "nextAttemptAt": null,
                  "lastFailure": null,
                  "paidAt": null,
                  "hostedInvoiceUrl": null,
                  "createdAt": "2026-11-01T04:13:00.000Z"
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx answer marks the delivery done. Anything else, or no answer within the timeout, is retried."
          }
        }
      }
    },
    "invoice.finalized": {
      "post": {
        "operationId": "webhook_invoice_finalized",
        "summary": "invoice.finalized",
        "description": "An invoice was numbered and opened for payment. data is the invoice.",
        "parameters": [
          {
            "name": "Payments-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> under the endpoint's signing secret (whsec_). While a rotated secret is kept, one v1 for each secret, the new one last: accept the delivery if any v1 matches. Refuse a delivery whose t is more than 300 seconds from your clock.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Payments-Event-Id",
            "in": "header",
            "required": true,
            "description": "The event's id, the same as id in the body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoiceFinalizedEvent"
              },
              "example": {
                "id": "evt_i2v8x1c7q3m9k6r4t0yzhw5n",
                "object": "event",
                "type": "invoice.finalized",
                "mode": "test",
                "created": "2026-11-01T05:13:00.000Z",
                "data": {
                  "object": "invoice",
                  "id": "in_x7c2v9q4m1k6r8t3y0hwnzp5",
                  "mode": "test",
                  "number": "INV-000002",
                  "status": "open",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "subscriptionId": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "billingReason": "subscription_cycle",
                  "periodStart": "2026-11-01T04:12:31.000Z",
                  "periodEnd": "2026-12-01T04:12:31.000Z",
                  "lines": [
                    {
                      "description": "Gym membership, every month",
                      "quantity": 1,
                      "unitAmountCents": 450000,
                      "amountCents": 450000,
                      "periodStart": "2026-11-01T04:12:31.000Z",
                      "periodEnd": "2026-12-01T04:12:31.000Z",
                      "proration": false
                    }
                  ],
                  "subtotalCents": 450000,
                  "discountCents": 0,
                  "couponId": null,
                  "taxCents": 0,
                  "taxes": [],
                  "totalCents": 450000,
                  "creditAppliedCents": 0,
                  "amountDueCents": 450000,
                  "amountPaidCents": 0,
                  "creditNotesCents": 0,
                  "collectionMethod": "charge_automatically",
                  "dueDate": null,
                  "memo": null,
                  "currency": "LKR",
                  "attemptCount": 0,
                  "nextAttemptAt": "2026-11-01T05:13:00.000Z",
                  "lastFailure": null,
                  "paidAt": null,
                  "hostedInvoiceUrl": "https://payments.lk/invoice/b3Nq8Zt2Xv6Lm1Kc9Rw4Hy7Pd5Gs0Jf2Ae4Uo7Ik9Mx",
                  "createdAt": "2026-11-01T04:13:00.000Z"
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx answer marks the delivery done. Anything else, or no answer within the timeout, is retried."
          }
        }
      }
    },
    "invoice.sent": {
      "post": {
        "operationId": "webhook_invoice_sent",
        "summary": "invoice.sent",
        "description": "An invoice collected by sending it was emailed to the customer, to pay on its page by its due date. data is the invoice.",
        "parameters": [
          {
            "name": "Payments-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> under the endpoint's signing secret (whsec_). While a rotated secret is kept, one v1 for each secret, the new one last: accept the delivery if any v1 matches. Refuse a delivery whose t is more than 300 seconds from your clock.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Payments-Event-Id",
            "in": "header",
            "required": true,
            "description": "The event's id, the same as id in the body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoiceSentEvent"
              },
              "example": {
                "id": "evt_i8s3v1x7c2q9m4k6r0ynhw5z",
                "object": "event",
                "type": "invoice.sent",
                "mode": "test",
                "created": "2026-11-15T09:30:00.000Z",
                "data": {
                  "object": "invoice",
                  "id": "in_s5v1x8c3q9m2k7r4t0yhwn6z",
                  "mode": "test",
                  "number": "INV-000014",
                  "status": "open",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "subscriptionId": null,
                  "billingReason": "manual",
                  "periodStart": null,
                  "periodEnd": null,
                  "lines": [
                    {
                      "description": "Grade 10 maths, third term",
                      "quantity": 1,
                      "unitAmountCents": 1800000,
                      "amountCents": 1800000,
                      "periodStart": null,
                      "periodEnd": null,
                      "proration": false
                    }
                  ],
                  "subtotalCents": 1800000,
                  "discountCents": 0,
                  "couponId": null,
                  "taxCents": 0,
                  "taxes": [],
                  "totalCents": 1800000,
                  "creditAppliedCents": 0,
                  "amountDueCents": 1800000,
                  "amountPaidCents": 0,
                  "creditNotesCents": 0,
                  "collectionMethod": "send_invoice",
                  "dueDate": "2026-10-31T18:29:59.000Z",
                  "memo": "Third term, grade 10",
                  "currency": "LKR",
                  "attemptCount": 0,
                  "nextAttemptAt": null,
                  "lastFailure": null,
                  "paidAt": null,
                  "hostedInvoiceUrl": "https://payments.lk/invoice/r2Vd9x4Kc7mZt3Wn1Rb8Hy6Lp5Gs0Jf4Ae2Uo9Ik7Nx",
                  "createdAt": "2026-10-01T08:00:00.000Z"
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx answer marks the delivery done. Anything else, or no answer within the timeout, is retried."
          }
        }
      }
    },
    "invoice.overdue": {
      "post": {
        "operationId": "webhook_invoice_overdue",
        "summary": "invoice.overdue",
        "description": "An invoice sent to be paid by a due date was not paid by then. Its subscription, if any, is past due. data is the invoice.",
        "parameters": [
          {
            "name": "Payments-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> under the endpoint's signing secret (whsec_). While a rotated secret is kept, one v1 for each secret, the new one last: accept the delivery if any v1 matches. Refuse a delivery whose t is more than 300 seconds from your clock.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Payments-Event-Id",
            "in": "header",
            "required": true,
            "description": "The event's id, the same as id in the body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoiceOverdueEvent"
              },
              "example": {
                "id": "evt_i9o4v2x8c3q1m5k7r0hwnz6y",
                "object": "event",
                "type": "invoice.overdue",
                "mode": "test",
                "created": "2026-11-15T09:30:00.000Z",
                "data": {
                  "object": "invoice",
                  "id": "in_s5v1x8c3q9m2k7r4t0yhwn6z",
                  "mode": "test",
                  "number": "INV-000014",
                  "status": "open",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "subscriptionId": null,
                  "billingReason": "manual",
                  "periodStart": null,
                  "periodEnd": null,
                  "lines": [
                    {
                      "description": "Grade 10 maths, third term",
                      "quantity": 1,
                      "unitAmountCents": 1800000,
                      "amountCents": 1800000,
                      "periodStart": null,
                      "periodEnd": null,
                      "proration": false
                    }
                  ],
                  "subtotalCents": 1800000,
                  "discountCents": 0,
                  "couponId": null,
                  "taxCents": 0,
                  "taxes": [],
                  "totalCents": 1800000,
                  "creditAppliedCents": 0,
                  "amountDueCents": 1800000,
                  "amountPaidCents": 0,
                  "creditNotesCents": 0,
                  "collectionMethod": "send_invoice",
                  "dueDate": "2026-10-31T18:29:59.000Z",
                  "memo": "Third term, grade 10",
                  "currency": "LKR",
                  "attemptCount": 0,
                  "nextAttemptAt": null,
                  "lastFailure": null,
                  "paidAt": null,
                  "hostedInvoiceUrl": "https://payments.lk/invoice/r2Vd9x4Kc7mZt3Wn1Rb8Hy6Lp5Gs0Jf4Ae2Uo9Ik7Nx",
                  "createdAt": "2026-10-01T08:00:00.000Z"
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx answer marks the delivery done. Anything else, or no answer within the timeout, is retried."
          }
        }
      }
    },
    "credit_note.created": {
      "post": {
        "operationId": "webhook_credit_note_created",
        "summary": "credit_note.created",
        "description": "A credit note was issued: an amount taken off an invoice, off what was due, refunded to the card, or added to the customer's credit balance. data is the credit note.",
        "parameters": [
          {
            "name": "Payments-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> under the endpoint's signing secret (whsec_). While a rotated secret is kept, one v1 for each secret, the new one last: accept the delivery if any v1 matches. Refuse a delivery whose t is more than 300 seconds from your clock.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Payments-Event-Id",
            "in": "header",
            "required": true,
            "description": "The event's id, the same as id in the body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreditNoteCreatedEvent"
              },
              "example": {
                "id": "evt_c9n5v3x9c4q2m6k8r0wnhy7z",
                "object": "event",
                "type": "credit_note.created",
                "mode": "test",
                "created": "2026-11-15T09:30:00.000Z",
                "data": {
                  "object": "credit_note",
                  "id": "cn_r7v2x9c4q1m8k3t6y0wnhz5p",
                  "mode": "test",
                  "invoiceId": "in_c4v9x2q7m1k8r3t6y0wnzhp5",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "number": "CN-000001",
                  "amountCents": 150000,
                  "reason": "order_change",
                  "memo": "Closed for a week in October",
                  "amountDueReducedCents": 0,
                  "refundedCents": 0,
                  "creditedToBalanceCents": 150000,
                  "refundId": null,
                  "createdAt": "2026-10-20T08:00:00.000Z"
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx answer marks the delivery done. Anything else, or no answer within the timeout, is retried."
          }
        }
      }
    },
    "entitlements.active_entitlement_summary.updated": {
      "post": {
        "operationId": "webhook_entitlements_active_entitlement_summary_updated",
        "summary": "entitlements.active_entitlement_summary.updated",
        "description": "A customer's features changed: a subscription started, changed, paused or ended, or a product gained or lost a feature. data is every feature the customer has now.",
        "parameters": [
          {
            "name": "Payments-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> under the endpoint's signing secret (whsec_). While a rotated secret is kept, one v1 for each secret, the new one last: accept the delivery if any v1 matches. Refuse a delivery whose t is more than 300 seconds from your clock.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Payments-Event-Id",
            "in": "header",
            "required": true,
            "description": "The event's id, the same as id in the body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ActiveEntitlementSummaryUpdatedEvent"
              },
              "example": {
                "id": "evt_e1n6v4x1c5q3m7k9r0hwnz8y",
                "object": "event",
                "type": "entitlements.active_entitlement_summary.updated",
                "mode": "test",
                "created": "2026-11-15T09:30:00.000Z",
                "data": {
                  "object": "entitlements.active_entitlement_summary",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "entitlements": [
                    {
                      "featureId": "feat_g2v7x9c5q1m8k3r6t0hwnz4y",
                      "lookupKey": "gym"
                    },
                    {
                      "featureId": "feat_p3v8x1c6q9m2k7r4t0ynhw5z",
                      "lookupKey": "pool"
                    }
                  ]
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx answer marks the delivery done. Anything else, or no answer within the timeout, is retried."
          }
        }
      }
    },
    "invoice.paid": {
      "post": {
        "operationId": "webhook_invoice_paid",
        "summary": "invoice.paid",
        "description": "An invoice was paid. Provision for the period it covers from this event. data is the invoice.",
        "parameters": [
          {
            "name": "Payments-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> under the endpoint's signing secret (whsec_). While a rotated secret is kept, one v1 for each secret, the new one last: accept the delivery if any v1 matches. Refuse a delivery whose t is more than 300 seconds from your clock.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Payments-Event-Id",
            "in": "header",
            "required": true,
            "description": "The event's id, the same as id in the body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoicePaidEvent"
              },
              "example": {
                "id": "evt_i3x2v9c8q1m4k7r6t0hwyn5z",
                "object": "event",
                "type": "invoice.paid",
                "mode": "test",
                "created": "2026-10-01T04:15:02.000Z",
                "data": {
                  "object": "invoice",
                  "id": "in_c4v9x2q7m1k8r3t6y0wnzhp5",
                  "mode": "test",
                  "number": "INV-000001",
                  "status": "paid",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "subscriptionId": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "billingReason": "subscription_create",
                  "periodStart": "2026-10-01T04:12:31.000Z",
                  "periodEnd": "2026-11-01T04:12:31.000Z",
                  "lines": [
                    {
                      "description": "Gym membership, every month",
                      "quantity": 1,
                      "unitAmountCents": 450000,
                      "amountCents": 450000,
                      "periodStart": "2026-10-01T04:12:31.000Z",
                      "periodEnd": "2026-11-01T04:12:31.000Z",
                      "proration": false
                    }
                  ],
                  "subtotalCents": 450000,
                  "discountCents": 0,
                  "couponId": null,
                  "taxCents": 0,
                  "taxes": [],
                  "totalCents": 450000,
                  "creditAppliedCents": 0,
                  "amountDueCents": 450000,
                  "amountPaidCents": 450000,
                  "creditNotesCents": 0,
                  "collectionMethod": "charge_automatically",
                  "dueDate": null,
                  "memo": null,
                  "currency": "LKR",
                  "attemptCount": 0,
                  "nextAttemptAt": null,
                  "lastFailure": null,
                  "paidAt": "2026-10-01T04:15:02.000Z",
                  "hostedInvoiceUrl": "https://payments.lk/invoice/q7Vd2x9Kc4mZt1Wn8Rb5Hy3Lp6Gs0Jf2Ae4Uo7Ik9Nx",
                  "createdAt": "2026-10-01T04:12:31.000Z"
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx answer marks the delivery done. Anything else, or no answer within the timeout, is retried."
          }
        }
      }
    },
    "invoice.payment_failed": {
      "post": {
        "operationId": "webhook_invoice_payment_failed",
        "summary": "invoice.payment_failed",
        "description": "A charge of the card on file failed, or there was no card to charge. data is the invoice, with attemptCount, lastFailure and nextAttemptAt (null when nothing more will be tried). The customer is emailed a pay link.",
        "parameters": [
          {
            "name": "Payments-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> under the endpoint's signing secret (whsec_). While a rotated secret is kept, one v1 for each secret, the new one last: accept the delivery if any v1 matches. Refuse a delivery whose t is more than 300 seconds from your clock.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Payments-Event-Id",
            "in": "header",
            "required": true,
            "description": "The event's id, the same as id in the body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoicePaymentFailedEvent"
              },
              "example": {
                "id": "evt_i4c1v8x9q2m3k6r7t0nwhz5y",
                "object": "event",
                "type": "invoice.payment_failed",
                "mode": "test",
                "created": "2026-11-01T05:13:04.000Z",
                "data": {
                  "object": "invoice",
                  "id": "in_x7c2v9q4m1k6r8t3y0hwnzp5",
                  "mode": "test",
                  "number": "INV-000002",
                  "status": "open",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "subscriptionId": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "billingReason": "subscription_cycle",
                  "periodStart": "2026-11-01T04:12:31.000Z",
                  "periodEnd": "2026-12-01T04:12:31.000Z",
                  "lines": [
                    {
                      "description": "Gym membership, every month",
                      "quantity": 1,
                      "unitAmountCents": 450000,
                      "amountCents": 450000,
                      "periodStart": "2026-11-01T04:12:31.000Z",
                      "periodEnd": "2026-12-01T04:12:31.000Z",
                      "proration": false
                    }
                  ],
                  "subtotalCents": 450000,
                  "discountCents": 0,
                  "couponId": null,
                  "taxCents": 0,
                  "taxes": [],
                  "totalCents": 450000,
                  "creditAppliedCents": 0,
                  "amountDueCents": 450000,
                  "amountPaidCents": 0,
                  "creditNotesCents": 0,
                  "collectionMethod": "charge_automatically",
                  "dueDate": null,
                  "memo": null,
                  "currency": "LKR",
                  "attemptCount": 1,
                  "nextAttemptAt": "2026-11-02T03:30:00.000Z",
                  "lastFailure": "The processor refused the charge.",
                  "paidAt": null,
                  "hostedInvoiceUrl": "https://payments.lk/invoice/b3Nq8Zt2Xv6Lm1Kc9Rw4Hy7Pd5Gs0Jf2Ae4Uo7Ik9Mx",
                  "createdAt": "2026-11-01T04:13:00.000Z"
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx answer marks the delivery done. Anything else, or no answer within the timeout, is retried."
          }
        }
      }
    },
    "invoice.upcoming": {
      "post": {
        "operationId": "webhook_invoice_upcoming",
        "summary": "invoice.upcoming",
        "description": "A renewal is a few days away (three unless set otherwise). data is a preview of the invoice it will make; its id is not an invoice's.",
        "parameters": [
          {
            "name": "Payments-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> under the endpoint's signing secret (whsec_). While a rotated secret is kept, one v1 for each secret, the new one last: accept the delivery if any v1 matches. Refuse a delivery whose t is more than 300 seconds from your clock.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Payments-Event-Id",
            "in": "header",
            "required": true,
            "description": "The event's id, the same as id in the body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoiceUpcomingEvent"
              },
              "example": {
                "id": "evt_i5v2x8c1q9m4k3r6t0yhzw7n",
                "object": "event",
                "type": "invoice.upcoming",
                "mode": "test",
                "created": "2026-10-29T04:13:00.000Z",
                "data": {
                  "object": "invoice",
                  "id": "upcoming_sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "mode": "test",
                  "number": null,
                  "status": "draft",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "subscriptionId": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "billingReason": "subscription_cycle",
                  "periodStart": "2026-11-01T04:12:31.000Z",
                  "periodEnd": "2026-12-01T04:12:31.000Z",
                  "lines": [
                    {
                      "description": "Gym membership, every month",
                      "quantity": 1,
                      "unitAmountCents": 450000,
                      "amountCents": 450000,
                      "periodStart": "2026-11-01T04:12:31.000Z",
                      "periodEnd": "2026-12-01T04:12:31.000Z",
                      "proration": false
                    }
                  ],
                  "subtotalCents": 450000,
                  "discountCents": 0,
                  "couponId": null,
                  "taxCents": 0,
                  "taxes": [],
                  "totalCents": 450000,
                  "creditAppliedCents": 0,
                  "amountDueCents": 450000,
                  "amountPaidCents": 0,
                  "creditNotesCents": 0,
                  "collectionMethod": "charge_automatically",
                  "dueDate": null,
                  "memo": null,
                  "currency": "LKR",
                  "attemptCount": 0,
                  "nextAttemptAt": null,
                  "lastFailure": null,
                  "paidAt": null,
                  "hostedInvoiceUrl": null,
                  "createdAt": "2026-10-29T04:13:00.000Z"
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx answer marks the delivery done. Anything else, or no answer within the timeout, is retried."
          }
        }
      }
    },
    "invoice.voided": {
      "post": {
        "operationId": "webhook_invoice_voided",
        "summary": "invoice.voided",
        "description": "An invoice was voided, because its subscription ended or expired before it was paid. data is the invoice.",
        "parameters": [
          {
            "name": "Payments-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> under the endpoint's signing secret (whsec_). While a rotated secret is kept, one v1 for each secret, the new one last: accept the delivery if any v1 matches. Refuse a delivery whose t is more than 300 seconds from your clock.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Payments-Event-Id",
            "in": "header",
            "required": true,
            "description": "The event's id, the same as id in the body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoiceVoidedEvent"
              },
              "example": {
                "id": "evt_i6x9v1c2q8m3k7r4t0zwyh5n",
                "object": "event",
                "type": "invoice.voided",
                "mode": "test",
                "created": "2026-10-20T08:00:00.000Z",
                "data": {
                  "object": "invoice",
                  "id": "in_x7c2v9q4m1k6r8t3y0hwnzp5",
                  "mode": "test",
                  "number": "INV-000002",
                  "status": "void",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "subscriptionId": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "billingReason": "subscription_cycle",
                  "periodStart": "2026-11-01T04:12:31.000Z",
                  "periodEnd": "2026-12-01T04:12:31.000Z",
                  "lines": [
                    {
                      "description": "Gym membership, every month",
                      "quantity": 1,
                      "unitAmountCents": 450000,
                      "amountCents": 450000,
                      "periodStart": "2026-11-01T04:12:31.000Z",
                      "periodEnd": "2026-12-01T04:12:31.000Z",
                      "proration": false
                    }
                  ],
                  "subtotalCents": 450000,
                  "discountCents": 0,
                  "couponId": null,
                  "taxCents": 0,
                  "taxes": [],
                  "totalCents": 450000,
                  "creditAppliedCents": 0,
                  "amountDueCents": 450000,
                  "amountPaidCents": 0,
                  "creditNotesCents": 0,
                  "collectionMethod": "charge_automatically",
                  "dueDate": null,
                  "memo": null,
                  "currency": "LKR",
                  "attemptCount": 1,
                  "nextAttemptAt": null,
                  "lastFailure": "The processor refused the charge.",
                  "paidAt": null,
                  "hostedInvoiceUrl": "https://payments.lk/invoice/b3Nq8Zt2Xv6Lm1Kc9Rw4Hy7Pd5Gs0Jf2Ae4Uo7Ik9Mx",
                  "createdAt": "2026-11-01T04:13:00.000Z"
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx answer marks the delivery done. Anything else, or no answer within the timeout, is retried."
          }
        }
      }
    },
    "invoice.marked_uncollectible": {
      "post": {
        "operationId": "webhook_invoice_marked_uncollectible",
        "summary": "invoice.marked_uncollectible",
        "description": "An invoice was written off: marked uncollectible by you, or when a subscription was canceled for non payment. It is never tried again. data is the invoice.",
        "parameters": [
          {
            "name": "Payments-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\"> under the endpoint's signing secret (whsec_). While a rotated secret is kept, one v1 for each secret, the new one last: accept the delivery if any v1 matches. Refuse a delivery whose t is more than 300 seconds from your clock.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Payments-Event-Id",
            "in": "header",
            "required": true,
            "description": "The event's id, the same as id in the body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoiceMarkedUncollectibleEvent"
              },
              "example": {
                "id": "evt_i7c3v1x9q8m2k5r4t0nhyw6z",
                "object": "event",
                "type": "invoice.marked_uncollectible",
                "mode": "test",
                "created": "2026-11-15T09:30:00.000Z",
                "data": {
                  "object": "invoice",
                  "id": "in_x7c2v9q4m1k6r8t3y0hwnzp5",
                  "mode": "test",
                  "number": "INV-000002",
                  "status": "uncollectible",
                  "customerId": "cus_q8w3n5v1x7c2m9r4t6ya0kzp",
                  "subscriptionId": "sub_p6x1c8v3q9m2k7r4t0yhwz5n",
                  "billingReason": "subscription_cycle",
                  "periodStart": "2026-11-01T04:12:31.000Z",
                  "periodEnd": "2026-12-01T04:12:31.000Z",
                  "lines": [
                    {
                      "description": "Gym membership, every month",
                      "quantity": 1,
                      "unitAmountCents": 450000,
                      "amountCents": 450000,
                      "periodStart": "2026-11-01T04:12:31.000Z",
                      "periodEnd": "2026-12-01T04:12:31.000Z",
                      "proration": false
                    }
                  ],
                  "subtotalCents": 450000,
                  "discountCents": 0,
                  "couponId": null,
                  "taxCents": 0,
                  "taxes": [],
                  "totalCents": 450000,
                  "creditAppliedCents": 0,
                  "amountDueCents": 450000,
                  "amountPaidCents": 0,
                  "creditNotesCents": 0,
                  "collectionMethod": "charge_automatically",
                  "dueDate": null,
                  "memo": null,
                  "currency": "LKR",
                  "attemptCount": 1,
                  "nextAttemptAt": null,
                  "lastFailure": "The processor refused the charge.",
                  "paidAt": null,
                  "hostedInvoiceUrl": "https://payments.lk/invoice/b3Nq8Zt2Xv6Lm1Kc9Rw4Hy7Pd5Gs0Jf2Ae4Uo7Ik9Mx",
                  "createdAt": "2026-11-01T04:13:00.000Z"
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx answer marks the delivery done. Anything else, or no answer within the timeout, is retried."
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Checkout": {
        "description": "A payment and the hosted page that takes it.",
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"checkout\".",
            "type": "string",
            "const": "checkout"
          },
          "id": {
            "description": "The checkout's id, chk_ followed by 24 characters.",
            "type": "string"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "status": {
            "description": "open until the customer pays or it expires; processing while the processor decides; then completed, expired or canceled. An open checkout past expiresAt reads as expired.",
            "type": "string",
            "enum": [
              "open",
              "processing",
              "completed",
              "expired",
              "canceled"
            ]
          },
          "url": {
            "description": "The hosted checkout page, in the checkout's language. Send the customer here.",
            "type": "string"
          },
          "expiresAt": {
            "description": "When the checkout stops taking a payment, 30 minutes after it was made.",
            "type": "string",
            "format": "date-time"
          },
          "payment": {
            "description": "The payment the checkout takes.",
            "$ref": "#/components/schemas/Payment"
          }
        },
        "required": [
          "object",
          "id",
          "mode",
          "status",
          "url",
          "expiresAt",
          "payment"
        ]
      },
      "Payment": {
        "description": "One payment, however it was made: a checkout, a payment link, a checkout page or a saved card.",
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"payment\".",
            "type": "string",
            "const": "payment"
          },
          "id": {
            "description": "The payment's id, pay_ followed by 24 characters.",
            "type": "string"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "status": {
            "description": "requires_payment_method until the customer pays; processing while the processor decides; then succeeded or failed. canceled when its checkout expired unpaid. partially_refunded and refunded once refunds succeed. disputed is reserved for chargebacks, which are not reported yet.",
            "type": "string",
            "enum": [
              "requires_payment_method",
              "processing",
              "succeeded",
              "failed",
              "canceled",
              "partially_refunded",
              "refunded",
              "disputed"
            ]
          },
          "amountCents": {
            "description": "The amount in LKR cents. Rs. 3,500 is 350000.",
            "type": "integer"
          },
          "currency": {
            "description": "Always \"LKR\".",
            "type": "string",
            "const": "LKR"
          },
          "description": {
            "description": "What the customer is paying for, as you sent it.",
            "type": "string"
          },
          "reference": {
            "description": "Your own reference, such as an order number, or null.",
            "type": [
              "string",
              "null"
            ]
          },
          "customer": {
            "description": "The customer's details, sent with the checkout or typed on the checkout page. Null when there are none.",
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "name": {
                "description": "The customer's name, or null.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "email": {
                "description": "The customer's email address, lower case, or null.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "phone": {
                "description": "The customer's phone number, or null.",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "name",
              "email",
              "phone"
            ]
          },
          "card": {
            "description": "The card's scheme and last four digits, once the processor reports them. Null before that.",
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "scheme": {
                "description": "The card scheme as the processor names it, such as VISA or MASTERCARD, or null.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "last4": {
                "description": "The last four digits of the card number, or null.",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "scheme",
              "last4"
            ]
          },
          "cardSave": {
            "description": "Whether the card was kept on file. not_requested: the checkout did not offer to keep it, or the customer did not agree. requested: keeping it was offered or agreed and the payment has not succeeded, so nothing is kept (and nothing will be, if it fails). saved: the card was kept, and card.saved names it. failed: the payment succeeded but the card was not kept, because the processor did not tokenise it or its answer carried no token; card.save_failed was sent, and the customer must add the card again.",
            "type": "string",
            "enum": [
              "not_requested",
              "requested",
              "saved",
              "failed"
            ]
          },
          "feeCents": {
            "description": "The Payments.lk fee in cents, set when the payment succeeds. Null until then.",
            "type": [
              "integer",
              "null"
            ]
          },
          "netCents": {
            "description": "amountCents less feeCents, set when the payment succeeds. Null until then.",
            "type": [
              "integer",
              "null"
            ]
          },
          "refundedCents": {
            "description": "How much has been refunded so far, in cents.",
            "type": "integer"
          },
          "failureMessage": {
            "description": "Why the payment failed, in a sentence you can show the customer. Null otherwise.",
            "type": [
              "string",
              "null"
            ]
          },
          "paymentLinkId": {
            "description": "The payment link it was paid through, or null.",
            "type": [
              "string",
              "null"
            ]
          },
          "savedCardId": {
            "description": "The saved card it was charged to, when it was charged without the customer present. Null otherwise.",
            "type": [
              "string",
              "null"
            ]
          },
          "invoiceId": {
            "description": "The invoice this payment pays: a subscription's first payment, a renewal charged to the card on file, or a payment through a pay link. Null otherwise.",
            "type": [
              "string",
              "null"
            ]
          },
          "checkoutId": {
            "description": "The checkout it belongs to, or null. A saved card charge has none.",
            "type": [
              "string",
              "null"
            ]
          },
          "checkoutPageId": {
            "description": "The checkout page it was made on, or null.",
            "type": [
              "string",
              "null"
            ]
          },
          "order": {
            "description": "What the customer ordered, on a checkout page or through a checkout's lineItems, priced by us. Null for every other payment.",
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "lines": {
                "description": "The lines of the order.",
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "description": "The line's id: the product's id on a checkout page, or line-1 to line-10 for lineItems in the order sent.",
                      "type": "string"
                    },
                    "name": {
                      "description": "The product's name.",
                      "type": "string"
                    },
                    "description": {
                      "description": "The line's description, when it has one.",
                      "type": "string"
                    },
                    "quantity": {
                      "description": "How many the customer ordered.",
                      "type": "integer"
                    },
                    "unitAmountCents": {
                      "description": "The price of one, in cents.",
                      "type": "integer"
                    },
                    "amountCents": {
                      "description": "The line's total, in cents.",
                      "type": "integer"
                    },
                    "suggested": {
                      "description": "True when this is the product the page suggested and the customer added.",
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "quantity",
                    "unitAmountCents",
                    "amountCents",
                    "suggested"
                  ]
                }
              },
              "subtotalCents": {
                "description": "The lines' total before discount, delivery and added tax, in cents.",
                "type": "integer"
              },
              "discount": {
                "description": "The promotion code used and what it took off, or null.",
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "code": {
                    "description": "The promotion code.",
                    "type": "string"
                  },
                  "cents": {
                    "description": "What it took off, in cents.",
                    "type": "integer"
                  }
                },
                "required": [
                  "code",
                  "cents"
                ]
              },
              "shipping": {
                "description": "The delivery option chosen, or null.",
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "id": {
                    "description": "The delivery option's id on the checkout page.",
                    "type": "string"
                  },
                  "label": {
                    "description": "The delivery option's name.",
                    "type": "string"
                  },
                  "cents": {
                    "description": "What delivery cost, in cents.",
                    "type": "integer"
                  }
                },
                "required": [
                  "id",
                  "label",
                  "cents"
                ]
              },
              "tax": {
                "description": "The tax on the order, or null when the page charges none.",
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "mode": {
                    "description": "included when prices already hold the tax, added when it was added on top.",
                    "type": "string",
                    "enum": [
                      "included",
                      "added"
                    ]
                  },
                  "rateBps": {
                    "description": "The tax rate in basis points: 1800 is 18%.",
                    "type": "integer"
                  },
                  "cents": {
                    "description": "The tax, in cents.",
                    "type": "integer"
                  }
                },
                "required": [
                  "mode",
                  "rateBps",
                  "cents"
                ]
              },
              "totalCents": {
                "description": "What the order came to, in cents.",
                "type": "integer"
              }
            },
            "required": [
              "lines",
              "subtotalCents",
              "discount",
              "shipping",
              "tax",
              "totalCents"
            ]
          },
          "delivery": {
            "description": "Where to deliver, from a checkout page that asks. Null otherwise.",
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "sameAsBilling": {
                "description": "True when the customer said to deliver to their billing address.",
                "type": "boolean"
              },
              "name": {
                "description": "Who to deliver to, or null.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "street": {
                "description": "The street address, or null.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "city": {
                "description": "The town or city, or null.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "postcode": {
                "description": "The postal code, or null.",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "sameAsBilling",
              "name",
              "street",
              "city",
              "postcode"
            ]
          },
          "customFields": {
            "description": "Answers to the questions a checkout page asked, or null.",
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "description": "The question's key on the checkout page.",
                  "type": "string"
                },
                "label": {
                  "description": "The question as the customer saw it.",
                  "type": "string"
                },
                "value": {
                  "description": "The customer's answer.",
                  "type": "string"
                }
              },
              "required": [
                "key",
                "label",
                "value"
              ]
            }
          },
          "customerTaxId": {
            "description": "The customer's tax number, when a checkout page asked for it. Null otherwise.",
            "type": [
              "string",
              "null"
            ]
          },
          "termsAcceptedAt": {
            "description": "When the customer accepted the checkout page's terms, or null.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "createdAt": {
            "description": "When it was created, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "succeededAt": {
            "description": "When the payment succeeded, or null.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        },
        "required": [
          "object",
          "id",
          "mode",
          "status",
          "amountCents",
          "currency",
          "description",
          "reference",
          "customer",
          "card",
          "cardSave",
          "feeCents",
          "netCents",
          "refundedCents",
          "failureMessage",
          "paymentLinkId",
          "savedCardId",
          "invoiceId",
          "checkoutId",
          "checkoutPageId",
          "order",
          "delivery",
          "customFields",
          "customerTaxId",
          "termsAcceptedAt",
          "createdAt",
          "succeededAt"
        ]
      },
      "Refund": {
        "description": "Money going back to the customer's card, in full or in part.",
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"refund\".",
            "type": "string",
            "const": "refund"
          },
          "id": {
            "description": "The refund's id, re_ followed by 24 characters.",
            "type": "string"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "paymentId": {
            "description": "The payment it refunds.",
            "type": "string"
          },
          "status": {
            "description": "pending when recorded, processing once sent to the processor, then succeeded or failed. The refund.succeeded or refund.failed webhook tells you which.",
            "type": "string",
            "enum": [
              "pending",
              "processing",
              "succeeded",
              "failed"
            ]
          },
          "amountCents": {
            "description": "The amount refunded, in cents.",
            "type": "integer"
          },
          "currency": {
            "description": "Always \"LKR\".",
            "type": "string",
            "const": "LKR"
          },
          "reason": {
            "description": "The reason you gave, or null.",
            "type": [
              "string",
              "null"
            ]
          },
          "failureMessage": {
            "description": "Why the refund failed, or null.",
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "description": "When it was created, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "succeededAt": {
            "description": "When the refund succeeded, or null.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        },
        "required": [
          "object",
          "id",
          "mode",
          "paymentId",
          "status",
          "amountCents",
          "currency",
          "reason",
          "failureMessage",
          "createdAt",
          "succeededAt"
        ]
      },
      "PaymentLink": {
        "description": "A fixed amount link you can send anywhere. Each payer gets a payment of their own.",
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"payment_link\".",
            "type": "string",
            "const": "payment_link"
          },
          "id": {
            "description": "The link's id, plink_ followed by 24 characters.",
            "type": "string"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "title": {
            "description": "What the link is for, shown to the payer.",
            "type": "string"
          },
          "description": {
            "description": "More about it, shown to the payer, or null.",
            "type": [
              "string",
              "null"
            ]
          },
          "amountCents": {
            "description": "The fixed amount every payer pays, in cents.",
            "type": "integer"
          },
          "url": {
            "description": "The link to send. Each payer who opens it gets a checkout of their own.",
            "type": "string"
          },
          "active": {
            "description": "False once the link has been retired. A retired link takes no payments.",
            "type": "boolean"
          },
          "paidCount": {
            "description": "How many payments the link has taken. The answers to create and retire always say 0; read the list for the count.",
            "type": "integer"
          },
          "createdAt": {
            "description": "When it was created, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "object",
          "id",
          "mode",
          "title",
          "description",
          "amountCents",
          "url",
          "active",
          "paidCount",
          "createdAt"
        ]
      },
      "SavedCard": {
        "description": "A card a customer chose to keep on file at a checkout.",
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"saved_card\".",
            "type": "string",
            "const": "saved_card"
          },
          "id": {
            "description": "The saved card's id, card_ followed by 24 characters. It is not a card number and works only with your key.",
            "type": "string"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "customerEmail": {
            "description": "The email address of the customer who kept the card, or null.",
            "type": [
              "string",
              "null"
            ]
          },
          "scheme": {
            "description": "The card scheme, such as VISA, or null.",
            "type": [
              "string",
              "null"
            ]
          },
          "last4": {
            "description": "The last four digits of the card number, or null.",
            "type": [
              "string",
              "null"
            ]
          },
          "expiry": {
            "description": "The month the card expires, as the processor reported it, or null. A charge after it will be declined, so ask the customer for a new card before then.",
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "month": {
                "description": "The month, 1 to 12.",
                "type": "integer",
                "minimum": 1,
                "maximum": 12
              },
              "year": {
                "description": "The four digit year.",
                "type": "integer"
              }
            },
            "required": [
              "month",
              "year"
            ]
          },
          "paymentId": {
            "description": "The payment the customer made when they kept the card, or null for a card saved before this was recorded.",
            "type": [
              "string",
              "null"
            ]
          },
          "consent": {
            "description": "What the customer agreed to when they kept the card, or null for a card saved before this was recorded. Keep it: it is your record of why you may charge them.",
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "agreedAt": {
                "description": "When the customer agreed, ISO 8601.",
                "type": "string",
                "format": "date-time"
              },
              "locale": {
                "description": "The language the customer was reading: en, si or ta.",
                "type": "string",
                "enum": [
                  "en",
                  "si",
                  "ta"
                ]
              },
              "wording": {
                "description": "Which wording the customer read, such as checkoutPage.saveCard@1. The sentence itself is on our checkout page in that language, and a change to the words mints a new id rather than rewriting this one.",
                "type": "string"
              }
            },
            "required": [
              "agreedAt",
              "locale",
              "wording"
            ]
          },
          "active": {
            "description": "False once the card has been deleted.",
            "type": "boolean"
          },
          "createdAt": {
            "description": "When it was created, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "retiredAt": {
            "description": "When the card was deleted, ISO 8601, or null while it is still usable.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        },
        "required": [
          "object",
          "id",
          "mode",
          "customerEmail",
          "scheme",
          "last4",
          "expiry",
          "paymentId",
          "consent",
          "active",
          "createdAt",
          "retiredAt"
        ]
      },
      "Event": {
        "description": "Something that happened on your account, in the same shape the webhook delivers it.",
        "oneOf": [
          {
            "$ref": "#/components/schemas/PaymentSucceededEvent"
          },
          {
            "$ref": "#/components/schemas/PaymentFailedEvent"
          },
          {
            "$ref": "#/components/schemas/CheckoutExpiredEvent"
          },
          {
            "$ref": "#/components/schemas/CardSavedEvent"
          },
          {
            "$ref": "#/components/schemas/CardSaveFailedEvent"
          },
          {
            "$ref": "#/components/schemas/CardExpiringEvent"
          },
          {
            "$ref": "#/components/schemas/BillingAlertTriggeredEvent"
          },
          {
            "$ref": "#/components/schemas/SubscriptionScheduleCreatedEvent"
          },
          {
            "$ref": "#/components/schemas/SubscriptionScheduleCompletedEvent"
          },
          {
            "$ref": "#/components/schemas/SubscriptionScheduleReleasedEvent"
          },
          {
            "$ref": "#/components/schemas/SubscriptionScheduleCanceledEvent"
          },
          {
            "$ref": "#/components/schemas/RefundSucceededEvent"
          },
          {
            "$ref": "#/components/schemas/RefundFailedEvent"
          },
          {
            "$ref": "#/components/schemas/AccountLimitApproachingEvent"
          },
          {
            "$ref": "#/components/schemas/AccountLimitReachedEvent"
          },
          {
            "$ref": "#/components/schemas/AccountLimitResetEvent"
          },
          {
            "$ref": "#/components/schemas/SubscriptionCreatedEvent"
          },
          {
            "$ref": "#/components/schemas/SubscriptionUpdatedEvent"
          },
          {
            "$ref": "#/components/schemas/SubscriptionDeletedEvent"
          },
          {
            "$ref": "#/components/schemas/SubscriptionTrialWillEndEvent"
          },
          {
            "$ref": "#/components/schemas/SubscriptionPausedEvent"
          },
          {
            "$ref": "#/components/schemas/SubscriptionResumedEvent"
          },
          {
            "$ref": "#/components/schemas/InvoiceCreatedEvent"
          },
          {
            "$ref": "#/components/schemas/InvoiceFinalizedEvent"
          },
          {
            "$ref": "#/components/schemas/InvoiceSentEvent"
          },
          {
            "$ref": "#/components/schemas/InvoiceOverdueEvent"
          },
          {
            "$ref": "#/components/schemas/CreditNoteCreatedEvent"
          },
          {
            "$ref": "#/components/schemas/ActiveEntitlementSummaryUpdatedEvent"
          },
          {
            "$ref": "#/components/schemas/InvoicePaidEvent"
          },
          {
            "$ref": "#/components/schemas/InvoicePaymentFailedEvent"
          },
          {
            "$ref": "#/components/schemas/InvoiceUpcomingEvent"
          },
          {
            "$ref": "#/components/schemas/InvoiceVoidedEvent"
          },
          {
            "$ref": "#/components/schemas/InvoiceMarkedUncollectibleEvent"
          }
        ],
        "discriminator": {
          "propertyName": "type",
          "mapping": {
            "payment.succeeded": "#/components/schemas/PaymentSucceededEvent",
            "payment.failed": "#/components/schemas/PaymentFailedEvent",
            "checkout.expired": "#/components/schemas/CheckoutExpiredEvent",
            "card.saved": "#/components/schemas/CardSavedEvent",
            "card.save_failed": "#/components/schemas/CardSaveFailedEvent",
            "card.expiring": "#/components/schemas/CardExpiringEvent",
            "billing.alert.triggered": "#/components/schemas/BillingAlertTriggeredEvent",
            "subscription_schedule.created": "#/components/schemas/SubscriptionScheduleCreatedEvent",
            "subscription_schedule.completed": "#/components/schemas/SubscriptionScheduleCompletedEvent",
            "subscription_schedule.released": "#/components/schemas/SubscriptionScheduleReleasedEvent",
            "subscription_schedule.canceled": "#/components/schemas/SubscriptionScheduleCanceledEvent",
            "refund.succeeded": "#/components/schemas/RefundSucceededEvent",
            "refund.failed": "#/components/schemas/RefundFailedEvent",
            "account.limit.approaching": "#/components/schemas/AccountLimitApproachingEvent",
            "account.limit.reached": "#/components/schemas/AccountLimitReachedEvent",
            "account.limit.reset": "#/components/schemas/AccountLimitResetEvent",
            "customer.subscription.created": "#/components/schemas/SubscriptionCreatedEvent",
            "customer.subscription.updated": "#/components/schemas/SubscriptionUpdatedEvent",
            "customer.subscription.deleted": "#/components/schemas/SubscriptionDeletedEvent",
            "customer.subscription.trial_will_end": "#/components/schemas/SubscriptionTrialWillEndEvent",
            "customer.subscription.paused": "#/components/schemas/SubscriptionPausedEvent",
            "customer.subscription.resumed": "#/components/schemas/SubscriptionResumedEvent",
            "invoice.created": "#/components/schemas/InvoiceCreatedEvent",
            "invoice.finalized": "#/components/schemas/InvoiceFinalizedEvent",
            "invoice.sent": "#/components/schemas/InvoiceSentEvent",
            "invoice.overdue": "#/components/schemas/InvoiceOverdueEvent",
            "credit_note.created": "#/components/schemas/CreditNoteCreatedEvent",
            "entitlements.active_entitlement_summary.updated": "#/components/schemas/ActiveEntitlementSummaryUpdatedEvent",
            "invoice.paid": "#/components/schemas/InvoicePaidEvent",
            "invoice.payment_failed": "#/components/schemas/InvoicePaymentFailedEvent",
            "invoice.upcoming": "#/components/schemas/InvoiceUpcomingEvent",
            "invoice.voided": "#/components/schemas/InvoiceVoidedEvent",
            "invoice.marked_uncollectible": "#/components/schemas/InvoiceMarkedUncollectibleEvent"
          }
        }
      },
      "Account": {
        "description": "The merchant account behind the key.",
        "type": "object",
        "properties": {
          "id": {
            "description": "Your merchant id, mer_ followed by 24 characters.",
            "type": "string"
          },
          "tradingName": {
            "description": "The name customers see, or null before you have given one.",
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "description": "Where your account is: prospect and applying while you fill in the application, submitted, in_review and needs_info while it is reviewed, approved, queued and activated after; rejected, suspended or closed when it cannot take payments. Live payments need activated.",
            "type": "string",
            "enum": [
              "prospect",
              "applying",
              "submitted",
              "in_review",
              "needs_info",
              "approved",
              "queued",
              "activated",
              "rejected",
              "suspended",
              "closed"
            ]
          },
          "applicationStatus": {
            "description": "Your application's status, or null before you have started one.",
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "draft",
                  "submitted",
                  "in_review",
                  "needs_info",
                  "approved",
                  "rejected"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "clearance": {
            "description": "Kept for integrations written before plans. Read plan and usage instead.",
            "type": "object",
            "properties": {
              "tier": {
                "description": "starter for the Starter plan, verified for Growth, enterprise for Enterprise.",
                "type": "string",
                "enum": [
                  "starter",
                  "verified",
                  "enterprise"
                ]
              },
              "monthlyCapCents": {
                "description": "Your plan's monthly limit in cents, or null for no limit. The same figure as usage.capCents.",
                "type": [
                  "integer",
                  "null"
                ]
              }
            },
            "required": [
              "tier",
              "monthlyCapCents"
            ]
          },
          "pricingPlan": {
            "description": "The pricing plan your fees are worked out on.",
            "type": "string"
          },
          "plan": {
            "description": "starter, growth or enterprise. Starter and Growth take card payments up to a monthly limit, the ceiling of their pricing bracket; Enterprise has none. Upgrade from the dashboard's Plans page.",
            "type": "string",
            "enum": [
              "starter",
              "growth",
              "enterprise"
            ]
          },
          "usage": {
            "description": "This month's card payments in the key's mode against your plan's monthly limit. Test mode counts separately, against the same limit.",
            "type": "object",
            "properties": {
              "month": {
                "description": "The calendar month in Sri Lanka, such as 2026-09.",
                "type": "string"
              },
              "mode": {
                "description": "live or test: the mode of the key that asked.",
                "type": "string",
                "enum": [
                  "live",
                  "test"
                ]
              },
              "plan": {
                "description": "The plan this month is counted against. An upgrade changes it at once.",
                "type": "string",
                "enum": [
                  "starter",
                  "growth",
                  "enterprise"
                ]
              },
              "capCents": {
                "description": "The monthly limit in cents, or null for no limit.",
                "type": [
                  "integer",
                  "null"
                ]
              },
              "settledCents": {
                "description": "Payments that succeeded this month, in cents, gross: refunds do not free up room.",
                "type": "integer"
              },
              "reservedCents": {
                "description": "Payments with the processor now, in cents. They count toward the limit until they settle or fail.",
                "type": "integer"
              },
              "percent": {
                "description": "Whole percent of the limit used by settled payments, rounded down. 0 with no limit.",
                "type": "integer"
              },
              "resetsAt": {
                "description": "When the limit resets: midnight on the 1st in Sri Lanka, as ISO 8601 in UTC.",
                "type": "string"
              },
              "refusedCount": {
                "description": "Payments refused this month because they would have passed the limit.",
                "type": "integer"
              },
              "refusedCents": {
                "description": "What those refused payments came to, in cents.",
                "type": "integer"
              }
            },
            "required": [
              "month",
              "mode",
              "plan",
              "capCents",
              "settledCents",
              "reservedCents",
              "percent",
              "resetsAt",
              "refusedCount",
              "refusedCents"
            ]
          },
          "locale": {
            "description": "The language of your dashboard and emails: en, si or ta.",
            "type": "string",
            "enum": [
              "en",
              "si",
              "ta"
            ]
          },
          "liveEnabled": {
            "description": "True once live keys can take payments.",
            "type": "boolean"
          },
          "phase1Position": {
            "description": "Your place in the launch queue if you were approved beyond the launch cap, or null.",
            "type": [
              "integer",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "tradingName",
          "status",
          "applicationStatus",
          "clearance",
          "pricingPlan",
          "plan",
          "usage",
          "locale",
          "liveEnabled",
          "phase1Position"
        ]
      },
      "Customer": {
        "description": "Someone you bill on a subscription.",
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"customer\".",
            "type": "string",
            "const": "customer"
          },
          "id": {
            "description": "The customer's id, cus_ followed by 24 characters.",
            "type": "string"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "email": {
            "description": "Their email address, lower case. One customer per email in each mode.",
            "type": "string"
          },
          "name": {
            "description": "Their name, or null.",
            "type": [
              "string",
              "null"
            ]
          },
          "phone": {
            "description": "Their Sri Lankan mobile number as +94771234567, or null.",
            "type": [
              "string",
              "null"
            ]
          },
          "locale": {
            "description": "The language of their emails and payment pages: en, si or ta.",
            "type": "string",
            "enum": [
              "en",
              "si",
              "ta"
            ]
          },
          "defaultCardId": {
            "description": "The card renewals are charged to unless a subscription names its own: the last card they kept on a subscription's payment. Null before any.",
            "type": [
              "string",
              "null"
            ]
          },
          "creditBalanceCents": {
            "description": "Credit the customer holds with you, in cents: taken off their next invoices before the card is charged. It grows when an invoice comes to less than nothing (a downgrade) or when you add credit.",
            "type": "integer"
          },
          "createdAt": {
            "description": "When it was created, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "object",
          "id",
          "mode",
          "email",
          "name",
          "phone",
          "locale",
          "defaultCardId",
          "creditBalanceCents",
          "createdAt"
        ]
      },
      "Price": {
        "description": "A recurring price: an amount every period, on a product.",
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"price\".",
            "type": "string",
            "const": "price"
          },
          "id": {
            "description": "The price's id, price_ followed by 24 characters.",
            "type": "string"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "product": {
            "description": "What the price is for.",
            "type": "object",
            "properties": {
              "id": {
                "description": "The product's id, prod_ followed by 24 characters.",
                "type": "string"
              },
              "name": {
                "description": "The product's name, as invoices and customers' emails show it.",
                "type": "string"
              },
              "description": {
                "description": "A line about the product, or null.",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "id",
              "name",
              "description"
            ]
          },
          "unitAmountCents": {
            "description": "The amount each period per unit (or per package), in LKR cents; 0 for a tiered price, which its tiers price.",
            "type": "integer"
          },
          "currency": {
            "description": "Always \"LKR\".",
            "type": "string",
            "const": "LKR"
          },
          "interval": {
            "description": "How often it bills: day, week, month or year.",
            "type": "string",
            "enum": [
              "day",
              "week",
              "month",
              "year"
            ]
          },
          "intervalCount": {
            "description": "How many intervals a period is: 3 with month is every three months.",
            "type": "integer"
          },
          "nickname": {
            "description": "Your own name for the price, shown on invoices instead of the product's, or null.",
            "type": [
              "string",
              "null"
            ]
          },
          "active": {
            "description": "False once archived: an archived price takes no new subscriptions, and those it has keep renewing.",
            "type": "boolean"
          },
          "billingScheme": {
            "description": "per_unit (the unit amount times the quantity), package (the unit amount per packageSize units, a part package rounded up) or tiered.",
            "type": "string",
            "enum": [
              "per_unit",
              "package",
              "tiered"
            ]
          },
          "tiersMode": {
            "description": "For a tiered price: graduated (each tier prices the units in it) or volume (the tier the whole quantity falls in prices every unit). Null otherwise.",
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "graduated",
                  "volume"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "tiers": {
            "description": "For a tiered price, its tiers in order; null otherwise.",
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "object",
              "properties": {
                "upTo": {
                  "description": "The last unit this tier prices, or null for every unit beyond the tier before.",
                  "type": [
                    "integer",
                    "null"
                  ]
                },
                "unitAmountCents": {
                  "description": "Per unit in this tier, in cents.",
                  "type": "integer"
                },
                "flatAmountCents": {
                  "description": "Added once when any unit falls in this tier (graduated) or the quantity does (volume), in cents; 0 for none.",
                  "type": "integer"
                }
              },
              "required": [
                "upTo",
                "unitAmountCents",
                "flatAmountCents"
              ]
            }
          },
          "packageSize": {
            "description": "For a package price: how many units a package is. Null otherwise.",
            "type": [
              "integer",
              "null"
            ]
          },
          "usageType": {
            "description": "licensed (a quantity, billed at the start of each period) or metered (the usage a meter counted, billed at the end of each period).",
            "type": "string",
            "enum": [
              "licensed",
              "metered"
            ]
          },
          "meterId": {
            "description": "For a metered price: the meter whose usage it bills. Null otherwise.",
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "description": "When it was created, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "object",
          "id",
          "mode",
          "product",
          "unitAmountCents",
          "currency",
          "interval",
          "intervalCount",
          "nickname",
          "active",
          "billingScheme",
          "tiersMode",
          "tiers",
          "packageSize",
          "usageType",
          "meterId",
          "createdAt"
        ]
      },
      "Subscription": {
        "description": "A customer paying a price every period.",
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"subscription\".",
            "type": "string",
            "const": "subscription"
          },
          "id": {
            "description": "The subscription's id, sub_ followed by 24 characters.",
            "type": "string"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "status": {
            "description": "incomplete until the first invoice is paid, and incomplete_expired if it is not within 23 hours. trialing during a free trial. active while paid up. past_due while a renewal is being retried. unpaid when retries are used up and your setting keeps it. paused when a trial ended with no card and trialEndBehavior is pause. canceled once ended.",
            "type": "string",
            "enum": [
              "incomplete",
              "incomplete_expired",
              "trialing",
              "active",
              "past_due",
              "unpaid",
              "paused",
              "canceled"
            ]
          },
          "customerId": {
            "description": "The customer's id.",
            "type": "string"
          },
          "price": {
            "description": "Its first item's price, kept for subscriptions of one price. Read items for all of them.",
            "type": "object",
            "properties": {
              "id": {
                "description": "The price's id.",
                "type": "string"
              },
              "productName": {
                "description": "The product's name.",
                "type": "string"
              },
              "unitAmountCents": {
                "description": "The amount each period, per unit, in cents.",
                "type": "integer"
              },
              "interval": {
                "description": "day, week, month or year.",
                "type": "string",
                "enum": [
                  "day",
                  "week",
                  "month",
                  "year"
                ]
              },
              "intervalCount": {
                "description": "How many intervals a period is.",
                "type": "integer"
              }
            },
            "required": [
              "id",
              "productName",
              "unitAmountCents",
              "interval",
              "intervalCount"
            ]
          },
          "quantity": {
            "description": "Its first item's quantity: seats, members, boxes.",
            "type": "integer"
          },
          "items": {
            "description": "What it bills each period: a price and a quantity each, all on the same interval.",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "description": "The item's id, si_ followed by 24 characters: send it to change or remove the item.",
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "price": {
                  "description": "The item's price.",
                  "type": "object",
                  "properties": {
                    "id": {
                      "description": "The price's id.",
                      "type": "string"
                    },
                    "productName": {
                      "description": "The product's name.",
                      "type": "string"
                    },
                    "unitAmountCents": {
                      "description": "The amount each period, per unit, in cents.",
                      "type": "integer"
                    },
                    "interval": {
                      "description": "day, week, month or year.",
                      "type": "string",
                      "enum": [
                        "day",
                        "week",
                        "month",
                        "year"
                      ]
                    },
                    "intervalCount": {
                      "description": "How many intervals a period is.",
                      "type": "integer"
                    }
                  },
                  "required": [
                    "id",
                    "productName",
                    "unitAmountCents",
                    "interval",
                    "intervalCount"
                  ]
                },
                "quantity": {
                  "description": "How many units of it each period bills.",
                  "type": "integer"
                }
              },
              "required": [
                "id",
                "price",
                "quantity"
              ]
            }
          },
          "currentPeriodStart": {
            "description": "When the period now running began, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "currentPeriodEnd": {
            "description": "When it ends and the next invoice is made, ISO 8601 in UTC. Periods renew on the anchor day of the month in Sri Lanka.",
            "type": "string",
            "format": "date-time"
          },
          "billingCycleAnchor": {
            "description": "The instant its renewals are anchored on, ISO 8601 in UTC: when it started, a trial's end, or the billingCycleAnchor it was created with, such as midnight on the 1st in Sri Lanka.",
            "type": "string",
            "format": "date-time"
          },
          "cancelAtPeriodEnd": {
            "description": "True when it is set to end at currentPeriodEnd.",
            "type": "boolean"
          },
          "cancelAt": {
            "description": "When it is set to end by itself, or null. The last period is billed only up to this time, by the day.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "canceledAt": {
            "description": "When the cancellation was asked for, or null.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "endedAt": {
            "description": "When it ended, or null while it runs.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "cancelReason": {
            "description": "Why it ended or will end: requested_by_merchant, requested_by_customer (in the customer portal), payment_failed, incomplete_expired, first_invoice_voided or trial_ended_without_card. Null otherwise.",
            "type": [
              "string",
              "null"
            ]
          },
          "cancellationDetails": {
            "description": "Why it was cancelled, with what the customer or you said.",
            "type": "object",
            "properties": {
              "reason": {
                "description": "The same as cancelReason.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "feedback": {
                "description": "customer_service, low_quality, missing_features, other, switched_service, too_complex, too_expensive or unused, as you recorded it. Null otherwise.",
                "anyOf": [
                  {
                    "type": "string",
                    "enum": [
                      "customer_service",
                      "low_quality",
                      "missing_features",
                      "other",
                      "switched_service",
                      "too_complex",
                      "too_expensive",
                      "unused"
                    ]
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "comment": {
                "description": "A comment you recorded, or null.",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "reason",
              "feedback",
              "comment"
            ]
          },
          "trialStart": {
            "description": "When its free trial began, or null for none.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "trialEnd": {
            "description": "When its free trial ends (or ended), or null. Renewals are anchored on it.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "trialEndBehavior": {
            "description": "What happens when the trial ends with no card on file: create_invoice (the customer is sent the first invoice to pay, the default), pause, or cancel.",
            "type": "string",
            "enum": [
              "create_invoice",
              "pause",
              "cancel"
            ]
          },
          "pauseCollection": {
            "description": "Collection paused, or null: invoices are still made each period but not charged.",
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "behavior": {
                "description": "keep_as_draft (left as drafts for you), mark_uncollectible (written off at once) or void (voided at once).",
                "type": "string",
                "enum": [
                  "keep_as_draft",
                  "mark_uncollectible",
                  "void"
                ]
              },
              "resumesAt": {
                "description": "When collection resumes by itself, or null to wait for you.",
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            },
            "required": [
              "behavior",
              "resumesAt"
            ]
          },
          "discount": {
            "description": "A coupon discounting its invoices, or null.",
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "couponId": {
                "description": "The coupon.",
                "type": "string"
              },
              "start": {
                "description": "When it was put on the subscription.",
                "type": "string",
                "format": "date-time"
              },
              "end": {
                "description": "When a repeating coupon stops discounting, or null (once discounts one invoice; forever never stops).",
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            },
            "required": [
              "couponId",
              "start",
              "end"
            ]
          },
          "taxRateIds": {
            "description": "The tax rates applied to its invoices, in order.",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "subscriptionLinkId": {
            "description": "The subscription link the customer subscribed through, or null.",
            "type": [
              "string",
              "null"
            ]
          },
          "collectionMethod": {
            "description": "charge_automatically (renewals charged to the card on file) or send_invoice (each invoice emailed to the customer, to pay on its page by its due date).",
            "type": "string",
            "enum": [
              "charge_automatically",
              "send_invoice"
            ]
          },
          "daysUntilDue": {
            "description": "For send_invoice: days from an invoice being sent to its due date. Null otherwise.",
            "type": [
              "integer",
              "null"
            ]
          },
          "pendingUpdate": {
            "description": "A change sent with paymentBehavior pending_if_incomplete, waiting for its invoice to be paid; null otherwise. It applies when the invoice is paid and lapses at expiresAt.",
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "items": {
                "description": "The items the subscription will have once the invoice is paid.",
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "priceId": {
                      "description": "The item's price.",
                      "type": "string"
                    },
                    "quantity": {
                      "description": "The item's quantity.",
                      "type": "integer"
                    }
                  },
                  "required": [
                    "priceId",
                    "quantity"
                  ]
                }
              },
              "invoiceId": {
                "description": "The invoice that has to be paid for the change to apply.",
                "type": "string"
              },
              "expiresAt": {
                "description": "When the change lapses unpaid and the invoice is voided: 23 hours after it was asked for, or the period's end if sooner.",
                "type": "string",
                "format": "date-time"
              }
            },
            "required": [
              "items",
              "invoiceId",
              "expiresAt"
            ]
          },
          "cardId": {
            "description": "The saved card renewals are charged to, once the customer has kept one. Null before that.",
            "type": [
              "string",
              "null"
            ]
          },
          "cardMissingSince": {
            "description": "When a payment that was to keep a card for this subscription succeeded without keeping one (the processor did not keep the card, or the customer did not agree), leaving it with no card of its own. While it is set, renewals are not charged to any card: each invoice is emailed to the customer to pay, with a link to add a card, and the invoice's retries and your after-retries setting apply as for a declined card. Null once a card is kept for it, and for a subscription never left without one.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "latestInvoiceId": {
            "description": "Its newest invoice.",
            "type": [
              "string",
              "null"
            ]
          },
          "checkoutUrl": {
            "description": "Where the customer makes the first payment, while the subscription is incomplete and waiting for it; for a metered subscription with nothing to pay yet, where their card is checked with Rs. 10 (refunded) and kept. Null otherwise.",
            "type": [
              "string",
              "null"
            ]
          },
          "reference": {
            "description": "Your own reference, or null.",
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "description": "When it was created, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "object",
          "id",
          "mode",
          "status",
          "customerId",
          "price",
          "quantity",
          "items",
          "currentPeriodStart",
          "currentPeriodEnd",
          "billingCycleAnchor",
          "cancelAtPeriodEnd",
          "cancelAt",
          "canceledAt",
          "endedAt",
          "cancelReason",
          "cancellationDetails",
          "trialStart",
          "trialEnd",
          "trialEndBehavior",
          "pauseCollection",
          "discount",
          "taxRateIds",
          "subscriptionLinkId",
          "collectionMethod",
          "daysUntilDue",
          "pendingUpdate",
          "cardId",
          "cardMissingSince",
          "latestInvoiceId",
          "checkoutUrl",
          "reference",
          "createdAt"
        ]
      },
      "Invoice": {
        "description": "A bill: its lines, its total and its collection.",
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"invoice\".",
            "type": "string",
            "const": "invoice"
          },
          "id": {
            "description": "The invoice's id, in_ followed by 24 characters.",
            "type": "string"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "number": {
            "description": "INV-000123, your own sequence, given when the invoice is finalised. Null on a draft.",
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "description": "draft during the draft window, open once finalised and being collected, then paid, void (voided, or its subscription ended or expired first) or uncollectible (written off: by you, or when its subscription was canceled for non payment).",
            "type": "string",
            "enum": [
              "draft",
              "open",
              "paid",
              "void",
              "uncollectible"
            ]
          },
          "customerId": {
            "description": "The customer billed.",
            "type": "string"
          },
          "subscriptionId": {
            "description": "The subscription it bills, or null.",
            "type": [
              "string",
              "null"
            ]
          },
          "billingReason": {
            "description": "subscription_create for a subscription's first invoice, subscription_cycle for a renewal, subscription_update for a change invoiced at once, manual for a standalone invoice.",
            "type": "string"
          },
          "periodStart": {
            "description": "The start of the period it bills, or null.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "periodEnd": {
            "description": "The end of the period it bills, or null.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "lines": {
            "description": "What is billed, one line each.",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "description": {
                  "description": "The line as the customer reads it.",
                  "type": "string"
                },
                "quantity": {
                  "description": "How many units.",
                  "type": "integer"
                },
                "unitAmountCents": {
                  "description": "The amount per unit, in cents.",
                  "type": "integer"
                },
                "amountCents": {
                  "description": "quantity times unitAmountCents.",
                  "type": "integer"
                },
                "periodStart": {
                  "description": "The start of the period the line covers, or null.",
                  "type": [
                    "string",
                    "null"
                  ],
                  "format": "date-time"
                },
                "periodEnd": {
                  "description": "The end of the period the line covers, or null.",
                  "type": [
                    "string",
                    "null"
                  ],
                  "format": "date-time"
                },
                "proration": {
                  "description": "True for a credit or charge a change made for part of a period.",
                  "type": "boolean"
                }
              },
              "required": [
                "description",
                "quantity",
                "unitAmountCents",
                "amountCents",
                "periodStart",
                "periodEnd",
                "proration"
              ]
            }
          },
          "subtotalCents": {
            "description": "The lines added up, in cents.",
            "type": "integer"
          },
          "discountCents": {
            "description": "A coupon's discount, in cents, taken off before tax.",
            "type": "integer"
          },
          "couponId": {
            "description": "The coupon that discounted it, or null.",
            "type": [
              "string",
              "null"
            ]
          },
          "taxCents": {
            "description": "Exclusive taxes, in cents, added to the total. Inclusive taxes are shown in taxes and already in the amounts.",
            "type": "integer"
          },
          "taxes": {
            "description": "Each tax rate applied, with what it came to.",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "taxRateId": {
                  "description": "The tax rate.",
                  "type": "string"
                },
                "displayName": {
                  "description": "Its name, such as VAT.",
                  "type": "string"
                },
                "percentageBps": {
                  "description": "Its rate in basis points.",
                  "type": "integer"
                },
                "inclusive": {
                  "description": "True when it was already in the amounts.",
                  "type": "boolean"
                },
                "amountCents": {
                  "description": "What it came to, in cents.",
                  "type": "integer"
                }
              },
              "required": [
                "taxRateId",
                "displayName",
                "percentageBps",
                "inclusive",
                "amountCents"
              ]
            }
          },
          "totalCents": {
            "description": "What is owed, in cents.",
            "type": "integer"
          },
          "creditAppliedCents": {
            "description": "The customer's credit balance used against it, in cents.",
            "type": "integer"
          },
          "amountDueCents": {
            "description": "What is charged or paid: totalCents less the credit used, never below zero. A total below zero becomes credit on the customer's balance.",
            "type": "integer"
          },
          "amountPaidCents": {
            "description": "What has been paid, in cents.",
            "type": "integer"
          },
          "creditNotesCents": {
            "description": "Credit notes issued against it, in cents.",
            "type": "integer"
          },
          "collectionMethod": {
            "description": "charge_automatically (the card on file is charged) or send_invoice (the customer pays at hostedInvoiceUrl by dueDate).",
            "type": "string",
            "enum": [
              "charge_automatically",
              "send_invoice"
            ]
          },
          "dueDate": {
            "description": "For send_invoice: when it is due, the end of that day in Sri Lanka; null until it is sent, and for charge_automatically.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "memo": {
            "description": "A note printed on it, or null.",
            "type": [
              "string",
              "null"
            ]
          },
          "currency": {
            "description": "Always \"LKR\".",
            "type": "string",
            "const": "LKR"
          },
          "attemptCount": {
            "description": "How many times the card on file has been charged for it.",
            "type": "integer"
          },
          "nextAttemptAt": {
            "description": "When the card on file is tried next: the retry days after the first failure, at 09:00 in Sri Lanka. Null when nothing more will be tried.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "lastFailure": {
            "description": "Why the last try failed, in a sentence, or null.",
            "type": [
              "string",
              "null"
            ]
          },
          "paidAt": {
            "description": "When it was paid, or null.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "hostedInvoiceUrl": {
            "description": "The invoice's page for your customer, where they see it, pay what is open (a new card becomes the default for renewals) and print it. Null while it is a draft. Every email we send about it links here.",
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "description": "When it was created, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "object",
          "id",
          "mode",
          "number",
          "status",
          "customerId",
          "subscriptionId",
          "billingReason",
          "periodStart",
          "periodEnd",
          "lines",
          "subtotalCents",
          "discountCents",
          "couponId",
          "taxCents",
          "taxes",
          "totalCents",
          "creditAppliedCents",
          "amountDueCents",
          "amountPaidCents",
          "creditNotesCents",
          "collectionMethod",
          "dueDate",
          "memo",
          "currency",
          "attemptCount",
          "nextAttemptAt",
          "lastFailure",
          "paidAt",
          "hostedInvoiceUrl",
          "createdAt"
        ]
      },
      "Coupon": {
        "description": "A discount for subscriptions: percent or amount off, for one invoice, some months or for ever.",
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"coupon\".",
            "type": "string",
            "const": "coupon"
          },
          "id": {
            "description": "The coupon's id, cpn_ followed by 24 characters.",
            "type": "string"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "name": {
            "description": "Its name, as invoices show it.",
            "type": "string"
          },
          "percentOffBps": {
            "description": "Basis points off (2000 is 20%), or null when it takes an amount off.",
            "type": [
              "integer",
              "null"
            ]
          },
          "amountOffCents": {
            "description": "Cents off each invoice it discounts, or null when it takes a percent off.",
            "type": [
              "integer",
              "null"
            ]
          },
          "duration": {
            "description": "once (the next invoice), repeating (for durationInMonths) or forever.",
            "type": "string",
            "enum": [
              "once",
              "repeating",
              "forever"
            ]
          },
          "durationInMonths": {
            "description": "How many months a repeating coupon discounts, or null.",
            "type": [
              "integer",
              "null"
            ]
          },
          "maxRedemptions": {
            "description": "How many subscriptions may take it, or null for no limit.",
            "type": [
              "integer",
              "null"
            ]
          },
          "timesRedeemed": {
            "description": "How many have.",
            "type": "integer"
          },
          "redeemBy": {
            "description": "The last time a subscription may take it, or null.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "active": {
            "description": "False once archived: no new subscription takes it, and those that have it keep it.",
            "type": "boolean"
          },
          "code": {
            "description": "The code customers type on a subscription link, or in the customer portal where you allow it, to take it; upper case, or null for none.",
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "description": "When it was created, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "object",
          "id",
          "mode",
          "name",
          "percentOffBps",
          "amountOffCents",
          "duration",
          "durationInMonths",
          "maxRedemptions",
          "timesRedeemed",
          "redeemBy",
          "active",
          "code",
          "createdAt"
        ]
      },
      "TaxRate": {
        "description": "A tax you charge on invoices, such as VAT 18%, added on top or included.",
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"tax_rate\".",
            "type": "string",
            "const": "tax_rate"
          },
          "id": {
            "description": "The tax rate's id, txr_ followed by 24 characters.",
            "type": "string"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "displayName": {
            "description": "Its name on invoices, such as VAT or SSCL.",
            "type": "string"
          },
          "description": {
            "description": "A line about it, or null.",
            "type": [
              "string",
              "null"
            ]
          },
          "percentageBps": {
            "description": "The rate in basis points: 1800 is 18%.",
            "type": "integer"
          },
          "inclusive": {
            "description": "True when your prices already include it (the invoice shows it); false when it is added on top.",
            "type": "boolean"
          },
          "active": {
            "description": "False once archived: no new subscription takes it, and those that have it keep it.",
            "type": "boolean"
          },
          "createdAt": {
            "description": "When it was created, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "object",
          "id",
          "mode",
          "displayName",
          "description",
          "percentageBps",
          "inclusive",
          "active",
          "createdAt"
        ]
      },
      "InvoiceItem": {
        "description": "A one-off line for a customer's next invoice: a setup fee, an add-on, a credit.",
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"invoice_item\".",
            "type": "string",
            "const": "invoice_item"
          },
          "id": {
            "description": "The item's id, ii_ followed by 24 characters.",
            "type": "string"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "customerId": {
            "description": "The customer it bills.",
            "type": "string"
          },
          "subscriptionId": {
            "description": "Only this subscription's next invoice takes it, or null for the customer's next invoice.",
            "type": [
              "string",
              "null"
            ]
          },
          "invoiceId": {
            "description": "The invoice that took it, or null while it waits.",
            "type": [
              "string",
              "null"
            ]
          },
          "description": {
            "description": "The line as the customer reads it.",
            "type": "string"
          },
          "quantity": {
            "description": "How many units.",
            "type": "integer"
          },
          "unitAmountCents": {
            "description": "Per unit, in cents; negative for a credit.",
            "type": "integer"
          },
          "amountCents": {
            "description": "quantity times unitAmountCents.",
            "type": "integer"
          },
          "proration": {
            "description": "True for a credit or charge a change made for part of a period.",
            "type": "boolean"
          },
          "discountable": {
            "description": "Whether a coupon discounts it.",
            "type": "boolean"
          },
          "createdAt": {
            "description": "When it was created, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "object",
          "id",
          "mode",
          "customerId",
          "subscriptionId",
          "invoiceId",
          "description",
          "quantity",
          "unitAmountCents",
          "amountCents",
          "proration",
          "discountable",
          "createdAt"
        ]
      },
      "DeletedInvoiceItem": {
        "description": "An invoice item that was deleted before an invoice took it.",
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"invoice_item\".",
            "type": "string",
            "const": "invoice_item"
          },
          "id": {
            "description": "The item's id, ii_ followed by 24 characters.",
            "type": "string"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "customerId": {
            "description": "The customer it bills.",
            "type": "string"
          },
          "subscriptionId": {
            "description": "Only this subscription's next invoice takes it, or null for the customer's next invoice.",
            "type": [
              "string",
              "null"
            ]
          },
          "invoiceId": {
            "description": "The invoice that took it, or null while it waits.",
            "type": [
              "string",
              "null"
            ]
          },
          "description": {
            "description": "The line as the customer reads it.",
            "type": "string"
          },
          "quantity": {
            "description": "How many units.",
            "type": "integer"
          },
          "unitAmountCents": {
            "description": "Per unit, in cents; negative for a credit.",
            "type": "integer"
          },
          "amountCents": {
            "description": "quantity times unitAmountCents.",
            "type": "integer"
          },
          "proration": {
            "description": "True for a credit or charge a change made for part of a period.",
            "type": "boolean"
          },
          "discountable": {
            "description": "Whether a coupon discounts it.",
            "type": "boolean"
          },
          "createdAt": {
            "description": "When it was created, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "deleted": {
            "description": "Always true.",
            "type": "boolean",
            "const": true
          }
        },
        "required": [
          "object",
          "id",
          "mode",
          "customerId",
          "subscriptionId",
          "invoiceId",
          "description",
          "quantity",
          "unitAmountCents",
          "amountCents",
          "proration",
          "discountable",
          "createdAt",
          "deleted"
        ]
      },
      "CustomerBalanceTransaction": {
        "description": "A change to a customer's credit balance.",
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"customer_balance_transaction\".",
            "type": "string",
            "const": "customer_balance_transaction"
          },
          "id": {
            "description": "The transaction's id, cbtx_ followed by 24 characters.",
            "type": "string"
          },
          "customerId": {
            "description": "The customer whose balance moved.",
            "type": "string"
          },
          "amountCents": {
            "description": "Positive added credit; negative used it.",
            "type": "integer"
          },
          "endingBalanceCents": {
            "description": "The customer's credit balance after it, in cents.",
            "type": "integer"
          },
          "type": {
            "description": "applied_to_invoice (an invoice used it), credit_from_invoice (an invoice came to less than nothing), adjustment (yours, or credit returned from a voided invoice) or credit_note.",
            "type": "string",
            "enum": [
              "applied_to_invoice",
              "credit_from_invoice",
              "adjustment",
              "credit_note"
            ]
          },
          "invoiceId": {
            "description": "The invoice it came from or went to, or null.",
            "type": [
              "string",
              "null"
            ]
          },
          "description": {
            "description": "Why, or null.",
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "description": "When it was created, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "object",
          "id",
          "customerId",
          "amountCents",
          "endingBalanceCents",
          "type",
          "invoiceId",
          "description",
          "createdAt"
        ]
      },
      "TestClock": {
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"test_clock\".",
            "type": "string",
            "const": "test_clock"
          },
          "subscriptionId": {
            "description": "The subscription whose clock moved.",
            "type": "string"
          },
          "frozenTime": {
            "description": "The subscription's time now, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "offsetSeconds": {
            "description": "How far ahead of the wall clock its time runs, in seconds.",
            "type": "integer"
          }
        },
        "required": [
          "object",
          "subscriptionId",
          "frozenTime",
          "offsetSeconds"
        ]
      },
      "BillingPortalSession": {
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"billing_portal.session\".",
            "type": "string",
            "const": "billing_portal.session"
          },
          "id": {
            "description": "The session's id, bps_ followed by 24 characters.",
            "type": "string"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "customerId": {
            "description": "The customer it is for.",
            "type": "string"
          },
          "url": {
            "description": "The customer portal's address for this customer. Send them there straight away; it works until expiresAt.",
            "type": "string"
          },
          "returnUrl": {
            "description": "Where the portal's back link takes the customer, or null for no back link.",
            "type": [
              "string",
              "null"
            ]
          },
          "expiresAt": {
            "description": "When the address stops working: an hour after it was made.",
            "type": "string",
            "format": "date-time"
          },
          "createdAt": {
            "description": "When it was created, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "object",
          "id",
          "mode",
          "customerId",
          "url",
          "returnUrl",
          "expiresAt",
          "createdAt"
        ]
      },
      "Error": {
        "description": "Every error, whatever the status.",
        "type": "object",
        "properties": {
          "code": {
            "description": "A stable code for the kind of error. Match on this and on reason, never on the message.",
            "type": "string",
            "enum": [
              "VALIDATION_FAILED",
              "UNAUTHENTICATED",
              "FORBIDDEN",
              "NOT_FOUND",
              "CONFLICT",
              "RATE_LIMITED",
              "NOT_SUPPORTED",
              "SERVICE_UNAVAILABLE",
              "INTERNAL"
            ]
          },
          "reason": {
            "description": "The exact cause in snake_case, when there is a more precise one than the code, such as merchant_not_live.",
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]{1,63}$"
          },
          "message": {
            "description": "A sentence you can show a person. It never carries internal detail.",
            "type": "string"
          },
          "docUrl": {
            "description": "Where this error is explained, on https://payments.lk/developers/errors, anchored at its reason or its code.",
            "type": "string",
            "format": "uri"
          },
          "traceId": {
            "description": "Quote this when you contact support; it finds the request in our logs.",
            "type": "string"
          },
          "fields": {
            "description": "For VALIDATION_FAILED: each field that was refused and why.",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "path": {
                  "description": "The field, as a dotted path such as customer.email.",
                  "type": "string"
                },
                "message": {
                  "description": "Why it was refused.",
                  "type": "string"
                }
              },
              "required": [
                "path",
                "message"
              ]
            }
          }
        },
        "required": [
          "code",
          "message",
          "docUrl",
          "traceId"
        ]
      },
      "PaymentSucceededEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's id, evt_ followed by 24 characters. Deliveries of the same event carry the same id, so use it to ignore a repeat.",
            "type": "string"
          },
          "object": {
            "description": "Always \"event\".",
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Always \"payment.succeeded\".",
            "type": "string",
            "const": "payment.succeeded"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "created": {
            "description": "When the event happened, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "The payment, now succeeded, with its fee.",
            "$ref": "#/components/schemas/Payment"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "mode",
          "created",
          "data"
        ]
      },
      "PaymentFailedEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's id, evt_ followed by 24 characters. Deliveries of the same event carry the same id, so use it to ignore a repeat.",
            "type": "string"
          },
          "object": {
            "description": "Always \"event\".",
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Always \"payment.failed\".",
            "type": "string",
            "const": "payment.failed"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "created": {
            "description": "When the event happened, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "The payment, now failed, with failureMessage.",
            "$ref": "#/components/schemas/Payment"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "mode",
          "created",
          "data"
        ]
      },
      "CheckoutExpiredEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's id, evt_ followed by 24 characters. Deliveries of the same event carry the same id, so use it to ignore a repeat.",
            "type": "string"
          },
          "object": {
            "description": "Always \"event\".",
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Always \"checkout.expired\".",
            "type": "string",
            "const": "checkout.expired"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "created": {
            "description": "When the event happened, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "The checkout that expired and its payment's id.",
            "$ref": "#/components/schemas/ExpiredCheckout"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "mode",
          "created",
          "data"
        ]
      },
      "CardSavedEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's id, evt_ followed by 24 characters. Deliveries of the same event carry the same id, so use it to ignore a repeat.",
            "type": "string"
          },
          "object": {
            "description": "Always \"event\".",
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Always \"card.saved\".",
            "type": "string",
            "const": "card.saved"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "created": {
            "description": "When the event happened, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "The saved card.",
            "$ref": "#/components/schemas/SavedCard"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "mode",
          "created",
          "data"
        ]
      },
      "CardSaveFailedEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's id, evt_ followed by 24 characters. Deliveries of the same event carry the same id, so use it to ignore a repeat.",
            "type": "string"
          },
          "object": {
            "description": "Always \"event\".",
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Always \"card.save_failed\".",
            "type": "string",
            "const": "card.save_failed"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "created": {
            "description": "When the event happened, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "The payment, succeeded, whose card was not kept: its cardSave is failed.",
            "$ref": "#/components/schemas/Payment"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "mode",
          "created",
          "data"
        ]
      },
      "CardExpiringEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's id, evt_ followed by 24 characters. Deliveries of the same event carry the same id, so use it to ignore a repeat.",
            "type": "string"
          },
          "object": {
            "description": "Always \"event\".",
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Always \"card.expiring\".",
            "type": "string",
            "const": "card.expiring"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "created": {
            "description": "When the event happened, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "The saved card that expires.",
            "$ref": "#/components/schemas/SavedCard"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "mode",
          "created",
          "data"
        ]
      },
      "BillingAlertTriggeredEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's id, evt_ followed by 24 characters. Deliveries of the same event carry the same id, so use it to ignore a repeat.",
            "type": "string"
          },
          "object": {
            "description": "Always \"event\".",
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Always \"billing.alert.triggered\".",
            "type": "string",
            "const": "billing.alert.triggered"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "created": {
            "description": "When the event happened, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "The alert, the customer and the usage that reached it.",
            "$ref": "#/components/schemas/UsageAlertTrigger"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "mode",
          "created",
          "data"
        ]
      },
      "SubscriptionScheduleCreatedEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's id, evt_ followed by 24 characters. Deliveries of the same event carry the same id, so use it to ignore a repeat.",
            "type": "string"
          },
          "object": {
            "description": "Always \"event\".",
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Always \"subscription_schedule.created\".",
            "type": "string",
            "const": "subscription_schedule.created"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "created": {
            "description": "When the event happened, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "The schedule.",
            "$ref": "#/components/schemas/SubscriptionSchedule"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "mode",
          "created",
          "data"
        ]
      },
      "SubscriptionScheduleCompletedEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's id, evt_ followed by 24 characters. Deliveries of the same event carry the same id, so use it to ignore a repeat.",
            "type": "string"
          },
          "object": {
            "description": "Always \"event\".",
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Always \"subscription_schedule.completed\".",
            "type": "string",
            "const": "subscription_schedule.completed"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "created": {
            "description": "When the event happened, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "The schedule.",
            "$ref": "#/components/schemas/SubscriptionSchedule"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "mode",
          "created",
          "data"
        ]
      },
      "SubscriptionScheduleReleasedEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's id, evt_ followed by 24 characters. Deliveries of the same event carry the same id, so use it to ignore a repeat.",
            "type": "string"
          },
          "object": {
            "description": "Always \"event\".",
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Always \"subscription_schedule.released\".",
            "type": "string",
            "const": "subscription_schedule.released"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "created": {
            "description": "When the event happened, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "The schedule.",
            "$ref": "#/components/schemas/SubscriptionSchedule"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "mode",
          "created",
          "data"
        ]
      },
      "SubscriptionScheduleCanceledEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's id, evt_ followed by 24 characters. Deliveries of the same event carry the same id, so use it to ignore a repeat.",
            "type": "string"
          },
          "object": {
            "description": "Always \"event\".",
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Always \"subscription_schedule.canceled\".",
            "type": "string",
            "const": "subscription_schedule.canceled"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "created": {
            "description": "When the event happened, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "The schedule.",
            "$ref": "#/components/schemas/SubscriptionSchedule"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "mode",
          "created",
          "data"
        ]
      },
      "RefundSucceededEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's id, evt_ followed by 24 characters. Deliveries of the same event carry the same id, so use it to ignore a repeat.",
            "type": "string"
          },
          "object": {
            "description": "Always \"event\".",
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Always \"refund.succeeded\".",
            "type": "string",
            "const": "refund.succeeded"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "created": {
            "description": "When the event happened, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "The refund, with the payment as it stands after it.",
            "$ref": "#/components/schemas/RefundWithPayment"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "mode",
          "created",
          "data"
        ]
      },
      "RefundFailedEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's id, evt_ followed by 24 characters. Deliveries of the same event carry the same id, so use it to ignore a repeat.",
            "type": "string"
          },
          "object": {
            "description": "Always \"event\".",
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Always \"refund.failed\".",
            "type": "string",
            "const": "refund.failed"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "created": {
            "description": "When the event happened, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "The refund, with the payment it was for.",
            "$ref": "#/components/schemas/RefundWithPayment"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "mode",
          "created",
          "data"
        ]
      },
      "AccountLimitApproachingEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's id, evt_ followed by 24 characters. Deliveries of the same event carry the same id, so use it to ignore a repeat.",
            "type": "string"
          },
          "object": {
            "description": "Always \"event\".",
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Always \"account.limit.approaching\".",
            "type": "string",
            "const": "account.limit.approaching"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "created": {
            "description": "When the event happened, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "This month's usage, at the threshold reached.",
            "$ref": "#/components/schemas/AccountUsageEventData"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "mode",
          "created",
          "data"
        ]
      },
      "AccountLimitReachedEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's id, evt_ followed by 24 characters. Deliveries of the same event carry the same id, so use it to ignore a repeat.",
            "type": "string"
          },
          "object": {
            "description": "Always \"event\".",
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Always \"account.limit.reached\".",
            "type": "string",
            "const": "account.limit.reached"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "created": {
            "description": "When the event happened, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "This month's usage, with what the limit has refused so far.",
            "$ref": "#/components/schemas/AccountUsageEventData"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "mode",
          "created",
          "data"
        ]
      },
      "AccountLimitResetEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's id, evt_ followed by 24 characters. Deliveries of the same event carry the same id, so use it to ignore a repeat.",
            "type": "string"
          },
          "object": {
            "description": "Always \"event\".",
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Always \"account.limit.reset\".",
            "type": "string",
            "const": "account.limit.reset"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "created": {
            "description": "When the event happened, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "The finished month's usage, with what the limit refused.",
            "$ref": "#/components/schemas/AccountUsageEventData"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "mode",
          "created",
          "data"
        ]
      },
      "AccountUsageEventData": {
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"account_usage\".",
            "type": "string",
            "const": "account_usage"
          },
          "month": {
            "description": "The calendar month in Sri Lanka, such as 2026-09.",
            "type": "string"
          },
          "plan": {
            "description": "starter, growth or enterprise.",
            "type": "string",
            "enum": [
              "starter",
              "growth",
              "enterprise"
            ]
          },
          "capCents": {
            "description": "The plan's monthly limit in cents, or null for no limit.",
            "type": [
              "integer",
              "null"
            ]
          },
          "settledCents": {
            "description": "Live card payments that succeeded that month, in cents, gross.",
            "type": "integer"
          },
          "percent": {
            "description": "Whole percent of the limit used, rounded down.",
            "type": "integer"
          },
          "threshold": {
            "description": "What this event is for: 60, 70, 80 or 90 on approaching, 100 on reached and reset.",
            "type": "integer"
          },
          "refusedCount": {
            "description": "Payments refused that month because they would have passed the limit.",
            "type": "integer"
          },
          "refusedCents": {
            "description": "What the refused payments came to, in cents.",
            "type": "integer"
          },
          "resetsAt": {
            "description": "When the limit resets: midnight on the 1st in Sri Lanka, as ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "projectedAt": {
            "description": "When the month's pace reaches the limit, ISO 8601 in UTC, or null when there is too little to go on or the month ends first.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        },
        "required": [
          "object",
          "month",
          "plan",
          "capCents",
          "settledCents",
          "percent",
          "threshold",
          "refusedCount",
          "refusedCents",
          "resetsAt",
          "projectedAt"
        ]
      },
      "SubscriptionCreatedEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's id, evt_ followed by 24 characters. Deliveries of the same event carry the same id, so use it to ignore a repeat.",
            "type": "string"
          },
          "object": {
            "description": "Always \"event\".",
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Always \"customer.subscription.created\".",
            "type": "string",
            "const": "customer.subscription.created"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "created": {
            "description": "When the event happened, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "The subscription.",
            "$ref": "#/components/schemas/Subscription"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "mode",
          "created",
          "data"
        ]
      },
      "SubscriptionUpdatedEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's id, evt_ followed by 24 characters. Deliveries of the same event carry the same id, so use it to ignore a repeat.",
            "type": "string"
          },
          "object": {
            "description": "Always \"event\".",
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Always \"customer.subscription.updated\".",
            "type": "string",
            "const": "customer.subscription.updated"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "created": {
            "description": "When the event happened, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "The subscription as it stands.",
            "$ref": "#/components/schemas/Subscription"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "mode",
          "created",
          "data"
        ]
      },
      "SubscriptionDeletedEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's id, evt_ followed by 24 characters. Deliveries of the same event carry the same id, so use it to ignore a repeat.",
            "type": "string"
          },
          "object": {
            "description": "Always \"event\".",
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Always \"customer.subscription.deleted\".",
            "type": "string",
            "const": "customer.subscription.deleted"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "created": {
            "description": "When the event happened, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "The subscription that ended.",
            "$ref": "#/components/schemas/Subscription"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "mode",
          "created",
          "data"
        ]
      },
      "SubscriptionTrialWillEndEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's id, evt_ followed by 24 characters. Deliveries of the same event carry the same id, so use it to ignore a repeat.",
            "type": "string"
          },
          "object": {
            "description": "Always \"event\".",
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Always \"customer.subscription.trial_will_end\".",
            "type": "string",
            "const": "customer.subscription.trial_will_end"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "created": {
            "description": "When the event happened, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "The trialing subscription.",
            "$ref": "#/components/schemas/Subscription"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "mode",
          "created",
          "data"
        ]
      },
      "SubscriptionPausedEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's id, evt_ followed by 24 characters. Deliveries of the same event carry the same id, so use it to ignore a repeat.",
            "type": "string"
          },
          "object": {
            "description": "Always \"event\".",
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Always \"customer.subscription.paused\".",
            "type": "string",
            "const": "customer.subscription.paused"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "created": {
            "description": "When the event happened, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "The paused subscription.",
            "$ref": "#/components/schemas/Subscription"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "mode",
          "created",
          "data"
        ]
      },
      "SubscriptionResumedEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's id, evt_ followed by 24 characters. Deliveries of the same event carry the same id, so use it to ignore a repeat.",
            "type": "string"
          },
          "object": {
            "description": "Always \"event\".",
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Always \"customer.subscription.resumed\".",
            "type": "string",
            "const": "customer.subscription.resumed"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "created": {
            "description": "When the event happened, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "The resumed subscription.",
            "$ref": "#/components/schemas/Subscription"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "mode",
          "created",
          "data"
        ]
      },
      "InvoiceCreatedEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's id, evt_ followed by 24 characters. Deliveries of the same event carry the same id, so use it to ignore a repeat.",
            "type": "string"
          },
          "object": {
            "description": "Always \"event\".",
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Always \"invoice.created\".",
            "type": "string",
            "const": "invoice.created"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "created": {
            "description": "When the event happened, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "The invoice.",
            "$ref": "#/components/schemas/Invoice"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "mode",
          "created",
          "data"
        ]
      },
      "InvoiceFinalizedEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's id, evt_ followed by 24 characters. Deliveries of the same event carry the same id, so use it to ignore a repeat.",
            "type": "string"
          },
          "object": {
            "description": "Always \"event\".",
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Always \"invoice.finalized\".",
            "type": "string",
            "const": "invoice.finalized"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "created": {
            "description": "When the event happened, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "The invoice, numbered and open.",
            "$ref": "#/components/schemas/Invoice"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "mode",
          "created",
          "data"
        ]
      },
      "InvoiceSentEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's id, evt_ followed by 24 characters. Deliveries of the same event carry the same id, so use it to ignore a repeat.",
            "type": "string"
          },
          "object": {
            "description": "Always \"event\".",
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Always \"invoice.sent\".",
            "type": "string",
            "const": "invoice.sent"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "created": {
            "description": "When the event happened, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "The invoice.",
            "$ref": "#/components/schemas/Invoice"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "mode",
          "created",
          "data"
        ]
      },
      "InvoiceOverdueEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's id, evt_ followed by 24 characters. Deliveries of the same event carry the same id, so use it to ignore a repeat.",
            "type": "string"
          },
          "object": {
            "description": "Always \"event\".",
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Always \"invoice.overdue\".",
            "type": "string",
            "const": "invoice.overdue"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "created": {
            "description": "When the event happened, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "The invoice.",
            "$ref": "#/components/schemas/Invoice"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "mode",
          "created",
          "data"
        ]
      },
      "CreditNoteCreatedEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's id, evt_ followed by 24 characters. Deliveries of the same event carry the same id, so use it to ignore a repeat.",
            "type": "string"
          },
          "object": {
            "description": "Always \"event\".",
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Always \"credit_note.created\".",
            "type": "string",
            "const": "credit_note.created"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "created": {
            "description": "When the event happened, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "The credit note.",
            "$ref": "#/components/schemas/CreditNote"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "mode",
          "created",
          "data"
        ]
      },
      "ActiveEntitlementSummaryUpdatedEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's id, evt_ followed by 24 characters. Deliveries of the same event carry the same id, so use it to ignore a repeat.",
            "type": "string"
          },
          "object": {
            "description": "Always \"event\".",
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Always \"entitlements.active_entitlement_summary.updated\".",
            "type": "string",
            "const": "entitlements.active_entitlement_summary.updated"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "created": {
            "description": "When the event happened, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "Every feature the customer has now.",
            "$ref": "#/components/schemas/ActiveEntitlementSummary"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "mode",
          "created",
          "data"
        ]
      },
      "InvoicePaidEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's id, evt_ followed by 24 characters. Deliveries of the same event carry the same id, so use it to ignore a repeat.",
            "type": "string"
          },
          "object": {
            "description": "Always \"event\".",
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Always \"invoice.paid\".",
            "type": "string",
            "const": "invoice.paid"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "created": {
            "description": "When the event happened, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "The paid invoice.",
            "$ref": "#/components/schemas/Invoice"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "mode",
          "created",
          "data"
        ]
      },
      "InvoicePaymentFailedEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's id, evt_ followed by 24 characters. Deliveries of the same event carry the same id, so use it to ignore a repeat.",
            "type": "string"
          },
          "object": {
            "description": "Always \"event\".",
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Always \"invoice.payment_failed\".",
            "type": "string",
            "const": "invoice.payment_failed"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "created": {
            "description": "When the event happened, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "The invoice, with attemptCount, lastFailure and nextAttemptAt.",
            "$ref": "#/components/schemas/Invoice"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "mode",
          "created",
          "data"
        ]
      },
      "InvoiceUpcomingEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's id, evt_ followed by 24 characters. Deliveries of the same event carry the same id, so use it to ignore a repeat.",
            "type": "string"
          },
          "object": {
            "description": "Always \"event\".",
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Always \"invoice.upcoming\".",
            "type": "string",
            "const": "invoice.upcoming"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "created": {
            "description": "When the event happened, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "A preview of the invoice the renewal will make.",
            "$ref": "#/components/schemas/Invoice"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "mode",
          "created",
          "data"
        ]
      },
      "InvoiceVoidedEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's id, evt_ followed by 24 characters. Deliveries of the same event carry the same id, so use it to ignore a repeat.",
            "type": "string"
          },
          "object": {
            "description": "Always \"event\".",
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Always \"invoice.voided\".",
            "type": "string",
            "const": "invoice.voided"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "created": {
            "description": "When the event happened, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "The voided invoice.",
            "$ref": "#/components/schemas/Invoice"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "mode",
          "created",
          "data"
        ]
      },
      "InvoiceMarkedUncollectibleEvent": {
        "type": "object",
        "properties": {
          "id": {
            "description": "The event's id, evt_ followed by 24 characters. Deliveries of the same event carry the same id, so use it to ignore a repeat.",
            "type": "string"
          },
          "object": {
            "description": "Always \"event\".",
            "type": "string",
            "const": "event"
          },
          "type": {
            "description": "Always \"invoice.marked_uncollectible\".",
            "type": "string",
            "const": "invoice.marked_uncollectible"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "created": {
            "description": "When the event happened, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "description": "The invoice written off.",
            "$ref": "#/components/schemas/Invoice"
          }
        },
        "required": [
          "id",
          "object",
          "type",
          "mode",
          "created",
          "data"
        ]
      },
      "RefundWithPayment": {
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"refund\".",
            "type": "string",
            "const": "refund"
          },
          "id": {
            "description": "The refund's id, re_ followed by 24 characters.",
            "type": "string"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "paymentId": {
            "description": "The payment it refunds.",
            "type": "string"
          },
          "status": {
            "description": "pending when recorded, processing once sent to the processor, then succeeded or failed. The refund.succeeded or refund.failed webhook tells you which.",
            "type": "string",
            "enum": [
              "pending",
              "processing",
              "succeeded",
              "failed"
            ]
          },
          "amountCents": {
            "description": "The amount refunded, in cents.",
            "type": "integer"
          },
          "currency": {
            "description": "Always \"LKR\".",
            "type": "string",
            "const": "LKR"
          },
          "reason": {
            "description": "The reason you gave, or null.",
            "type": [
              "string",
              "null"
            ]
          },
          "failureMessage": {
            "description": "Why the refund failed, or null.",
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "description": "When it was created, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "succeededAt": {
            "description": "When the refund succeeded, or null.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "payment": {
            "description": "The payment the refund is for, as it stands after the refund.",
            "$ref": "#/components/schemas/Payment"
          }
        },
        "required": [
          "object",
          "id",
          "mode",
          "paymentId",
          "status",
          "amountCents",
          "currency",
          "reason",
          "failureMessage",
          "createdAt",
          "succeededAt",
          "payment"
        ]
      },
      "ExpiredCheckout": {
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"checkout\".",
            "type": "string",
            "const": "checkout"
          },
          "id": {
            "description": "The checkout's id.",
            "type": "string"
          },
          "paymentId": {
            "description": "The id of the payment it would have taken, now canceled.",
            "type": "string"
          }
        },
        "required": [
          "object",
          "id",
          "paymentId"
        ]
      },
      "PaymentList": {
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"list\".",
            "type": "string",
            "const": "list"
          },
          "data": {
            "description": "The payments, newest first.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Payment"
            }
          },
          "hasMore": {
            "description": "True when there is another page.",
            "type": "boolean"
          },
          "nextCursor": {
            "description": "Pass this as cursor to read the next page. Null on the last page.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "object",
          "data",
          "hasMore",
          "nextCursor"
        ]
      },
      "RefundList": {
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"list\".",
            "type": "string",
            "const": "list"
          },
          "data": {
            "description": "The refunds, newest first.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Refund"
            }
          },
          "hasMore": {
            "description": "True when there is another page.",
            "type": "boolean"
          },
          "nextCursor": {
            "description": "Pass this as cursor to read the next page. Null on the last page.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "object",
          "data",
          "hasMore",
          "nextCursor"
        ]
      },
      "PaymentLinkList": {
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"list\".",
            "type": "string",
            "const": "list"
          },
          "data": {
            "description": "Your payment links, retired ones included, newest first.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PaymentLink"
            }
          },
          "hasMore": {
            "description": "Always false: the list holds your 200 newest links.",
            "type": "boolean"
          },
          "nextCursor": {
            "description": "Always null.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "object",
          "data",
          "hasMore",
          "nextCursor"
        ]
      },
      "SavedCardList": {
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"list\".",
            "type": "string",
            "const": "list"
          },
          "data": {
            "description": "The saved cards that are still usable, newest first.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SavedCard"
            }
          },
          "hasMore": {
            "description": "True when there is another page.",
            "type": "boolean"
          },
          "nextCursor": {
            "description": "Pass this as cursor to read the next page. Null on the last page.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "object",
          "data",
          "hasMore",
          "nextCursor"
        ]
      },
      "EventList": {
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"list\".",
            "type": "string",
            "const": "list"
          },
          "data": {
            "description": "The events, newest first.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Event"
            }
          },
          "hasMore": {
            "description": "True when there is another page.",
            "type": "boolean"
          },
          "nextCursor": {
            "description": "Pass this as cursor to read the next page. Null on the last page.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "object",
          "data",
          "hasMore",
          "nextCursor"
        ]
      },
      "CustomerList": {
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"list\".",
            "type": "string",
            "const": "list"
          },
          "data": {
            "description": "The customers, newest first.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Customer"
            }
          },
          "hasMore": {
            "description": "True when there is another page.",
            "type": "boolean"
          },
          "nextCursor": {
            "description": "Pass this as cursor to read the next page. Null on the last page.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "object",
          "data",
          "hasMore",
          "nextCursor"
        ]
      },
      "PriceList": {
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"list\".",
            "type": "string",
            "const": "list"
          },
          "data": {
            "description": "The prices, newest first.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Price"
            }
          },
          "hasMore": {
            "description": "True when there is another page.",
            "type": "boolean"
          },
          "nextCursor": {
            "description": "Pass this as cursor to read the next page. Null on the last page.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "object",
          "data",
          "hasMore",
          "nextCursor"
        ]
      },
      "SubscriptionList": {
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"list\".",
            "type": "string",
            "const": "list"
          },
          "data": {
            "description": "The subscriptions, newest first.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Subscription"
            }
          },
          "hasMore": {
            "description": "True when there is another page.",
            "type": "boolean"
          },
          "nextCursor": {
            "description": "Pass this as cursor to read the next page. Null on the last page.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "object",
          "data",
          "hasMore",
          "nextCursor"
        ]
      },
      "InvoiceList": {
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"list\".",
            "type": "string",
            "const": "list"
          },
          "data": {
            "description": "The invoices, newest first.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Invoice"
            }
          },
          "hasMore": {
            "description": "True when there is another page.",
            "type": "boolean"
          },
          "nextCursor": {
            "description": "Pass this as cursor to read the next page. Null on the last page.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "object",
          "data",
          "hasMore",
          "nextCursor"
        ]
      },
      "CouponList": {
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"list\".",
            "type": "string",
            "const": "list"
          },
          "data": {
            "description": "The coupons, newest first.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Coupon"
            }
          },
          "hasMore": {
            "description": "True when there is another page.",
            "type": "boolean"
          },
          "nextCursor": {
            "description": "Pass this as cursor to read the next page. Null on the last page.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "object",
          "data",
          "hasMore",
          "nextCursor"
        ]
      },
      "SubscriptionLink": {
        "description": "A public link to subscribe: a plan chooser, a trial if you want one, and promotion codes.",
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"subscription_link\".",
            "type": "string",
            "const": "subscription_link"
          },
          "id": {
            "description": "The link's id, slk_ followed by 24 characters.",
            "type": "string"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "url": {
            "description": "The link to share: the customer chooses a plan, gives their email and pays the first period, or starts the trial.",
            "type": "string"
          },
          "name": {
            "description": "Its name, for you: customers see the prices, not this.",
            "type": "string"
          },
          "prices": {
            "description": "The prices a customer chooses from, in the order they are shown. An archived one is left off the page.",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "description": "The price's id.",
                  "type": "string"
                },
                "productName": {
                  "description": "The product's name.",
                  "type": "string"
                },
                "nickname": {
                  "description": "The price's own name, or null.",
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "unitAmountCents": {
                  "description": "The amount each period, in cents.",
                  "type": "integer"
                },
                "interval": {
                  "description": "day, week, month or year.",
                  "type": "string",
                  "enum": [
                    "day",
                    "week",
                    "month",
                    "year"
                  ]
                },
                "intervalCount": {
                  "description": "How many intervals a period is.",
                  "type": "integer"
                },
                "active": {
                  "description": "False once the price is archived.",
                  "type": "boolean"
                }
              },
              "required": [
                "id",
                "productName",
                "nickname",
                "unitAmountCents",
                "interval",
                "intervalCount",
                "active"
              ]
            }
          },
          "trialDays": {
            "description": "A free trial of this many days for everyone who subscribes through it, or null for none.",
            "type": [
              "integer",
              "null"
            ]
          },
          "allowPromotionCodes": {
            "description": "Whether the page takes a code customers type, matched to your coupons' codes.",
            "type": "boolean"
          },
          "successUrl": {
            "description": "Where customers land after subscribing, or null for the link's own thank you page.",
            "type": [
              "string",
              "null"
            ]
          },
          "active": {
            "description": "False once turned off: its page says the link does not work.",
            "type": "boolean"
          },
          "createdAt": {
            "description": "When it was created, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "object",
          "id",
          "mode",
          "url",
          "name",
          "prices",
          "trialDays",
          "allowPromotionCodes",
          "successUrl",
          "active",
          "createdAt"
        ]
      },
      "SubscriptionLinkList": {
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"list\".",
            "type": "string",
            "const": "list"
          },
          "data": {
            "description": "The subscription links, newest first.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SubscriptionLink"
            }
          },
          "hasMore": {
            "description": "True when there is another page.",
            "type": "boolean"
          },
          "nextCursor": {
            "description": "Pass this as cursor to read the next page. Null on the last page.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "object",
          "data",
          "hasMore",
          "nextCursor"
        ]
      },
      "Meter": {
        "description": "What you count for usage based billing, by the name your meter events carry.",
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"meter\".",
            "type": "string",
            "const": "meter"
          },
          "id": {
            "description": "The meter's id, mtr_ followed by 24 characters.",
            "type": "string"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "name": {
            "description": "Its name, as invoice lines show the usage: 12,000 API calls.",
            "type": "string"
          },
          "eventName": {
            "description": "The name your meter events carry for it.",
            "type": "string"
          },
          "aggregation": {
            "description": "sum (the values added up), count (how many events) or last (the latest value in the period).",
            "type": "string",
            "enum": [
              "sum",
              "count",
              "last"
            ]
          },
          "active": {
            "description": "False once turned off: its events are refused, and its prices bill what it counted.",
            "type": "boolean"
          },
          "createdAt": {
            "description": "When it was created, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "object",
          "id",
          "mode",
          "name",
          "eventName",
          "aggregation",
          "active",
          "createdAt"
        ]
      },
      "MeterList": {
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"list\".",
            "type": "string",
            "const": "list"
          },
          "data": {
            "description": "The meters, newest first.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Meter"
            }
          },
          "hasMore": {
            "description": "True when there is another page.",
            "type": "boolean"
          },
          "nextCursor": {
            "description": "Pass this as cursor to read the next page. Null on the last page.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "object",
          "data",
          "hasMore",
          "nextCursor"
        ]
      },
      "Feature": {
        "description": "A feature customers get with a product, by the lookup key your app checks.",
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"entitlements.feature\".",
            "type": "string",
            "const": "entitlements.feature"
          },
          "id": {
            "description": "The feature's id, feat_ followed by 24 characters.",
            "type": "string"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "name": {
            "description": "Its name, for you.",
            "type": "string"
          },
          "lookupKey": {
            "description": "The key your app checks a customer for: pool, api_access.",
            "type": "string"
          },
          "active": {
            "description": "True while it can be given with a product.",
            "type": "boolean"
          },
          "createdAt": {
            "description": "When it was created, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "object",
          "id",
          "mode",
          "name",
          "lookupKey",
          "active",
          "createdAt"
        ]
      },
      "FeatureList": {
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"list\".",
            "type": "string",
            "const": "list"
          },
          "data": {
            "description": "The features, newest first.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Feature"
            }
          },
          "hasMore": {
            "description": "True when there is another page.",
            "type": "boolean"
          },
          "nextCursor": {
            "description": "Pass this as cursor to read the next page. Null on the last page.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "object",
          "data",
          "hasMore",
          "nextCursor"
        ]
      },
      "ProductFeature": {
        "description": "A feature given with a product.",
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"product_feature\".",
            "type": "string",
            "const": "product_feature"
          },
          "id": {
            "description": "The link's id, pfeat_ followed by 24 characters.",
            "type": "string"
          },
          "productId": {
            "description": "The product.",
            "type": "string"
          },
          "featureId": {
            "description": "The feature it gives.",
            "type": "string"
          },
          "lookupKey": {
            "description": "The feature's lookup key.",
            "type": "string"
          },
          "createdAt": {
            "description": "When it was created, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "object",
          "id",
          "productId",
          "featureId",
          "lookupKey",
          "createdAt"
        ]
      },
      "ProductFeatureList": {
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"list\".",
            "type": "string",
            "const": "list"
          },
          "data": {
            "description": "The the product's features, newest first.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProductFeature"
            }
          },
          "hasMore": {
            "description": "True when there is another page.",
            "type": "boolean"
          },
          "nextCursor": {
            "description": "Pass this as cursor to read the next page. Null on the last page.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "object",
          "data",
          "hasMore",
          "nextCursor"
        ]
      },
      "DeletedProductFeature": {
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"product_feature\".",
            "type": "string",
            "const": "product_feature"
          },
          "productId": {
            "description": "The product.",
            "type": "string"
          },
          "featureId": {
            "description": "The feature taken off it.",
            "type": "string"
          },
          "deleted": {
            "description": "Always true.",
            "type": "boolean",
            "const": true
          }
        },
        "required": [
          "object",
          "productId",
          "featureId",
          "deleted"
        ]
      },
      "ActiveEntitlement": {
        "description": "A feature a customer has now.",
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"entitlements.active_entitlement\".",
            "type": "string",
            "const": "entitlements.active_entitlement"
          },
          "featureId": {
            "description": "The feature.",
            "type": "string"
          },
          "lookupKey": {
            "description": "Its lookup key: check this in your app.",
            "type": "string"
          }
        },
        "required": [
          "object",
          "featureId",
          "lookupKey"
        ]
      },
      "ActiveEntitlementList": {
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"list\".",
            "type": "string",
            "const": "list"
          },
          "data": {
            "description": "The customer's features, by lookup key.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ActiveEntitlement"
            }
          },
          "hasMore": {
            "description": "True when there is another page.",
            "type": "boolean"
          },
          "nextCursor": {
            "description": "Pass this as cursor to read the next page. Null on the last page.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "object",
          "data",
          "hasMore",
          "nextCursor"
        ]
      },
      "ActiveEntitlementSummary": {
        "description": "Every feature a customer has now.",
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"entitlements.active_entitlement_summary\".",
            "type": "string",
            "const": "entitlements.active_entitlement_summary"
          },
          "customerId": {
            "description": "The customer.",
            "type": "string"
          },
          "entitlements": {
            "description": "Every feature they have now, by lookup key.",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "featureId": {
                  "description": "The feature.",
                  "type": "string"
                },
                "lookupKey": {
                  "description": "Its lookup key.",
                  "type": "string"
                }
              },
              "required": [
                "featureId",
                "lookupKey"
              ]
            }
          }
        },
        "required": [
          "object",
          "customerId",
          "entitlements"
        ]
      },
      "CreditNote": {
        "description": "An amount taken off an invoice: off what was due, refunded, or added to the customer's credit.",
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"credit_note\".",
            "type": "string",
            "const": "credit_note"
          },
          "id": {
            "description": "The credit note's id, cn_ followed by 24 characters.",
            "type": "string"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "invoiceId": {
            "description": "The invoice it credits.",
            "type": "string"
          },
          "customerId": {
            "description": "The customer.",
            "type": "string"
          },
          "number": {
            "description": "CN-000001, your own sequence.",
            "type": "string"
          },
          "amountCents": {
            "description": "How much, in cents.",
            "type": "integer"
          },
          "reason": {
            "description": "duplicate, fraudulent, order_change or product_unsatisfactory, or null.",
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "duplicate",
                  "fraudulent",
                  "order_change",
                  "product_unsatisfactory"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "memo": {
            "description": "Its note, or null.",
            "type": [
              "string",
              "null"
            ]
          },
          "amountDueReducedCents": {
            "description": "The part taken off what was due on an open invoice.",
            "type": "integer"
          },
          "refundedCents": {
            "description": "The part refunded to the card, as refundId.",
            "type": "integer"
          },
          "creditedToBalanceCents": {
            "description": "The part added to the customer's credit balance.",
            "type": "integer"
          },
          "refundId": {
            "description": "The refund it made, or null.",
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "description": "When it was created, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "object",
          "id",
          "mode",
          "invoiceId",
          "customerId",
          "number",
          "amountCents",
          "reason",
          "memo",
          "amountDueReducedCents",
          "refundedCents",
          "creditedToBalanceCents",
          "refundId",
          "createdAt"
        ]
      },
      "CreditNoteList": {
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"list\".",
            "type": "string",
            "const": "list"
          },
          "data": {
            "description": "The credit notes, newest first.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CreditNote"
            }
          },
          "hasMore": {
            "description": "True when there is another page.",
            "type": "boolean"
          },
          "nextCursor": {
            "description": "Pass this as cursor to read the next page. Null on the last page.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "object",
          "data",
          "hasMore",
          "nextCursor"
        ]
      },
      "SubscriptionSchedule": {
        "description": "Phases a subscription moves through, each its prices for a number of periods.",
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"subscription_schedule\".",
            "type": "string",
            "const": "subscription_schedule"
          },
          "id": {
            "description": "The schedule's id, sched_ followed by 24 characters.",
            "type": "string"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "customerId": {
            "description": "The customer it bills.",
            "type": "string"
          },
          "subscriptionId": {
            "description": "The subscription it made, once it has started; null before.",
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "description": "not_started until startDate, active while its phases run, then completed (it ended its subscription), released (the subscription carries on) or canceled.",
            "type": "string",
            "enum": [
              "not_started",
              "active",
              "completed",
              "released",
              "canceled"
            ]
          },
          "endBehavior": {
            "description": "After the last phase: release (the subscription carries on) or cancel (it ends).",
            "type": "string",
            "enum": [
              "release",
              "cancel"
            ]
          },
          "startDate": {
            "description": "When its subscription starts, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "phases": {
            "description": "Its phases, in order.",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "items": {
                  "description": "The phase's prices, each with its quantity.",
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "priceId": {
                        "description": "The price.",
                        "type": "string"
                      },
                      "quantity": {
                        "description": "How many units.",
                        "type": "integer"
                      }
                    },
                    "required": [
                      "priceId",
                      "quantity"
                    ]
                  }
                },
                "iterations": {
                  "description": "How many billing periods the phase lasts, or null for a last phase that runs on.",
                  "type": [
                    "integer",
                    "null"
                  ]
                },
                "trialDays": {
                  "description": "A free trial at the start of the first phase, in days, or null.",
                  "type": [
                    "integer",
                    "null"
                  ]
                },
                "couponId": {
                  "description": "A coupon put on the subscription when the phase starts, or null.",
                  "type": [
                    "string",
                    "null"
                  ]
                }
              },
              "required": [
                "items",
                "iterations",
                "trialDays",
                "couponId"
              ]
            }
          },
          "currentPhase": {
            "description": "The phase now running, from 0.",
            "type": "integer"
          },
          "currentPhaseEndsAt": {
            "description": "When the current phase ends, in the subscription's own time: the renewal at that time moves it on. Null before it starts, after it ends, or for a last phase that runs on.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "reference": {
            "description": "Your own reference, or null.",
            "type": [
              "string",
              "null"
            ]
          },
          "completedAt": {
            "description": "When it completed, or null.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "releasedAt": {
            "description": "When it was released, or null.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "canceledAt": {
            "description": "When it was canceled, or null.",
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "createdAt": {
            "description": "When it was created, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "object",
          "id",
          "mode",
          "customerId",
          "subscriptionId",
          "status",
          "endBehavior",
          "startDate",
          "phases",
          "currentPhase",
          "currentPhaseEndsAt",
          "reference",
          "completedAt",
          "releasedAt",
          "canceledAt",
          "createdAt"
        ]
      },
      "SubscriptionScheduleList": {
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"list\".",
            "type": "string",
            "const": "list"
          },
          "data": {
            "description": "The subscription schedules, newest first.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SubscriptionSchedule"
            }
          },
          "hasMore": {
            "description": "True when there is another page.",
            "type": "boolean"
          },
          "nextCursor": {
            "description": "Pass this as cursor to read the next page. Null on the last page.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "object",
          "data",
          "hasMore",
          "nextCursor"
        ]
      },
      "MeterEvent": {
        "description": "One use of a customer's, counted by a meter.",
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"meter_event\".",
            "type": "string",
            "const": "meter_event"
          },
          "id": {
            "description": "The event's id, mev_ followed by 24 characters.",
            "type": "string"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "meterId": {
            "description": "The meter that counted it.",
            "type": "string"
          },
          "eventName": {
            "description": "The name it carried.",
            "type": "string"
          },
          "customerId": {
            "description": "The customer whose usage it is.",
            "type": "string"
          },
          "value": {
            "description": "How much.",
            "type": "integer"
          },
          "timestamp": {
            "description": "When it happened, ISO 8601 in UTC. A period counts the events dated inside it.",
            "type": "string",
            "format": "date-time"
          },
          "identifier": {
            "description": "Your own id for it, or null.",
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "description": "When it was created, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "object",
          "id",
          "mode",
          "meterId",
          "eventName",
          "customerId",
          "value",
          "timestamp",
          "identifier",
          "createdAt"
        ]
      },
      "MeterEventSummary": {
        "description": "A customer's usage on a meter between two times.",
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"meter_event_summary\".",
            "type": "string",
            "const": "meter_event_summary"
          },
          "meterId": {
            "description": "The meter.",
            "type": "string"
          },
          "customerId": {
            "description": "The customer.",
            "type": "string"
          },
          "start": {
            "description": "From this time, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          },
          "end": {
            "description": "Up to (not including) this time.",
            "type": "string",
            "format": "date-time"
          },
          "aggregatedValue": {
            "description": "The usage in between, as the meter adds it up.",
            "type": "integer"
          }
        },
        "required": [
          "object",
          "meterId",
          "customerId",
          "start",
          "end",
          "aggregatedValue"
        ]
      },
      "UsageAlert": {
        "description": "An alert that fires once a customer's usage in their period reaches a threshold.",
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"usage_alert\".",
            "type": "string",
            "const": "usage_alert"
          },
          "id": {
            "description": "The alert's id, ual_ followed by 24 characters.",
            "type": "string"
          },
          "mode": {
            "description": "test for a sandbox key, live for a live key. The key decides it; a key never reads the other mode's rows.",
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "meterId": {
            "description": "The meter it watches.",
            "type": "string"
          },
          "customerId": {
            "description": "The customer it watches, or null for every customer.",
            "type": [
              "string",
              "null"
            ]
          },
          "title": {
            "description": "Its name, sent with the event.",
            "type": "string"
          },
          "threshold": {
            "description": "The usage in a customer's current period that fires it, once per customer.",
            "type": "integer"
          },
          "active": {
            "description": "False once archived: it fires for no one new.",
            "type": "boolean"
          },
          "createdAt": {
            "description": "When it was created, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "object",
          "id",
          "mode",
          "meterId",
          "customerId",
          "title",
          "threshold",
          "active",
          "createdAt"
        ]
      },
      "UsageAlertList": {
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"list\".",
            "type": "string",
            "const": "list"
          },
          "data": {
            "description": "The usage alerts, newest first.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UsageAlert"
            }
          },
          "hasMore": {
            "description": "True when there is another page.",
            "type": "boolean"
          },
          "nextCursor": {
            "description": "Pass this as cursor to read the next page. Null on the last page.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "object",
          "data",
          "hasMore",
          "nextCursor"
        ]
      },
      "UsageAlertTrigger": {
        "description": "What billing.alert.triggered carries: the alert, the customer and the usage.",
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"usage_alert_trigger\".",
            "type": "string",
            "const": "usage_alert_trigger"
          },
          "alertId": {
            "description": "The alert that fired.",
            "type": "string"
          },
          "title": {
            "description": "The alert's title.",
            "type": "string"
          },
          "meterId": {
            "description": "The meter it watches.",
            "type": "string"
          },
          "customerId": {
            "description": "The customer whose usage reached it.",
            "type": "string"
          },
          "threshold": {
            "description": "The alert's threshold.",
            "type": "integer"
          },
          "value": {
            "description": "The customer's usage in their current period when it fired.",
            "type": "integer"
          },
          "triggeredAt": {
            "description": "When, ISO 8601 in UTC.",
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "object",
          "alertId",
          "title",
          "meterId",
          "customerId",
          "threshold",
          "value",
          "triggeredAt"
        ]
      },
      "TaxRateList": {
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"list\".",
            "type": "string",
            "const": "list"
          },
          "data": {
            "description": "The tax rates, newest first.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaxRate"
            }
          },
          "hasMore": {
            "description": "True when there is another page.",
            "type": "boolean"
          },
          "nextCursor": {
            "description": "Pass this as cursor to read the next page. Null on the last page.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "object",
          "data",
          "hasMore",
          "nextCursor"
        ]
      },
      "InvoiceItemList": {
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"list\".",
            "type": "string",
            "const": "list"
          },
          "data": {
            "description": "The invoice items, newest first.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoiceItem"
            }
          },
          "hasMore": {
            "description": "True when there is another page.",
            "type": "boolean"
          },
          "nextCursor": {
            "description": "Pass this as cursor to read the next page. Null on the last page.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "object",
          "data",
          "hasMore",
          "nextCursor"
        ]
      },
      "CustomerBalanceTransactionList": {
        "type": "object",
        "properties": {
          "object": {
            "description": "Always \"list\".",
            "type": "string",
            "const": "list"
          },
          "data": {
            "description": "The credit balance changes, newest first.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CustomerBalanceTransaction"
            }
          },
          "hasMore": {
            "description": "True when there is another page.",
            "type": "boolean"
          },
          "nextCursor": {
            "description": "Pass this as cursor to read the next page. Null on the last page.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "object",
          "data",
          "hasMore",
          "nextCursor"
        ]
      },
      "CreateCheckoutRequest": {
        "type": "object",
        "properties": {
          "amountCents": {
            "description": "The amount in LKR cents, from Rs. 10 (1000) to Rs. 1,000,000 (100000000). Required unless you send lineItems, and refused with them. Take it from your own records, never from the browser.",
            "type": "integer",
            "minimum": 1000,
            "maximum": 100000000
          },
          "description": {
            "description": "What the customer is paying for, shown on the checkout. 1 to 120 characters. Required with amountCents; with lineItems a summary such as your trading name and the number of items stands in when you leave it out.",
            "type": "string",
            "maxLength": 120,
            "minLength": 1
          },
          "lineItems": {
            "description": "What the customer is buying, 1 to 10 lines, shown on the checkout; the total is worked out from them and must come to Rs. 10 to Rs. 1,000,000. Send lineItems or amountCents, never both.",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "description": "The line's name, 1 to 80 characters.",
                  "type": "string",
                  "maxLength": 80,
                  "minLength": 1
                },
                "description": {
                  "description": "More about the line, up to 200 characters.",
                  "type": "string",
                  "maxLength": 200
                },
                "unitAmountCents": {
                  "description": "The price of one, in LKR cents, from Rs. 1 (100) to Rs. 1,000,000 (100000000).",
                  "type": "integer",
                  "minimum": 100,
                  "maximum": 100000000
                },
                "quantity": {
                  "description": "How many, from 1 to 99. The customer cannot change it on the checkout.",
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 99
                }
              },
              "required": [
                "name",
                "unitAmountCents",
                "quantity"
              ],
              "additionalProperties": false
            },
            "minItems": 1,
            "maxItems": 10
          },
          "locale": {
            "description": "The language the checkout opens in: en, si or ta. English when left out; url then carries /si or /ta.",
            "type": "string",
            "enum": [
              "en",
              "si",
              "ta"
            ]
          },
          "reference": {
            "description": "Your own reference, such as an order number. Up to 64 characters; it comes back on the payment and its webhooks.",
            "type": "string",
            "maxLength": 64
          },
          "customer": {
            "description": "The customer's details, if you have them. Otherwise the checkout page asks for them.",
            "type": "object",
            "properties": {
              "name": {
                "description": "The customer's name, 2 to 80 characters.",
                "type": "string",
                "maxLength": 80,
                "minLength": 2
              },
              "email": {
                "description": "The customer's email address.",
                "type": "string",
                "minLength": 3,
                "maxLength": 254,
                "pattern": "^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$"
              },
              "phone": {
                "description": "A Sri Lankan phone number, such as 0771234567 or +94771234567. Spaces and dashes are removed.",
                "type": "string"
              }
            },
            "required": [
              "name",
              "email"
            ],
            "additionalProperties": false
          },
          "successUrl": {
            "description": "Where the customer's browser goes after paying: https, http on localhost, or your app's own scheme such as myshop://paid. It proves nothing; confirm from the webhook.",
            "type": "string",
            "maxLength": 2000
          },
          "cancelUrl": {
            "description": "Where the customer's browser goes if they give up. The same rules as successUrl.",
            "type": "string",
            "maxLength": 2000
          },
          "saveCard": {
            "description": "Offer the customer to keep the card on file for later charges. A live checkout refuses it until saved cards are switched on for your account.",
            "type": "boolean",
            "default": false
          }
        },
        "additionalProperties": false,
        "oneOf": [
          {
            "required": [
              "amountCents",
              "description"
            ],
            "not": {
              "required": [
                "lineItems"
              ]
            }
          },
          {
            "required": [
              "lineItems"
            ],
            "not": {
              "required": [
                "amountCents"
              ]
            }
          }
        ]
      },
      "CreateRefundRequest": {
        "type": "object",
        "properties": {
          "paymentId": {
            "description": "The payment to refund. It must have succeeded.",
            "type": "string",
            "pattern": "^pay_[0-9a-z]{24}$"
          },
          "amountCents": {
            "description": "How much to refund, in cents, at least Rs. 1 (100). Leave it out to refund everything still refundable.",
            "type": "integer",
            "minimum": 100,
            "maximum": 9007199254740991
          },
          "reason": {
            "description": "Why, for your records. Up to 200 characters.",
            "type": "string",
            "maxLength": 200
          }
        },
        "required": [
          "paymentId"
        ],
        "additionalProperties": false
      },
      "CreatePaymentLinkRequest": {
        "type": "object",
        "properties": {
          "title": {
            "description": "What the link is for, 1 to 80 characters. Payers see it.",
            "type": "string",
            "maxLength": 80,
            "minLength": 1
          },
          "description": {
            "description": "More about it, up to 200 characters. Payers see it.",
            "type": "string",
            "maxLength": 200
          },
          "amountCents": {
            "description": "The fixed amount in LKR cents, from Rs. 10 (1000) to Rs. 1,000,000 (100000000).",
            "type": "integer",
            "minimum": 1000,
            "maximum": 100000000
          }
        },
        "required": [
          "title",
          "amountCents"
        ],
        "additionalProperties": false
      },
      "ChargeSavedCardRequest": {
        "type": "object",
        "properties": {
          "amountCents": {
            "description": "The amount in LKR cents, from Rs. 10 (1000) to Rs. 1,000,000 (100000000). Charge only what the customer agreed to.",
            "type": "integer",
            "minimum": 1000,
            "maximum": 100000000
          },
          "description": {
            "description": "What the charge is for, 1 to 120 characters.",
            "type": "string",
            "maxLength": 120,
            "minLength": 1
          },
          "reference": {
            "description": "Your own reference, up to 64 characters.",
            "type": "string",
            "maxLength": 64
          }
        },
        "required": [
          "amountCents",
          "description"
        ],
        "additionalProperties": false
      },
      "CreateCustomerRequest": {
        "type": "object",
        "properties": {
          "email": {
            "description": "Their email address. A customer with this email in this mode is answered, not made again.",
            "type": "string",
            "minLength": 3,
            "maxLength": 254,
            "pattern": "^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$"
          },
          "name": {
            "description": "Their name, 1 to 120 characters.",
            "type": "string",
            "maxLength": 120,
            "minLength": 1
          },
          "phone": {
            "description": "A Sri Lankan mobile number, such as 0771234567.",
            "type": "string",
            "maxLength": 24,
            "pattern": "^(?:\\+94|94|0)?7\\d{8}$"
          },
          "locale": {
            "description": "The language of their emails and payment pages: en (the default), si or ta.",
            "type": "string",
            "enum": [
              "en",
              "si",
              "ta"
            ]
          }
        },
        "required": [
          "email"
        ],
        "additionalProperties": false
      },
      "CreatePriceRequest": {
        "type": "object",
        "properties": {
          "productId": {
            "description": "A product of yours already made. Send this or product, not both.",
            "type": "string",
            "pattern": "^prod_[0-9a-z]{20,32}$"
          },
          "product": {
            "description": "A product made with this price. Send this or productId, not both.",
            "type": "object",
            "properties": {
              "name": {
                "description": "The product's name, 1 to 120 characters.",
                "type": "string",
                "maxLength": 120,
                "minLength": 1
              },
              "description": {
                "description": "A line about it, up to 500 characters.",
                "type": "string",
                "maxLength": 500
              }
            },
            "required": [
              "name"
            ],
            "additionalProperties": false
          },
          "unitAmountCents": {
            "description": "The amount per unit (or per package), in LKR cents, up to Rs. 1,000,000 (100000000). A licensed price per unit is Rs. 10 (1000) at least; a metered or package price may be less. Leave it out for a tiered price.",
            "type": "integer",
            "minimum": 0,
            "maximum": 100000000
          },
          "interval": {
            "description": "How often it bills: day, week, month or year.",
            "type": "string",
            "enum": [
              "day",
              "week",
              "month",
              "year"
            ]
          },
          "intervalCount": {
            "description": "How many intervals a period is, 1 to 12. Defaults to 1; a yearly price is every year.",
            "type": "integer",
            "minimum": 1,
            "maximum": 12,
            "default": 1
          },
          "nickname": {
            "description": "Your own name for it on invoices, up to 80 characters.",
            "type": "string",
            "maxLength": 80
          },
          "billingScheme": {
            "description": "per_unit (the default), package or tiered.",
            "type": "string",
            "enum": [
              "per_unit",
              "package",
              "tiered"
            ],
            "default": "per_unit"
          },
          "tiersMode": {
            "description": "With tiered: graduated or volume.",
            "type": "string",
            "enum": [
              "graduated",
              "volume"
            ]
          },
          "tiers": {
            "description": "With tiered: 2 to 10 tiers in order, each upTo above the one before, the last upTo null.",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "upTo": {
                  "description": "The last unit the tier prices, or null for the last tier.",
                  "type": [
                    "integer",
                    "null"
                  ],
                  "minimum": 1
                },
                "unitAmountCents": {
                  "description": "Per unit in the tier, in cents, from 0.",
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 100000000
                },
                "flatAmountCents": {
                  "description": "Added once for the tier, in cents. Defaults to 0.",
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 100000000,
                  "default": 0
                }
              },
              "required": [
                "upTo",
                "unitAmountCents"
              ],
              "additionalProperties": false
            },
            "minItems": 2,
            "maxItems": 10
          },
          "packageSize": {
            "description": "With package: how many units a package is, 2 to 1000000.",
            "type": "integer",
            "minimum": 2,
            "maximum": 1000000
          },
          "usageType": {
            "description": "licensed (the default: a quantity, billed in advance) or metered (a meter's usage, billed in arrears).",
            "type": "string",
            "enum": [
              "licensed",
              "metered"
            ],
            "default": "licensed"
          },
          "meterId": {
            "description": "With metered: the active meter whose usage it bills.",
            "type": "string",
            "pattern": "^mtr_[0-9a-z]{20,32}$"
          }
        },
        "required": [
          "interval"
        ],
        "additionalProperties": false
      },
      "CreateSubscriptionRequest": {
        "type": "object",
        "properties": {
          "customerId": {
            "description": "Your customer, by id. Send this or customer, not both.",
            "type": "string",
            "pattern": "^cus_[0-9a-z]{20,32}$"
          },
          "customer": {
            "description": "Your customer's details: found by email, or made. Send this or customerId, not both.",
            "$ref": "#/components/schemas/CreateCustomerRequest"
          },
          "priceId": {
            "description": "The active price to bill. Send this or items.",
            "type": "string",
            "pattern": "^price_[0-9a-z]{20,32}$"
          },
          "quantity": {
            "description": "How many units each period, 1 to 10000. Defaults to 1.",
            "type": "integer",
            "minimum": 1,
            "maximum": 10000,
            "default": 1
          },
          "items": {
            "description": "Up to 10 active prices, each once and all on the same interval, such as a base plan and add-ons. Send this or priceId.",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "priceId": {
                  "description": "The price.",
                  "type": "string",
                  "pattern": "^price_[0-9a-z]{20,32}$"
                },
                "quantity": {
                  "description": "How many units of it each period, 1 to 10000. Defaults to 1.",
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 10000,
                  "default": 1
                }
              },
              "required": [
                "priceId"
              ],
              "additionalProperties": false
            },
            "minItems": 1,
            "maxItems": 10
          },
          "cardId": {
            "description": "A card this customer kept with you: the first invoice is charged to it. Without it, the customer's default card, and without that, checkoutUrl.",
            "type": "string",
            "pattern": "^card_[0-9a-z]{20,32}$"
          },
          "reference": {
            "description": "Your own reference, up to 120 characters.",
            "type": "string",
            "maxLength": 120
          },
          "successUrl": {
            "description": "Where the customer lands after the first payment at checkoutUrl: https, or your app's scheme.",
            "type": "string",
            "maxLength": 2000
          },
          "cancelUrl": {
            "description": "Where the customer lands if they leave checkoutUrl without paying.",
            "type": "string",
            "maxLength": 2000
          },
          "trialDays": {
            "description": "A free trial of this many days, 1 to 730: the subscription starts trialing, with no payment, and its first invoice is for nothing. Send this or trialEnd.",
            "type": "integer",
            "minimum": 1,
            "maximum": 730
          },
          "trialEnd": {
            "description": "A free trial until this time, ISO 8601, within two years. Send this or trialDays.",
            "type": "string",
            "format": "date-time"
          },
          "trialEndBehavior": {
            "description": "With no card on file when the trial ends: create_invoice (the default: the customer is sent the invoice to pay), pause, or cancel.",
            "type": "string",
            "enum": [
              "create_invoice",
              "pause",
              "cancel"
            ],
            "default": "create_invoice"
          },
          "cancelAt": {
            "description": "Ends the subscription at this time, ISO 8601, within two years; the last period is billed only up to it.",
            "type": "string",
            "format": "date-time"
          },
          "couponId": {
            "description": "A coupon of yours discounting its invoices.",
            "type": "string",
            "pattern": "^cpn_[0-9a-z]{20,32}$"
          },
          "taxRateIds": {
            "description": "Up to 5 tax rates of yours applied to its invoices.",
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^txr_[0-9a-z]{20,32}$"
            },
            "maxItems": 5
          },
          "addInvoiceItems": {
            "description": "Up to 10 one-off lines on its first invoice, such as a joining fee.",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "description": {
                  "description": "The line as the customer reads it.",
                  "type": "string",
                  "maxLength": 200,
                  "minLength": 1
                },
                "unitAmountCents": {
                  "description": "Per unit, in cents; negative for a credit.",
                  "type": "integer",
                  "minimum": -100000000,
                  "maximum": 100000000
                },
                "quantity": {
                  "description": "How many units, 1 to 10000. Defaults to 1.",
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 10000,
                  "default": 1
                },
                "discountable": {
                  "description": "Whether a coupon discounts it. Defaults to true.",
                  "type": "boolean",
                  "default": true
                }
              },
              "required": [
                "description",
                "unitAmountCents"
              ],
              "additionalProperties": false
            },
            "maxItems": 10
          },
          "collectionMethod": {
            "description": "charge_automatically (the default) or send_invoice: it starts active, and each invoice is emailed to the customer to pay by its due date instead of being charged.",
            "type": "string",
            "enum": [
              "charge_automatically",
              "send_invoice"
            ],
            "default": "charge_automatically"
          },
          "daysUntilDue": {
            "description": "For send_invoice: days from an invoice being sent to its due date, 0 to 365. Defaults to 30.",
            "type": "integer",
            "minimum": 0,
            "maximum": 365
          },
          "billingCycleAnchor": {
            "description": "Where its renewals fall: now (from the moment it starts), first_of_month (midnight on the 1st of each month in Sri Lanka; monthly and yearly prices only), or an ISO 8601 time after now and at most one period ahead. The part period up to it is its first, invoiced now and priced by the day (or the second, as your billing settings say); one worth less than Rs. 10 is added to the first renewal's invoice instead. Not with a trial, whose end anchors the renewals. Leave it out for your billing settings' default.",
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "now",
                  "first_of_month"
                ]
              },
              {
                "type": "string",
                "format": "date-time"
              }
            ]
          }
        },
        "additionalProperties": false
      },
      "CancelSubscriptionRequest": {
        "type": "object",
        "properties": {
          "atPeriodEnd": {
            "description": "False (the default) ends it now. True lets the period that is paid for run out first.",
            "type": "boolean",
            "default": false
          },
          "feedback": {
            "description": "Why, in Stripe's words: customer_service, low_quality, missing_features, other, switched_service, too_complex, too_expensive or unused.",
            "type": "string",
            "enum": [
              "customer_service",
              "low_quality",
              "missing_features",
              "other",
              "switched_service",
              "too_complex",
              "too_expensive",
              "unused"
            ]
          },
          "comment": {
            "description": "A comment on why, up to 500 characters.",
            "type": "string",
            "maxLength": 500
          }
        },
        "additionalProperties": false
      },
      "AdvanceTestClockRequest": {
        "type": "object",
        "properties": {
          "subscriptionId": {
            "description": "A sandbox subscription.",
            "type": "string",
            "pattern": "^sub_[0-9a-z]{20,32}$"
          },
          "seconds": {
            "description": "How far to move its clock forward: 60 seconds to a year.",
            "type": "integer",
            "minimum": 60,
            "maximum": 31622400
          }
        },
        "required": [
          "subscriptionId",
          "seconds"
        ],
        "additionalProperties": false
      }
    },
    "securitySchemes": {
      "secretKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "A secret key, sk_test_ or sk_live_, from the dashboard under Developers. Keep it on your server."
      },
      "publishableKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "A publishable key, pk_test_ or pk_live_. It may only create checkouts."
      }
    },
    "headers": {
      "x-trace-id": {
        "description": "This request's id in our logs. Quote it to support.",
        "schema": {
          "type": "string"
        }
      },
      "X-RateLimit-Limit": {
        "description": "Requests allowed per 60 seconds from your address to this endpoint.",
        "schema": {
          "type": "integer"
        }
      },
      "X-RateLimit-Remaining": {
        "description": "Requests left in the current window.",
        "schema": {
          "type": "integer"
        }
      },
      "X-RateLimit-Reset": {
        "description": "Seconds until the window resets.",
        "schema": {
          "type": "integer"
        }
      },
      "Retry-After": {
        "description": "Seconds to wait before trying again.",
        "schema": {
          "type": "integer"
        }
      },
      "Idempotent-Replayed": {
        "description": "true when this answer is the stored answer to an earlier request with the same Idempotency-Key.",
        "schema": {
          "type": "string",
          "enum": [
            "true"
          ]
        }
      }
    }
  },
  "x-rate-limit": {
    "limit": 120,
    "windowSeconds": 60,
    "scope": "Per client address, counted separately for each endpoint."
  },
  "x-webhook-delivery": {
    "method": "POST",
    "contentType": "application/json",
    "userAgent": "Payments.lk-Webhooks/1.0",
    "signatureHeader": "Payments-Signature",
    "eventIdHeader": "Payments-Event-Id",
    "signatureScheme": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" under the endpoint's signing secret>; while a rotated secret is kept, one v1 for each secret, the new one last",
    "toleranceSeconds": 300,
    "timeoutSeconds": 10,
    "retryAfterMinutes": [
      1,
      5,
      30,
      120,
      360,
      720
    ]
  }
}
