{
  "openapi": "3.0.3",
  "info": {
    "title": "Claude CMS agent payments",
    "version": "1.0",
    "description": "Create a hosted Stripe payment page for a store built on Claude CMS, on behalf of a human buyer. The agent never handles card details; the buyer pays on Stripe's page and the money settles in the merchant's own Stripe account. Guide: https://claudecms.com/agents"
  },
  "servers": [
    {
      "url": "https://claudecms.com/api/agent"
    }
  ],
  "paths": {
    "/checkout": {
      "post": {
        "summary": "Create a payment page (or quote it with preview)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateRequest"
              },
              "examples": {
                "products": {
                  "summary": "Buy products by SKU",
                  "value": {
                    "store": "example.com",
                    "items": [
                      {
                        "sku": "SKU-12345",
                        "quantity": 1
                      }
                    ],
                    "buyer_email": "sam@example.com",
                    "shipping_country": "US",
                    "agent": "MyAssistant/2.1"
                  }
                },
                "amount": {
                  "summary": "A plain amount",
                  "value": {
                    "store": "example-store",
                    "amount_pence": 4500,
                    "description": "Consultation, 12 October",
                    "buyer_email": "sam@example.com",
                    "reference": "consult-2026-10-12-sam"
                  }
                },
                "preview": {
                  "summary": "Quote first, create nothing",
                  "value": {
                    "store": "example.com",
                    "items": [
                      {
                        "handle": "example-product",
                        "quantity": 2
                      }
                    ],
                    "preview": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Checkout"
                    }
                  }
                }
              }
            }
          },
          "200": {
            "description": "Preview quote, or an existing open link returned for the same reference",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Quote"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "502": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "get": {
        "summary": "Status of a payment page (or the manifest when called with no parameters)",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "t",
            "in": "query",
            "description": "The token from the create response",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Checkout"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    }
  },
  "components": {
    "responses": {
      "Error": {
        "description": "Error",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "blockers": {
                  "type": "array",
                  "items": {
                    "type": "object"
                  }
                }
              }
            }
          }
        }
      }
    },
    "schemas": {
      "Item": {
        "type": "object",
        "properties": {
          "sku": {
            "type": "string"
          },
          "handle": {
            "type": "string",
            "description": "Product handle (URL slug). Add variant when the product has several."
          },
          "variant": {
            "type": "string",
            "description": "Option text or SKU that picks one variant of a handle"
          },
          "variant_id": {
            "type": "integer"
          },
          "quantity": {
            "type": "integer",
            "minimum": 1,
            "maximum": 999,
            "default": 1
          }
        }
      },
      "CreateRequest": {
        "type": "object",
        "required": [
          "store"
        ],
        "properties": {
          "store": {
            "type": "string",
            "description": "The merchant's website domain or Claude CMS store handle"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Item"
            },
            "description": "What to buy. Shipping and tax are added on the payment page from the store's own rates."
          },
          "amount_pence": {
            "type": "integer",
            "minimum": 100,
            "description": "Instead of items: the total to pay, in the store currency's minor unit (2500 = 25.00). Needs description."
          },
          "description": {
            "type": "string",
            "maxLength": 255
          },
          "buyer_email": {
            "type": "string",
            "format": "email"
          },
          "reference": {
            "type": "string",
            "maxLength": 80,
            "description": "Your own id for this payment; repeating it returns the same open link"
          },
          "shipping_country": {
            "type": "string",
            "description": "ISO 3166-1 alpha-2; defaults to where the store ships"
          },
          "success_url": {
            "type": "string",
            "format": "uri"
          },
          "cancel_url": {
            "type": "string",
            "format": "uri"
          },
          "agent": {
            "type": "string",
            "maxLength": 120,
            "description": "Your name/version; shown to the merchant on the order"
          },
          "preview": {
            "type": "boolean",
            "description": "Validate and quote; create nothing"
          }
        }
      },
      "Quote": {
        "type": "object",
        "properties": {
          "preview": {
            "type": "boolean"
          },
          "ready": {
            "type": "boolean"
          },
          "blockers": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "kind": {
            "type": "string",
            "enum": [
              "items",
              "amount"
            ]
          },
          "amount_pence": {
            "type": "integer"
          },
          "currency": {
            "type": "string"
          },
          "lines": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "merchant": {
            "type": "object"
          },
          "shipping_country": {
            "type": "string",
            "nullable": true
          },
          "note": {
            "type": "string"
          }
        }
      },
      "Checkout": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "token": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "paid",
              "expired",
              "cancelled",
              "failed"
            ]
          },
          "kind": {
            "type": "string"
          },
          "checkout_url": {
            "type": "string",
            "format": "uri",
            "nullable": true,
            "description": "Give this to the human. Single use; null once the link is no longer open."
          },
          "status_url": {
            "type": "string",
            "format": "uri"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "amount_pence": {
            "type": "integer"
          },
          "currency": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "lines": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "reference": {
            "type": "string",
            "nullable": true
          },
          "merchant": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "handle": {
                "type": "string"
              }
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "paid_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "order_number": {
            "type": "string",
            "nullable": true
          },
          "reused": {
            "type": "boolean"
          }
        }
      }
    }
  }
}