{
  "openapi": "3.1.0",
  "info": {
    "title": "Gully Pay API",
    "version": "1.0.0",
    "summary": "Checkout, subscriptions, refunds, x402 and agent payments.",
    "description": "Take payments with a hosted checkout, bill subscriptions, refund, and accept x402 and agent payments. JSON over HTTPS.\n\n**Keys.** Create a store key in the dashboard (Developers, API keys). Send it from your server as `x-api-key`, or as `Authorization: Bearer`. Keys start with `rk_live_` or `rk_test_`. Never put a key in a web page or an app: use a single-use checkout token there. Agent wallets use their own key (`agk_`).\n\n**Money.** Amounts are integers in the smallest currency unit: `4999` with `USD` is $49.99.\n\n**Limits.** Calls are limited per caller. The routes below state their own limit where they have one. Answers carry `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset`; over the limit the answer is HTTP 429 with `Retry-After`.\n\n**Errors.** `{ \"statusCode\", \"message\", \"error\" }`, plus a stable `code` where there is one. 400 bad input, 401 missing or unknown key, 403 the key may not do this, 404 not found (also for an id that is not a UUID), 409 already exists, 429 slow down.\n\n**Webhooks.** Gully Pay posts events to your endpoint, signed. Headers: `X-GullyPay-Attempt`, `X-GullyPay-Event`, `X-GullyPay-Event-Id`, `X-GullyPay-Signature`, `X-GullyPay-Timestamped-Signature`. The timestamped signature is `t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\">` with your endpoint's signing key; reject a `t` more than 5 minutes from your clock. Deliveries are retried: process each event id once.",
    "x-generated-by": "apps/api/scripts/gen-openapi.mjs"
  },
  "servers": [
    {
      "url": "https://gullypay.xyz/api",
      "description": "Gully Pay"
    }
  ],
  "tags": [
    {
      "name": "Agents"
    },
    {
      "name": "Checkout"
    },
    {
      "name": "Payment links"
    },
    {
      "name": "Refunds"
    },
    {
      "name": "Public data"
    },
    {
      "name": "Subscriptions"
    },
    {
      "name": "x402"
    }
  ],
  "paths": {
    "/agents/config": {
      "get": {
        "operationId": "getAgentConfig",
        "tags": [
          "Agents"
        ],
        "summary": "Agent payment settings",
        "description": "Networks, assets and limits that apply to agent wallets.",
        "security": [],
        "parameters": [],
        "responses": {
          "200": {
            "description": "The settings.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/agents/v1/checkout/{sessionId}/pay": {
      "post": {
        "operationId": "agentPayCheckout",
        "tags": [
          "Agents"
        ],
        "summary": "Pay a checkout session",
        "description": "Pays a hosted checkout session from the agent wallet, inside its limits.\n\nLimit: 60 calls per minute.",
        "security": [
          {
            "agentKeyBearer": []
          },
          {
            "agentKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "sessionId",
            "in": "path",
            "required": true,
            "description": "Checkout session id (UUID).",
            "schema": {
              "type": "string"
            },
            "example": "3f2b8c1e-9a4d-4e7b-8c21-0d5e6f7a8b9c"
          }
        ],
        "x-rate-limit": {
          "calls": 60,
          "seconds": 60
        },
        "responses": {
          "200": {
            "description": "The result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/agents/v1/me": {
      "get": {
        "operationId": "getAgent",
        "tags": [
          "Agents"
        ],
        "summary": "The calling agent",
        "description": "The agent the key belongs to, its wallet and its spending limits.",
        "security": [
          {
            "agentKeyBearer": []
          },
          {
            "agentKeyHeader": []
          }
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "The agent.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/agents/v1/payments/{paymentId}/settle": {
      "post": {
        "operationId": "settleAgentPayment",
        "tags": [
          "Agents"
        ],
        "summary": "Settle a pending agent payment",
        "description": "Checks the payment on chain and marks it settled.",
        "security": [
          {
            "agentKeyBearer": []
          },
          {
            "agentKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "paymentId",
            "in": "path",
            "required": true,
            "description": "Payment id (UUID).",
            "schema": {
              "type": "string"
            },
            "example": "d41f0c2a-6b7e-4f80-9a1b-2c3d4e5f6a7b"
          }
        ],
        "responses": {
          "200": {
            "description": "The result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/agents/v1/prepare": {
      "post": {
        "operationId": "prepareAgentPayment",
        "tags": [
          "Agents"
        ],
        "summary": "Prepare a payment",
        "description": "Builds the payment for the agent wallet to sign: an x402 payment or a checkout session.\n\nLimit: 120 calls per minute.",
        "security": [
          {
            "agentKeyBearer": []
          },
          {
            "agentKeyHeader": []
          }
        ],
        "parameters": [],
        "x-rate-limit": {
          "calls": 120,
          "seconds": 60
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AgentPrepare"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "What to sign.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/agents/v1/submit": {
      "post": {
        "operationId": "submitAgentPayment",
        "tags": [
          "Agents"
        ],
        "summary": "Submit a signed payment",
        "description": "Sends the signed payment prepared before.",
        "security": [
          {
            "agentKeyBearer": []
          },
          {
            "agentKeyHeader": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AgentSubmit"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/agents/v1/x402/pay": {
      "post": {
        "operationId": "agentPayX402",
        "tags": [
          "Agents"
        ],
        "summary": "Pay an x402 resource",
        "description": "Pays for a resource from the agent wallet, inside its limits.\n\nLimit: 120 calls per minute.",
        "security": [
          {
            "agentKeyBearer": []
          },
          {
            "agentKeyHeader": []
          }
        ],
        "parameters": [],
        "x-rate-limit": {
          "calls": 120,
          "seconds": 60
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AgentPayX402"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The receipt.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/checkout/{sessionId}": {
      "get": {
        "operationId": "getCheckoutSession",
        "tags": [
          "Checkout"
        ],
        "summary": "Read a checkout session",
        "description": "What the hosted page shows: amount, currency, state and the ways to pay. The session id is unguessable; no key is needed.",
        "security": [],
        "parameters": [
          {
            "name": "sessionId",
            "in": "path",
            "required": true,
            "description": "Checkout session id (UUID).",
            "schema": {
              "type": "string"
            },
            "example": "3f2b8c1e-9a4d-4e7b-8c21-0d5e6f7a8b9c"
          }
        ],
        "responses": {
          "200": {
            "description": "The session.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/checkout/{sessionId}/crypto/status": {
      "get": {
        "operationId": "getCheckoutCryptoStatus",
        "tags": [
          "Checkout"
        ],
        "summary": "Read the on-chain payment state of a session",
        "description": "Whether a stablecoin payment for the session has been seen and confirmed.",
        "security": [],
        "parameters": [
          {
            "name": "sessionId",
            "in": "path",
            "required": true,
            "description": "Checkout session id (UUID).",
            "schema": {
              "type": "string"
            },
            "example": "3f2b8c1e-9a4d-4e7b-8c21-0d5e6f7a8b9c"
          }
        ],
        "responses": {
          "200": {
            "description": "The state.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/checkout/demo": {
      "get": {
        "operationId": "getDemoCheckout",
        "tags": [
          "Checkout"
        ],
        "summary": "A demo session",
        "description": "A fixed test-mode session for trying the checkout page. It never moves money.\n\nLimit: 60 calls per minute.",
        "security": [],
        "parameters": [],
        "x-rate-limit": {
          "calls": 60,
          "seconds": 60
        },
        "responses": {
          "200": {
            "description": "The demo session.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/checkout/hosted/{storeId}": {
      "post": {
        "operationId": "createCheckoutSession",
        "tags": [
          "Checkout"
        ],
        "summary": "Create a hosted checkout session",
        "description": "Creates a payment page for an amount in the smallest currency unit (4999 = $49.99). Send your store key from your server, or a single-use checkout token from a page. Redirect the buyer to `checkoutUrl` and fulfil the order on the `checkout.session.completed` webhook.\n\nLimit: 30 calls per minute.",
        "security": [
          {
            "storeKeyHeader": []
          },
          {
            "storeKeyBearer": []
          },
          {
            "checkoutToken": []
          }
        ],
        "parameters": [
          {
            "name": "storeId",
            "in": "path",
            "required": true,
            "description": "Your store id (UUID), from the dashboard.",
            "schema": {
              "type": "string"
            },
            "example": "8a1d2c3b-4e5f-4a6b-8c7d-9e0f1a2b3c4d"
          }
        ],
        "x-rate-limit": {
          "calls": 30,
          "seconds": 60
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateHostedCheckout"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The session.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                },
                "example": {
                  "sessionId": "3f2b8c1e-9a4d-4e7b-8c21-0d5e6f7a8b9c",
                  "checkoutUrl": "https://gullypay.xyz/checkout/3f2b8c1e-9a4d-4e7b-8c21-0d5e6f7a8b9c",
                  "expiresAt": "2026-11-23T12:29:58.000Z"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/checkout/tokens/{storeId}": {
      "post": {
        "operationId": "createCheckoutToken",
        "tags": [
          "Checkout"
        ],
        "summary": "Mint a single-use checkout token",
        "description": "A short-lived token (60 to 900 seconds) that lets a page create one session without holding your key. A token that pins an amount and currency can only create a session for exactly those.\n\nLimit: 60 calls per minute.",
        "security": [
          {
            "storeKeyHeader": []
          },
          {
            "storeKeyBearer": []
          }
        ],
        "parameters": [
          {
            "name": "storeId",
            "in": "path",
            "required": true,
            "description": "Your store id (UUID), from the dashboard.",
            "schema": {
              "type": "string"
            },
            "example": "8a1d2c3b-4e5f-4a6b-8c7d-9e0f1a2b3c4d"
          }
        ],
        "x-rate-limit": {
          "calls": 60,
          "seconds": 60
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MintCheckoutToken"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                },
                "example": {
                  "token": "ct_EXAMPLE",
                  "expiresAt": "2026-11-23T12:05:00.000Z",
                  "storeId": "8a1d2c3b-4e5f-4a6b-8c7d-9e0f1a2b3c4d"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/payment-links/{slug}": {
      "get": {
        "operationId": "getPaymentLink",
        "tags": [
          "Payment links"
        ],
        "summary": "Read a payment link",
        "description": "Title, amount and state of a payment link.\n\nLimit: 60 calls per minute.",
        "security": [],
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Public slug.",
            "schema": {
              "type": "string"
            },
            "example": "my-store"
          }
        ],
        "x-rate-limit": {
          "calls": 60,
          "seconds": 60
        },
        "responses": {
          "200": {
            "description": "The link.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/payment-links/{slug}/checkout": {
      "post": {
        "operationId": "checkoutPaymentLink",
        "tags": [
          "Payment links"
        ],
        "summary": "Start a checkout from a payment link",
        "description": "Creates a checkout session for the link and returns where to send the buyer.\n\nLimit: 10 calls per minute.",
        "security": [],
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Public slug.",
            "schema": {
              "type": "string"
            },
            "example": "my-store"
          }
        ],
        "x-rate-limit": {
          "calls": 10,
          "seconds": 60
        },
        "responses": {
          "201": {
            "description": "The session.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/payments/{id}/refund": {
      "post": {
        "operationId": "refundPayment",
        "tags": [
          "Refunds"
        ],
        "summary": "Refund a payment",
        "description": "Full refund, or partial with `amount` in the smallest currency unit. Needs a store key with the `refunds:write` scope; a key can only refund payments of its own store.\n\nLimit: 30 calls per minute.",
        "security": [
          {
            "storeKeyHeader": []
          },
          {
            "storeKeyBearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Id (UUID).",
            "schema": {
              "type": "string"
            },
            "example": "d41f0c2a-6b7e-4f80-9a1b-2c3d4e5f6a7b"
          }
        ],
        "x-rate-limit": {
          "calls": 30,
          "seconds": 60
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RefundPayment"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The refund.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/public/stats": {
      "get": {
        "operationId": "getPublicStats",
        "tags": [
          "Public data"
        ],
        "summary": "Gully Pay in numbers",
        "description": "Totals shown on the Gully Pay site. USD.\n\nLimit: 120 calls per minute.",
        "security": [],
        "parameters": [
          {
            "name": "days",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "x-rate-limit": {
          "calls": 120,
          "seconds": 60
        },
        "responses": {
          "200": {
            "description": "The totals.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/public/stores/{slug}": {
      "get": {
        "operationId": "getStore",
        "tags": [
          "Public data"
        ],
        "summary": "A public store",
        "description": "Name, description and branding of a storefront.",
        "security": [],
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Public slug.",
            "schema": {
              "type": "string"
            },
            "example": "my-store"
          }
        ],
        "responses": {
          "200": {
            "description": "The store.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/public/stores/{slug}/products": {
      "get": {
        "operationId": "listStoreProducts",
        "tags": [
          "Public data"
        ],
        "summary": "Products of a public store",
        "description": "The live catalog with prices.",
        "security": [],
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Public slug.",
            "schema": {
              "type": "string"
            },
            "example": "my-store"
          }
        ],
        "responses": {
          "200": {
            "description": "The products.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/status": {
      "get": {
        "operationId": "getStatus",
        "tags": [
          "Public data"
        ],
        "summary": "Service status",
        "description": "Component states shown on the status page.",
        "security": [],
        "parameters": [],
        "responses": {
          "200": {
            "description": "The states.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/subscriptions/{storeId}": {
      "post": {
        "operationId": "createSubscription",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Start a subscription",
        "description": "Starts a plan subscription for your customer (`reference` is your own id for them). Each period is paid through its pay link; you hear about it on the `subscription.*` webhooks.\n\nLimit: 30 calls per minute.",
        "security": [
          {
            "storeKeyHeader": []
          },
          {
            "storeKeyBearer": []
          }
        ],
        "parameters": [
          {
            "name": "storeId",
            "in": "path",
            "required": true,
            "description": "Your store id (UUID), from the dashboard.",
            "schema": {
              "type": "string"
            },
            "example": "8a1d2c3b-4e5f-4a6b-8c7d-9e0f1a2b3c4d"
          }
        ],
        "x-rate-limit": {
          "calls": 30,
          "seconds": 60
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreatePlanSubscription"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The subscription.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/subscriptions/{storeId}/{id}": {
      "get": {
        "operationId": "getSubscription",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Read a subscription",
        "description": "State, current period and pay link.",
        "security": [
          {
            "storeKeyHeader": []
          },
          {
            "storeKeyBearer": []
          }
        ],
        "parameters": [
          {
            "name": "storeId",
            "in": "path",
            "required": true,
            "description": "Your store id (UUID), from the dashboard.",
            "schema": {
              "type": "string"
            },
            "example": "8a1d2c3b-4e5f-4a6b-8c7d-9e0f1a2b3c4d"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Id (UUID).",
            "schema": {
              "type": "string"
            },
            "example": "d41f0c2a-6b7e-4f80-9a1b-2c3d4e5f6a7b"
          }
        ],
        "responses": {
          "200": {
            "description": "The subscription.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/subscriptions/{storeId}/{id}/cancel": {
      "post": {
        "operationId": "cancelSubscription",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Cancel a subscription",
        "description": "Ends the subscription now or at the end of the paid period.",
        "security": [
          {
            "storeKeyHeader": []
          },
          {
            "storeKeyBearer": []
          }
        ],
        "parameters": [
          {
            "name": "storeId",
            "in": "path",
            "required": true,
            "description": "Your store id (UUID), from the dashboard.",
            "schema": {
              "type": "string"
            },
            "example": "8a1d2c3b-4e5f-4a6b-8c7d-9e0f1a2b3c4d"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Id (UUID).",
            "schema": {
              "type": "string"
            },
            "example": "d41f0c2a-6b7e-4f80-9a1b-2c3d4e5f6a7b"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CancelPlanSubscription"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The subscription.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/subscriptions/plans": {
      "get": {
        "operationId": "listSubscriptionPlans",
        "tags": [
          "Subscriptions"
        ],
        "summary": "List subscription plans",
        "description": "The plans that can be subscribed to, with their USD price and period.\n\nLimit: 60 calls per minute.",
        "security": [],
        "parameters": [],
        "x-rate-limit": {
          "calls": 60,
          "seconds": 60
        },
        "responses": {
          "200": {
            "description": "The plans.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/x402/pay": {
      "post": {
        "operationId": "submitX402Payment",
        "tags": [
          "x402"
        ],
        "summary": "Submit an x402 payment",
        "description": "Reports the on-chain payment for a resource. It is checked on chain and a receipt is issued.",
        "security": [
          {
            "storeKeyHeader": []
          },
          {
            "storeKeyBearer": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/X402Pay"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The receipt.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/x402/refund": {
      "post": {
        "operationId": "refundX402Payment",
        "tags": [
          "x402"
        ],
        "summary": "Refund an x402 payment",
        "description": "Starts a refund of an x402 payment.",
        "security": [
          {
            "storeKeyHeader": []
          },
          {
            "storeKeyBearer": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/X402Refund"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The refund.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/x402/requirements/{resource}": {
      "get": {
        "operationId": "getX402Requirements",
        "tags": [
          "x402"
        ],
        "summary": "Payment requirements of a resource",
        "description": "What a client must pay to access the resource, in the x402 shape.",
        "security": [],
        "parameters": [
          {
            "name": "resource",
            "in": "path",
            "required": true,
            "description": "Resource id.",
            "schema": {
              "type": "string"
            },
            "example": "article-42"
          }
        ],
        "responses": {
          "200": {
            "description": "The requirements.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/x402/status": {
      "get": {
        "operationId": "getX402Status",
        "tags": [
          "x402"
        ],
        "summary": "x402 settings",
        "description": "Networks and assets x402 payments are accepted on.",
        "security": [],
        "parameters": [],
        "responses": {
          "200": {
            "description": "The settings.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/x402/verify": {
      "post": {
        "operationId": "verifyX402Receipt",
        "tags": [
          "x402"
        ],
        "summary": "Verify an x402 receipt",
        "description": "Checks a receipt token your server received from a client.",
        "security": [
          {
            "storeKeyHeader": []
          },
          {
            "storeKeyBearer": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/X402Verify"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Whether the receipt holds, and for what.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    }
  },
  "webhooks": {
    "checkout.session.completed": {
      "post": {
        "operationId": "on_checkout_session_completed",
        "tags": [
          "Webhooks"
        ],
        "summary": "checkout.session.completed",
        "description": "A hosted checkout session was paid (card confirmed by Stripe, or crypto verified on-chain). Fulfil orders on this.",
        "parameters": [
          {
            "name": "X-GullyPay-Attempt",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Timestamped-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Answer with any 2xx within 10 seconds to acknowledge."
          }
        }
      }
    },
    "checkout.session.expired": {
      "post": {
        "operationId": "on_checkout_session_expired",
        "tags": [
          "Webhooks"
        ],
        "summary": "checkout.session.expired",
        "description": "A hosted checkout session passed its 30-minute window unpaid",
        "parameters": [
          {
            "name": "X-GullyPay-Attempt",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Timestamped-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Answer with any 2xx within 10 seconds to acknowledge."
          }
        }
      }
    },
    "checkout.session.payment_failed": {
      "post": {
        "operationId": "on_checkout_session_payment_failed",
        "tags": [
          "Webhooks"
        ],
        "summary": "checkout.session.payment_failed",
        "description": "Stripe reported a failed card attempt for a session (the session stays open)",
        "parameters": [
          {
            "name": "X-GullyPay-Attempt",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Timestamped-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Answer with any 2xx within 10 seconds to acknowledge."
          }
        }
      }
    },
    "payment.succeeded": {
      "post": {
        "operationId": "on_payment_succeeded",
        "tags": [
          "Webhooks"
        ],
        "summary": "payment.succeeded",
        "description": "A card payment succeeded (Stripe)",
        "parameters": [
          {
            "name": "X-GullyPay-Attempt",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Timestamped-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Answer with any 2xx within 10 seconds to acknowledge."
          }
        }
      }
    },
    "payment.failed": {
      "post": {
        "operationId": "on_payment_failed",
        "tags": [
          "Webhooks"
        ],
        "summary": "payment.failed",
        "description": "A card payment failed (Stripe)",
        "parameters": [
          {
            "name": "X-GullyPay-Attempt",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Timestamped-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Answer with any 2xx within 10 seconds to acknowledge."
          }
        }
      }
    },
    "payment.refunded": {
      "post": {
        "operationId": "on_payment_refunded",
        "tags": [
          "Webhooks"
        ],
        "summary": "payment.refunded",
        "description": "A payment was fully or partially refunded",
        "parameters": [
          {
            "name": "X-GullyPay-Attempt",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Timestamped-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Answer with any 2xx within 10 seconds to acknowledge."
          }
        }
      }
    },
    "order.fulfilled": {
      "post": {
        "operationId": "on_order_fulfilled",
        "tags": [
          "Webhooks"
        ],
        "summary": "order.fulfilled",
        "description": "An order was marked as fulfilled",
        "parameters": [
          {
            "name": "X-GullyPay-Attempt",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Timestamped-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Answer with any 2xx within 10 seconds to acknowledge."
          }
        }
      }
    },
    "order.cancelled": {
      "post": {
        "operationId": "on_order_cancelled",
        "tags": [
          "Webhooks"
        ],
        "summary": "order.cancelled",
        "description": "An order was cancelled",
        "parameters": [
          {
            "name": "X-GullyPay-Attempt",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Timestamped-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Answer with any 2xx within 10 seconds to acknowledge."
          }
        }
      }
    },
    "x402.payment.received": {
      "post": {
        "operationId": "on_x402_payment_received",
        "tags": [
          "Webhooks"
        ],
        "summary": "x402.payment.received",
        "description": "An x402 payment was verified on-chain and a receipt issued",
        "parameters": [
          {
            "name": "X-GullyPay-Attempt",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Timestamped-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Answer with any 2xx within 10 seconds to acknowledge."
          }
        }
      }
    },
    "payout.paid": {
      "post": {
        "operationId": "on_payout_paid",
        "tags": [
          "Webhooks"
        ],
        "summary": "payout.paid",
        "description": "A payout was completed",
        "parameters": [
          {
            "name": "X-GullyPay-Attempt",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Timestamped-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Answer with any 2xx within 10 seconds to acknowledge."
          }
        }
      }
    },
    "payout.failed": {
      "post": {
        "operationId": "on_payout_failed",
        "tags": [
          "Webhooks"
        ],
        "summary": "payout.failed",
        "description": "A payout failed",
        "parameters": [
          {
            "name": "X-GullyPay-Attempt",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Timestamped-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Answer with any 2xx within 10 seconds to acknowledge."
          }
        }
      }
    },
    "settlement.settled": {
      "post": {
        "operationId": "on_settlement_settled",
        "tags": [
          "Webhooks"
        ],
        "summary": "settlement.settled",
        "description": "Settle on Gully Chain: a balance collected elsewhere arrived as USDC.e in your Gully Chain account (`data.object` carries source, destination, route, tx hash and fee lines)",
        "parameters": [
          {
            "name": "X-GullyPay-Attempt",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Timestamped-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Answer with any 2xx within 10 seconds to acknowledge."
          }
        }
      }
    },
    "settlement.held": {
      "post": {
        "operationId": "on_settlement_held",
        "tags": [
          "Webhooks"
        ],
        "summary": "settlement.held",
        "description": "Settle on Gully Chain: a settlement needs attention (route unavailable, cap reached, bridge late); `data.object.reason` says why",
        "parameters": [
          {
            "name": "X-GullyPay-Attempt",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Timestamped-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Answer with any 2xx within 10 seconds to acknowledge."
          }
        }
      }
    },
    "subscription.created": {
      "post": {
        "operationId": "on_subscription_created",
        "tags": [
          "Webhooks"
        ],
        "summary": "subscription.created",
        "description": "A plan subscription started (its free trial, when the plan has one)",
        "parameters": [
          {
            "name": "X-GullyPay-Attempt",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Timestamped-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Answer with any 2xx within 10 seconds to acknowledge."
          }
        }
      }
    },
    "subscription.payment_due": {
      "post": {
        "operationId": "on_subscription_payment_due",
        "tags": [
          "Webhooks"
        ],
        "summary": "subscription.payment_due",
        "description": "A subscription period ended: the next payment is due through its pay link",
        "parameters": [
          {
            "name": "X-GullyPay-Attempt",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Timestamped-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Answer with any 2xx within 10 seconds to acknowledge."
          }
        }
      }
    },
    "subscription.paid": {
      "post": {
        "operationId": "on_subscription_paid",
        "tags": [
          "Webhooks"
        ],
        "summary": "subscription.paid",
        "description": "The next period was paid; the subscription is active until `currentPeriodEnd`",
        "parameters": [
          {
            "name": "X-GullyPay-Attempt",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Timestamped-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Answer with any 2xx within 10 seconds to acknowledge."
          }
        }
      }
    },
    "subscription.cancelled": {
      "post": {
        "operationId": "on_subscription_cancelled",
        "tags": [
          "Webhooks"
        ],
        "summary": "subscription.cancelled",
        "description": "A subscription ended: cancelled by you, or unpaid when its grace period ran out",
        "parameters": [
          {
            "name": "X-GullyPay-Attempt",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Event-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-GullyPay-Timestamped-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Answer with any 2xx within 10 seconds to acknowledge."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "storeKeyHeader": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "Your store key."
      },
      "storeKeyBearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "Your store key."
      },
      "checkoutToken": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Checkout-Token",
        "description": "A single-use checkout token."
      },
      "agentKeyBearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "An agent key."
      },
      "agentKeyHeader": {
        "type": "apiKey",
        "in": "header",
        "name": "x-agent-key",
        "description": "An agent key."
      }
    },
    "responses": {
      "BadRequest": {
        "description": "A field is missing or malformed.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "statusCode": 400,
              "message": [
                "amount must not be less than 1"
              ],
              "error": "Bad Request"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Missing or unknown key.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "statusCode": 401,
              "message": "Unauthorized"
            }
          }
        }
      },
      "Forbidden": {
        "description": "The key may not do this (wrong store or missing scope).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "statusCode": 403,
              "message": "Forbidden"
            }
          }
        }
      },
      "NotFound": {
        "description": "Not found.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "statusCode": 404,
              "message": "Not found"
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "Over the limit.",
        "headers": {
          "Retry-After": {
            "description": "Seconds to wait.",
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "statusCode": 429,
              "message": "ThrottlerException: Too Many Requests"
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "statusCode",
          "message"
        ],
        "properties": {
          "statusCode": {
            "type": "integer"
          },
          "message": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            ]
          },
          "error": {
            "type": "string",
            "description": "Short name of the status, e.g. \"Bad Request\"."
          },
          "code": {
            "type": "string",
            "description": "A stable code, when the error has one."
          }
        }
      },
      "WebhookEvent": {
        "type": "object",
        "required": [
          "id",
          "type",
          "created",
          "data"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Event id. The same on every retry: use it to process an event once."
          },
          "type": {
            "type": "string",
            "enum": [
              "checkout.session.completed",
              "checkout.session.expired",
              "checkout.session.payment_failed",
              "payment.succeeded",
              "payment.failed",
              "payment.refunded",
              "order.fulfilled",
              "order.cancelled",
              "x402.payment.received",
              "payout.paid",
              "payout.failed",
              "settlement.settled",
              "settlement.held",
              "subscription.created",
              "subscription.payment_due",
              "subscription.paid",
              "subscription.cancelled"
            ]
          },
          "created": {
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "type": "object",
            "additionalProperties": true,
            "description": "For checkout.session.* and x402.payment.received: `{ object: {...} }`."
          }
        }
      },
      "AgentPrepare": {
        "type": "object",
        "required": [
          "kind"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "x402",
              "checkout"
            ]
          }
        }
      },
      "AgentSubmit": {
        "type": "object",
        "required": [
          "paymentId",
          "signature"
        ],
        "properties": {
          "paymentId": {
            "type": "string",
            "format": "uuid"
          },
          "signature": {
            "type": "string"
          }
        }
      },
      "AgentPayX402": {
        "type": "object",
        "required": [
          "resource"
        ],
        "properties": {
          "resource": {
            "type": "string",
            "maxLength": 2000
          }
        }
      },
      "CreateHostedCheckout": {
        "type": "object",
        "required": [
          "amount",
          "currency"
        ],
        "properties": {
          "amount": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100000000
          },
          "currency": {
            "type": "string"
          },
          "successUrl": {
            "type": "string",
            "format": "uri",
            "maxLength": 2048
          },
          "cancelUrl": {
            "type": "string",
            "format": "uri",
            "maxLength": 2048
          },
          "customerEmail": {
            "type": "string",
            "format": "email",
            "maxLength": 255
          },
          "clientReferenceId": {
            "type": "string",
            "maxLength": 200
          }
        }
      },
      "MintCheckoutToken": {
        "type": "object",
        "properties": {
          "amount": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100000000
          },
          "currency": {
            "type": "string"
          },
          "ttlSeconds": {
            "type": "integer",
            "minimum": 60,
            "maximum": 900
          },
          "clientReferenceId": {
            "type": "string",
            "maxLength": 200
          }
        }
      },
      "RefundPayment": {
        "type": "object",
        "properties": {
          "amount": {
            "type": "number",
            "minimum": 1
          },
          "reason": {
            "type": "string"
          }
        }
      },
      "CreatePlanSubscription": {
        "type": "object",
        "required": [
          "plan",
          "reference"
        ],
        "properties": {
          "plan": {
            "type": "string"
          },
          "reference": {
            "type": "string",
            "maxLength": 200,
            "minLength": 1
          },
          "customerEmail": {
            "type": "string",
            "format": "email",
            "maxLength": 255
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "CancelPlanSubscription": {
        "type": "object",
        "properties": {
          "reason": {
            "type": "string",
            "maxLength": 200
          }
        }
      },
      "X402Pay": {
        "type": "object",
        "required": [
          "resource",
          "txHash",
          "network",
          "amount",
          "payerAddress"
        ],
        "properties": {
          "resource": {
            "type": "string"
          },
          "txHash": {
            "type": "string"
          },
          "network": {
            "type": "string"
          },
          "amount": {
            "type": "string"
          },
          "payerAddress": {
            "type": "string"
          }
        }
      },
      "X402Refund": {
        "type": "object",
        "required": [
          "receiptToken"
        ],
        "properties": {
          "receiptToken": {
            "type": "string"
          },
          "reason": {
            "type": "string"
          }
        }
      },
      "X402Verify": {
        "type": "object",
        "required": [
          "receiptToken"
        ],
        "properties": {
          "receiptToken": {
            "type": "string"
          }
        }
      }
    }
  },
  "x-rate-limit": {
    "headers": [
      "X-RateLimit-Limit",
      "X-RateLimit-Remaining",
      "X-RateLimit-Reset",
      "Retry-After"
    ],
    "perOperation": [
      {
        "operationId": "agentPayCheckout",
        "calls": 60,
        "seconds": 60
      },
      {
        "operationId": "agentPayX402",
        "calls": 120,
        "seconds": 60
      },
      {
        "operationId": "checkoutPaymentLink",
        "calls": 10,
        "seconds": 60
      },
      {
        "operationId": "createCheckoutSession",
        "calls": 30,
        "seconds": 60
      },
      {
        "operationId": "createCheckoutToken",
        "calls": 60,
        "seconds": 60
      },
      {
        "operationId": "createSubscription",
        "calls": 30,
        "seconds": 60
      },
      {
        "operationId": "getDemoCheckout",
        "calls": 60,
        "seconds": 60
      },
      {
        "operationId": "getPaymentLink",
        "calls": 60,
        "seconds": 60
      },
      {
        "operationId": "getPublicStats",
        "calls": 120,
        "seconds": 60
      },
      {
        "operationId": "listSubscriptionPlans",
        "calls": 60,
        "seconds": 60
      },
      {
        "operationId": "prepareAgentPayment",
        "calls": 120,
        "seconds": 60
      },
      {
        "operationId": "refundPayment",
        "calls": 30,
        "seconds": 60
      }
    ]
  },
  "x-errors": [
    {
      "code": "Bad Request",
      "http": 400,
      "meaning": "A field is missing or malformed. `message` lists what."
    },
    {
      "code": "Unauthorized",
      "http": 401,
      "meaning": "Missing or unknown key."
    },
    {
      "code": "Forbidden",
      "http": 403,
      "meaning": "The key may not do this."
    },
    {
      "code": "Not Found",
      "http": 404,
      "meaning": "No such record, or an id that is not a UUID."
    },
    {
      "code": "Conflict",
      "http": 409,
      "meaning": "Already exists."
    },
    {
      "code": "Too Many Requests",
      "http": 429,
      "meaning": "Over the limit. Wait `Retry-After` seconds."
    }
  ],
  "x-try-it": {
    "keyless": false,
    "operations": [],
    "note": "Payments need a store key, so the hub shows curl with a placeholder. Use a test key (rk_test_) while you build."
  }
}
