{
  "openapi": "3.1.0",
  "info": {
    "title": "Herbert & Phyllis Public Commerce API",
    "version": "2026-06-14",
    "description": "Public API for AI agents to discover Herbert & Phyllis products (memorial trees planted in Israel and kosher comfort baskets) and create a Stripe Checkout link. NOTE: creating a checkout returns a hosted Stripe URL that a HUMAN must open to complete payment. There is no autonomous-charge path. All prices are USD.",
    "contact": { "name": "Herbert & Phyllis", "email": "info@herbertandphyllis.com", "url": "https://www.herbertandphyllis.com" }
  },
  "servers": [{ "url": "https://www.herbertandphyllis.com" }],
  "paths": {
    "/api/catalog": {
      "get": {
        "operationId": "getCatalog",
        "summary": "List all active products",
        "description": "Returns the live, sanitized product catalog as JSON. Use the returned product 'name' and 'price' when building a checkout. Only public fields are exposed (no vendor, cost, or SKU data).",
        "responses": {
          "200": {
            "description": "The product catalog.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Catalog" } } }
          },
          "500": { "description": "Catalog unavailable.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    },
    "/api/coupon/validate": {
      "post": {
        "operationId": "validateCoupon",
        "summary": "Validate a coupon code",
        "description": "Checks a coupon code and (if order_total is supplied) returns the dollar discount it would apply. Use discount_amount with coupon_code when creating a checkout.",
        "requestBody": {
          "required": true,
          "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CouponRequest" }, "example": { "code": "SHIVA7", "order_total": 54 } } }
        },
        "responses": {
          "200": {
            "description": "Validation result (valid or invalid).",
            "content": { "application/json": { "schema": { "oneOf": [ { "$ref": "#/components/schemas/CouponValid" }, { "$ref": "#/components/schemas/CouponInvalid" } ] } } }
          }
        }
      }
    },
    "/api/delivery/estimate": {
      "post": {
        "operationId": "estimateDelivery",
        "summary": "Estimate delivery for non-tree products",
        "description": "Returns an arrival window and any shipping surcharge for shipping the given product IDs to a US ZIP code. Trees ship by certificate mail and do not use this endpoint.",
        "requestBody": {
          "required": true,
          "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DeliveryRequest" }, "example": { "zip": "11201", "productIds": ["basket"], "method": "standard" } } }
        },
        "responses": {
          "200": { "description": "Delivery estimate.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DeliveryResponse" } } } },
          "400": { "description": "Invalid request.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    },
    "/api/checkout": {
      "post": {
        "operationId": "createCheckout",
        "summary": "Create a Stripe Checkout link for a cart",
        "description": "Creates a Stripe Checkout Session and returns a payable URL. IMPORTANT: a human must open this URL and complete card entry on Stripe's hosted page. This call does NOT charge anyone and does NOT place a paid order. Provide a cart of line items plus sender and recipient details. After the human pays, the order is persisted and a receipt is emailed automatically.",
        "requestBody": {
          "required": true,
          "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CheckoutRequest" }, "example": { "cart": [ { "name": "Memorial Grove — 3 Trees in Israel", "price": 54, "quantity": 1 } ], "sender": { "name": "Jane Donor", "email": "jane@example.com" }, "recipient": { "name": "The Cohen Family", "address": "123 Main St", "city": "Brooklyn", "state": "NY", "zip": "11201" }, "shipping_method": "Certificate by Mail", "shipping_cost": 0, "message": "With deepest sympathy." } } }
        },
        "responses": {
          "200": { "description": "A payable Stripe Checkout URL for a human to complete.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CheckoutResponse" }, "example": { "url": "https://checkout.stripe.com/c/pay/cs_test_..." } } } },
          "503": { "description": "Payment processor not configured.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    },
    "/api/checkout/trees": {
      "post": {
        "operationId": "createTreeCheckout",
        "summary": "Create a Stripe Checkout link for a tree-in-Israel order",
        "description": "Dedicated checkout for trees planted in Israel (certificate delivery). Returns a payable Stripe URL a human must complete. Requires product_name, price (>= 0.50), sender_name, sender_email. Optional honoree and certificate-delivery fields personalize the certificate.",
        "requestBody": {
          "required": true,
          "content": { "application/json": { "schema": { "$ref": "#/components/schemas/TreeCheckoutRequest" }, "example": { "product_name": "1 Tree", "price": 18, "sender_name": "Jane Donor", "sender_email": "jane@example.com", "honoree_type": "In memory of", "honoree_name": "Sarah Cohen" } } }
        },
        "responses": {
          "200": { "description": "A payable Stripe Checkout URL.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CheckoutResponse" } } } },
          "400": { "description": "Missing required fields or price below minimum.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Error": {
        "type": "object",
        "additionalProperties": false,
        "properties": { "error": { "type": "string", "description": "Human-readable error message." } }
      },
      "Catalog": {
        "type": "object",
        "properties": {
          "store": { "type": "string" },
          "currency": { "type": "string", "example": "USD" },
          "updated_at": { "type": "string", "format": "date-time" },
          "count": { "type": "integer" },
          "products": { "type": "array", "items": { "$ref": "#/components/schemas/Product" } }
        }
      },
      "Product": {
        "type": "object",
        "properties": {
          "id": { "type": "string", "example": "tree-1" },
          "slug": { "type": "string", "example": "tree-in-israel" },
          "url": { "type": "string", "format": "uri" },
          "name": { "type": "string" },
          "description": { "type": "string" },
          "price": { "type": "number", "example": 18.0 },
          "currency": { "type": "string", "example": "USD" },
          "category": { "type": "string", "enum": ["Fruit & Nut Gifts", "Trees in Israel"] },
          "badge": { "type": ["string", "null"] },
          "availability": { "type": "string", "enum": ["in_stock", "out_of_stock"] },
          "image": { "type": ["string", "null"], "format": "uri" },
          "images": { "type": "array", "items": { "type": "string", "format": "uri" } },
          "is_tree": { "type": "boolean" },
          "fulfillment": { "type": "string", "enum": ["certificate", "local_delivery", "shipment"] },
          "shipping_method": { "type": "string", "enum": ["Certificate by Mail", "Ground Shipping"] },
          "free_standard_shipping": { "type": "boolean" }
        }
      },
      "CouponRequest": {
        "type": "object",
        "required": ["code"],
        "additionalProperties": false,
        "properties": {
          "code": { "type": "string", "description": "Coupon code, e.g. SHIVA7." },
          "order_total": { "type": "number", "description": "Order subtotal in USD; needed to compute the dollar discount." }
        }
      },
      "CouponValid": {
        "type": "object",
        "properties": {
          "valid": { "type": "boolean", "const": true },
          "discount_type": { "type": "string", "enum": ["percent", "fixed"] },
          "discount_value": { "type": "number" },
          "discount_amount": { "type": "number", "description": "Dollar discount to pass as discount_amount in createCheckout." },
          "description": { "type": "string" }
        }
      },
      "CouponInvalid": {
        "type": "object",
        "properties": { "valid": { "type": "boolean", "const": false }, "error": { "type": "string" } }
      },
      "DeliveryRequest": {
        "type": "object",
        "required": ["zip", "productIds", "method"],
        "additionalProperties": false,
        "properties": {
          "zip": { "type": "string", "description": "US ZIP code, e.g. 11201." },
          "productIds": { "type": "array", "items": { "type": "string" }, "description": "Catalog product IDs, e.g. [\"basket\"]." },
          "method": { "type": "string", "enum": ["standard", "2day", "overnight"] }
        }
      },
      "DeliveryResponse": {
        "type": "object",
        "properties": {
          "estimate": {
            "type": ["object", "null"],
            "properties": {
              "shipDate": { "type": "string" },
              "arrivalMin": { "type": "string" },
              "arrivalMax": { "type": "string" },
              "businessDays": { "type": "integer" },
              "surchargeCents": { "type": "integer", "description": "Shipping surcharge in cents. Divide by 100 for shipping_cost in createCheckout." },
              "zoneName": { "type": "string" },
              "vendorCity": { "type": "string" },
              "vendorState": { "type": "string" }
            }
          },
          "recipientState": { "type": ["string", "null"] }
        }
      },
      "CartItem": {
        "type": "object",
        "required": ["name", "price", "quantity"],
        "additionalProperties": false,
        "properties": {
          "name": { "type": "string", "description": "Product name exactly as returned by getCatalog." },
          "price": { "type": "number", "description": "Unit price in USD." },
          "quantity": { "type": "integer", "minimum": 1 }
        }
      },
      "Party": {
        "type": "object",
        "properties": {
          "name": { "type": "string" },
          "email": { "type": "string", "format": "email" }
        }
      },
      "Recipient": {
        "type": "object",
        "properties": {
          "name": { "type": "string" },
          "address": { "type": "string" },
          "apt": { "type": "string" },
          "city": { "type": "string" },
          "state": { "type": "string", "description": "2-letter US state code." },
          "zip": { "type": "string" },
          "phone": { "type": "string" }
        }
      },
      "CheckoutRequest": {
        "type": "object",
        "description": "Provide either cart[] (preferred) or product_name+price+quantity for a single item.",
        "properties": {
          "cart": { "type": "array", "items": { "$ref": "#/components/schemas/CartItem" } },
          "product_name": { "type": "string" },
          "price": { "type": "number" },
          "quantity": { "type": "integer", "minimum": 1 },
          "sender": { "$ref": "#/components/schemas/Party" },
          "recipient": { "$ref": "#/components/schemas/Recipient" },
          "shipping_method": { "type": "string", "example": "Certificate by Mail" },
          "shipping_cost": { "type": "number", "description": "USD; 0 for free standard shipping and for trees." },
          "message": { "type": "string", "description": "Condolence message for the family." },
          "coupon_code": { "type": "string" },
          "discount_amount": { "type": "number", "description": "Dollar discount from validateCoupon; send together with coupon_code." },
          "tax_amount": { "type": "number", "description": "NY sales tax in USD for non-tree NY orders; usually omit and let the site compute." },
          "cancel_path": { "type": "string" }
        }
      },
      "TreeCheckoutRequest": {
        "type": "object",
        "required": ["product_name", "price", "sender_name", "sender_email"],
        "properties": {
          "product_name": { "type": "string" },
          "price": { "type": "number", "minimum": 0.5 },
          "quantity": { "type": "integer", "minimum": 1 },
          "sender_name": { "type": "string" },
          "sender_email": { "type": "string", "format": "email" },
          "honoree_type": { "type": "string", "example": "In memory of" },
          "honoree_name": { "type": "string" },
          "honoree_message": { "type": "string" },
          "honoree_from": { "type": "string" },
          "cert_name": { "type": "string" },
          "cert_address": { "type": "string" },
          "cert_city": { "type": "string" },
          "cert_state": { "type": "string" },
          "cert_zip": { "type": "string" }
        }
      },
      "CheckoutResponse": {
        "type": "object",
        "properties": { "url": { "type": "string", "format": "uri", "description": "Stripe-hosted Checkout URL. Hand to a human to complete payment." } }
      }
    }
  }
}
