{
  "openapi": "3.1.0",
  "info": {
    "title": "Payments AI MoR Merchant Public API",
    "version": "1.0.0",
    "description": "Merchant Public API, platform onboarding, and buyer checkout endpoints. Authenticate every call with a Merchant API Key (pai_test_* / pai_live_*). The same key reaches its own merchant resources and those of any sub-merchant it has onboarded via POST /v1/public-api/merchants."
  },
  "servers": [
    {
      "url": "https://sandbox.mor.payments.ai/api",
      "description": "Sandbox API"
    }
  ],
  "paths": {
    "/v1/checkout/invoices/{invoiceId}": {
      "get": {
        "operationId": "PublicCheckout_getByInvoiceId",
        "description": "Find or create the payable order for an open or past_due invoice. Non-payable invoices, and invoices in a currency outside the supported ten or above the 100000 order limit, return 422 checkout.invoice_not_payable with details.status and no other invoice fields.",
        "parameters": [
          {
            "name": "invoiceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicCheckoutByInvoiceResponse"
                }
              }
            }
          },
          "422": {
            "description": "Client error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckoutInvoiceNotPayableResponse"
                }
              }
            }
          }
        },
        "summary": "Get by invoice id",
        "tags": ["Buyer checkout"]
      }
    },
    "/v1/checkout/merchants/{merchantId}/config": {
      "get": {
        "operationId": "PublicCheckout_getMerchantConfig",
        "description": "Merchant-level bootstrap for mounting payment fields without a plan. Returns no customer data and no purchase URL.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicCheckoutMerchantConfigResponse"
                }
              }
            }
          }
        },
        "summary": "Get buyer checkout merchant config",
        "tags": ["Buyer checkout"]
      }
    },
    "/v1/checkout/orders/{orderId}": {
      "get": {
        "operationId": "PublicCheckout_getByOrderId",
        "description": "Itemised order plus mount fields. Does not include a processor purchase URL.",
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicCheckoutOrderResponse"
                }
              }
            }
          }
        },
        "summary": "Get buyer checkout by order",
        "tags": ["Buyer checkout"]
      }
    },
    "/v1/checkout/orders/{orderId}/confirm": {
      "post": {
        "operationId": "PublicCheckout_confirmPaymentByOrderId",
        "description": "Charge an open order. Optional promoCode must be store-wide. Product-scoped codes are rejected the same way as unknown codes.",
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicCheckoutPaymentConfirmationResponse"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ConfirmPublicOrderPaymentRequest"
              }
            }
          }
        },
        "summary": "Confirm buyer checkout order",
        "tags": ["Buyer checkout"]
      }
    },
    "/v1/checkout/orders/{orderId}/policies/{policyType}": {
      "get": {
        "operationId": "PublicCheckout_redirectPolicyByOrderId",
        "description": "302 to a fresh presigned GET for a seller PDF policy. 404 otherwise. URL policies are returned in termsUrl, privacyUrl, returnPolicyUrl, and eulaUrl on the order read.",
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "policyType",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "302": {
            "description": "Redirection",
            "headers": {
              "location": {
                "required": true,
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "The server cannot find the requested resource."
          }
        },
        "summary": "Redirect buyer checkout order policy",
        "tags": ["Buyer checkout"]
      }
    },
    "/v1/checkout/orders/{orderId}/promo-code-preview": {
      "post": {
        "operationId": "PublicCheckout_previewPromoCodeByOrderId",
        "description": "Read-only store-wide promo quote for an open order. Does not create a processor promo and does not charge. Product-scoped codes return 400 checkout.promo_code_invalid.",
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PreviewPublicCheckoutPromoCodeResponse"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PreviewPublicCheckoutPromoCodeRequest"
              }
            }
          }
        },
        "summary": "Preview promo code by order id",
        "tags": ["Buyer checkout"]
      }
    },
    "/v1/checkout/orders/{orderId}/receipts/{receiptId}": {
      "get": {
        "operationId": "PublicCheckout_getReceiptByOrderId",
        "description": "Receipt lookup by payment reference. Prefer internal transaction UUID v7 in `receiptId`; legacy provider `pay_…` ids are deprecated until removal on 2027-01-15.",
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "receiptId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicCheckoutReceiptResponse"
                }
              }
            }
          }
        },
        "summary": "Get buyer checkout order receipt",
        "tags": ["Buyer checkout"]
      }
    },
    "/v1/checkout/orders/{orderId}/tax": {
      "post": {
        "operationId": "PublicCheckout_previewTaxByOrderId",
        "description": "Returns the tax for this open order and billing address, and the amount the buyer pays today. Does not charge the buyer. When tax cannot be calculated, the answer is HTTP 200 with calculated false: keep showing the price without tax. Tax is calculated in live only: in sandbox the answer is always calculated false with taxAmount 0.",
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicCheckoutTaxPreviewResponse"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PreviewPublicCheckoutTaxRequest"
              }
            }
          }
        },
        "summary": "Preview tax by order id",
        "tags": ["Buyer checkout"]
      }
    },
    "/v1/checkout/payment-method-sessions/{sessionId}": {
      "get": {
        "operationId": "PublicCheckout_getPaymentMethodSession",
        "description": "Read a payment method session by its id: the account to mount the payment elements for in setup mode, the status, and the client secret for the buyer's next action while `requires_action`, read from the payment provider. Reading never changes the session: only a confirmation moves it on. The embed polls every 2 seconds for the first minute, then doubles the interval up to 30 seconds, and stops at `succeeded`, `failed` or `expired`. 404 `payment_method_session.not_found` for an unknown id.",
        "parameters": [
          {
            "name": "sessionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicCheckoutPaymentMethodSessionResponse"
                }
              }
            }
          }
        },
        "summary": "Get payment method session",
        "tags": ["Buyer checkout"]
      }
    },
    "/v1/checkout/payment-method-sessions/{sessionId}/confirm": {
      "post": {
        "operationId": "PublicCheckout_confirmPaymentMethodSession",
        "description": "Save the card the buyer entered, without charging it. The first confirmation submits the card; a repeat reports how far saving it got and never saves a second card, so confirm again after `handleNextAction` or while `processing`. The answer is the session as the read returns it, with `paymentMethodId` once it has `succeeded`. 400 `checkout.confirmation_token_invalid` when the payment provider refuses the card details: the session stays `open`, so collect them again. 400 `checkout.return_url_forbidden` for a return URL off the merchant's hosts. 409 `payment_method_session.expired` when no card was submitted before `expiresAt`, or saving it had not finished 24 hours after the session was opened. 409 `payment_method_session.customer_not_linked` when the customer is no longer linked to a buyer at the payment provider. 502 `payment_method.provider_unavailable`: confirm again. 404 `payment_method_session.not_found` for an unknown id.",
        "parameters": [
          {
            "name": "sessionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicCheckoutPaymentMethodSessionResponse"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ConfirmPublicCheckoutPaymentMethodSessionRequest"
              }
            }
          }
        },
        "summary": "Confirm payment method session",
        "tags": ["Buyer checkout"]
      }
    },
    "/v1/checkout/plans/{planId}": {
      "get": {
        "operationId": "PublicCheckout_getByPlanId",
        "parameters": [
          {
            "name": "planId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicCheckoutByPlanResponse"
                }
              }
            }
          }
        },
        "summary": "Get buyer checkout by plan",
        "tags": ["Buyer checkout"]
      }
    },
    "/v1/checkout/plans/{planId}/confirm": {
      "post": {
        "operationId": "PublicCheckout_confirmPaymentByPlanId",
        "parameters": [
          {
            "name": "planId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicCheckoutPaymentConfirmationResponse"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ConfirmPublicCheckoutPaymentRequest"
              }
            }
          }
        },
        "summary": "Confirm payment by plan id",
        "tags": ["Buyer checkout"]
      }
    },
    "/v1/checkout/plans/{planId}/policies/{policyType}": {
      "get": {
        "operationId": "PublicCheckout_redirectPolicyByPlanId",
        "description": "302 to a fresh presigned GET for a seller PDF policy. 404 otherwise. URL policies are returned on the plan checkout read.",
        "parameters": [
          {
            "name": "planId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "policyType",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "302": {
            "description": "Redirection",
            "headers": {
              "location": {
                "required": true,
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "The server cannot find the requested resource."
          }
        },
        "summary": "Redirect policy by plan id",
        "tags": ["Buyer checkout"]
      }
    },
    "/v1/checkout/plans/{planId}/promo-code-preview": {
      "post": {
        "operationId": "PublicCheckout_previewPromoCodeByPlanId",
        "description": "Read-only promo quote for this plan. Does not create a processor promo and does not charge.",
        "parameters": [
          {
            "name": "planId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PreviewPublicCheckoutPromoCodeResponse"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PreviewPublicCheckoutPromoCodeRequest"
              }
            }
          }
        },
        "summary": "Preview promo code by plan id",
        "tags": ["Buyer checkout"]
      }
    },
    "/v1/checkout/plans/{planId}/promo-codes": {
      "post": {
        "operationId": "PublicCheckout_applyPromoCodeByPlanId",
        "description": "Validate a promo code for this plan and return the discounted quote. Does not charge. Deprecated alias of promo-code-preview.",
        "parameters": [
          {
            "name": "planId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApplyPublicCheckoutPromoCodeResponse"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApplyPublicCheckoutPromoCodeRequest"
              }
            }
          }
        },
        "deprecated": true,
        "summary": "Apply promo code by plan id",
        "tags": ["Buyer checkout"]
      }
    },
    "/v1/checkout/plans/{planId}/receipts/{receiptId}": {
      "get": {
        "operationId": "PublicCheckout_getReceiptByPlanId",
        "description": "Receipt lookup by payment reference. Prefer internal transaction UUID v7 in `receiptId`; legacy provider `pay_…` ids are deprecated until removal on 2027-01-15.",
        "parameters": [
          {
            "name": "planId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "receiptId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicCheckoutReceiptResponse"
                }
              }
            }
          }
        },
        "summary": "Get buyer checkout receipt",
        "tags": ["Buyer checkout"]
      }
    },
    "/v1/checkout/plans/{planId}/session": {
      "post": {
        "operationId": "PublicCheckout_createSessionByPlanId",
        "parameters": [
          {
            "name": "planId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicCheckoutSessionResponse"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreatePublicCheckoutSessionRequest"
              }
            }
          }
        },
        "summary": "Create buyer checkout session",
        "tags": ["Buyer checkout"]
      }
    },
    "/v1/checkout/plans/{planId}/tax": {
      "post": {
        "operationId": "PublicCheckout_previewTaxByPlanId",
        "description": "Returns the tax for this plan and billing address, and the amount the buyer pays today. Does not charge the buyer. Pass promoCode to scale tax to the discounted price. When tax cannot be calculated, the answer is HTTP 200 with calculated false: keep showing the price without tax. Tax is calculated in live only: in sandbox the answer is always calculated false with taxAmount 0.",
        "parameters": [
          {
            "name": "planId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicCheckoutTaxPreviewResponse"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PreviewPublicCheckoutTaxRequest"
              }
            }
          }
        },
        "summary": "Preview tax by plan id",
        "tags": ["Buyer checkout"]
      }
    },
    "/v1/public-api/me/merchants": {
      "get": {
        "operationId": "PublicApiOwnMerchants_list",
        "description": "Lists the merchants the signed-in user is an active member of, with the user's role on each. Auth: user OAuth credential with `merchant:read` · tenant none (the user's memberships) · no role · 401 `auth.invalid_token` · 403 `auth.insufficient_scope`, `auth.credential_type_forbidden`.",
        "parameters": [],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiOwnMerchantListResponse"
                }
              }
            }
          }
        },
        "tags": ["API"],
        "security": [
          {
            "UserOAuthCredentialAuth": []
          }
        ],
        "summary": "List merchants"
      },
      "post": {
        "operationId": "PublicApiOwnMerchants_create",
        "description": "Creates a top-level merchant on this environment with the signed-in user as Owner. Auth: user OAuth credential with `merchant:create` · tenant none · no role (the caller becomes Owner) · 401 `auth.invalid_token` · 403 `auth.insufficient_scope`, `auth.credential_type_forbidden` · 400 `invalid_request` no `email` and none on the user · 409 `merchant.create_conflict` when `merchantId` is reused with different details · 409 `merchant.limit_reached` when the user already owns 50 top-level merchants (idempotent replay of an existing owned `merchantId` still succeeds).",
        "parameters": [],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiCreateOwnMerchantResponse"
                }
              }
            }
          },
          "201": {
            "description": "The request has succeeded and a new resource has been created as a result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiCreateOwnMerchantResponse"
                }
              }
            }
          }
        },
        "tags": ["API"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicApiCreateOwnMerchantRequest"
              }
            }
          }
        },
        "security": [
          {
            "UserOAuthCredentialAuth": []
          }
        ],
        "summary": "Create merchant"
      }
    },
    "/v1/public-api/merchants": {
      "post": {
        "operationId": "PublicApiMerchants_create",
        "description": "Creates a sub-merchant parented to the calling key's own merchant. The parent is always derived from the Bearer key, never from the request body. A merchant that already has a parent cannot itself become a parent — calling this with a sub-merchant's own key returns 409 `merchant.hierarchy_depth_exceeded`.",
        "parameters": [],
        "responses": {
          "201": {
            "description": "The request has succeeded and a new resource has been created as a result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiCreateMerchantResponse"
                }
              }
            }
          }
        },
        "tags": ["Merchant"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicApiCreateMerchantRequest"
              }
            }
          }
        },
        "summary": "Create merchant"
      }
    },
    "/v1/public-api/merchants/{merchantId}": {
      "get": {
        "operationId": "PublicApiMerchants_get",
        "description": "Reads whether a merchant has an owner and how far it is through activation. `merchantId` must be your own merchant or a sub-merchant you created. Any other id returns 403, including one that does not exist, so a key cannot probe for merchant ids outside its scope. After you deliver a join URL, poll this route or subscribe to the `merchant.owner_attached` webhook instead of reminting the link. Auth: Merchant API key, or user OAuth credential with `merchant:read` · tenant `{merchantId}` · any team member · 401 `auth.invalid_token` · 403 `auth.insufficient_scope`, `merchant.access_forbidden`.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiGetMerchantResponse"
                }
              }
            }
          }
        },
        "tags": ["Merchant"],
        "security": [
          {
            "MerchantApiKeyAuth": []
          },
          {
            "UserOAuthCredentialAuth": []
          }
        ],
        "summary": "Get merchant"
      },
      "patch": {
        "operationId": "PublicApiMerchantWebsiteUrl_updateWebsiteUrl",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiUpdateMerchantWebsiteUrlResponse"
                }
              }
            }
          }
        },
        "tags": ["Merchant"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicApiUpdateMerchantWebsiteUrlRequest"
              }
            }
          }
        },
        "summary": "Update merchant website URL"
      }
    },
    "/v1/public-api/merchants/{merchantId}/api-keys": {
      "get": {
        "operationId": "PublicApiApiKeys_list",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PublicApiApiKeySummary"
                  }
                }
              }
            }
          }
        },
        "tags": ["API Keys"],
        "summary": "List API keys"
      },
      "post": {
        "operationId": "PublicApiApiKeys_create",
        "description": "Mint a key. Omitting `permissions` creates a key with none. A non-empty `permissions` returns 403 `api_key.permission_forbidden` and records `api_key_permission_grant_denied`.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "The request has succeeded and a new resource has been created as a result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiCreateApiKeyResponse"
                }
              }
            }
          },
          "403": {
            "description": "Access is forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        },
        "tags": ["API Keys"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicApiCreateApiKeyRequest"
              }
            }
          }
        },
        "summary": "Create API key"
      }
    },
    "/v1/public-api/merchants/{merchantId}/api-keys/{id}": {
      "delete": {
        "operationId": "PublicApiApiKeys_revoke",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "There is no content to send for this request, but the headers may be useful. "
          }
        },
        "tags": ["API Keys"],
        "summary": "Revoke API key"
      }
    },
    "/v1/public-api/merchants/{merchantId}/balances/summary": {
      "get": {
        "operationId": "PublicApiBalances_summary",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiBalanceSummaryResponse"
                }
              }
            }
          }
        },
        "tags": ["API"],
        "summary": "Summary balance"
      }
    },
    "/v1/public-api/merchants/{merchantId}/checkout/customization": {
      "get": {
        "operationId": "PublicApiCheckoutCustomizationApi_getCustomization",
        "description": "Auth: Merchant API key, or user OAuth credential with `checkout:read` · tenant `{merchantId}` · any team member · 401 `auth.invalid_token` · 403 `auth.insufficient_scope`, `merchant.access_forbidden`.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiCheckoutCustomizationResponse"
                }
              }
            }
          }
        },
        "tags": ["Checkout"],
        "security": [
          {
            "MerchantApiKeyAuth": []
          },
          {
            "UserOAuthCredentialAuth": []
          }
        ],
        "summary": "Get customization"
      },
      "patch": {
        "operationId": "PublicApiCheckoutCustomizationApi_updateCustomization",
        "description": "Auth: Merchant API key, or user OAuth credential with `checkout:write` · tenant `{merchantId}` · Owner, Admin, or Editor (user credential) · 401 `auth.invalid_token` · 403 `auth.insufficient_scope`, `merchant.access_forbidden`, `team.role_forbidden`.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiCheckoutCustomizationResponse"
                }
              }
            }
          }
        },
        "tags": ["Checkout"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicApiUpdateCheckoutCustomizationRequest"
              }
            }
          }
        },
        "security": [
          {
            "MerchantApiKeyAuth": []
          },
          {
            "UserOAuthCredentialAuth": []
          }
        ],
        "summary": "Update customization"
      }
    },
    "/v1/public-api/merchants/{merchantId}/checkout/logo/confirm": {
      "post": {
        "operationId": "PublicApiCheckoutCustomizationApi_confirmLogo",
        "description": "Step 2 of 2: confirm the uploaded logo and store it on the customization. The backend never fetches a client-supplied URL. Auth: Merchant API key, or user OAuth credential with `checkout:write` · tenant `{merchantId}` · Owner, Admin, or Editor (user credential) · 401 `auth.invalid_token` · 403 `auth.insufficient_scope`, `merchant.access_forbidden`, `team.role_forbidden`.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiConfirmCheckoutLogoResponse"
                }
              }
            }
          }
        },
        "tags": ["Checkout"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicApiConfirmCheckoutLogoRequest"
              }
            }
          }
        },
        "security": [
          {
            "MerchantApiKeyAuth": []
          },
          {
            "UserOAuthCredentialAuth": []
          }
        ],
        "summary": "Confirm logo"
      }
    },
    "/v1/public-api/merchants/{merchantId}/checkout/logo/upload-url": {
      "post": {
        "operationId": "PublicApiCheckoutCustomizationApi_createLogoUploadUrl",
        "description": "Step 1 of 2: mint a logo upload URL. Auth: Merchant API key, or user OAuth credential with `checkout:write` · tenant `{merchantId}` · Owner, Admin, or Editor (user credential) · 401 `auth.invalid_token` · 403 `auth.insufficient_scope`, `merchant.access_forbidden`, `team.role_forbidden`.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiCheckoutLogoUploadUrlResponse"
                }
              }
            }
          }
        },
        "tags": ["Checkout"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicApiCheckoutLogoUploadUrlRequest"
              }
            }
          }
        },
        "security": [
          {
            "MerchantApiKeyAuth": []
          },
          {
            "UserOAuthCredentialAuth": []
          }
        ],
        "summary": "Create logo upload url"
      }
    },
    "/v1/public-api/merchants/{merchantId}/checkout/plans/{planId}": {
      "get": {
        "operationId": "PublicApiCheckout_resolveByPlanId",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "planId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiCheckoutByPlanResponse"
                }
              }
            }
          }
        },
        "summary": "Get checkout by plan",
        "tags": ["Checkout"]
      }
    },
    "/v1/public-api/merchants/{merchantId}/checkout/plans/{planId}/confirm": {
      "post": {
        "operationId": "PublicApiCheckout_confirmPaymentByPlanId",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "planId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiCheckoutPaymentConfirmationResponse"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicApiConfirmCheckoutPaymentRequest"
              }
            }
          }
        },
        "summary": "Confirm payment by plan id",
        "tags": ["Checkout"]
      }
    },
    "/v1/public-api/merchants/{merchantId}/checkout/plans/{planId}/promo-code-preview": {
      "post": {
        "operationId": "PublicApiCheckout_previewPromoCodeByPlanId",
        "description": "Read-only promo quote for this plan. Same result as the deprecated promo-codes path.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "planId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiPreviewCheckoutPromoCodeResponse"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicApiPreviewCheckoutPromoCodeRequest"
              }
            }
          }
        },
        "summary": "Preview promo code by plan id",
        "tags": ["Checkout"]
      }
    },
    "/v1/public-api/merchants/{merchantId}/checkout/plans/{planId}/promo-codes": {
      "post": {
        "operationId": "PublicApiCheckout_applyPromoCodeByPlanId",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "planId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiApplyCheckoutPromoCodeResponse"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicApiApplyCheckoutPromoCodeRequest"
              }
            }
          }
        },
        "deprecated": true,
        "summary": "Apply promo code by plan id",
        "tags": ["Checkout"]
      }
    },
    "/v1/public-api/merchants/{merchantId}/checkout/plans/{planId}/receipts/{receiptId}": {
      "get": {
        "operationId": "PublicApiCheckout_getReceiptByPlanId",
        "description": "Receipt lookup by payment reference. Prefer internal transaction UUID v7 in `receiptId`; legacy provider `pay_…` ids are deprecated until removal on 2027-01-15.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "planId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "receiptId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiCheckoutReceiptResponse"
                }
              }
            }
          }
        },
        "summary": "Get checkout receipt",
        "tags": ["Checkout"]
      }
    },
    "/v1/public-api/merchants/{merchantId}/checkout/plans/{planId}/session": {
      "post": {
        "operationId": "PublicApiCheckout_createSessionByPlanId",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "planId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiCheckoutSessionResponse"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicApiCreateCheckoutSessionRequest"
              }
            }
          }
        },
        "summary": "Create checkout session",
        "tags": ["Checkout"]
      }
    },
    "/v1/public-api/merchants/{merchantId}/customers": {
      "get": {
        "operationId": "PublicApiCustomers_listCustomers",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "explode": false
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "explode": false
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "explode": false
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": {}
                }
              }
            }
          }
        },
        "summary": "List customers",
        "tags": ["Customers"]
      }
    },
    "/v1/public-api/merchants/{merchantId}/customers/{customerId}/payment-method-sessions": {
      "post": {
        "operationId": "PublicApiCustomers_createPaymentMethodSession",
        "description": "Open a setup-only session (no charge) to collect a new card for the customer in the checkout embed. Pass the session `id` to the embed. The session only saves the card: to make it a subscription's card, send the `paymentMethodId` of the `succeeded` session to POST `/v1/public-api/merchants/{merchantId}/subscriptions/{subscriptionId}/payment-method`. Nothing reaches the payment provider until the buyer submits a card. Each request opens a new session; an unused one expires after one hour. 404 when the customer does not exist or belongs to another merchant. 400 for any field in the body. 409 `payment_method_session.customer_email_required` when the customer has no email address: the payment provider files the card under the buyer its email resolves to. 409 `payment_method_session.customer_not_linked` when the payment provider has not linked the customer to a buyer yet, for example a customer who never paid: the saved card could not be listed for them. 400 when the merchant is not linked to the payment provider yet and cannot save cards. Recorded in the merchant's audit log with the API key as the actor. `merchantId` must be your own merchant or a sub-merchant you created; any other id returns 403.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "The request has succeeded and a new resource has been created as a result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiPaymentMethodSessionResponse"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicApiCreatePaymentMethodSessionRequest"
              }
            }
          }
        },
        "summary": "Create payment method session",
        "tags": ["Customers"]
      }
    },
    "/v1/public-api/merchants/{merchantId}/customers/{customerId}/payment-method-sessions/{sessionId}": {
      "get": {
        "operationId": "PublicApiCustomers_getPaymentMethodSession",
        "description": "Read a payment method session from your server, for example after the embed reports completion, to see its final `status`; once it has `succeeded`, `paymentMethodId` names the saved card, which is then among the customer's saved cards. Poll every 2 seconds for the first minute, then double the interval up to 30 seconds, and stop at `succeeded`, `failed` or `expired`. Reading never changes the session. 404 `payment_method_session.not_found` when it does not exist or was opened for another customer. `merchantId` must be your own merchant or a sub-merchant you created; any other id returns 403.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sessionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiPaymentMethodSessionResponse"
                }
              }
            }
          }
        },
        "summary": "Get payment method session",
        "tags": ["Customers"]
      }
    },
    "/v1/public-api/merchants/{merchantId}/customers/{customerId}/payment-methods": {
      "get": {
        "operationId": "PublicApiCustomers_listCustomerPaymentMethods",
        "description": "List the customer's saved cards, read from the payment provider: `id`, `brand`, `last4`, `expMonth`, `expYear` and `isDefault`. Never the card number or a provider secret. A customer who never paid has none. 404 when the customer does not exist, was erased, or belongs to another merchant. 502 `payment_method.provider_unavailable` when the payment provider cannot be read: retry. `merchantId` must be your own merchant or a sub-merchant you created; any other id returns 403.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiSavedPaymentMethodListResponse"
                }
              }
            }
          }
        },
        "summary": "List customer payment methods",
        "tags": ["Customers"]
      }
    },
    "/v1/public-api/merchants/{merchantId}/customers/{id}": {
      "get": {
        "operationId": "PublicApiCustomers_getCustomer",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": {}
                }
              }
            }
          }
        },
        "summary": "Get customer",
        "tags": ["Customers"]
      }
    },
    "/v1/public-api/merchants/{merchantId}/discount-codes": {
      "get": {
        "operationId": "PublicApiDiscountCodes_list",
        "description": "List the merchant's discount codes, archived ones included unless filtered out.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "Matches internal name or code.",
            "schema": {
              "type": "string"
            },
            "explode": false
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/PublicApiDiscountCodeStatus"
            },
            "explode": false
          },
          {
            "name": "promoType",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/PublicApiDiscountPromoType"
            },
            "explode": false
          },
          {
            "name": "billingPeriod",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/PublicApiDiscountBillingPeriod"
            },
            "explode": false
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "maximum": 100,
              "default": 20
            },
            "explode": false
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 1
            },
            "explode": false
          },
          {
            "name": "sortBy",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/PublicApiDiscountCodeSortField"
            },
            "explode": false
          },
          {
            "name": "sortOrder",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["asc", "desc"]
            },
            "explode": false
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiDiscountCodeListResponse"
                }
              }
            }
          }
        },
        "summary": "List codes",
        "tags": ["API"]
      },
      "post": {
        "operationId": "PublicApiDiscountCodes_create",
        "description": "Create a discount code and sync it to the payment provider. A code that already exists for the merchant returns 409. A repeat with the same Idempotency-Key returns the first code and does not compare the body.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "idempotency-key",
            "in": "header",
            "required": false,
            "description": "Optional. Maximum 255 characters.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "responses": {
          "201": {
            "description": "The request has succeeded and a new resource has been created as a result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiDiscountCode"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicApiCreateDiscountCodeRequest"
              }
            }
          }
        },
        "summary": "Create code",
        "tags": ["API"]
      }
    },
    "/v1/public-api/merchants/{merchantId}/discount-codes/{id}": {
      "get": {
        "operationId": "PublicApiDiscountCodes_getById",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiDiscountCode"
                }
              }
            }
          }
        },
        "summary": "Get code by id",
        "tags": ["API"]
      },
      "patch": {
        "operationId": "PublicApiDiscountCodes_update",
        "description": "Update a discount code. Archived codes return 409.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiDiscountCode"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicApiUpdateDiscountCodeRequest"
              }
            }
          }
        },
        "summary": "Update code",
        "tags": ["API"]
      }
    },
    "/v1/public-api/merchants/{merchantId}/discount-codes/{id}/archive": {
      "post": {
        "operationId": "PublicApiDiscountCodes_archive",
        "description": "Archive a discount code. It stays readable but can no longer be redeemed or updated. There is no delete.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiDiscountCode"
                }
              }
            }
          }
        },
        "summary": "Archive code",
        "tags": ["API"]
      }
    },
    "/v1/public-api/merchants/{merchantId}/invoices": {
      "get": {
        "operationId": "PublicApiInvoices_listInvoices",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "explode": false
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "explode": false
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "explode": false
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "explode": false
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": {}
                }
              }
            }
          }
        },
        "summary": "List invoices",
        "tags": ["Invoices"]
      }
    },
    "/v1/public-api/merchants/{merchantId}/invoices/{id}": {
      "get": {
        "operationId": "PublicApiInvoices_getInvoice",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": {}
                }
              }
            }
          }
        },
        "summary": "Get invoice",
        "tags": ["Invoices"]
      }
    },
    "/v1/public-api/merchants/{merchantId}/invoices/{id}/download": {
      "get": {
        "operationId": "PublicApiInvoices_downloadInvoice",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "headers": {
              "content-disposition": {
                "required": true,
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          }
        },
        "summary": "Download invoice",
        "tags": ["Invoices"]
      }
    },
    "/v1/public-api/merchants/{merchantId}/join-link": {
      "post": {
        "operationId": "PublicApiMerchantJoinLink_remint",
        "description": "Re-mint an owner-claim join URL for a sub-merchant with no owner attached yet. The caller's key must be allowed to access `merchantId` (your own key for a sub-merchant you created). Each call invalidates the previously issued link, so do not call it to check whether the seller claimed the merchant — read `ownerAttached` from `GET /v1/public-api/merchants/{merchantId}` instead. Returns 409 once an owner has been claimed.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "The request has succeeded and a new resource has been created as a result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiMerchantJoinLinkResponse"
                }
              }
            }
          }
        },
        "tags": ["API"],
        "summary": "Remint link"
      }
    },
    "/v1/public-api/merchants/{merchantId}/kyc": {
      "get": {
        "operationId": "PublicApiMerchants_getKyc",
        "description": "Reads identity verification (KYC) status for a merchant. `merchantId` must be your own merchant or a sub-merchant you created. Any other id returns 403, including one that does not exist. Subscribe to `merchant.kyc.updated` to learn about changes without polling. Auth: Merchant API key, or user OAuth credential with `merchant:read` · tenant `{merchantId}` · any team member · 401 `auth.invalid_token` · 403 `auth.insufficient_scope`, `merchant.access_forbidden`.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiGetMerchantKycResponse"
                }
              }
            }
          }
        },
        "tags": ["Merchant"],
        "security": [
          {
            "MerchantApiKeyAuth": []
          },
          {
            "UserOAuthCredentialAuth": []
          }
        ],
        "summary": "Get kyc"
      }
    },
    "/v1/public-api/merchants/{merchantId}/members": {
      "post": {
        "operationId": "PublicApiMerchantMembers_assign",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "The request has succeeded and a new resource has been created as a result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiAssignMerchantMemberResponse"
                }
              }
            }
          }
        },
        "tags": ["Merchant"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicApiAssignMerchantMemberRequest"
              }
            }
          }
        },
        "summary": "Assign member"
      }
    },
    "/v1/public-api/merchants/{merchantId}/orders": {
      "post": {
        "operationId": "PublicApiOrders_create",
        "description": "Create an immutable order. A repeat with the same Idempotency-Key returns the original order even when the body differs.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "idempotency-key",
            "in": "header",
            "required": false,
            "description": "Optional. Maximum 255 characters. A replay returns the original order and does not compare the body.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "responses": {
          "201": {
            "description": "The request has succeeded and a new resource has been created as a result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiOrderResponse"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicApiCreateOrderRequest"
              }
            }
          }
        },
        "summary": "Create order",
        "tags": ["Orders"]
      }
    },
    "/v1/public-api/merchants/{merchantId}/orders/{orderId}": {
      "get": {
        "operationId": "PublicApiOrders_getById",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiOrderResponse"
                }
              }
            }
          }
        },
        "summary": "Get order",
        "tags": ["Orders"]
      }
    },
    "/v1/public-api/merchants/{merchantId}/orders/{orderId}/confirm": {
      "post": {
        "operationId": "PublicApiOrders_confirmPayment",
        "description": "Pay an open order. With `paymentMethodId`, charge one of a customer's saved cards with no buyer present. The card is looked up within this merchant and checked live at the payment processor: another merchant's card, a card whose customer is not the order's buyer (an order with a customer email takes only a card of the customer with that email; an order without one takes the card customer's email), or a card the customer no longer holds, returns 404 `payment_method.not_found`, and a deleted customer returns 404 `customer.not_found`; nothing is charged. Once the processor takes the charge, the call returns 200 `{ paymentId, status: \"processing\" }` without waiting for its decision: the order is paid only once `payment.completed` with `orderId` arrives. A card the processor refuses after taking the charge sends `payment.failed` with `orderId` and `declineReason` and releases the order, so a confirm with a new Idempotency-Key can charge it again. A card that needs the buyer to authenticate (3-D Secure) charges nothing; send the buyer to the order's `checkoutUrl` or your embedded checkout. A recurring item starts a subscription (`subscription.created`) whose renewals are charged to the same card. 409 `order.requires_on_session_payment` when the card needs the buyer to authenticate: nothing is charged. 402 `order.payment_declined` with `details.declineReason` (`insufficient_funds`, `expired_card` or `card_declined`) when the card is refused right away: nothing is recorded on the order; a card refused later sends `payment.failed` instead. 422 `order.payment_refused` when the processor refuses the charge request for another reason: nothing is charged and the order stays open. With `confirmationToken` and `returnUrl`, confirm a token the buyer's payment fields minted, as the hosted checkout does; 400 `checkout.confirmation_token_invalid` when it is unknown or expired. 409 `order.payment_in_flight` while another payment of the order is in progress, including a saved-card charge the processor has not decided; a saved-card charge that has held the order for more than 15 minutes is first sent to the processor again under its own key by any other confirm of the order, which goes on if it was declined; one that has held it for 24 hours is never sent again, not even by a repeat with its own Idempotency-Key: the processor is asked for the payment it made, and the order is released when there is none from 10 minutes after those 24 hours on (a repeat with the charge's own key then returns 502 `checkout.provider_unavailable` saying nothing was charged, and repeating it once more charges the card anew); a processor that cannot be asked, has still not decided the charge, or lists no payment within those 10 minutes, is not asked again for 10 minutes. 429 `order.payment_attempts_exceeded` when 5 saved-card charges of the order were declined in the last 24 hours, or 10 of the card in the last hour, counting its charges in progress on other orders: nothing is sent to the processor; send the buyer to the order's checkout or try again later. 409 `order.not_open` once it is paid or expired. 502 `payment_method.provider_unavailable` or `checkout.provider_unavailable` when the processor cannot be reached or has not taken the charge yet: retry with the same Idempotency-Key, which never charges twice. Recorded in the merchant's audit log with the API key as the actor. 404 `order.not_found` when the order does not exist or belongs to another merchant. `merchantId` must be your own merchant or a sub-merchant you created; any other id returns 403. A user OAuth credential is refused.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "idempotency-key",
            "in": "header",
            "required": false,
            "description": "Optional. At most 255 characters; the order id when omitted. A repeat with the same key and card returns the first answer and never charges twice, even after the order is paid; while the processor has not decided the charge, it picks that charge up with the card it started with and answers what the processor decided by then. A promo code is compared without letter case or surrounding spaces. The same key with another card, or with another promo code while the charge is undecided, returns 409 `idempotency.key_reused`.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiConfirmOrderPaymentResponse"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicApiConfirmOrderPaymentRequest"
              }
            }
          }
        },
        "summary": "Confirm payment",
        "tags": ["Orders"]
      }
    },
    "/v1/public-api/merchants/{merchantId}/payouts": {
      "post": {
        "operationId": "PublicApiPayouts_requestPayout",
        "description": "Request a payout of available funds to a saved payout method. Requires `Idempotency-Key`; retries with the same key and body return the original `withdrawalId`. The key must have been granted the `payouts:write` permission from the dashboard, otherwise the request returns 403. Only the key's own merchant may request a payout: a parent merchant's key gets 403 for a sub-merchant.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "idempotency-key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "The request has succeeded and a new resource has been created as a result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiRequestPayoutResponse"
                }
              }
            }
          }
        },
        "tags": ["API"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicApiRequestPayoutBody"
              }
            }
          }
        },
        "summary": "Request payout"
      }
    },
    "/v1/public-api/merchants/{merchantId}/payouts/payout-methods": {
      "get": {
        "operationId": "PublicApiPayouts_listPayoutMethods",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiPayoutMethodsResponse"
                }
              }
            }
          }
        },
        "tags": ["API"],
        "summary": "List payout methods"
      }
    },
    "/v1/public-api/merchants/{merchantId}/products": {
      "get": {
        "operationId": "PublicApiProducts_list",
        "description": "Auth: Merchant API key, or user OAuth credential with `product:read` · tenant `{merchantId}` · any team member · 401 `auth.invalid_token` · 403 `auth.insufficient_scope`, `merchant.access_forbidden`.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "explode": false
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/ProductStatus"
            },
            "explode": false
          },
          {
            "name": "type",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/PlanType"
            },
            "explode": false
          },
          {
            "name": "dateRangeStart",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "explode": false
          },
          {
            "name": "dateRangeEnd",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "explode": false
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "explode": false
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "explode": false
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiProductListResponse"
                }
              }
            }
          }
        },
        "tags": ["Products"],
        "security": [
          {
            "MerchantApiKeyAuth": []
          },
          {
            "UserOAuthCredentialAuth": []
          }
        ],
        "summary": "List products"
      },
      "post": {
        "operationId": "PublicApiProducts_create",
        "description": "Auth: Merchant API key, or user OAuth credential with `product:create` · tenant `{merchantId}` · Owner, Admin, or Editor (user credential) · 401 `auth.invalid_token` · 403 `auth.insufficient_scope`, `merchant.access_forbidden`, `team.role_forbidden`. Send `Idempotency-Key` to make retries safe: the same key with the same body always returns the original product id, with no expiry once the product exists; the same key with a different body returns 409.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "The request has succeeded and a new resource has been created as a result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateProductResponse"
                }
              }
            }
          }
        },
        "tags": ["Products"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicApiCreateProduct"
              }
            }
          }
        },
        "security": [
          {
            "MerchantApiKeyAuth": []
          },
          {
            "UserOAuthCredentialAuth": []
          }
        ],
        "summary": "Create product"
      }
    },
    "/v1/public-api/merchants/{merchantId}/products/{id}": {
      "get": {
        "operationId": "PublicApiProducts_getById",
        "description": "Auth: Merchant API key, or user OAuth credential with `product:read` · tenant `{merchantId}` · any team member · 401 `auth.invalid_token` · 403 `auth.insufficient_scope`, `merchant.access_forbidden`.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiProduct"
                }
              }
            }
          }
        },
        "tags": ["Products"],
        "security": [
          {
            "MerchantApiKeyAuth": []
          },
          {
            "UserOAuthCredentialAuth": []
          }
        ],
        "summary": "Get product"
      },
      "patch": {
        "operationId": "PublicApiProducts_update",
        "description": "Partial update; omitted fields keep their stored value. Auth: Merchant API key, or user OAuth credential with `product:create` · tenant `{merchantId}` · Owner, Admin, or Editor (user credential) · 401 `auth.invalid_token` · 403 `auth.insufficient_scope`, `merchant.access_forbidden`, `team.role_forbidden`.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiProduct"
                }
              }
            }
          }
        },
        "tags": ["Products"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicApiUpdateProductRequest"
              }
            }
          }
        },
        "security": [
          {
            "MerchantApiKeyAuth": []
          },
          {
            "UserOAuthCredentialAuth": []
          }
        ],
        "summary": "Update product"
      }
    },
    "/v1/public-api/merchants/{merchantId}/products/{id}/image/confirm": {
      "post": {
        "operationId": "PublicApiProducts_confirmImage",
        "description": "Step 2 of 2: confirm the uploaded object and link it to the product. The backend never fetches a client-supplied URL. Auth: Merchant API key, or user OAuth credential with `product:create` · tenant `{merchantId}` · Owner, Admin, or Editor (user credential) · 401 `auth.invalid_token` · 403 `auth.insufficient_scope`, `merchant.access_forbidden`, `team.role_forbidden`.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiConfirmProductImageResponse"
                }
              }
            }
          }
        },
        "tags": ["Products"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicApiConfirmProductImageRequest"
              }
            }
          }
        },
        "security": [
          {
            "MerchantApiKeyAuth": []
          },
          {
            "UserOAuthCredentialAuth": []
          }
        ],
        "summary": "Confirm image"
      }
    },
    "/v1/public-api/merchants/{merchantId}/products/{id}/image/upload-url": {
      "post": {
        "operationId": "PublicApiProducts_createImageUploadUrl",
        "description": "Step 1 of 2: mint an upload policy for the product image. Auth: Merchant API key, or user OAuth credential with `product:create` · tenant `{merchantId}` · Owner, Admin, or Editor (user credential) · 401 `auth.invalid_token` · 403 `auth.insufficient_scope`, `merchant.access_forbidden`, `team.role_forbidden`.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiProductImageUploadUrlResponse"
                }
              }
            }
          }
        },
        "tags": ["Products"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicApiProductImageUploadUrlRequest"
              }
            }
          }
        },
        "security": [
          {
            "MerchantApiKeyAuth": []
          },
          {
            "UserOAuthCredentialAuth": []
          }
        ],
        "summary": "Create image upload url"
      }
    },
    "/v1/public-api/merchants/{merchantId}/products/{id}/plans": {
      "get": {
        "operationId": "PublicApiProducts_listPlans",
        "description": "Auth: Merchant API key, or user OAuth credential with `product:read` · tenant `{merchantId}` · any team member · 401 `auth.invalid_token` · 403 `auth.insufficient_scope`, `merchant.access_forbidden`.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PublicApiPlan"
                  }
                }
              }
            }
          }
        },
        "tags": ["Products"],
        "security": [
          {
            "MerchantApiKeyAuth": []
          },
          {
            "UserOAuthCredentialAuth": []
          }
        ],
        "summary": "List plans"
      },
      "post": {
        "operationId": "PublicApiProducts_createPlan",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "The request has succeeded and a new resource has been created as a result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiPlan"
                }
              }
            }
          }
        },
        "tags": ["Products"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreatePlan"
              }
            }
          }
        },
        "summary": "Create plan"
      }
    },
    "/v1/public-api/merchants/{merchantId}/products/{id}/plans/{planId}": {
      "patch": {
        "operationId": "PublicApiProducts_updatePlan",
        "description": "Partial update of one plan; omitted fields keep their stored value. Auth: Merchant API key, or user OAuth credential with `product:create` · tenant `{merchantId}` · Owner, Admin, or Editor (user credential) · 401 `auth.invalid_token` · 403 `auth.insufficient_scope`, `merchant.access_forbidden`, `team.role_forbidden`.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "planId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiPlan"
                }
              }
            }
          }
        },
        "tags": ["Products"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicApiUpdatePlanRequest"
              }
            }
          }
        },
        "security": [
          {
            "MerchantApiKeyAuth": []
          },
          {
            "UserOAuthCredentialAuth": []
          }
        ],
        "summary": "Update plan"
      }
    },
    "/v1/public-api/merchants/{merchantId}/settings/tax": {
      "get": {
        "operationId": "PublicApiMerchantTaxSettingsApi_get",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiMerchantTaxSettings"
                }
              }
            }
          }
        },
        "tags": ["API"],
        "summary": "Get api"
      },
      "patch": {
        "operationId": "PublicApiMerchantTaxSettingsApi_update",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiMerchantTaxSettings"
                }
              }
            }
          }
        },
        "tags": ["API"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicApiMerchantTaxSettingsPatch"
              }
            }
          }
        },
        "summary": "Update api"
      }
    },
    "/v1/public-api/merchants/{merchantId}/sub-merchants": {
      "get": {
        "operationId": "PublicApiMerchants_listSubMerchants",
        "description": "Lists the active sub-merchants of `merchantId`, newest first, including those attached outside `POST /v1/public-api/merchants`. Each item includes `merchantId`, `parentMerchantId`, `name`, and `createdAt`. A sub-merchant id returns an empty list. `merchantId` must be your own merchant or a sub-merchant you created; any other id returns 403. Auth: Merchant API key, or user OAuth credential with `merchant:read` · tenant `{merchantId}` · any team member · 400 `limit` above 100 · 401 `auth.invalid_token` · 403 `auth.insufficient_scope`, `merchant.access_forbidden`.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 1
            },
            "explode": false
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "At most 100.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 20
            },
            "explode": false
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiSubMerchantListResponse"
                }
              }
            }
          }
        },
        "tags": ["Merchant"],
        "security": [
          {
            "MerchantApiKeyAuth": []
          },
          {
            "UserOAuthCredentialAuth": []
          }
        ],
        "summary": "List sub merchants"
      }
    },
    "/v1/public-api/merchants/{merchantId}/subscriptions": {
      "get": {
        "operationId": "PublicApiSubscriptions_listSubscriptions",
        "description": "List the merchant's subscriptions, newest first. Unknown query parameters, including camelCase spellings of the filters, are rejected with 400. `merchantId` must be your own merchant or a sub-merchant you created; any other id returns 403.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 1
            },
            "explode": false
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "At most 200.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 20
            },
            "explode": false
          },
          {
            "name": "customer_id",
            "in": "query",
            "required": false,
            "description": "Return only this customer's subscriptions.",
            "schema": {
              "type": "string"
            },
            "explode": false
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/PublicApiSubscriptionStatus"
            },
            "explode": false
          },
          {
            "name": "order_id",
            "in": "query",
            "required": false,
            "description": "Return only the subscriptions started by this order.",
            "schema": {
              "type": "string"
            },
            "explode": false
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiSubscriptionListResponse"
                }
              }
            }
          }
        },
        "summary": "List subscriptions",
        "tags": ["Subscriptions"]
      }
    },
    "/v1/public-api/merchants/{merchantId}/subscriptions/{subscriptionId}": {
      "get": {
        "operationId": "PublicApiSubscriptions_getSubscription",
        "description": "Read one subscription. 404 `subscription.not_found` when it does not exist or belongs to another merchant. `merchantId` must be your own merchant or a sub-merchant you created; any other id returns 403.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "subscriptionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiSubscriptionResponse"
                }
              }
            }
          }
        },
        "summary": "Get subscription",
        "tags": ["Subscriptions"]
      },
      "patch": {
        "operationId": "PublicApiSubscriptions_changeSubscriptionDates",
        "description": "Move a trial end or the next renewal charge later and return the subscription. Dates only move later: the date must be in the future and after the current `trialEndsAt` or `nextChargeAt`. A date the current one already reaches, equal to it or less than 24 hours before it, returns the subscription unchanged and sends nothing. Idempotent by nature: it sets a target date, so repeating a request returns 200 with the subscription and changes nothing again. The payment provider moves a subscription by whole days of 24 hours, so the stored date is the first whole day after the current one that reaches the requested date, at the current time of day, and can be up to a day later than requested; the response and the webhook carry the stored date. `currentPeriodEnd` moves with it. A date can be at most 1095 days (three years) from now, so repeated changes cannot push it further, and at most 1095 days past the current period end in one change. Sends `subscription.updated` with the new dates; the provider's own notification of the change sends nothing more. The subscription is changed only once the payment provider confirms it. No proration or charge is made for the moved dates. 400 `subscription.date_in_past` for a date that is not in the future. 400 `subscription.date_not_later` for a date 24 hours or more before the current one. 400 `subscription.date_too_far` for a date more than 1095 days from now or past the current period end. 400 when `trialEndsAt` and `nextChargeAt` differ. 409 `subscription.not_trialing` for `trialEndsAt` on a subscription that is not trialing. 409 `subscription.cancellation_pending` when a cancellation is pending: undo it first. 409 `subscription.already_ended` when the subscription has ended. 409 `subscription.no_upcoming_charge` when no renewal is scheduled. 409 `subscription.change_refused` when the subscription changed at the provider, for example its trial converted or it ended. 502 `subscription.provider_unavailable` when the outcome is unknown: retry, which never moves the date twice. 404 `subscription.not_found` when it does not exist or belongs to another merchant. `merchantId` must be your own merchant or a sub-merchant you created; any other id returns 403.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "subscriptionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiSubscriptionResponse"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicApiChangeSubscriptionDatesRequest"
              }
            }
          }
        },
        "summary": "Change subscription dates",
        "tags": ["Subscriptions"]
      }
    },
    "/v1/public-api/merchants/{merchantId}/subscriptions/{subscriptionId}/cancel": {
      "post": {
        "operationId": "PublicApiSubscriptions_cancelSubscription",
        "description": "Cancel a subscription and return it. `immediately` ends access now: the status becomes `inactive` and `subscription.cancelled` then `subscription.updated` are sent. Cancelling immediately does not refund or credit the unused part of the current period. To give money back, refund the payment separately. `at_period_end` keeps access until `currentPeriodEnd`: the status becomes `canceling`, `cancelAtPeriodEnd` becomes `true`, and `subscription.cancellation_scheduled` then `subscription.updated` are sent. The subscription is changed only once the payment provider confirms it. Idempotent by nature: it sets a target state, so repeating a request returns 200 with the subscription and sends no second event; every request except `immediately` on an ended subscription is confirmed with the payment provider, so the subscription returned holds the provider's state, and `subscription.updated` is sent if that differs from the stored one. 409 `subscription.already_ended` for `at_period_end` on an ended subscription. 409 `subscription.change_refused` when the subscription cannot be cancelled this way, for example a buy-now-pay-later or split-pay subscription, or `at_period_end` on one that has already ended at the provider. A cancellation the provider already holds is returned as confirmed, not refused. 502 `subscription.provider_unavailable` when the outcome is unknown: the change may still apply, so retry, which is safe whether or not it applied, and read the subscription or wait for its webhooks for the final state. 404 `subscription.not_found` when it does not exist or belongs to another merchant. `merchantId` must be your own merchant or a sub-merchant you created; any other id returns 403.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "subscriptionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiSubscriptionResponse"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicApiCancelSubscriptionRequest"
              }
            }
          }
        },
        "summary": "Cancel subscription",
        "tags": ["Subscriptions"]
      }
    },
    "/v1/public-api/merchants/{merchantId}/subscriptions/{subscriptionId}/payment-method": {
      "post": {
        "operationId": "PublicApiSubscriptions_setSubscriptionPaymentMethod",
        "description": "Charge the subscription's renewals to one of its customer's saved cards and return the subscription. The payment provider also retries an open past-due payment on the card right away. The subscription is changed only once the payment provider confirms it. Sends `subscription.payment_method_updated` with `subscriptionId`, `customerId`, `paymentMethodId`, `brand` and `last4`; the provider's own notification of the change sends nothing more. Idempotent by nature: it sets a target card, so setting the card the subscription already has, including a repeat, returns 200, sets it at the payment provider again and sends no webhook. The card then reads `isDefault: true` in the customer's saved cards. 404 `payment_method.not_found` when the card is not one of the subscription customer's saved cards, or the payment provider no longer lists it. 400 when `paymentMethodId` is missing or is not a saved card `id`. 409 `subscription.already_ended` when the subscription has ended. 409 `subscription.change_refused` when the payment provider will not charge this subscription to the card, for example a buy-now-pay-later or split-pay subscription. 502 `subscription.provider_unavailable` when the outcome is unknown: retrying is safe. 502 `payment_method.provider_unavailable` when the saved cards could not be read: nothing changed, retry. Recorded in the merchant's audit log with the API key as the actor. 404 `subscription.not_found` when it does not exist or belongs to another merchant. `merchantId` must be your own merchant or a sub-merchant you created; any other id returns 403.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "subscriptionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiSubscriptionResponse"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicApiSetSubscriptionPaymentMethodRequest"
              }
            }
          }
        },
        "summary": "Set subscription payment method",
        "tags": ["Subscriptions"]
      }
    },
    "/v1/public-api/merchants/{merchantId}/subscriptions/{subscriptionId}/undo-cancel": {
      "post": {
        "operationId": "PublicApiSubscriptions_undoSubscriptionCancellation",
        "description": "Withdraw a pending cancellation and return the subscription. `cancelAtPeriodEnd` becomes `false`, the subscription renews at `currentPeriodEnd` again, and `subscription.cancellation_undone` then `subscription.updated` are sent. The subscription is changed only once the payment provider confirms it. Idempotent by nature: it sets a target state, so on a subscription without a pending cancellation, including a repeat, it returns 200 with the subscription and sends no `subscription.cancellation_undone`; every request is confirmed with the payment provider, so the subscription returned holds the provider's state, and `subscription.updated` is sent if that differs from the stored one. 409 `subscription.already_ended` when the subscription has ended. 409 `subscription.change_refused` when the provider will not withdraw it. 502 `subscription.provider_unavailable` when the outcome is unknown: the change may still apply, so retry, which is safe whether or not it applied, and read the subscription or wait for its webhooks for the final state. 404 `subscription.not_found` when it does not exist or belongs to another merchant. `merchantId` must be your own merchant or a sub-merchant you created; any other id returns 403.",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "subscriptionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiSubscriptionResponse"
                }
              }
            }
          }
        },
        "summary": "Undo subscription cancellation",
        "tags": ["Subscriptions"]
      }
    },
    "/v1/public-api/merchants/{merchantId}/transactions": {
      "post": {
        "operationId": "PublicApiTransactions_createTransaction",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "idempotency-key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "The request has succeeded and a new resource has been created as a result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiCheckoutPaymentConfirmationResponse"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicApiCreateTransactionRequest"
              }
            }
          }
        },
        "summary": "Create transaction",
        "tags": ["Transactions"]
      },
      "get": {
        "operationId": "PublicApiTransactions_listTransactions",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "explode": false
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "explode": false
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "explode": false
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "explode": false
          },
          {
            "name": "created_after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "explode": false
          },
          {
            "name": "order_id",
            "in": "query",
            "required": false,
            "description": "Return only the payments for this order id.",
            "schema": {
              "type": "string"
            },
            "explode": false
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiTransactionListResponse"
                }
              }
            }
          }
        },
        "summary": "List transactions",
        "tags": ["Transactions"]
      }
    },
    "/v1/public-api/merchants/{merchantId}/transactions/{id}": {
      "get": {
        "operationId": "PublicApiTransactions_getTransaction",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiTransactionDetailResponse"
                }
              }
            }
          }
        },
        "summary": "Get transaction",
        "tags": ["Transactions"]
      }
    },
    "/v1/public-api/merchants/{merchantId}/webhook-listen-sessions": {
      "post": {
        "operationId": "PublicApiWebhookListen_createSession",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "The request has succeeded and a new resource has been created as a result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateWebhookListenSessionResponse"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateWebhookListenSessionRequest"
              }
            }
          }
        },
        "security": [
          {
            "UserOAuthCredentialAuth": []
          }
        ],
        "summary": "Create session",
        "tags": ["API"]
      },
      "get": {
        "operationId": "PublicApiWebhookListen_listSessions",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookListenSessionListResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "UserOAuthCredentialAuth": []
          }
        ],
        "summary": "List sessions",
        "tags": ["API"]
      }
    },
    "/v1/public-api/merchants/{merchantId}/webhook-listen-sessions/resend": {
      "post": {
        "operationId": "PublicApiWebhookListen_resendEvent",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookListenDispatchResponse"
                }
              }
            }
          },
          "400": {
            "description": "The server could not understand the request due to invalid syntax.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "The server cannot find the requested resource.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "409": {
            "description": "The request conflicts with the current state of the server.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ResendWebhookListenEventRequest"
              }
            }
          }
        },
        "security": [
          {
            "UserOAuthCredentialAuth": []
          }
        ],
        "summary": "Resend event",
        "tags": ["API"]
      }
    },
    "/v1/public-api/merchants/{merchantId}/webhook-listen-sessions/trigger": {
      "post": {
        "operationId": "PublicApiWebhookListen_triggerEvent",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookListenDispatchResponse"
                }
              }
            }
          },
          "400": {
            "description": "The server could not understand the request due to invalid syntax.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "409": {
            "description": "The request conflicts with the current state of the server.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TriggerWebhookListenEventRequest"
              }
            }
          }
        },
        "security": [
          {
            "UserOAuthCredentialAuth": []
          }
        ],
        "summary": "Trigger event",
        "tags": ["API"]
      }
    },
    "/v1/public-api/merchants/{merchantId}/webhook-listen-sessions/{sessionId}": {
      "delete": {
        "operationId": "PublicApiWebhookListen_deleteSession",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sessionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "There is no content to send for this request, but the headers may be useful. "
          }
        },
        "security": [
          {
            "UserOAuthCredentialAuth": []
          }
        ],
        "summary": "Delete session",
        "tags": ["API"]
      }
    },
    "/v1/public-api/merchants/{merchantId}/webhook-listen-sessions/{sessionId}/deliveries/{deliveryId}/result": {
      "post": {
        "operationId": "PublicApiWebhookListen_reportResult",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sessionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "deliveryId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "There is no content to send for this request, but the headers may be useful. "
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReportWebhookListenResultRequest"
              }
            }
          }
        },
        "security": [
          {
            "UserOAuthCredentialAuth": []
          }
        ],
        "summary": "Report result",
        "tags": ["API"]
      }
    },
    "/v1/public-api/merchants/{merchantId}/webhook-listen-sessions/{sessionId}/stream": {
      "get": {
        "operationId": "PublicApiWebhookListen_streamSession",
        "parameters": [
          {
            "name": "merchantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sessionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Last-Event-ID",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "There is no content to send for this request, but the headers may be useful. "
          }
        },
        "security": [
          {
            "UserOAuthCredentialAuth": []
          }
        ],
        "summary": "Stream session",
        "tags": ["API"]
      }
    }
  },
  "components": {
    "schemas": {
      "PublicCheckoutByInvoiceResponse": {
        "type": "object",
        "required": [
          "orderId",
          "checkoutUrl",
          "currency",
          "amountDue",
          "recurringAmount",
          "billingPeriod",
          "periodLength",
          "trialPeriodDays",
          "items",
          "merchantId",
          "paymentMethodTypes",
          "customization",
          "websiteUrl",
          "termsUrl",
          "privacyUrl",
          "returnPolicyUrl",
          "eulaUrl",
          "externalInvoiceNumber",
          "dueAt",
          "status"
        ],
        "properties": {
          "orderId": {
            "type": "string"
          },
          "checkoutUrl": {
            "type": "string"
          },
          "currency": {
            "$ref": "#/components/schemas/SharedTypes.CurrencyCode"
          },
          "amountDue": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ],
            "description": "Amount the buyer owes today, before tax."
          },
          "recurringAmount": {
            "type": "number",
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ],
            "nullable": true,
            "description": "Later renewal total. Null when the order has no recurring item."
          },
          "billingPeriod": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PublicOrderBillingPeriod"
              }
            ],
            "nullable": true
          },
          "periodLength": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "trialPeriodDays": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicOrderItemResponse"
            }
          },
          "merchantId": {
            "type": "string"
          },
          "externalMerchantId": {
            "type": "string",
            "description": "Account id used to mount payment fields. Omitted when the merchant is not linked."
          },
          "externalPlanId": {
            "type": "string",
            "description": "Plan the trial starts on when amountDue is zero (e.g. trial-only orders). Payment fields then mount in setup mode to save the card, and confirm starts the trial on this plan. Present only while the order is open with nothing due today and the plan is linked."
          },
          "paymentMethodTypes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Enabled payment method types for this merchant. Empty when none are enabled."
          },
          "customization": {
            "$ref": "#/components/schemas/CheckoutCustomization"
          },
          "websiteUrl": {
            "type": "string",
            "nullable": true,
            "description": "Merchant store URL from business settings (`merchants.url`). Null when not configured."
          },
          "termsUrl": {
            "type": "string",
            "nullable": true,
            "description": "Seller Terms URL or stable API redirect for a PDF. Null when unset."
          },
          "privacyUrl": {
            "type": "string",
            "nullable": true,
            "description": "Seller Privacy URL or stable API redirect for a PDF. Null when unset."
          },
          "returnPolicyUrl": {
            "type": "string",
            "nullable": true,
            "description": "Seller Return policy URL or stable API redirect for a PDF. Null when unset."
          },
          "eulaUrl": {
            "type": "string",
            "nullable": true,
            "description": "Seller EULA URL or stable API redirect for a PDF. Null when unset."
          },
          "discount": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PublicCheckoutDiscount"
              }
            ],
            "description": "Stored store-wide discount. Present after confirm saved a code. Omitted when none is applied."
          },
          "externalInvoiceNumber": {
            "type": "string",
            "nullable": true
          },
          "dueAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "status": {
            "type": "string"
          }
        },
        "description": "Keyless invoice checkout. The order read plus the invoice number, due date, and status."
      },
      "CheckoutInvoiceNotPayableResponse": {
        "type": "object",
        "required": ["code", "message", "details"],
        "properties": {
          "code": {
            "type": "string",
            "enum": ["checkout.invoice_not_payable"],
            "description": "Always `checkout.invoice_not_payable`."
          },
          "message": {
            "type": "string"
          },
          "details": {
            "$ref": "#/components/schemas/CheckoutInvoiceNotPayableDetails"
          }
        },
        "description": "The invoice cannot be paid on this page."
      },
      "PublicCheckoutMerchantConfigResponse": {
        "type": "object",
        "required": ["paymentMethodTypes", "customization"],
        "properties": {
          "externalMerchantId": {
            "type": "string",
            "description": "Account id used to mount payment fields. Omitted when the merchant is not linked."
          },
          "paymentMethodTypes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Enabled payment method types for this merchant. Empty when none are enabled."
          },
          "customization": {
            "$ref": "#/components/schemas/CheckoutCustomization"
          },
          "websiteUrl": {
            "type": "string",
            "nullable": true,
            "description": "Merchant store URL from business settings (`merchants.url`). Null when not configured."
          }
        }
      },
      "PublicCheckoutOrderResponse": {
        "type": "object",
        "required": [
          "orderId",
          "checkoutUrl",
          "currency",
          "amountDue",
          "recurringAmount",
          "billingPeriod",
          "periodLength",
          "trialPeriodDays",
          "items",
          "merchantId",
          "paymentMethodTypes",
          "customization",
          "websiteUrl",
          "termsUrl",
          "privacyUrl",
          "returnPolicyUrl",
          "eulaUrl"
        ],
        "properties": {
          "orderId": {
            "type": "string"
          },
          "checkoutUrl": {
            "type": "string"
          },
          "currency": {
            "$ref": "#/components/schemas/SharedTypes.CurrencyCode"
          },
          "amountDue": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ],
            "description": "Amount the buyer owes today, before tax."
          },
          "recurringAmount": {
            "type": "number",
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ],
            "nullable": true,
            "description": "Later renewal total. Null when the order has no recurring item."
          },
          "billingPeriod": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PublicOrderBillingPeriod"
              }
            ],
            "nullable": true
          },
          "periodLength": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "trialPeriodDays": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicOrderItemResponse"
            }
          },
          "merchantId": {
            "type": "string"
          },
          "externalMerchantId": {
            "type": "string",
            "description": "Account id used to mount payment fields. Omitted when the merchant is not linked."
          },
          "externalPlanId": {
            "type": "string",
            "description": "Plan the trial starts on when amountDue is zero (e.g. trial-only orders). Payment fields then mount in setup mode to save the card, and confirm starts the trial on this plan. Present only while the order is open with nothing due today and the plan is linked."
          },
          "paymentMethodTypes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Enabled payment method types for this merchant. Empty when none are enabled."
          },
          "customization": {
            "$ref": "#/components/schemas/CheckoutCustomization"
          },
          "websiteUrl": {
            "type": "string",
            "nullable": true,
            "description": "Merchant store URL from business settings (`merchants.url`). Null when not configured."
          },
          "termsUrl": {
            "type": "string",
            "nullable": true,
            "description": "Seller Terms URL or stable API redirect for a PDF. Null when unset."
          },
          "privacyUrl": {
            "type": "string",
            "nullable": true,
            "description": "Seller Privacy URL or stable API redirect for a PDF. Null when unset."
          },
          "returnPolicyUrl": {
            "type": "string",
            "nullable": true,
            "description": "Seller Return policy URL or stable API redirect for a PDF. Null when unset."
          },
          "eulaUrl": {
            "type": "string",
            "nullable": true,
            "description": "Seller EULA URL or stable API redirect for a PDF. Null when unset."
          },
          "discount": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PublicCheckoutDiscount"
              }
            ],
            "description": "Stored store-wide discount. Present after confirm saved a code. Omitted when none is applied."
          }
        },
        "description": "Keyless order read. Order fields plus what the buyer page needs to mount payment."
      },
      "PublicCheckoutPaymentConfirmationResponse": {
        "type": "object",
        "required": ["paymentId", "clientSecret", "status"],
        "properties": {
          "transactionId": {
            "type": "string",
            "description": "Internal PAI transaction id (UUID v7) when the payment row exists in Payments AI."
          },
          "paymentId": {
            "type": "string",
            "description": "Deprecated payment provider id (`pay_…`). Removed on 2027-01-15.",
            "deprecated": true
          },
          "clientSecret": {
            "type": "string",
            "description": "Credential for `handleNextAction()` on the client."
          },
          "status": {
            "type": "string",
            "description": "Payment status immediately after create (processing may continue asynchronously)."
          }
        }
      },
      "ConfirmPublicOrderPaymentRequest": {
        "type": "object",
        "required": ["confirmationToken", "returnUrl"],
        "properties": {
          "confirmationToken": {
            "type": "string",
            "description": "Payment token (`ctok_…`) from the client SDK."
          },
          "returnUrl": {
            "type": "string",
            "description": "Return URL for off-site buyer steps (3DS, bank redirect). Must match the page that calls `handleNextAction`."
          },
          "promoCode": {
            "type": "string",
            "description": "Optional store-wide promo code. Product-scoped codes are rejected."
          }
        }
      },
      "PreviewPublicCheckoutPromoCodeResponse": {
        "type": "object",
        "required": [
          "code",
          "promoType",
          "amountOff",
          "discountAmount",
          "subtotal",
          "total",
          "renewalTotal",
          "currency",
          "billingPeriod",
          "billingPeriodLength",
          "billingPeriodUnit"
        ],
        "properties": {
          "code": {
            "type": "string",
            "description": "Normalized (uppercased) code that was applied."
          },
          "promoType": {
            "type": "string",
            "description": "percentage | flat_amount"
          },
          "amountOff": {
            "type": "string",
            "description": "Raw amount-off value from the discount definition (percent points or flat major units)."
          },
          "discountAmount": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ],
            "description": "Absolute discount applied to this plan amount, in major currency units."
          },
          "subtotal": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ],
            "description": "Price before the discount, before tax."
          },
          "total": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ],
            "description": "Amount after discount, before tax."
          },
          "renewalTotal": {
            "type": "number",
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ],
            "nullable": true,
            "description": "Later renewal after the discount. Null when there is no renewal. Unchanged when billingPeriod is once."
          },
          "currency": {
            "type": "string"
          },
          "billingPeriod": {
            "type": "string",
            "description": "once | repeating | forever — how long the promo applies after purchase."
          },
          "billingPeriodLength": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "billingPeriodUnit": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "PreviewPublicCheckoutPromoCodeRequest": {
        "type": "object",
        "required": ["code"],
        "properties": {
          "code": {
            "type": "string",
            "description": "Buyer-entered promo/discount code (case-insensitive; stored uppercased)."
          }
        }
      },
      "PublicCheckoutReceiptResponse": {
        "type": "object",
        "required": ["subtotal", "taxAmount", "total", "currency", "taxBehavior"],
        "properties": {
          "subtotal": {
            "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
          },
          "taxAmount": {
            "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
          },
          "total": {
            "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
          },
          "currency": {
            "type": "string"
          },
          "taxBehavior": {
            "type": "string",
            "enum": ["exclusive", "inclusive"],
            "description": "Whether tax is included in the listed amounts (`inclusive`) or added on top (`exclusive`)."
          },
          "discount": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PublicCheckoutDiscount"
              }
            ],
            "description": "Present on an order receipt when a store-wide code was applied. Omitted for plan receipts."
          }
        }
      },
      "PublicCheckoutTaxPreviewResponse": {
        "type": "object",
        "required": [
          "subtotal",
          "taxAmount",
          "total",
          "currency",
          "taxBehavior",
          "calculated",
          "renewal"
        ],
        "properties": {
          "subtotal": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ],
            "description": "Price before tax, in major units. 19.99 means $19.99. When taxBehavior is inclusive, this price already includes the tax."
          },
          "taxAmount": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ],
            "description": "Tax in major units. Show this only when calculated is true. Zero with calculated true means the buyer owes no tax. When calculated is false, this is 0 and is not a tax of zero: ignore it."
          },
          "total": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ],
            "description": "Amount the buyer pays today, in major units. Use this only when calculated is true."
          },
          "currency": {
            "type": "string",
            "description": "Three-letter currency code, lowercase, such as usd."
          },
          "taxBehavior": {
            "type": "string",
            "enum": ["exclusive", "inclusive"],
            "description": "exclusive: add taxAmount on top of subtotal. inclusive: subtotal already includes the tax, so do not add taxAmount again."
          },
          "calculated": {
            "type": "boolean",
            "description": "true when taxAmount and total are ready to show the buyer. false when tax is not known for this address: ignore taxAmount and total, and keep showing the price without tax. false is not a tax of zero."
          },
          "renewal": {
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/PublicCheckoutRenewalTaxPreview"
              }
            ],
            "nullable": true,
            "description": "Estimated tax on each renewal charge of a recurring plan, such as the first charge after a free trial. null when the plan does not renew or tax is not known for the renewal price. The renewal tax is calculated again at each charge."
          }
        }
      },
      "PreviewPublicCheckoutTaxRequest": {
        "type": "object",
        "required": ["address"],
        "properties": {
          "address": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PublicCheckoutTaxAddress"
              }
            ],
            "description": "Billing address to calculate tax for. At least country is required."
          },
          "taxId": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PublicCheckoutTaxId"
              }
            ],
            "description": "Business tax ID, if the buyer has one. A valid ID can reduce the tax to zero."
          },
          "promoCode": {
            "type": "string",
            "description": "Optional buyer-entered promo code. When set, tax is scaled to the discounted price. Read-only."
          }
        }
      },
      "PublicCheckoutPaymentMethodSessionResponse": {
        "type": "object",
        "required": [
          "id",
          "status",
          "expiresAt",
          "externalMerchantId",
          "paymentMethodId",
          "failureCode",
          "clientSecret"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/PublicCheckoutPaymentMethodSessionStatus"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "externalMerchantId": {
            "type": "string",
            "description": "The account to mount the payment elements for, in setup mode."
          },
          "paymentMethodId": {
            "type": "string",
            "nullable": true,
            "format": "uuid",
            "description": "Payments AI id of the saved card once the session has `succeeded`, for the embed to report to your checkout page. Null otherwise."
          },
          "failureCode": {
            "type": "string",
            "nullable": true,
            "description": "Why a `failed` session failed, as a Public API error code. Null otherwise."
          },
          "clientSecret": {
            "type": "string",
            "nullable": true,
            "description": "Hand to the payment elements' `handleNextAction` while `requires_action`. Null otherwise."
          }
        },
        "description": "Keyless payment method session read: what the embed needs to collect a card without charging it. No customer details."
      },
      "ConfirmPublicCheckoutPaymentMethodSessionRequest": {
        "type": "object",
        "required": ["confirmationToken", "returnUrl"],
        "properties": {
          "confirmationToken": {
            "type": "string",
            "description": "Token (`ctok_…`) the payment elements produced in setup mode."
          },
          "returnUrl": {
            "type": "string",
            "description": "Return URL for an off-site buyer step (3-D Secure). Must use https and a host the merchant allows, like every checkout `returnUrl`."
          }
        }
      },
      "PublicCheckoutByPlanResponse": {
        "type": "object",
        "required": [
          "planId",
          "productId",
          "merchantId",
          "productName",
          "type",
          "amount",
          "initialPrice",
          "currency",
          "checkoutUrl",
          "customization"
        ],
        "properties": {
          "planId": {
            "type": "string"
          },
          "externalPlanId": {
            "type": "string"
          },
          "externalMerchantId": {
            "type": "string"
          },
          "productId": {
            "type": "string"
          },
          "merchantId": {
            "type": "string"
          },
          "productName": {
            "type": "string"
          },
          "productDescription": {
            "type": "string"
          },
          "richDescription": {
            "type": "string",
            "description": "Long-form copy authored on the plan (`plans.rich_description`), rendered as plain text beneath the short description. Newlines are preserved; markup is not interpreted."
          },
          "productImagePath": {
            "type": "string"
          },
          "productImageExpiresAt": {
            "type": "string",
            "format": "date-time",
            "description": "ISO-8601 UTC expiry of `productImagePath`. Present only when the image is a presigned URL."
          },
          "type": {
            "type": "string"
          },
          "billingPeriod": {
            "type": "string",
            "description": "Present for recurring plans; drives checkout recurrence policy copy (day | week | month | year)."
          },
          "lengthOfBillingPeriod": {
            "type": "integer",
            "format": "int32",
            "description": "Number of billing periods per charge cycle (e.g. 3 with month = every 3 months)."
          },
          "amount": {
            "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
          },
          "initialPrice": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ],
            "description": "Amount charged at checkout today. Zero for recurring plans with a free trial; otherwise matches amount."
          },
          "currency": {
            "type": "string"
          },
          "checkoutUrl": {
            "type": "string"
          },
          "websiteUrl": {
            "type": "string",
            "nullable": true,
            "description": "Merchant store URL from business settings (`merchants.url`). Null when not configured."
          },
          "termsUrl": {
            "type": "string",
            "nullable": true,
            "description": "Seller Terms URL or stable API redirect for a PDF. Null when unset (hosted checkout uses the default terms)."
          },
          "privacyUrl": {
            "type": "string",
            "nullable": true,
            "description": "Seller Privacy URL or stable API redirect for a PDF. Null when unset (hosted checkout uses the default privacy policy)."
          },
          "returnPolicyUrl": {
            "type": "string",
            "nullable": true,
            "description": "Seller Return policy URL or stable API redirect for a PDF. Null when unset (link omitted on checkout)."
          },
          "eulaUrl": {
            "type": "string",
            "nullable": true,
            "description": "Seller EULA URL or stable API redirect for a PDF. Null when unset (link omitted on checkout)."
          },
          "customization": {
            "$ref": "#/components/schemas/CheckoutCustomization"
          }
        }
      },
      "ConfirmPublicCheckoutPaymentRequest": {
        "type": "object",
        "required": ["confirmationToken", "returnUrl"],
        "properties": {
          "confirmationToken": {
            "type": "string",
            "description": "Payment token (`ctok_…`) from the client SDK."
          },
          "returnUrl": {
            "type": "string",
            "description": "Return URL for off-site buyer steps (3DS, bank redirect). Must match the page that calls `handleNextAction`."
          },
          "promoCode": {
            "type": "string",
            "description": "Optional buyer-entered promo/discount code. Resolved server-side before charging."
          }
        }
      },
      "ApplyPublicCheckoutPromoCodeResponse": {
        "type": "object",
        "required": [
          "code",
          "promoType",
          "amountOff",
          "discountAmount",
          "subtotal",
          "total",
          "renewalTotal",
          "currency",
          "billingPeriod",
          "billingPeriodLength",
          "billingPeriodUnit"
        ],
        "properties": {
          "code": {
            "type": "string",
            "description": "Normalized (uppercased) code that was applied."
          },
          "promoType": {
            "type": "string",
            "description": "percentage | flat_amount"
          },
          "amountOff": {
            "type": "string",
            "description": "Raw amount-off value from the discount definition (percent points or flat major units)."
          },
          "discountAmount": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ],
            "description": "Absolute discount applied to this plan amount, in major currency units."
          },
          "subtotal": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ],
            "description": "Price before the discount, before tax."
          },
          "total": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ],
            "description": "Amount after discount, before tax."
          },
          "renewalTotal": {
            "type": "number",
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ],
            "nullable": true,
            "description": "Later renewal after the discount. Null when there is no renewal. Unchanged when billingPeriod is once."
          },
          "currency": {
            "type": "string"
          },
          "billingPeriod": {
            "type": "string",
            "description": "once | repeating | forever — how long the promo applies after purchase."
          },
          "billingPeriodLength": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "billingPeriodUnit": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "ApplyPublicCheckoutPromoCodeRequest": {
        "type": "object",
        "required": ["code"],
        "properties": {
          "code": {
            "type": "string",
            "description": "Buyer-entered promo/discount code (case-insensitive; stored uppercased)."
          }
        }
      },
      "PublicCheckoutSessionResponse": {
        "type": "object",
        "required": ["sessionId"],
        "properties": {
          "sessionId": {
            "type": "string"
          },
          "purchaseUrl": {
            "type": "string"
          }
        }
      },
      "CreatePublicCheckoutSessionRequest": {
        "type": "object",
        "required": ["returnUrl"],
        "properties": {
          "returnUrl": {
            "type": "string"
          }
        }
      },
      "PublicApiOwnMerchantListResponse": {
        "type": "object",
        "required": ["data"],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicApiOwnMerchant"
            }
          }
        }
      },
      "PublicApiCreateOwnMerchantResponse": {
        "type": "object",
        "required": ["merchantId", "created"],
        "properties": {
          "merchantId": {
            "type": "string"
          },
          "created": {
            "type": "boolean",
            "description": "True on first create; false when the call returned a merchant that already existed for this user or this `merchantId`."
          }
        }
      },
      "PublicApiCreateOwnMerchantRequest": {
        "type": "object",
        "required": ["name"],
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 145,
            "description": "Business name displayed to customers. `'s Merchant` is appended when stored. Capped at 145 so the provider company title fits."
          },
          "email": {
            "type": "string",
            "format": "email",
            "description": "Optional merchant contact email. Defaults to the signed-in user's email; 400 `invalid_request` when omitted and the user has no email on file. The signed-in user becomes Owner whatever this value is."
          },
          "phone": {
            "type": "string",
            "pattern": "^\\+[1-9]\\d{1,14}$",
            "description": "Optional E.164 phone. The identity-verification link is sent to it by SMS after go-live; if omitted, the merchant provides it during KYC."
          },
          "merchantId": {
            "type": "string",
            "description": "Optional client-supplied UUID v7 retry key. Re-submitting the same id with the same details returns the original merchant with `created: false`; the same id with different details returns 409. Without it, a user who already owns a merchant on this environment gets that merchant back with `created: false`."
          }
        }
      },
      "PublicApiCreateMerchantResponse": {
        "type": "object",
        "required": ["merchantId", "created", "ownerAttached"],
        "properties": {
          "merchantId": {
            "type": "string"
          },
          "created": {
            "type": "boolean",
            "description": "True on first create; false when this `merchantId` had already been provisioned with matching details."
          },
          "ownerAttached": {
            "type": "boolean",
            "description": "True when the owner email matched an existing user and was assigned the `owner` role. False when the email is unknown to PAI — the response then also carries `joinUrl` / `joinUrlExpiresAt`, a claim link your platform delivers to the seller. PAI does not email the seller directly. Alternatively use `POST .../members` to copy an existing active member of your team onto the sub-merchant after create, or have the owner sign up before create. Read the current value later with `GET /v1/public-api/merchants/{merchantId}`."
          },
          "joinUrl": {
            "type": "string",
            "description": "Owner-claim join URL. Present only when `ownerAttached` is false. Deliver to the seller so they can sign up (or in) and claim ownership. Regenerate via `POST /v1/public-api/merchants/{merchantId}/join-link` if the seller loses or expires it."
          },
          "joinUrlExpiresAt": {
            "type": "string",
            "format": "date-time",
            "description": "Expiration of the `joinUrl` (7 days after issuance). Present only when `joinUrl` is present."
          }
        }
      },
      "PublicApiCreateMerchantRequest": {
        "type": "object",
        "required": ["name", "email"],
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 145,
            "description": "Business name displayed to customers. `'s Merchant` is appended when stored. Capped at 145 so the provider company title fits."
          },
          "email": {
            "type": "string",
            "format": "email",
            "description": "Owner email. If a user with this email already exists, they are assigned as Owner; otherwise the merchant is created without a membership and `ownerAttached` is false."
          },
          "phone": {
            "type": "string",
            "pattern": "^\\+[1-9]\\d{1,14}$",
            "description": "Optional E.164 phone. If omitted, the merchant provides it during KYC."
          },
          "merchantId": {
            "type": "string",
            "description": "Optional client-supplied UUID v7 idempotency key. Re-submitting the same id with the same details is safe and returns `created: false`."
          },
          "websiteUrl": {
            "type": "string",
            "maxLength": 255,
            "pattern": "^https://",
            "format": "uri",
            "description": "Optional HTTPS website URL for the sub-merchant. Used to validate checkout `returnUrl` hosts. Must start with `https://`. Max 255 characters."
          },
          "allowedReturnHosts": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "maxItems": 20,
            "description": "Optional. Exact hostnames, besides the `websiteUrl` host and the checkout host, that a checkout `returnUrl` may point to. Each entry is a bare hostname such as `shop.example.com`: no scheme, path, port, wildcard, IP address or `localhost`. Entries are lowercased, converted to punycode and de-duplicated. Matching is exact: a listed host does not cover its subdomains. At most 20 entries. Sending the list replaces the stored list; `[]` clears it. An invalid entry returns 400 naming the entry. On idempotent replay the list is applied only when the stored list is still empty; a replay with a different list returns 409."
          }
        }
      },
      "PublicApiGetMerchantResponse": {
        "type": "object",
        "required": ["merchantId", "ownerAttached", "activation", "allowedReturnHosts"],
        "properties": {
          "merchantId": {
            "type": "string"
          },
          "ownerAttached": {
            "type": "boolean",
            "description": "True once the merchant has an active owner — attached at create, claimed by the seller through the join URL, or assigned with `POST .../members`. To learn about a join URL claim without polling, subscribe to the `merchant.owner_attached` webhook."
          },
          "activation": {
            "$ref": "#/components/schemas/PublicApiMerchantActivation"
          },
          "allowedReturnHosts": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Hosts a checkout `returnUrl` may use besides the `websiteUrl` host and the checkout host. Empty when none are set."
          }
        }
      },
      "PublicApiUpdateMerchantWebsiteUrlResponse": {
        "type": "object",
        "properties": {
          "websiteUrl": {
            "type": "string",
            "description": "Present when the request set `websiteUrl`."
          },
          "allowedReturnHosts": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Present when the request set `allowedReturnHosts`: the stored, normalised list."
          }
        },
        "description": "Echoes the fields sent in the request, with their stored values."
      },
      "PublicApiUpdateMerchantWebsiteUrlRequest": {
        "type": "object",
        "properties": {
          "websiteUrl": {
            "type": "string",
            "maxLength": 255,
            "pattern": "^https://",
            "format": "uri",
            "description": "HTTPS website URL for the merchant. Its hostname is always allowed as a checkout `returnUrl` host."
          },
          "allowedReturnHosts": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "maxItems": 20,
            "description": "Exact hostnames, besides the `websiteUrl` host and the checkout host, that a checkout `returnUrl` may point to. Each entry is a bare hostname such as `shop.example.com`: no scheme, path, port, wildcard, IP address or `localhost`. Entries are lowercased, converted to punycode and de-duplicated. Matching is exact: a listed host does not cover its subdomains. At most 20 entries. Sending the list replaces the stored list; `[]` clears it. An invalid entry returns 400 naming the entry."
          }
        },
        "description": "Send `websiteUrl`, `allowedReturnHosts` or both."
      },
      "PublicApiApiKeySummary": {
        "type": "object",
        "required": [
          "id",
          "name",
          "maskedKey",
          "environment",
          "permissions",
          "lastUsedAt",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "maskedKey": {
            "type": "string"
          },
          "environment": {
            "type": "string",
            "enum": ["sandbox", "live"]
          },
          "permissions": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": ["payouts:write"]
            },
            "description": "Opt-in capabilities granted to this key. Granted from the dashboard only; a key cannot grant permissions when minting another key."
          },
          "lastUsedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PublicApiCreateApiKeyResponse": {
        "type": "object",
        "required": ["key", "maskedKey", "id", "createdAt"],
        "properties": {
          "key": {
            "type": "string",
            "description": "Plaintext key, returned exactly once. Only its hash is persisted — store it now."
          },
          "maskedKey": {
            "type": "string"
          },
          "id": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ApiError": {
        "type": "object",
        "required": ["code", "message"],
        "properties": {
          "code": {
            "type": "string",
            "description": "Machine-readable error code (e.g. `product.not_found`, `invalid_request`)."
          },
          "message": {
            "type": "string",
            "description": "Human-readable error message suitable for display or logs."
          },
          "docUrl": {
            "type": "string",
            "format": "uri",
            "description": "Optional Fix-It guide URL. v1 invariant: `https://doc.mor.payments.ai/errors/{slug}` where `slug` is kebab-case derived from the internal domain error code (see model doc)."
          }
        },
        "description": "Standard API error response with optional documentation link."
      },
      "PublicApiCreateApiKeyRequest": {
        "type": "object",
        "required": ["name", "environment"],
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 128
          },
          "environment": {
            "type": "string",
            "enum": ["sandbox", "live"]
          },
          "permissions": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": ["payouts:write"]
            },
            "description": "Not a grant. A non-empty list returns 403 `api_key.permission_forbidden`. Permissions are granted from the dashboard only."
          }
        }
      },
      "PublicApiBalanceSummaryResponse": {
        "type": "object",
        "required": ["needsLedgerAccount", "balances"],
        "properties": {
          "needsLedgerAccount": {
            "type": "boolean"
          },
          "balances": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicApiBalanceCurrencyBreakdown"
            }
          }
        }
      },
      "PublicApiCheckoutCustomizationResponse": {
        "type": "object",
        "required": ["merchantId", "customization"],
        "properties": {
          "merchantId": {
            "type": "string"
          },
          "customization": {
            "$ref": "#/components/schemas/PublicApiCheckoutCustomization"
          }
        }
      },
      "PublicApiUpdateCheckoutCustomizationRequest": {
        "type": "object",
        "required": ["customization"],
        "properties": {
          "customization": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PublicApiCheckoutCustomizationPatch"
              }
            ],
            "description": "Merged over the stored customization; omitted fields keep their value (ADR-0008). Explicit `null` resets a field to its default. The logo is set only through the logo upload steps."
          }
        }
      },
      "PublicApiConfirmCheckoutLogoResponse": {
        "type": "object",
        "required": ["logoUrl"],
        "properties": {
          "logoUrl": {
            "type": "string",
            "description": "Presigned GET URL for the stored logo."
          }
        }
      },
      "PublicApiConfirmCheckoutLogoRequest": {
        "type": "object",
        "required": ["path"],
        "properties": {
          "path": {
            "type": "string",
            "description": "Exact `path` returned by the upload-url step."
          }
        }
      },
      "PublicApiCheckoutLogoUploadUrlResponse": {
        "type": "object",
        "required": ["uploadUrl", "path", "expiresAt"],
        "properties": {
          "uploadUrl": {
            "type": "string",
            "description": "Presigned S3 PUT URL. Upload the raw bytes with the same Content-Type used when minting."
          },
          "path": {
            "type": "string",
            "description": "Storage key to echo back to the confirm step. Bound to the merchant."
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PublicApiCheckoutLogoUploadUrlRequest": {
        "type": "object",
        "required": ["fileName", "contentType"],
        "properties": {
          "fileName": {
            "type": "string"
          },
          "contentType": {
            "type": "string",
            "enum": ["image/png", "image/jpeg", "image/jpg", "image/webp"]
          }
        },
        "description": "Request a short-lived presigned S3 PUT URL for a checkout logo. Upload size limit is 5 MB, checked at confirm."
      },
      "PublicApiCheckoutByPlanResponse": {
        "type": "object",
        "required": [
          "planId",
          "productId",
          "productName",
          "type",
          "amount",
          "initialPrice",
          "currency",
          "checkoutUrl",
          "customization"
        ],
        "properties": {
          "planId": {
            "type": "string"
          },
          "productId": {
            "type": "string"
          },
          "productName": {
            "type": "string"
          },
          "productDescription": {
            "type": "string"
          },
          "productImagePath": {
            "type": "string",
            "nullable": true
          },
          "type": {
            "type": "string"
          },
          "billingPeriod": {
            "type": "string"
          },
          "lengthOfBillingPeriod": {
            "type": "integer",
            "format": "int32"
          },
          "amount": {
            "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
          },
          "initialPrice": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ],
            "description": "Amount charged at checkout today. Zero for recurring plans with a free trial; otherwise matches amount."
          },
          "currency": {
            "type": "string"
          },
          "checkoutUrl": {
            "type": "string"
          },
          "websiteUrl": {
            "type": "string",
            "nullable": true
          },
          "termsUrl": {
            "type": "string",
            "nullable": true,
            "description": "Seller Terms URL or stable API redirect for a PDF. Null when unset."
          },
          "privacyUrl": {
            "type": "string",
            "nullable": true,
            "description": "Seller Privacy URL or stable API redirect for a PDF. Null when unset."
          },
          "returnPolicyUrl": {
            "type": "string",
            "nullable": true,
            "description": "Seller Return policy URL or stable API redirect for a PDF. Null when unset."
          },
          "eulaUrl": {
            "type": "string",
            "nullable": true,
            "description": "Seller EULA URL or stable API redirect for a PDF. Null when unset."
          },
          "customization": {
            "type": "object",
            "additionalProperties": {}
          }
        }
      },
      "PublicApiCheckoutPaymentConfirmationResponse": {
        "type": "object",
        "required": ["paymentId", "clientSecret", "status"],
        "properties": {
          "transactionId": {
            "type": "string",
            "description": "Internal PAI transaction id (UUID v7) when the payment row exists in Payments AI."
          },
          "paymentId": {
            "type": "string",
            "description": "Deprecated payment provider id (`pay_…`). Removed on 2027-01-15.",
            "deprecated": true
          },
          "clientSecret": {
            "type": "string"
          },
          "status": {
            "type": "string"
          }
        }
      },
      "PublicApiConfirmCheckoutPaymentRequest": {
        "type": "object",
        "required": ["confirmationToken", "returnUrl"],
        "properties": {
          "confirmationToken": {
            "type": "string"
          },
          "returnUrl": {
            "type": "string"
          },
          "promoCode": {
            "type": "string",
            "description": "Optional buyer-entered promo/discount code. Resolved server-side before charging."
          }
        }
      },
      "PublicApiPreviewCheckoutPromoCodeResponse": {
        "type": "object",
        "required": [
          "code",
          "promoType",
          "amountOff",
          "discountAmount",
          "subtotal",
          "total",
          "renewalTotal",
          "currency",
          "billingPeriod",
          "billingPeriodLength",
          "billingPeriodUnit"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "promoType": {
            "type": "string"
          },
          "amountOff": {
            "type": "string"
          },
          "discountAmount": {
            "type": "number",
            "format": "double"
          },
          "subtotal": {
            "type": "number",
            "format": "double"
          },
          "total": {
            "type": "number",
            "format": "double"
          },
          "renewalTotal": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "currency": {
            "type": "string"
          },
          "billingPeriod": {
            "type": "string"
          },
          "billingPeriodLength": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "billingPeriodUnit": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "PublicApiPreviewCheckoutPromoCodeRequest": {
        "type": "object",
        "required": ["code"],
        "properties": {
          "code": {
            "type": "string",
            "description": "Buyer-entered promo/discount code (case-insensitive; stored uppercased)."
          }
        }
      },
      "PublicApiApplyCheckoutPromoCodeResponse": {
        "type": "object",
        "required": [
          "code",
          "promoType",
          "amountOff",
          "discountAmount",
          "subtotal",
          "total",
          "renewalTotal",
          "currency",
          "billingPeriod",
          "billingPeriodLength",
          "billingPeriodUnit"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "promoType": {
            "type": "string"
          },
          "amountOff": {
            "type": "string"
          },
          "discountAmount": {
            "type": "number",
            "format": "double"
          },
          "subtotal": {
            "type": "number",
            "format": "double"
          },
          "total": {
            "type": "number",
            "format": "double"
          },
          "renewalTotal": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "currency": {
            "type": "string"
          },
          "billingPeriod": {
            "type": "string"
          },
          "billingPeriodLength": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "billingPeriodUnit": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "PublicApiApplyCheckoutPromoCodeRequest": {
        "type": "object",
        "required": ["code"],
        "properties": {
          "code": {
            "type": "string",
            "description": "Buyer-entered promo/discount code (case-insensitive; stored uppercased)."
          }
        }
      },
      "PublicApiCheckoutReceiptResponse": {
        "type": "object",
        "required": ["subtotal", "taxAmount", "total", "currency", "taxBehavior"],
        "properties": {
          "subtotal": {
            "type": "number",
            "format": "double"
          },
          "taxAmount": {
            "type": "number",
            "format": "double"
          },
          "total": {
            "type": "number",
            "format": "double"
          },
          "currency": {
            "type": "string"
          },
          "taxBehavior": {
            "type": "string",
            "enum": ["exclusive", "inclusive"]
          }
        }
      },
      "PublicApiCheckoutSessionResponse": {
        "type": "object",
        "required": ["sessionId"],
        "properties": {
          "sessionId": {
            "type": "string"
          },
          "purchaseUrl": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "PublicApiCreateCheckoutSessionRequest": {
        "type": "object",
        "required": ["returnUrl"],
        "properties": {
          "returnUrl": {
            "type": "string"
          }
        }
      },
      "PublicApiPaymentMethodSessionResponse": {
        "type": "object",
        "required": [
          "id",
          "customerId",
          "status",
          "paymentMethodId",
          "failureCode",
          "expiresAt",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Pass it to the checkout embed to collect the card. It is the only credential the embed needs."
          },
          "customerId": {
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/PublicApiPaymentMethodSessionStatus"
          },
          "paymentMethodId": {
            "type": "string",
            "nullable": true,
            "format": "uuid",
            "description": "Payments AI id of the saved card once the session has `succeeded`; null before. To make it a subscription's card, send it as `paymentMethodId` to POST `/v1/public-api/merchants/{merchantId}/subscriptions/{subscriptionId}/payment-method`."
          },
          "failureCode": {
            "type": "string",
            "nullable": true,
            "description": "Why a `failed` session failed: `payment_method_session.card_not_saved` when the payment provider did not save the card, or `payment_method_session.customer_not_linked` when the payment provider saved the card for another buyer than the customer, or without naming its buyer. Null otherwise."
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "description": "A session no card was submitted to by then reads `expired`. One hour after it was opened. A session still saving a card reads `expired` 24 hours after it was opened."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "description": "A setup-only session: the embed collects a card for the customer without charging it."
      },
      "PublicApiCreatePaymentMethodSessionRequest": {
        "type": "object",
        "description": "Send an empty object or no body. A session only saves a card, so any field is rejected with 400."
      },
      "PublicApiSavedPaymentMethodListResponse": {
        "type": "object",
        "required": ["data"],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicApiSavedPaymentMethod"
            }
          }
        }
      },
      "PublicApiDiscountCodeStatus": {
        "type": "string",
        "enum": ["active", "expired", "archived"],
        "description": "`expired` is derived from expiresAt. `archived` codes stay readable but cannot be redeemed or updated."
      },
      "PublicApiDiscountPromoType": {
        "type": "string",
        "enum": ["percentage", "flat_amount"]
      },
      "PublicApiDiscountBillingPeriod": {
        "type": "string",
        "enum": ["once", "repeating", "forever"],
        "description": "How long the discount applies to a subscription: the first payment only (once), a number of billing periods (repeating), or every payment (forever)."
      },
      "PublicApiDiscountCodeSortField": {
        "type": "string",
        "enum": ["internalName", "expiresAt"]
      },
      "PublicApiDiscountCodeListResponse": {
        "type": "object",
        "required": ["data", "meta"],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicApiDiscountCodeListItem"
            }
          },
          "meta": {
            "$ref": "#/components/schemas/PaginationMeta"
          }
        }
      },
      "PublicApiDiscountCode": {
        "type": "object",
        "required": [
          "id",
          "merchantId",
          "internalName",
          "code",
          "promoType",
          "amountOff",
          "currency",
          "billingPeriod",
          "billingPeriodLength",
          "billingPeriodUnit",
          "productId",
          "expiresAt",
          "status",
          "scopeLabel",
          "amountDisplay",
          "billingPeriodLabel",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "merchantId": {
            "type": "string"
          },
          "internalName": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "promoType": {
            "$ref": "#/components/schemas/PublicApiDiscountPromoType"
          },
          "amountOff": {
            "type": "string",
            "description": "Decimal string. A flat amount uses its currency's minor units, for example \"10.00\" usd or \"500\" jpy; a percentage has two decimals, for example \"20.00\"."
          },
          "currency": {
            "type": "string",
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.CurrencyCode"
              }
            ],
            "nullable": true
          },
          "billingPeriod": {
            "$ref": "#/components/schemas/PublicApiDiscountBillingPeriod"
          },
          "billingPeriodLength": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "billingPeriodUnit": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PublicApiDiscountBillingPeriodUnit"
              }
            ],
            "nullable": true
          },
          "productId": {
            "type": "string",
            "nullable": true,
            "description": "Null for a store-wide code."
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/PublicApiDiscountCodeStatus"
          },
          "scopeLabel": {
            "type": "string",
            "description": "All Products, or the scoped product's name."
          },
          "amountDisplay": {
            "type": "string",
            "description": "Display text, for example \"20% OFF\"."
          },
          "billingPeriodLabel": {
            "type": "string",
            "description": "Display text, for example \"Once\" or \"3 Months\"."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PublicApiCreateDiscountCodeRequest": {
        "type": "object",
        "required": ["internalName", "code", "promoType", "amountOff", "billingPeriod"],
        "properties": {
          "internalName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255,
            "description": "Name shown to the merchant only."
          },
          "code": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255,
            "description": "Code the buyer types at checkout. Stored upper case and unique per merchant. Cannot be changed after create."
          },
          "promoType": {
            "$ref": "#/components/schemas/PublicApiDiscountPromoType"
          },
          "amountOff": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/PublicApiDiscountAmountOff"
              },
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ],
            "description": "For percentage: greater than 0 and at most 100. For flat_amount: money in `currency`, a whole number of that currency's minor unit (whole yen for jpy, so 500 and not 500.5)."
          },
          "currency": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.CurrencyCode"
              }
            ],
            "description": "Required when promoType is flat_amount. Lowercase ISO 4217."
          },
          "billingPeriod": {
            "$ref": "#/components/schemas/PublicApiDiscountBillingPeriod"
          },
          "billingPeriodLength": {
            "type": "integer",
            "format": "int32",
            "minimum": 1,
            "description": "Required when billingPeriod is repeating."
          },
          "billingPeriodUnit": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PublicApiDiscountBillingPeriodUnit"
              }
            ],
            "description": "Required when billingPeriod is repeating."
          },
          "productId": {
            "type": "string",
            "nullable": true,
            "description": "Product the code is limited to. Omit or send null for a store-wide code."
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "description": "The code stops applying after this time. Omit for no expiry."
          }
        }
      },
      "PublicApiUpdateDiscountCodeRequest": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "internalName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "promoType": {
            "$ref": "#/components/schemas/PublicApiDiscountPromoType"
          },
          "amountOff": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/PublicApiDiscountAmountOff"
              },
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ]
          },
          "currency": {
            "$ref": "#/components/schemas/SharedTypes.CurrencyCode"
          },
          "billingPeriod": {
            "$ref": "#/components/schemas/PublicApiDiscountBillingPeriod"
          },
          "billingPeriodLength": {
            "type": "integer",
            "format": "int32",
            "nullable": true,
            "minimum": 1,
            "description": "Required with billingPeriod repeating. Cleared when billingPeriod becomes once or forever."
          },
          "billingPeriodUnit": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PublicApiDiscountBillingPeriodUnit"
              }
            ],
            "nullable": true,
            "description": "Required with billingPeriod repeating. Cleared when billingPeriod becomes once or forever."
          },
          "productId": {
            "type": "string",
            "nullable": true,
            "description": "Send null to make the code store-wide."
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Send null to remove the expiry."
          }
        },
        "description": "Send only the fields to change. `code` may be sent only with its current value."
      },
      "PublicApiMerchantJoinLinkResponse": {
        "type": "object",
        "required": ["joinUrl", "joinUrlExpiresAt"],
        "properties": {
          "joinUrl": {
            "type": "string",
            "description": "Freshly minted owner-claim join URL (7-day TTL). The previously-issued token, if any, is invalidated by this call."
          },
          "joinUrlExpiresAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PublicApiGetMerchantKycResponse": {
        "type": "object",
        "required": ["merchantId", "kycStatus", "activationStatus", "updatedAt"],
        "properties": {
          "merchantId": {
            "type": "string"
          },
          "kycStatus": {
            "type": "string",
            "enum": ["not_started", "pending", "in_review", "verified", "rejected"],
            "description": "Identity verification (KYC) state. Same values as `activation.identityVerification` on `GET /v1/public-api/merchants/{merchantId}`."
          },
          "activationStatus": {
            "type": "string",
            "enum": ["not_provisioned", "pending", "verification_pending", "active"],
            "description": "Go-live progress after the status change. Same values as `activation.status` on `GET /v1/public-api/merchants/{merchantId}`."
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When `merchant_kyc` was last updated for this merchant, or `null` when identity verification has not started (no row yet)."
          }
        }
      },
      "PublicApiAssignMerchantMemberResponse": {
        "type": "object",
        "required": ["userId", "email", "role", "status"],
        "properties": {
          "userId": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "role": {
            "$ref": "#/components/schemas/PublicApiTeamRole"
          },
          "status": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PublicApiTeamMemberStatus"
              }
            ],
            "description": "Always `active` after a successful assign."
          }
        }
      },
      "PublicApiAssignMerchantMemberRequest": {
        "type": "object",
        "required": ["email", "role"],
        "properties": {
          "email": {
            "type": "string",
            "format": "email"
          },
          "role": {
            "$ref": "#/components/schemas/PublicApiTeamRole"
          }
        }
      },
      "PublicApiOrderResponse": {
        "type": "object",
        "required": [
          "orderId",
          "checkoutUrl",
          "currency",
          "amountDue",
          "recurringAmount",
          "billingPeriod",
          "periodLength",
          "trialPeriodDays",
          "items",
          "metadata",
          "status",
          "transactionId"
        ],
        "properties": {
          "orderId": {
            "type": "string"
          },
          "checkoutUrl": {
            "type": "string"
          },
          "currency": {
            "$ref": "#/components/schemas/SharedTypes.CurrencyCode"
          },
          "amountDue": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ],
            "description": "Amount the buyer owes today, before tax."
          },
          "recurringAmount": {
            "type": "number",
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ],
            "nullable": true,
            "description": "Later renewal total. Null when the order has no recurring item."
          },
          "billingPeriod": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BillingPeriod"
              }
            ],
            "nullable": true
          },
          "periodLength": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "trialPeriodDays": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicApiOrderItemResponse"
            }
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "The metadata sent on create, exactly as sent. `{}` when none was sent."
          },
          "status": {
            "$ref": "#/components/schemas/PublicApiOrderStatus"
          },
          "transactionId": {
            "type": "string",
            "nullable": true,
            "description": "Internal Payments AI transaction id when a payment row exists for this order (excluding pending or failed). Null while unpaid or between checkout confirm and webhook linkage."
          },
          "subscriptionId": {
            "type": "string",
            "description": "Present when the order has exactly one recurring line item and one subscription row is linked."
          },
          "subscriptionIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Present when the order has two or more recurring line items, or when multiple subscription rows are linked."
          }
        },
        "description": "Order returned by API-key create and read. No mount fields and no processor purchase URL."
      },
      "PublicApiCreateOrderRequest": {
        "type": "object",
        "required": ["currency", "items"],
        "properties": {
          "currency": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.CurrencyCode"
              }
            ],
            "description": "One of usd, eur, gbp, pln, chf, sek, dkk, nok, cad, aud, jpy. jpy has no minor unit, so its amounts are whole yen (500, not 500.5)."
          },
          "items": {
            "type": "array",
            "items": {
              "anyOf": [
                {
                  "$ref": "#/components/schemas/PublicApiCreateOrderPlanItem"
                },
                {
                  "$ref": "#/components/schemas/PublicApiCreateOrderCustomItem"
                },
                {
                  "$ref": "#/components/schemas/PublicApiCreateOrderInvoiceItem"
                }
              ]
            },
            "minItems": 1,
            "maxItems": 20
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Optional. Your own key/value pairs for this order, such as a CRM or ERP order number. Flat object with string values only. At most 50 keys; each key is 1 to 40 characters and each value is at most 500 characters, else 400 `Validation failed`. Keys and values are stored and returned exactly as sent. Omitted means `{}`. Returned on order reads and on `payment.*` and `subscription.*` webhooks that name this order. Never sent to the payment processor."
          }
        }
      },
      "PublicApiConfirmOrderPaymentResponse": {
        "type": "object",
        "required": ["paymentId", "status"],
        "properties": {
          "paymentId": {
            "type": "string",
            "description": "The payment's id at the payment processor, sent as `externalTransactionId` on `payment.*` webhooks."
          },
          "status": {
            "type": "string",
            "description": "`processing` for a saved card: the order is paid only once `payment.completed` arrives, and released by `payment.failed`. For a confirmation token, the processor's status of the payment."
          },
          "clientSecret": {
            "type": "string",
            "description": "Confirmation token only: the client secret the buyer's payment fields use for a next step."
          },
          "transactionId": {
            "type": "string",
            "description": "Confirmation token only: the Payments AI transaction id when the payment is already recorded."
          }
        },
        "description": "The answer to an order confirm."
      },
      "PublicApiConfirmOrderPaymentRequest": {
        "type": "object",
        "properties": {
          "paymentMethodId": {
            "type": "string",
            "format": "uuid",
            "description": "A saved card `id` from `GET /v1/public-api/merchants/{merchantId}/customers/{customerId}/payment-methods`. The order is charged to it with no buyer present, and the card's customer is the order's buyer. Omit when sending `confirmationToken`."
          },
          "confirmationToken": {
            "type": "string",
            "minLength": 1,
            "description": "A confirmation token the buyer's payment fields minted. Requires `returnUrl`. Omit when sending `paymentMethodId`."
          },
          "returnUrl": {
            "type": "string",
            "format": "uri",
            "description": "Where the buyer returns after an off-site step. Required with `confirmationToken`, refused with `paymentMethodId`. Must be on the checkout host, your merchant website, or one of your allowed return hosts."
          },
          "promoCode": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255,
            "description": "Optional promo code, applied as on the hosted checkout."
          }
        },
        "description": "Send exactly one of `paymentMethodId` or `confirmationToken`, else 400 `Validation failed`."
      },
      "PublicApiRequestPayoutResponse": {
        "type": "object",
        "required": ["withdrawalId"],
        "properties": {
          "withdrawalId": {
            "type": "string"
          }
        }
      },
      "PublicApiRequestPayoutBody": {
        "type": "object",
        "required": ["amount", "payout_method_id"],
        "properties": {
          "amount": {
            "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
          },
          "currency": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.CurrencyCode"
              }
            ],
            "description": "ISO 4217 currency code. Defaults to `usd` when omitted."
          },
          "payout_method_id": {
            "type": "string"
          }
        }
      },
      "PublicApiPayoutMethodsResponse": {
        "type": "object",
        "required": ["payoutMethods"],
        "properties": {
          "payoutMethods": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicApiPayoutMethodItem"
            }
          }
        }
      },
      "ProductStatus": {
        "type": "string",
        "enum": ["active", "draft", "archived"]
      },
      "PlanType": {
        "type": "string",
        "enum": ["free-access", "one-time", "recurring"]
      },
      "PublicApiProductListResponse": {
        "type": "object",
        "required": ["data", "meta"],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicApiProductListItem"
            }
          },
          "meta": {
            "$ref": "#/components/schemas/PaginationMeta"
          }
        }
      },
      "CreateProductResponse": {
        "type": "object",
        "required": ["id"],
        "properties": {
          "id": {
            "type": "string"
          }
        }
      },
      "PublicApiCreateProduct": {
        "type": "object",
        "required": ["name", "plans"],
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 30
          },
          "description": {
            "type": "string",
            "maxLength": 80
          },
          "status": {
            "$ref": "#/components/schemas/ProductStatus"
          },
          "discountCode": {
            "type": "string",
            "description": "Deprecated: legacy discount codes on the product. New promos are first-class DiscountCode entities."
          },
          "plans": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CreatePlan"
            }
          },
          "imagePath": {
            "type": "string",
            "maxLength": 255
          },
          "productTaxCodeId": {
            "type": "string",
            "maxLength": 255,
            "description": "Optional product tax code id for catalog sync."
          },
          "taxCodeId": {
            "type": "string",
            "maxLength": 255,
            "description": "Deprecated alias of productTaxCodeId.",
            "deprecated": true
          }
        }
      },
      "PublicApiProduct": {
        "type": "object",
        "required": [
          "id",
          "merchantId",
          "name",
          "status",
          "revenue",
          "discountCodes",
          "plans",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "merchantId": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/ProductStatus"
          },
          "revenue": {
            "type": "number",
            "format": "decimal"
          },
          "discountCodes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Deprecated: legacy discount codes on the product. New promos are first-class DiscountCode entities. Retained for backward compatibility until migration (PAIM-285)."
          },
          "plans": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicApiPlanVariant"
            }
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "deletedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "imageUrl": {
            "type": "string",
            "nullable": true,
            "description": "Presigned URL resolved on the read side from the stored S3 image key."
          },
          "activeSubscriptionCount": {
            "type": "integer",
            "format": "int32",
            "description": "Active subscriptions billed against this product"
          },
          "totalSalesCount": {
            "type": "integer",
            "format": "int32",
            "description": "Lifetime sales count for delete eligibility"
          },
          "canPermanentlyDelete": {
            "type": "boolean",
            "description": "True when draft with zero sales and zero active subscriptions"
          },
          "productTaxCodeId": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "PublicApiUpdateProductRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 30
          },
          "description": {
            "type": "string",
            "maxLength": 80
          },
          "status": {
            "type": "string",
            "enum": ["active", "draft"],
            "description": "Only `active` and `draft` can be set here. Moving an active product with active subscriptions out of `active` returns 409."
          },
          "productTaxCodeId": {
            "type": "string",
            "nullable": true,
            "maxLength": 255,
            "description": "Product tax code id for catalog sync; `null` clears it."
          },
          "taxCodeId": {
            "type": "string",
            "nullable": true,
            "maxLength": 255,
            "description": "Deprecated alias of productTaxCodeId. `null` clears the stored tax code.",
            "deprecated": true
          }
        }
      },
      "PublicApiConfirmProductImageResponse": {
        "type": "object",
        "required": ["imageUrl"],
        "properties": {
          "imageUrl": {
            "type": "string",
            "description": "Presigned GET URL for the stored image."
          }
        }
      },
      "PublicApiConfirmProductImageRequest": {
        "type": "object",
        "required": ["key"],
        "properties": {
          "key": {
            "type": "string",
            "description": "Exact `key` returned by the upload-url step."
          }
        }
      },
      "PublicApiProductImageUploadUrlResponse": {
        "type": "object",
        "required": ["url", "fields", "key", "expiresIn"],
        "properties": {
          "url": {
            "type": "string",
            "description": "S3 POST endpoint for the multipart/form-data upload."
          },
          "fields": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Form fields to include in the multipart body; the `file` field goes last."
          },
          "key": {
            "type": "string",
            "description": "Storage key to echo back to the confirm step. Bound to the merchant."
          },
          "expiresIn": {
            "type": "integer",
            "format": "int32",
            "description": "Seconds until the upload policy expires."
          }
        }
      },
      "PublicApiProductImageUploadUrlRequest": {
        "type": "object",
        "required": ["fileName", "mimeType"],
        "properties": {
          "fileName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "mimeType": {
            "type": "string",
            "enum": ["image/png", "image/jpeg", "image/jpg", "image/webp"]
          }
        },
        "description": "Request a short-lived presigned S3 POST policy for a product image. Upload size limit is 5 MB."
      },
      "PublicApiPlan": {
        "type": "object",
        "required": [
          "id",
          "productId",
          "name",
          "type",
          "billingPeriod",
          "lengthOfBillingPeriod",
          "amount",
          "initialPrice",
          "currency",
          "freeTrial",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "productId": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "type": {
            "type": "string"
          },
          "billingPeriod": {
            "type": "string"
          },
          "lengthOfBillingPeriod": {
            "type": "integer",
            "format": "int32"
          },
          "amount": {
            "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
          },
          "initialPrice": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ],
            "description": "Amount charged at checkout today. Zero for recurring plans with a free trial; otherwise matches amount."
          },
          "currency": {
            "type": "string"
          },
          "freeTrial": {
            "type": "integer",
            "format": "int32"
          },
          "taxBehavior": {
            "type": "string",
            "enum": ["exclusive", "inclusive"],
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreatePlan": {
        "type": "object",
        "required": ["name", "currency", "amount", "type", "billingPeriod", "periodLength"],
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 30
          },
          "description": {
            "type": "string",
            "maxLength": 80
          },
          "richDescription": {
            "type": "string",
            "maxLength": 65535
          },
          "currency": {
            "$ref": "#/components/schemas/SharedTypes.CurrencyCode"
          },
          "amount": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ],
            "description": "Strictly flat pricing amount"
          },
          "type": {
            "$ref": "#/components/schemas/PlanType"
          },
          "billingPeriod": {
            "$ref": "#/components/schemas/CreateBillingPeriod"
          },
          "periodLength": {
            "type": "integer",
            "format": "int32",
            "minimum": 1
          },
          "freeTrial": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "taxBehavior": {
            "type": "string",
            "enum": ["exclusive", "inclusive"],
            "description": "Optional per-plan tax behaviour override. When omitted, the plan inherits the merchant default."
          }
        }
      },
      "PublicApiUpdatePlanRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 30
          },
          "description": {
            "type": "string",
            "maxLength": 80
          },
          "type": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PlanType"
              }
            ],
            "description": "Immutable after creation; a value different from the plan's current type returns 409."
          },
          "billingPeriod": {
            "$ref": "#/components/schemas/BillingPeriod"
          },
          "lengthOfBillingPeriod": {
            "type": "integer",
            "format": "int32",
            "minimum": 1
          },
          "amount": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ],
            "description": "Must be zero for free-access plans. Changing amount or currency on a plan with active subscriptions returns 409."
          },
          "currency": {
            "$ref": "#/components/schemas/SharedTypes.CurrencyCode"
          },
          "freeTrial": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "taxBehavior": {
            "type": "string",
            "enum": ["exclusive", "inclusive"],
            "nullable": true,
            "description": "`null` clears the override so the plan inherits the merchant default."
          }
        }
      },
      "PublicApiMerchantTaxSettings": {
        "type": "object",
        "required": ["defaultTaxBehavior"],
        "properties": {
          "defaultTaxBehavior": {
            "type": "string",
            "enum": ["exclusive", "inclusive"]
          }
        }
      },
      "PublicApiMerchantTaxSettingsPatch": {
        "type": "object",
        "required": ["defaultTaxBehavior"],
        "properties": {
          "defaultTaxBehavior": {
            "type": "string",
            "enum": ["exclusive", "inclusive"]
          }
        }
      },
      "PublicApiSubMerchantListResponse": {
        "type": "object",
        "required": ["data", "meta"],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicApiSubMerchant"
            }
          },
          "meta": {
            "$ref": "#/components/schemas/PaginationMeta"
          }
        }
      },
      "PublicApiSubscriptionStatus": {
        "type": "string",
        "enum": ["active", "trialing", "canceling", "inactive"],
        "description": "`active` renews at the period end. `trialing` is in a free trial. `canceling` keeps access until the period end and then ends. `inactive` has ended."
      },
      "PublicApiSubscriptionListResponse": {
        "type": "object",
        "required": ["data", "meta"],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicApiSubscriptionResponse"
            }
          },
          "meta": {
            "$ref": "#/components/schemas/PaginationMeta"
          }
        }
      },
      "PublicApiSubscriptionResponse": {
        "type": "object",
        "required": [
          "id",
          "status",
          "customerId",
          "planId",
          "productId",
          "orderId",
          "currentPeriodStart",
          "currentPeriodEnd",
          "nextChargeAt",
          "trialEndsAt",
          "cancelAtPeriodEnd",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/PublicApiSubscriptionStatus"
          },
          "customerId": {
            "type": "string",
            "nullable": true,
            "description": "Null when the buyer could not be linked to a customer."
          },
          "planId": {
            "type": "string",
            "nullable": true,
            "description": "Null when the subscription is not on a catalogue plan."
          },
          "productId": {
            "type": "string",
            "nullable": true,
            "description": "Null when the subscription is not on a catalogue product."
          },
          "orderId": {
            "type": "string",
            "nullable": true,
            "description": "Order that started the subscription. Null for a plan checkout without an order."
          },
          "currentPeriodStart": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Start of the current billing period. Null on a subscription that has not renewed or changed since this field was added."
          },
          "currentPeriodEnd": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "End of the current billing period. During a trial, the trial end."
          },
          "nextChargeAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the next renewal charge is due. Null when no charge is scheduled: a pending cancellation, an ended subscription, or a one-time purchase."
          },
          "trialEndsAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "End of the free trial. Null when the subscription is not in a trial."
          },
          "cancelAtPeriodEnd": {
            "type": "boolean",
            "description": "True when the subscription ends at the end of the current period instead of renewing."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "description": "Subscription read. Every id is a Payments AI id."
      },
      "PublicApiChangeSubscriptionDatesRequest": {
        "type": "object",
        "properties": {
          "trialEndsAt": {
            "type": "string",
            "format": "date-time",
            "description": "New end of the free trial. Only while `status` is `trialing`."
          },
          "nextChargeAt": {
            "type": "string",
            "format": "date-time",
            "description": "New date of the next renewal charge. During a trial, the same moment as the trial end."
          }
        },
        "description": "Send `trialEndsAt`, `nextChargeAt`, or both. An ISO 8601 date-time with `Z` or an offset. During a trial the trial ends in the first charge, so both name one moment and must be equal when both are sent."
      },
      "PublicApiCancelSubscriptionRequest": {
        "type": "object",
        "required": ["mode"],
        "properties": {
          "mode": {
            "$ref": "#/components/schemas/PublicApiSubscriptionCancelMode"
          }
        }
      },
      "PublicApiSetSubscriptionPaymentMethodRequest": {
        "type": "object",
        "required": ["paymentMethodId"],
        "properties": {
          "paymentMethodId": {
            "type": "string",
            "format": "uuid",
            "description": "The `id` of one of the subscription customer's saved cards, from GET `/v1/public-api/merchants/{merchantId}/customers/{customerId}/payment-methods`."
          }
        }
      },
      "PublicApiCreateTransactionRequest": {
        "type": "object",
        "required": ["amount", "currency", "confirmationToken", "returnUrl"],
        "properties": {
          "amount": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ],
            "description": "Charge amount in major currency units. Minimums are enforced per currency."
          },
          "currency": {
            "$ref": "#/components/schemas/SharedTypes.CurrencyCode"
          },
          "confirmationToken": {
            "type": "string",
            "description": "Payment token (`ctok_…`) from the client SDK. Never send card numbers or PANs."
          },
          "returnUrl": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "recurring": {
            "$ref": "#/components/schemas/PublicApiCreateTransactionRecurring"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Optional string map stored with the charge and in audit logs. At most 25 keys; keys ≤64 chars, values ≤500 chars. Do not send card numbers, CVV, or PAN-like data."
          }
        }
      },
      "PublicApiTransactionListResponse": {
        "type": "object",
        "required": ["data", "meta"],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicApiTransactionListItem"
            }
          },
          "meta": {
            "$ref": "#/components/schemas/PaginationMeta"
          }
        }
      },
      "PublicApiTransactionDetailResponse": {
        "type": "object",
        "required": [
          "id",
          "transactionId",
          "date",
          "orderId",
          "method",
          "amountIsProvisional",
          "breakdown",
          "history",
          "refunds"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Canonical merchant-facing transaction id (internal UUID v7)."
          },
          "transactionId": {
            "type": "string",
            "description": "Deprecated payment provider id (`pay_…`). Removed on 2027-01-15.",
            "deprecated": true
          },
          "date": {
            "type": "string",
            "format": "date-time"
          },
          "status": {
            "type": "string"
          },
          "result": {
            "type": "string"
          },
          "customerId": {
            "type": "string"
          },
          "orderId": {
            "type": "string",
            "nullable": true,
            "description": "Order this payment paid for; `null` when the payment is not tied to an order."
          },
          "method": {
            "$ref": "#/components/schemas/PublicApiTransactionMethod"
          },
          "amountIsProvisional": {
            "type": "boolean",
            "description": "True while `breakdown.gross` is provisional: the payment provider sent a refund event before the payment's success event, without the sale total or currency, so the amount is a lower bound or the currency a placeholder. Becomes `false` when the payment succeeds and its final amount replaces the provisional one. `remainingRefundable` is computed from the provisional amount, so it can be lower than the real remaining amount, never higher."
          },
          "breakdown": {
            "$ref": "#/components/schemas/PublicApiTransactionBreakdown"
          },
          "humanReadableWhy": {
            "type": "string"
          },
          "history": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicApiTransactionHistoryEvent"
            }
          },
          "refunds": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicApiTransactionRefund"
            },
            "description": "Each refund Payments AI has recorded for this payment, oldest first. `breakdown.refundedAmount` is never lower than the sum of these refunds. It can be higher for a payment refunded before Payments AI tracked each refund separately, or while a refund the payment provider has already reported is still being recorded."
          }
        }
      },
      "CreateWebhookListenSessionResponse": {
        "type": "object",
        "required": ["sessionId", "signingSecret", "events", "expiresAt", "environment"],
        "properties": {
          "sessionId": {
            "type": "string"
          },
          "signingSecret": {
            "type": "string"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "payment.completed",
                "payment.refunded",
                "payment.failed",
                "customer.created",
                "subscription.created",
                "subscription.cancelled",
                "subscription.updated",
                "subscription.cancellation_scheduled",
                "subscription.cancellation_undone",
                "subscription.payment_method_updated",
                "dispute.created",
                "dispute.updated",
                "dispute.won",
                "dispute.lost",
                "dispute.alert_created",
                "payout.sent",
                "merchant.owner_attached",
                "merchant.kyc.updated"
              ]
            },
            "nullable": true
          },
          "expiresAt": {
            "type": "string"
          },
          "environment": {
            "type": "string",
            "enum": ["sandbox", "live"]
          }
        }
      },
      "CreateWebhookListenSessionRequest": {
        "type": "object",
        "required": ["forwardTargetKind"],
        "properties": {
          "events": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "payment.completed",
                "payment.refunded",
                "payment.failed",
                "customer.created",
                "subscription.created",
                "subscription.cancelled",
                "subscription.updated",
                "subscription.cancellation_scheduled",
                "subscription.cancellation_undone",
                "subscription.payment_method_updated",
                "dispute.created",
                "dispute.updated",
                "dispute.won",
                "dispute.lost",
                "dispute.alert_created",
                "payout.sent",
                "merchant.owner_attached",
                "merchant.kyc.updated"
              ]
            }
          },
          "acknowledgeLiveData": {
            "type": "boolean",
            "enum": [true]
          },
          "forwardTargetKind": {
            "type": "string",
            "enum": ["loopback", "non_loopback", "none"]
          }
        }
      },
      "WebhookListenSessionListResponse": {
        "type": "object",
        "required": ["data"],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebhookListenSessionSummary"
            }
          }
        }
      },
      "WebhookListenDispatchResponse": {
        "type": "object",
        "required": ["eventId", "deliveredToSessions"],
        "properties": {
          "eventId": {
            "type": "string"
          },
          "deliveredToSessions": {
            "type": "integer",
            "format": "int32"
          }
        }
      },
      "ResendWebhookListenEventRequest": {
        "type": "object",
        "required": ["eventId"],
        "properties": {
          "eventId": {
            "type": "string"
          },
          "acknowledgeLiveData": {
            "type": "boolean",
            "enum": [true]
          }
        }
      },
      "TriggerWebhookListenEventRequest": {
        "type": "object",
        "required": ["eventType"],
        "properties": {
          "eventType": {
            "type": "string",
            "enum": [
              "payment.completed",
              "payment.refunded",
              "payment.failed",
              "customer.created",
              "subscription.created",
              "subscription.cancelled",
              "subscription.updated",
              "subscription.cancellation_scheduled",
              "subscription.cancellation_undone",
              "subscription.payment_method_updated",
              "dispute.created",
              "dispute.updated",
              "dispute.won",
              "dispute.lost",
              "dispute.alert_created",
              "payout.sent",
              "merchant.owner_attached",
              "merchant.kyc.updated"
            ]
          },
          "acknowledgeLiveData": {
            "type": "boolean",
            "enum": [true]
          }
        }
      },
      "ReportWebhookListenResultRequest": {
        "type": "object",
        "required": ["outcome", "durationMs"],
        "properties": {
          "outcome": {
            "type": "string",
            "enum": ["delivered", "failed", "error", "printed"]
          },
          "statusCode": {
            "type": "integer",
            "format": "int32"
          },
          "durationMs": {
            "type": "integer",
            "format": "int32"
          },
          "errorClass": {
            "type": "string",
            "enum": ["connection_refused", "timeout", "dns", "redirect", "other"]
          }
        }
      },
      "SharedTypes.CurrencyCode": {
        "type": "string",
        "pattern": "^[a-z]{3}$",
        "description": "ISO 4217 currency code. Always lowercase (e.g. 'usd', 'eur')."
      },
      "SharedTypes.MoneyAmountValue": {
        "type": "number",
        "format": "decimal",
        "description": "Decimal money amount for financial values."
      },
      "PublicOrderBillingPeriod": {
        "type": "string",
        "enum": ["day", "week", "month", "year"]
      },
      "PublicOrderItemResponse": {
        "type": "object",
        "required": ["label", "unitPrice", "quantity", "lineTotal", "itemType"],
        "properties": {
          "label": {
            "type": "string"
          },
          "unitPrice": {
            "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
          },
          "quantity": {
            "type": "integer",
            "format": "int32",
            "minimum": 1
          },
          "lineTotal": {
            "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
          },
          "itemType": {
            "$ref": "#/components/schemas/PublicOrderItemType"
          },
          "billingPeriod": {
            "$ref": "#/components/schemas/PublicOrderBillingPeriod"
          },
          "periodLength": {
            "type": "integer",
            "format": "int32",
            "minimum": 1
          }
        },
        "description": "One line on a payable checkout order. Recurring lines include cadence; one-time lines omit it."
      },
      "CheckoutCustomization": {
        "type": "object",
        "properties": {
          "themeMode": {
            "$ref": "#/components/schemas/CheckoutThemeMode"
          },
          "backgroundColor": {
            "type": "string"
          },
          "buttonColor": {
            "type": "string"
          },
          "buttonTextColor": {
            "type": "string"
          },
          "fontColor": {
            "type": "string",
            "description": "Primary body/content text color for the merchant product panel."
          },
          "logoUrl": {
            "type": "string",
            "description": "Presigned URL resolved on the read side from the stored `logoPath` S3 key."
          },
          "logoExpiresAt": {
            "type": "string",
            "format": "date-time",
            "description": "ISO-8601 UTC expiry of `logoUrl`. Refresh the checkout context before this moment."
          },
          "fontFamily": {
            "$ref": "#/components/schemas/CheckoutFontFamily"
          },
          "inputStyle": {
            "allOf": [
              {
                "$ref": "#/components/schemas/CheckoutInputStyle"
              }
            ],
            "description": "Corner radius preset for checkout inputs (`rounded` maps to 8px, `square` to 0)."
          }
        }
      },
      "PublicCheckoutDiscount": {
        "type": "object",
        "required": [
          "code",
          "discountAmount",
          "billingPeriod",
          "billingPeriodLength",
          "billingPeriodUnit"
        ],
        "properties": {
          "code": {
            "type": "string",
            "description": "Buyer-entered code stored on the order. Never the processor promo id."
          },
          "discountAmount": {
            "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
          },
          "billingPeriod": {
            "type": "string",
            "description": "once | repeating | forever"
          },
          "billingPeriodLength": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "billingPeriodUnit": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "CheckoutInvoiceNotPayableDetails": {
        "type": "object",
        "required": ["status"],
        "properties": {
          "status": {
            "$ref": "#/components/schemas/PublicInvoiceCheckoutStatus"
          }
        },
        "description": "Only the invoice status. No amount, number, due date, or merchant id."
      },
      "PublicCheckoutRenewalTaxPreview": {
        "type": "object",
        "required": ["subtotal", "taxAmount", "total"],
        "properties": {
          "subtotal": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ],
            "description": "Renewal price before tax, in major units. When taxBehavior is inclusive, this price already includes the tax."
          },
          "taxAmount": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ],
            "description": "Estimated tax on each renewal charge, in major units."
          },
          "total": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ],
            "description": "Estimated amount of each renewal charge, in major units."
          }
        }
      },
      "PublicCheckoutTaxAddress": {
        "type": "object",
        "required": ["country"],
        "properties": {
          "country": {
            "type": "string",
            "description": "Two-letter country code, such as US."
          },
          "state": {
            "type": "string",
            "description": "State or region, such as NY. Required for tax in most of the United States."
          },
          "postalCode": {
            "type": "string",
            "description": "Postal or ZIP code, such as 10001."
          },
          "city": {
            "type": "string",
            "description": "City name."
          },
          "line1": {
            "type": "string",
            "description": "Street address."
          }
        }
      },
      "PublicCheckoutTaxId": {
        "type": "object",
        "required": ["type", "value"],
        "properties": {
          "type": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PublicCheckoutTaxIdType"
              }
            ],
            "description": "Kind of business tax ID, such as eu_vat, gb_vat, or us_ein."
          },
          "value": {
            "type": "string",
            "description": "The tax ID the buyer entered, such as a VAT number."
          }
        }
      },
      "PublicCheckoutPaymentMethodSessionStatus": {
        "type": "string",
        "enum": ["open", "requires_action", "processing", "succeeded", "failed", "expired"],
        "description": "`open` waits for the buyer to submit a card. `requires_action`: pass `clientSecret` to the payment elements' `handleNextAction`, then confirm again. `processing`: confirm again shortly. `succeeded`: the card is saved, and `paymentMethodId` names it. `failed`: see `failureCode`. `expired`: open a new session; a session the buyer or the payment provider had not finished 24 hours after it was opened expires too. A session moves on only when the embed confirms it, so if the buyer leaves during 3-D Secure or while the payment provider is still processing, it can end `expired` even though the card was saved; the merchant's server finds it among the customer's saved cards."
      },
      "PublicApiOwnMerchant": {
        "type": "object",
        "required": ["merchantId", "name", "role"],
        "properties": {
          "merchantId": {
            "type": "string"
          },
          "name": {
            "type": "string",
            "description": "Business name as submitted on create, without the stored suffix."
          },
          "role": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PublicApiTeamRole"
              }
            ],
            "description": "The signed-in user's team role on this merchant."
          }
        }
      },
      "PublicApiMerchantActivation": {
        "type": "object",
        "required": ["status", "identityVerification"],
        "properties": {
          "status": {
            "type": "string",
            "enum": ["not_provisioned", "pending", "verification_pending", "active"],
            "description": "Go-live progress: `not_provisioned` (no payment account yet), `pending` (payment account created, go-live not recorded and identity verification not submitted), `verification_pending` (live, identity verification not complete), `active` (live and identity verified). A merchant counts as live once go-live is recorded or identity verification has been submitted. Follow the seller's identity verification with `identityVerification`."
          },
          "identityVerification": {
            "type": "string",
            "enum": ["not_started", "pending", "in_review", "verified", "rejected"],
            "description": "Identity verification (KYC) state. `not_started` until the owner starts identity verification in the dashboard."
          }
        }
      },
      "PublicApiBalanceCurrencyBreakdown": {
        "type": "object",
        "required": ["currency", "available", "pending", "reserve", "total", "isNegative"],
        "properties": {
          "currency": {
            "$ref": "#/components/schemas/SharedTypes.CurrencyCode"
          },
          "available": {
            "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
          },
          "pending": {
            "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
          },
          "reserve": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ],
            "description": "Funds held back by the payment provider against refunds and disputes. Not available to pay out yet. Included in `total`."
          },
          "total": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ],
            "description": "Sum of `available`, `pending`, and `reserve`."
          },
          "isNegative": {
            "type": "boolean"
          }
        }
      },
      "PublicApiCheckoutCustomization": {
        "type": "object",
        "properties": {
          "themeMode": {
            "type": "string",
            "enum": ["light", "dark"]
          },
          "backgroundColor": {
            "type": "string"
          },
          "buttonColor": {
            "type": "string"
          },
          "buttonTextColor": {
            "type": "string"
          },
          "fontColor": {
            "type": "string",
            "description": "Primary body/content text color for the merchant product panel."
          },
          "logoUrl": {
            "type": "string",
            "description": "Presigned URL resolved on the read side from the stored logo."
          },
          "logoExpiresAt": {
            "type": "string",
            "format": "date-time",
            "description": "ISO-8601 UTC expiry of `logoUrl`."
          },
          "fontFamily": {
            "type": "string",
            "enum": ["Inter", "Roboto"]
          },
          "inputStyle": {
            "type": "string",
            "enum": ["rounded", "square"],
            "description": "Corner radius preset for checkout inputs (`rounded` maps to 8px, `square` to 0)."
          }
        }
      },
      "PublicApiCheckoutCustomizationPatch": {
        "type": "object",
        "properties": {
          "themeMode": {
            "type": "string",
            "enum": ["light", "dark"],
            "nullable": true
          },
          "backgroundColor": {
            "type": "string",
            "nullable": true
          },
          "buttonColor": {
            "type": "string",
            "nullable": true
          },
          "buttonTextColor": {
            "type": "string",
            "nullable": true
          },
          "fontColor": {
            "type": "string",
            "nullable": true
          },
          "fontFamily": {
            "type": "string",
            "enum": ["Inter", "Roboto"],
            "nullable": true
          },
          "inputStyle": {
            "type": "string",
            "enum": ["rounded", "square"],
            "nullable": true
          }
        }
      },
      "PublicApiPaymentMethodSessionStatus": {
        "type": "string",
        "enum": ["open", "requires_action", "processing", "succeeded", "failed", "expired"],
        "description": "`open` waits for the buyer to submit a card. `requires_action` waits for the buyer's next step, such as 3-D Secure. `processing` waits for the payment provider to save the card. `succeeded`: the card is saved, and `paymentMethodId` names it. `failed`: see `failureCode`. `expired`: no card was submitted before `expiresAt`, or the buyer or the payment provider had not finished saving it 24 hours after the session was opened. A session moves on only when the embed confirms it, so if the buyer leaves during 3-D Secure or while the payment provider is still processing, it can end `expired` even though the card was saved: check GET `/v1/public-api/merchants/{merchantId}/customers/{customerId}/payment-methods` for the customer's saved cards."
      },
      "PublicApiSavedPaymentMethod": {
        "type": "object",
        "required": ["id", "brand", "last4", "expMonth", "expYear", "isDefault"],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Payments AI id of the saved card. Send it as `paymentMethodId` to set a subscription's card. It stays the same across reads."
          },
          "brand": {
            "type": "string",
            "nullable": true,
            "description": "Card network, for example `visa` or `mastercard`. Null when it could not be determined."
          },
          "last4": {
            "type": "string",
            "nullable": true,
            "description": "Last four digits of the card number."
          },
          "expMonth": {
            "type": "integer",
            "format": "int32",
            "nullable": true,
            "description": "Expiry month, 1 to 12."
          },
          "expYear": {
            "type": "integer",
            "format": "int32",
            "nullable": true,
            "description": "Expiry year in four digits, for example 2033."
          },
          "isDefault": {
            "type": "boolean",
            "description": "True when this card is the card of at least one of the customer's subscriptions that has not ended (`active`, `trialing` or `canceling`), as set with POST `/v1/public-api/merchants/{merchantId}/subscriptions/{subscriptionId}/payment-method`. A card used at checkout and never set through the API reads false: the payment provider does not report which card a subscription renews on."
          }
        },
        "description": "A customer's saved card. Never the card number or a payment provider secret."
      },
      "PublicApiDiscountCodeListItem": {
        "type": "object",
        "required": [
          "id",
          "internalName",
          "scopeLabel",
          "code",
          "status",
          "promoType",
          "amountOff",
          "currency",
          "amountDisplay",
          "billingPeriod",
          "billingPeriodLength",
          "billingPeriodUnit",
          "billingPeriodLabel",
          "expiresAt",
          "productId",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "internalName": {
            "type": "string"
          },
          "scopeLabel": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/PublicApiDiscountCodeStatus"
          },
          "promoType": {
            "$ref": "#/components/schemas/PublicApiDiscountPromoType"
          },
          "amountOff": {
            "type": "string",
            "description": "Decimal string. A flat amount uses its currency's minor units, for example \"10.00\" usd or \"500\" jpy; a percentage has two decimals, for example \"20.00\"."
          },
          "currency": {
            "type": "string",
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.CurrencyCode"
              }
            ],
            "nullable": true
          },
          "amountDisplay": {
            "type": "string"
          },
          "billingPeriod": {
            "$ref": "#/components/schemas/PublicApiDiscountBillingPeriod"
          },
          "billingPeriodLength": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "billingPeriodUnit": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PublicApiDiscountBillingPeriodUnit"
              }
            ],
            "nullable": true
          },
          "billingPeriodLabel": {
            "type": "string"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "productId": {
            "type": "string",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PaginationMeta": {
        "type": "object",
        "required": ["totalRecords", "totalPages", "currentPage", "limit"],
        "properties": {
          "totalRecords": {
            "type": "integer",
            "format": "int32"
          },
          "totalPages": {
            "type": "integer",
            "format": "int32"
          },
          "currentPage": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          }
        }
      },
      "PublicApiDiscountBillingPeriodUnit": {
        "type": "string",
        "enum": ["day", "week", "month", "year"]
      },
      "PublicApiDiscountAmountOff": {
        "type": "string",
        "description": "Decimal string, for example \"20\" or \"10.50\". A JSON number is also accepted."
      },
      "PublicApiTeamRole": {
        "type": "string",
        "enum": ["owner", "admin", "editor", "viewer"]
      },
      "PublicApiTeamMemberStatus": {
        "type": "string",
        "enum": ["active"]
      },
      "BillingPeriod": {
        "type": "string",
        "enum": ["day", "week", "month", "year"]
      },
      "PublicApiOrderItemResponse": {
        "type": "object",
        "required": ["label", "unitPrice", "quantity", "lineTotal", "itemType"],
        "properties": {
          "label": {
            "type": "string"
          },
          "unitPrice": {
            "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
          },
          "quantity": {
            "type": "integer",
            "format": "int32",
            "minimum": 1
          },
          "lineTotal": {
            "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
          },
          "itemType": {
            "$ref": "#/components/schemas/PublicApiOrderItemType"
          },
          "billingPeriod": {
            "$ref": "#/components/schemas/BillingPeriod"
          },
          "periodLength": {
            "type": "integer",
            "format": "int32",
            "minimum": 1
          }
        },
        "description": "One line returned after create or merchant read."
      },
      "PublicApiOrderStatus": {
        "type": "string",
        "enum": ["open", "completed", "expired"],
        "description": "Payment lifecycle for a merchant order read. `open` includes unpaid and paid-awaiting-webhook (checkout confirmed, transaction row not yet linked)."
      },
      "PublicApiCreateOrderPlanItem": {
        "type": "object",
        "required": ["planId", "quantity"],
        "properties": {
          "planId": {
            "type": "string"
          },
          "quantity": {
            "type": "integer",
            "format": "int32",
            "minimum": 1,
            "maximum": 10000
          }
        },
        "description": "Catalogue line. Price comes from the plan. Do not send label or unitPrice on this shape."
      },
      "PublicApiCreateOrderCustomItem": {
        "type": "object",
        "required": ["label", "unitPrice", "quantity", "type"],
        "properties": {
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "unitPrice": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ],
            "maximum": 100000,
            "description": "Must be greater than 0 and at most 100000. unitPrice x quantity, and the order total, are also capped at 100000.",
            "minimum": 0,
            "exclusiveMinimum": true
          },
          "quantity": {
            "type": "integer",
            "format": "int32",
            "minimum": 1,
            "maximum": 10000
          },
          "type": {
            "$ref": "#/components/schemas/PublicApiOrderItemType"
          },
          "billingPeriod": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BillingPeriod"
              }
            ],
            "description": "Required when type is recurring. Omit for one_time."
          },
          "periodLength": {
            "type": "integer",
            "format": "int32",
            "minimum": 1,
            "maximum": 365,
            "description": "Required when type is recurring. Omit for one_time. At most one year of billingPeriod: 365 day, 52 week, 12 month, 1 year."
          },
          "trialPeriodDays": {
            "type": "integer",
            "format": "int32",
            "minimum": 1,
            "maximum": 730,
            "description": "Optional free trial in days for recurring custom lines only. Omit when there is no trial. At most 730 days. When set, amountDue today can be 0 until the trial ends. All recurring lines in the order must use the same trial length."
          }
        },
        "description": "Caller-priced line. Accepted only on this API-key route. When type is recurring, send both billingPeriod and periodLength. Omit both for one_time."
      },
      "PublicApiCreateOrderInvoiceItem": {
        "type": "object",
        "required": ["invoiceId"],
        "properties": {
          "invoiceId": {
            "type": "string"
          }
        },
        "description": "Invoice line. The price comes from the invoice. Send only invoiceId. The invoice must be open or past due, have a positive amount, and belong to this merchant."
      },
      "PublicApiPayoutMethodItem": {
        "type": "object",
        "required": [
          "id",
          "externalPayoutMethodId",
          "currency",
          "accountReference",
          "institutionName",
          "nickname",
          "destinationCategory",
          "destinationCountryCode",
          "destinationName",
          "isDefault"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "externalPayoutMethodId": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "accountReference": {
            "type": "string",
            "nullable": true
          },
          "institutionName": {
            "type": "string",
            "nullable": true
          },
          "nickname": {
            "type": "string",
            "nullable": true
          },
          "destinationCategory": {
            "type": "string",
            "nullable": true
          },
          "destinationCountryCode": {
            "type": "string",
            "nullable": true
          },
          "destinationName": {
            "type": "string",
            "nullable": true
          },
          "isDefault": {
            "type": "boolean"
          }
        }
      },
      "PublicApiProductListItem": {
        "type": "object",
        "required": [
          "id",
          "name",
          "status",
          "variantCount",
          "types",
          "pricing",
          "revenueSummary",
          "checkoutUrl",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/ProductStatus"
          },
          "variantCount": {
            "type": "integer",
            "format": "int32"
          },
          "types": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PlanType"
            }
          },
          "pricing": {
            "$ref": "#/components/schemas/ProductListPricing"
          },
          "revenueSummary": {
            "$ref": "#/components/schemas/ProductRevenueSummary"
          },
          "checkoutUrl": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "activeSubscriptionCount": {
            "type": "integer",
            "format": "int32",
            "description": "Active subscriptions billed against this product; used for archive warning and delete gating"
          },
          "canPermanentlyDelete": {
            "type": "boolean",
            "description": "True when the product is a draft with zero sales and zero active subscriptions"
          }
        }
      },
      "PublicApiPlanVariant": {
        "type": "object",
        "required": [
          "id",
          "productId",
          "name",
          "type",
          "billingPeriod",
          "lengthOfBillingPeriod",
          "amount",
          "initialPrice",
          "currency",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "productId": {
            "type": "string"
          },
          "name": {
            "type": "string",
            "maxLength": 30,
            "description": "Merchant-facing display name for the variant (e.g. Pro, Monthly)."
          },
          "description": {
            "type": "string",
            "nullable": true,
            "maxLength": 80
          },
          "type": {
            "$ref": "#/components/schemas/PlanType"
          },
          "billingPeriod": {
            "$ref": "#/components/schemas/BillingPeriod"
          },
          "lengthOfBillingPeriod": {
            "type": "integer",
            "format": "int32"
          },
          "amount": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ],
            "description": "Strictly flat pricing amount"
          },
          "initialPrice": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ],
            "description": "Amount charged at checkout today. Zero for recurring plans with a free trial; otherwise matches amount."
          },
          "currency": {
            "$ref": "#/components/schemas/SharedTypes.CurrencyCode"
          },
          "freeTrial": {
            "type": "integer",
            "format": "int32"
          },
          "taxBehavior": {
            "type": "string",
            "enum": ["exclusive", "inclusive"],
            "nullable": true,
            "description": "Per-plan override when set; otherwise inherits merchant default."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreateBillingPeriod": {
        "type": "string",
        "enum": ["week", "month", "year"],
        "description": "Billing periods allowed when creating a new plan (daily is excluded for new plans)."
      },
      "PublicApiSubMerchant": {
        "type": "object",
        "required": ["merchantId", "parentMerchantId", "name", "createdAt"],
        "properties": {
          "merchantId": {
            "type": "string",
            "description": "Payments AI id of the sub-merchant."
          },
          "parentMerchantId": {
            "type": "string",
            "description": "Payments AI id of the parent merchant that owns this sub-merchant."
          },
          "name": {
            "type": "string",
            "description": "Business name, without the stored suffix."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PublicApiSubscriptionCancelMode": {
        "type": "string",
        "enum": ["immediately", "at_period_end"],
        "description": "`immediately` ends access now. `at_period_end` keeps access until `currentPeriodEnd`, then ends it instead of renewing."
      },
      "PublicApiCreateTransactionRecurring": {
        "type": "object",
        "required": ["amount", "intervalDays"],
        "properties": {
          "amount": {
            "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
          },
          "intervalDays": {
            "type": "integer",
            "format": "int32",
            "minimum": 2
          },
          "trialDays": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          }
        }
      },
      "PublicApiTransactionListItem": {
        "type": "object",
        "required": [
          "id",
          "transactionId",
          "date",
          "amountGross",
          "currencyGross",
          "amountIsProvisional",
          "orderId"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Canonical merchant-facing transaction id (internal UUID v7)."
          },
          "transactionId": {
            "type": "string",
            "description": "Deprecated payment provider id (`pay_…`). Removed on 2027-01-15.",
            "deprecated": true
          },
          "date": {
            "type": "string",
            "format": "date-time"
          },
          "method": {
            "$ref": "#/components/schemas/PublicApiTransactionMethod"
          },
          "amountGross": {
            "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
          },
          "currencyGross": {
            "$ref": "#/components/schemas/SharedTypes.CurrencyCode"
          },
          "amountIsProvisional": {
            "type": "boolean",
            "description": "True while `amountGross` is provisional: the payment provider sent a refund event before the payment's success event, without the sale total or currency, so the amount is a lower bound or the currency a placeholder. Becomes `false` when the payment succeeds and its final amount replaces the provisional one."
          },
          "amountNet": {
            "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
          },
          "currencyNet": {
            "$ref": "#/components/schemas/SharedTypes.CurrencyCode"
          },
          "status": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "errorReason": {
            "type": "string"
          },
          "orderId": {
            "type": "string",
            "nullable": true,
            "description": "Order this payment paid for; `null` when the payment is not tied to an order."
          }
        }
      },
      "PublicApiTransactionMethod": {
        "type": "object",
        "properties": {
          "scheme": {
            "type": "string"
          },
          "lastFour": {
            "type": "string"
          }
        }
      },
      "PublicApiTransactionBreakdown": {
        "type": "object",
        "required": [
          "gross",
          "grossCurrency",
          "refundedAmount",
          "refundedCurrency",
          "remainingRefundable"
        ],
        "properties": {
          "gross": {
            "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
          },
          "grossCurrency": {
            "$ref": "#/components/schemas/SharedTypes.CurrencyCode"
          },
          "refundedAmount": {
            "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
          },
          "refundedCurrency": {
            "$ref": "#/components/schemas/SharedTypes.CurrencyCode"
          },
          "remainingRefundable": {
            "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
          },
          "net": {
            "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
          },
          "netCurrency": {
            "$ref": "#/components/schemas/SharedTypes.CurrencyCode"
          }
        }
      },
      "PublicApiTransactionHistoryEvent": {
        "type": "object",
        "required": ["event", "timestamp"],
        "properties": {
          "event": {
            "type": "string"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          },
          "id": {
            "type": "string"
          },
          "amount": {
            "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
          },
          "currency": {
            "$ref": "#/components/schemas/SharedTypes.CurrencyCode"
          },
          "type": {
            "type": "string"
          },
          "triggeredBy": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "details": {
            "type": "string"
          },
          "occurredAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PublicApiTransactionRefund": {
        "type": "object",
        "required": ["id", "amount", "currency", "refundedAt"],
        "properties": {
          "id": {
            "type": "string",
            "description": "Payments AI refund id (internal UUID v7). `payment.refunded` carries the same id as `refundId`."
          },
          "amount": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
              }
            ],
            "description": "Amount of this refund, in `currency`."
          },
          "currency": {
            "$ref": "#/components/schemas/SharedTypes.CurrencyCode"
          },
          "refundedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the refund was made."
          }
        }
      },
      "WebhookListenSessionSummary": {
        "type": "object",
        "required": ["sessionId", "events", "expiresAt", "connected", "createdAt"],
        "properties": {
          "sessionId": {
            "type": "string"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "payment.completed",
                "payment.refunded",
                "payment.failed",
                "customer.created",
                "subscription.created",
                "subscription.cancelled",
                "subscription.updated",
                "subscription.cancellation_scheduled",
                "subscription.cancellation_undone",
                "subscription.payment_method_updated",
                "dispute.created",
                "dispute.updated",
                "dispute.won",
                "dispute.lost",
                "dispute.alert_created",
                "payout.sent",
                "merchant.owner_attached",
                "merchant.kyc.updated"
              ]
            },
            "nullable": true
          },
          "expiresAt": {
            "type": "string"
          },
          "connected": {
            "type": "boolean"
          },
          "createdAt": {
            "type": "string"
          }
        }
      },
      "PublicOrderItemType": {
        "type": "string",
        "enum": ["one_time", "recurring"]
      },
      "CheckoutThemeMode": {
        "type": "string",
        "enum": ["light", "dark"]
      },
      "CheckoutFontFamily": {
        "type": "string",
        "enum": ["Inter", "Roboto"]
      },
      "CheckoutInputStyle": {
        "type": "string",
        "enum": ["rounded", "square"]
      },
      "PublicInvoiceCheckoutStatus": {
        "type": "string",
        "enum": ["draft", "open", "paid", "past_due", "uncollectible", "void"]
      },
      "PublicCheckoutTaxIdType": {
        "type": "string",
        "enum": [
          "ad_nrt",
          "ao_tin",
          "ar_cuit",
          "al_tin",
          "am_tin",
          "aw_tin",
          "au_abn",
          "au_arn",
          "eu_vat",
          "az_tin",
          "bs_tin",
          "bh_vat",
          "bd_bin",
          "bb_tin",
          "by_tin",
          "bj_ifu",
          "bo_tin",
          "ba_tin",
          "br_cnpj",
          "br_cpf",
          "bg_uic",
          "bf_ifu",
          "kh_tin",
          "cm_niu",
          "ca_bn",
          "ca_gst_hst",
          "ca_pst_bc",
          "ca_pst_mb",
          "ca_pst_sk",
          "ca_qst",
          "cv_nif",
          "cl_tin",
          "cn_tin",
          "co_nit",
          "cd_nif",
          "cr_tin",
          "hr_oib",
          "do_rcn",
          "ec_ruc",
          "eg_tin",
          "sv_nit",
          "et_tin",
          "eu_oss_vat",
          "ge_vat",
          "gh_tin",
          "de_stn",
          "gb_vat",
          "gn_nif",
          "hk_br",
          "hu_tin",
          "is_vat",
          "in_gst",
          "id_npwp",
          "il_vat",
          "jp_cn",
          "jp_rn",
          "jp_trn",
          "kz_bin",
          "ke_pin",
          "kg_tin",
          "la_tin",
          "li_uid",
          "li_vat",
          "my_frp",
          "my_itn",
          "my_sst",
          "mr_nif",
          "mx_rfc",
          "md_vat",
          "me_pib",
          "ma_vat",
          "np_pan",
          "nz_gst",
          "ng_tin",
          "mk_vat",
          "no_vat",
          "no_voec",
          "om_vat",
          "pe_ruc",
          "ph_tin",
          "ro_tin",
          "ru_inn",
          "ru_kpp",
          "sa_vat",
          "sn_ninea",
          "rs_pib",
          "sg_gst",
          "sg_uen",
          "si_tin",
          "za_vat",
          "kr_brn",
          "es_cif",
          "ch_uid",
          "ch_vat",
          "tw_vat",
          "tj_tin",
          "tz_vat",
          "th_vat",
          "tr_tin",
          "ug_tin",
          "ua_vat",
          "ae_trn",
          "us_ein",
          "uy_ruc",
          "uz_tin",
          "uz_vat",
          "ve_rif",
          "vn_tin",
          "zm_tin",
          "zw_tin",
          "sr_fin"
        ]
      },
      "PublicApiOrderItemType": {
        "type": "string",
        "enum": ["one_time", "recurring"]
      },
      "ProductListPricing": {
        "type": "object",
        "required": ["minPrice", "maxPrice", "currency", "billingLabel", "items"],
        "properties": {
          "minPrice": {
            "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
          },
          "maxPrice": {
            "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
          },
          "currency": {
            "$ref": "#/components/schemas/SharedTypes.CurrencyCode"
          },
          "billingLabel": {
            "type": "string"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProductListPricingItem"
            }
          }
        }
      },
      "ProductRevenueSummary": {
        "type": "object",
        "required": ["totalRevenue", "currency", "totalSalesCount"],
        "properties": {
          "totalRevenue": {
            "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
          },
          "currency": {
            "$ref": "#/components/schemas/SharedTypes.CurrencyCode"
          },
          "totalSalesCount": {
            "type": "integer",
            "format": "int32"
          }
        }
      },
      "ProductListPricingItem": {
        "type": "object",
        "required": ["planId", "name", "amount", "currency", "type", "checkoutUrl", "isPrimary"],
        "properties": {
          "planId": {
            "type": "string"
          },
          "name": {
            "type": "string",
            "description": "Merchant-facing display name of the plan variant."
          },
          "amount": {
            "$ref": "#/components/schemas/SharedTypes.MoneyAmountValue"
          },
          "currency": {
            "$ref": "#/components/schemas/SharedTypes.CurrencyCode"
          },
          "type": {
            "$ref": "#/components/schemas/PlanType"
          },
          "billingPeriod": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BillingPeriod"
              }
            ],
            "description": "Billing cadence. Present only for recurring plans; omitted for one-time and free-access."
          },
          "lengthOfBillingPeriod": {
            "type": "integer",
            "format": "int32",
            "description": "Multiplier for the billing period. Present only for recurring plans; omitted for one-time and free-access."
          },
          "freeTrial": {
            "type": "integer",
            "format": "int32",
            "description": "Remaining trial days when a trial is active. Omitted otherwise."
          },
          "checkoutUrl": {
            "type": "string"
          },
          "isPrimary": {
            "type": "boolean",
            "description": "True for the single plan the product-level checkoutUrl points to; false for all others."
          }
        }
      }
    },
    "securitySchemes": {
      "UserOAuthCredentialAuth": {
        "type": "http",
        "scheme": "Bearer",
        "description": "Signed-in user OAuth credential (`pai_mcp_*`) issued through the dashboard consent screen for this API: the authorization and token requests name the RFC 8707 resource `<API_URL>/v1/public-api` (ADR-0020). Credentials issued for the MCP server, or for no resource, are rejected with 401 `auth.invalid_token` and `WWW-Authenticate: Bearer resource_metadata=\"<API_URL>/.well-known/oauth-protected-resource/v1/public-api\", error=\"invalid_token\"`. Valid on the environment that issued it only. Each operation that accepts it names one required permission; a missing permission is 403 `auth.insufficient_scope` with `WWW-Authenticate: Bearer error=\"insufficient_scope\", scope=\"<permission>\"`. A merchant outside the user's active memberships is 403 `merchant.access_forbidden`; a team role below the operation's minimum is 403 `team.role_forbidden`."
      },
      "MerchantApiKeyAuth": {
        "type": "http",
        "scheme": "Bearer",
        "description": "Merchant API key from Developer Tools → API Keys. Example: `Authorization: Bearer pai_test_...`. Also accepted for any active sub-merchant this key's own merchant created."
      }
    }
  },
  "tags": [
    {
      "name": "Merchant",
      "description": "Platform onboarding and merchant team operations — create sub-merchants and assign active members of your team onto merchants you manage."
    },
    {
      "name": "API Keys",
      "description": "List, create, and revoke Merchant API keys for your merchant or any sub-merchant in your allowed set."
    },
    {
      "name": "Products"
    },
    {
      "name": "Checkout"
    },
    {
      "name": "Orders"
    },
    {
      "name": "Subscriptions"
    },
    {
      "name": "Customers"
    },
    {
      "name": "Invoices"
    },
    {
      "name": "Transactions"
    },
    {
      "name": "Buyer checkout"
    },
    {
      "name": "API"
    }
  ]
}
