{
  "openapi": "3.1.0",
  "info": {
    "title": "Madely agent API",
    "version": "0.1.0",
    "summary": "Print-on-demand fulfillment an AI agent can use end to end: find a product, get an exact whole-dollar quote, place an order, track it.",
    "description": "Madely prints and ships custom products (shirts, hoodies, totes, mugs and more) made in the USA.\nThis is a v0 SANDBOX: a mock store, test orders only (your external_id must start with \"madely-smoketest-\"), payments run against a mock of Stripe (no real charges), nothing is printed or shipped.\n\nHow an agent uses it, with no human step:\n1. GET /v1/products?q=mug to find a product_id and its price_usd.\n2. POST /v1/quotes with items and ship_to. You get an itemized quote with whole-dollar product prices, shipping at carrier cost, a total and an estimated ship date.\n3. POST /v1/sandbox/keys to mint a test API key (no signup).\n4. Pick how to pay (GET /v1/payments): a Stripe Shared Payment Token your agent grants to Madely, a saved card (POST /v1/payment-methods), or a prepaid balance (POST /v1/balance/top-ups).\n5. POST /v1/orders with the quote_id, artwork URLs, payment and an Idempotency-Key. You are charged when the order is submitted, before production.\n6. GET /v1/orders/{order_id} for status and tracking. POST /v1/orders/{order_id}/cancel refunds an order that has not shipped.\n\nRules that never change: every product price is a whole dollar. The same input returns the same quote. Price = blank_cost_usd + flat_fee_usd. Shipping is added at carrier cost. No subscription. Volume tiers are published at /v1/pricing/tiers and are the same for everyone; there is no private negotiation.\nEvery error has a code, a plain sentence, the field (param) and a fix you can act on.",
    "termsOfService": "https://api.madely.ai/llms-full.txt#terms",
    "license": {
      "name": "Proprietary (test version)",
      "url": "https://api.madely.ai/terms"
    },
    "contact": {
      "name": "Madely",
      "url": "https://api.madely.ai/agents"
    }
  },
  "servers": [
    {
      "url": "https://api.madely.ai",
      "description": "This host (the URL you fetched this file from). v0 test version: sandbox only."
    }
  ],
  "tags": [
    {
      "name": "Discover",
      "description": "Find products and prices. No API key."
    },
    {
      "name": "Design",
      "description": "Preview artwork on a product, get a mockup and a print-ready file. No API key."
    },
    {
      "name": "Quote",
      "description": "Exact, repeatable prices. No API key."
    },
    {
      "name": "Order",
      "description": "Create and track orders. API key needed (mint one free)."
    },
    {
      "name": "Payment",
      "description": "How to pay, saved cards, prepaid balance."
    },
    {
      "name": "Sandbox",
      "description": "SANDBOX ONLY. Test helpers and infrastructure webhooks: /v1/sandbox/* and the Stripe webhook receiver. They exist only in the test version and are not part of the production contract. Agents placing real orders never call them."
    }
  ],
  "paths": {
    "/.well-known/api-catalog": {
      "get": {
        "tags": [
          "Discover"
        ],
        "operationId": "getApiCatalog",
        "summary": "API catalog (RFC 9727 linkset)",
        "description": "Machine-readable list of this publisher's APIs (REST and MCP) with links to the OpenAPI spec, docs and MCP descriptor. Content-Type is application/linkset+json with the RFC 9727 profile. No API key.",
        "responses": {
          "200": {
            "description": "Linkset",
            "content": {
              "application/linkset+json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "linkset"
                  ],
                  "properties": {
                    "linkset": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                },
                "example": {
                  "linkset": [
                    {
                      "anchor": "https://api.madely.ai/v1",
                      "service-desc": [
                        {
                          "href": "https://api.madely.ai/openapi.json",
                          "type": "application/json"
                        }
                      ]
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "not_found or unknown_product (error envelope with a fix)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/v1/products": {
      "get": {
        "tags": [
          "Discover"
        ],
        "operationId": "listProducts",
        "summary": "Search products with prices",
        "description": "Returns products with price_usd (a whole dollar), blank_cost_usd and flat_fee_usd. Filter by words, category, print_method, or max_price_usd. Use product_id in quotes and orders.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Words to match in name, category or sku, e.g. \"mug\" or \"hoodie black\".",
            "example": "mug"
          },
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "print_method",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "DTF, Sublimation, Laser/UV, Inkjet or Mixed."
          },
          {
            "name": "max_price_usd",
            "in": "query",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Use next_cursor from the previous page."
          }
        ],
        "responses": {
          "200": {
            "description": "Products",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProductList"
                }
              }
            }
          },
          "422": {
            "description": "Bad filter",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/v1/products/{product_id}": {
      "get": {
        "tags": [
          "Discover"
        ],
        "operationId": "getProduct",
        "summary": "Get one product (JSON, or schema.org JSON-LD)",
        "description": "Send \"Accept: application/ld+json\" or add \".jsonld\" to the path to get a schema.org Product with an Offer.",
        "parameters": [
          {
            "name": "product_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "K04"
          }
        ],
        "responses": {
          "200": {
            "description": "Product",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Product"
                }
              },
              "application/ld+json": {
                "schema": {
                  "type": "object",
                  "description": "schema.org Product with Offer"
                }
              }
            }
          },
          "404": {
            "description": "unknown_product",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/v1/pricing/tiers": {
      "get": {
        "tags": [
          "Discover"
        ],
        "operationId": "getPricingTiers",
        "summary": "Published volume tiers",
        "description": "Same for every merchant. Status \"draft_proposal_not_approved\" until the owner approves. A tier lowers a price only where there is room above that tier's minimum margin.",
        "responses": {
          "200": {
            "description": "Tiers",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Tiers"
                }
              }
            }
          },
          "404": {
            "description": "not_found or unknown_product (error envelope with a fix)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/v1/quotes": {
      "post": {
        "tags": [
          "Quote"
        ],
        "operationId": "createQuote",
        "summary": "Get an exact whole-dollar quote",
        "description": "Itemized product prices (whole dollars), shipping at carrier cost, total, estimated ship date and the tier applied. Deterministic: the same items, ship_to and tier return the same quote_id. Valid 24 hours. Send committed_monthly_items to price at a published tier.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuoteRequest"
              },
              "example": {
                "items": [
                  {
                    "product_id": "A29",
                    "quantity": 120
                  }
                ],
                "ship_to": {
                  "country": "US",
                  "zip": "80202"
                },
                "committed_monthly_items": 0
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Quote",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Quote"
                }
              }
            }
          },
          "422": {
            "description": "unknown_product, invalid_quantity, ship_to_zip_invalid, ship_to_country_unsupported and similar",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/v1/products/{product_id}/print-spec": {
      "get": {
        "tags": [
          "Discover"
        ],
        "operationId": "getPrintSpec",
        "summary": "Machine-readable print spec for one product (source of truth for template sizes)",
        "description": "Returns canvas_px, inches, dpi, bleed, trim_box_px, safe_zone, print_zones (wrap/curvature for mugs), color_mode, accepted_formats, max_file_mb, background, orientation, generation_hint (a prompt suffix for image models) and template_urls. \"source\" says how much to trust it: \"measured\" is confirmed; \"Madely product specs\" and \"industry standard, to verify\" are not yet confirmed. Product_id or sku both work.",
        "parameters": [
          {
            "name": "product_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "K04"
          }
        ],
        "responses": {
          "200": {
            "description": "Print spec",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrintSpec"
                }
              }
            }
          },
          "404": {
            "description": "unknown_product, or print_spec_not_available when no source has a print area for the product",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/print-specs.json": {
      "get": {
        "tags": [
          "Discover"
        ],
        "operationId": "listPrintSpecs",
        "summary": "Bulk print specs for every product, one file",
        "description": "All specs plus a by_source count and a list of products with no spec. Filter with ?category= or ?source=measured.",
        "parameters": [
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "source",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "measured",
                "Madely product specs",
                "industry standard, to verify"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Print specs",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "integer"
                    },
                    "by_source": {
                      "type": "object"
                    },
                    "unavailable": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "specs": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PrintSpec"
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "not_found or unknown_product (error envelope with a fix)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/schemas/print-spec.schema.json": {
      "get": {
        "tags": [
          "Discover"
        ],
        "operationId": "getPrintSpecSchema",
        "summary": "JSON Schema (2020-12) for a print spec",
        "description": "Validate or generate code against this schema.",
        "responses": {
          "200": {
            "description": "JSON Schema",
            "content": {
              "application/schema+json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "not_found or unknown_product (error envelope with a fix)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/v1/print-spec/validate": {
      "post": {
        "tags": [
          "Discover"
        ],
        "operationId": "validatePrintFile",
        "summary": "Validate a file URL or declared properties against a product's print spec",
        "description": "Send a url and/or width_px, height_px, format, file_size_mb, has_transparency, color_mode, content_bbox_px. Returns valid, per-check pass/warn/fail with expected, actual and fix, a fixes list, a placement fit (cover/contain, scale, crop) and, with preview:true, a preview_url (SVG of the file placed on the template). v0 does not download the file. No API key.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "product_id"
                ],
                "properties": {
                  "product_id": {
                    "type": "string",
                    "description": "product_id or sku"
                  },
                  "url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "placement": {
                    "type": "string"
                  },
                  "width_px": {
                    "type": "integer"
                  },
                  "height_px": {
                    "type": "integer"
                  },
                  "format": {
                    "type": "string",
                    "description": "png, jpg, pdf, svg or a mime type"
                  },
                  "file_size_mb": {
                    "type": "number"
                  },
                  "has_transparency": {
                    "type": "boolean"
                  },
                  "color_mode": {
                    "type": "string"
                  },
                  "content_bbox_px": {
                    "type": "object",
                    "properties": {
                      "x": {
                        "type": "integer"
                      },
                      "y": {
                        "type": "integer"
                      },
                      "width": {
                        "type": "integer"
                      },
                      "height": {
                        "type": "integer"
                      }
                    }
                  },
                  "fit": {
                    "type": "string",
                    "enum": [
                      "cover",
                      "contain",
                      "stretch"
                    ]
                  },
                  "preview": {
                    "type": "boolean"
                  }
                }
              },
              "example": {
                "product_id": "K04",
                "width_px": 2550,
                "height_px": 1155,
                "format": "png",
                "has_transparency": false,
                "preview": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Validation result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "valid": {
                      "type": "boolean"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "pass",
                        "warn",
                        "fail"
                      ]
                    },
                    "checks": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "fixes": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "fit": {
                      "type": "object"
                    },
                    "preview_url": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "unknown_product, nothing_to_check",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/v1/print-spec/preview.svg": {
      "get": {
        "tags": [
          "Discover"
        ],
        "operationId": "previewPlacement",
        "summary": "SVG preview of a file placed on the template",
        "description": "Draws the trim line, safe box and your https image placed per the fit. Same output as the template when no url is given.",
        "parameters": [
          {
            "name": "product_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "url",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uri"
            }
          },
          {
            "name": "width_px",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "height_px",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "fit",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "cover",
                "contain",
                "stretch"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "SVG",
            "content": {
              "image/svg+xml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "not_found or unknown_product (error envelope with a fix)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/templates/{product_id}.{ext}": {
      "get": {
        "tags": [
          "Discover"
        ],
        "operationId": "downloadTemplate",
        "summary": "Download a template (png, svg, pdf) or the spec (json), generated from the print spec",
        "description": "For humans and design tools. PNG is at full print resolution with trim, safe and bleed guides on a guide layer. Agents should use the JSON spec instead.",
        "parameters": [
          {
            "name": "product_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "ext",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "png",
                "svg",
                "pdf",
                "json"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The file"
          },
          "404": {
            "description": "unknown_product, print_spec_not_available",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/v1/previews": {
      "post": {
        "tags": [
          "Design"
        ],
        "operationId": "createPreview",
        "summary": "Preview artwork on a product (mockup image + print-file check)",
        "description": "Send a product, a color, front side and an artwork URL (or a design JSON). Returns a stable design_id, a mockup image URL (artwork shaded onto the real product photo), the print-ready file spec and a print_check (effective dpi, fits the print area, warnings). Warnings never block. Options: remove_background (true, or {tolerance}) uses a plain-backdrop colour key, not an AI cut-out; pattern {type: grid|half_drop|brick|mirror, scale: tile width as a fraction of the print area 0.05-1, gap_in, rotation_deg} repeats the artwork across the print area. Then order with items[].design_id instead of artwork. Front print only; the same request always returns the same design_id. No API key needed (rate limited).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "product"
                ],
                "properties": {
                  "product": {
                    "type": "string",
                    "description": "Slug, SKU or order product id from GET /v1/print-areas, e.g. gildan-64000 or A29."
                  },
                  "color": {
                    "type": "string"
                  },
                  "side": {
                    "type": "string",
                    "enum": [
                      "front"
                    ]
                  },
                  "artwork_url": {
                    "type": "string",
                    "description": "Public https URL (or a data: URI) to a PNG, JPEG, WebP or SVG up to 12 MB."
                  },
                  "design": {
                    "type": "object",
                    "description": "Alternative to artwork_url: {objects:[{type:\"image\"|\"text\"|\"shape\", x_in, y_in, width_in, height_in, rotation_deg, ...}]} in inches from the top-left of the print area."
                  },
                  "placement": {
                    "type": "object",
                    "properties": {
                      "width_in": {
                        "type": "number"
                      },
                      "x_in": {
                        "type": "number"
                      },
                      "y_in": {
                        "type": "number"
                      },
                      "scale": {
                        "type": "number"
                      },
                      "fit": {
                        "type": "string",
                        "enum": [
                          "contain",
                          "cover"
                        ]
                      },
                      "anchor": {
                        "type": "string",
                        "enum": [
                          "center",
                          "top"
                        ]
                      },
                      "rotation_deg": {
                        "type": "number"
                      }
                    }
                  },
                  "remove_background": {
                    "oneOf": [
                      {
                        "type": "boolean"
                      },
                      {
                        "type": "object",
                        "properties": {
                          "tolerance": {
                            "type": "integer"
                          }
                        }
                      }
                    ]
                  },
                  "pattern": {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "enum": [
                          "grid",
                          "half_drop",
                          "brick",
                          "mirror"
                        ]
                      },
                      "scale": {
                        "type": "number"
                      },
                      "gap_in": {
                        "type": "number"
                      },
                      "rotation_deg": {
                        "type": "number"
                      }
                    }
                  }
                }
              },
              "example": {
                "product": "gildan-64000",
                "color": "Black",
                "side": "front",
                "artwork_url": "https://example.com/logo.png",
                "placement": {
                  "width_in": 10
                },
                "remove_background": true
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Preview created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "design_id": {
                      "type": "string"
                    },
                    "mockup_url": {
                      "type": "string",
                      "nullable": true
                    },
                    "print_file_url": {
                      "type": "string"
                    },
                    "print_check": {
                      "type": "object",
                      "properties": {
                        "dpi": {
                          "type": "integer",
                          "nullable": true
                        },
                        "level": {
                          "type": "string",
                          "enum": [
                            "good",
                            "fair",
                            "low"
                          ],
                          "nullable": true
                        },
                        "fits": {
                          "type": "boolean"
                        },
                        "warnings": {
                          "type": "array",
                          "items": {
                            "type": "object"
                          }
                        }
                      }
                    },
                    "print_file": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "product_not_previewable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          },
          "422": {
            "description": "color_not_found, artwork_url_invalid, artwork_unreadable, side_not_supported, pattern_type_invalid, pattern_too_dense",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/v1/fonts": {
      "get": {
        "tags": [
          "Design"
        ],
        "operationId": "listFonts",
        "summary": "Typefaces available in the designer and for design JSON text objects",
        "description": "The same Google Fonts catalog the human designer uses (100+ families, official popularity order). Each entry has category, weights, italic availability and license. Server-side mockups and print files load the matching OFL (or other open) TTF on demand so print output matches the editor. Use family names in design.objects[].font.",
        "responses": {
          "200": {
            "description": "Font catalog"
          },
          "404": {
            "description": "not_found or unknown_product (error envelope with a fix)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/v1/print-areas": {
      "get": {
        "tags": [
          "Design"
        ],
        "operationId": "listPrintAreas",
        "summary": "Previewable products with print areas, colors and provisional flags",
        "description": "Print areas in inches and 300 dpi pixels per product and placement, with safe area, minimum dpi, confidence and provisional (unverified) flags. One record per product: GET /v1/print-areas/{slug} adds the per-color photo rectangles.",
        "responses": {
          "200": {
            "description": "Print areas"
          },
          "404": {
            "description": "not_found or unknown_product (error envelope with a fix)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/v1/mockups/{design_id}.png": {
      "get": {
        "tags": [
          "Design"
        ],
        "operationId": "getMockup",
        "summary": "Mockup image for a design",
        "parameters": [
          {
            "name": "design_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "PNG",
            "content": {
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "404": {
            "description": "design_not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/v1/designs/{design_id}/print-file.png": {
      "get": {
        "tags": [
          "Design"
        ],
        "operationId": "getPrintFile",
        "summary": "Print-ready PNG (transparent, 300 dpi) for a design",
        "parameters": [
          {
            "name": "design_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "PNG",
            "content": {
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "404": {
            "description": "design_not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/v1/files/check": {
      "post": {
        "tags": [
          "Order"
        ],
        "operationId": "checkPrintFile",
        "summary": "Check an artwork file before ordering",
        "description": "Same as POST /v1/print-spec/validate (kept for older clients). Checks the URL, file type, placement and the dimensions you declare against the product's print spec. It does not download the file in v0. Each check is pass, warn or fail with a fix.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "product_id",
                  "url"
                ],
                "properties": {
                  "product_id": {
                    "type": "string"
                  },
                  "url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "placement": {
                    "type": "string"
                  },
                  "width_px": {
                    "type": "integer"
                  },
                  "height_px": {
                    "type": "integer"
                  }
                }
              },
              "example": {
                "product_id": "A29",
                "url": "https://example.com/art.png",
                "placement": "front",
                "width_px": 3600,
                "height_px": 4800
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Check result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FileCheck"
                }
              }
            }
          },
          "422": {
            "description": "Bad input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/v1/sandbox/keys": {
      "post": {
        "tags": [
          "Sandbox"
        ],
        "operationId": "mintSandboxKey",
        "summary": "SANDBOX: Mint a test API key (no signup)",
        "description": "Returns a test-mode key. Works for test orders only. No human step.",
        "responses": {
          "201": {
            "description": "Key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "api_key": {
                      "type": "string"
                    },
                    "mode": {
                      "type": "string"
                    },
                    "scopes": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        },
        "x-sandbox-only": true,
        "security": []
      }
    },
    "/v1/orders": {
      "post": {
        "tags": [
          "Order"
        ],
        "operationId": "createOrder",
        "summary": "Create an order from a quote (test only in v0)",
        "description": "ETSY: send {source:\"etsy\", store_id, external_order_id (Etsy receipt id), items:[{sku, listing_id, variant_id?, quantity, variations?}], ship_to:{name,line1,city,state,zip}} instead of a quote; no Idempotency-Key needed, the Etsy receipt id is the key (a re-send returns the same order, re-checked while it is on hold); holds come back in plain English. Playbook: /agents/etsy.md. QUOTED ORDERS: Needs a quote_id (price is locked), your own external_id (must start with \"madely-smoketest-\" in the sandbox), artwork for every item, and an Idempotency-Key header so a retry never creates a duplicate: the same key and body returns the original order (header Idempotent-Replay: true); the same key with a different body is a 409. Print files are checked first; failures return 422 with the exact fix and no order is created. submit=false (default) creates a draft; submit=true pays and starts production. Payment is charged at submit: send payment as {method:\"agent_token\",shared_payment_token:\"spt_...\"}, {method:\"card_on_file\"} or {method:\"balance\"}; omit it to use the balance if it covers the order, else the card on file, else a 402 payment_required with a fix. If the charge fails, no order is created and you can retry with the same Idempotency-Key and a different payment. max_cost_usd refuses the order, and the charge, if the total is higher.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 120
            },
            "example": "madely-smoketest-key-001"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrderRequest"
              },
              "example": {
                "quote_id": "q_example",
                "external_id": "madely-smoketest-001",
                "submit": true,
                "max_cost_usd": 2000,
                "payment": {
                  "method": "agent_token",
                  "shared_payment_token": "spt_..."
                },
                "ship_to": {
                  "name": "Test Buyer",
                  "address1": "1 Test St",
                  "city": "Denver",
                  "state": "CO",
                  "zip": "80202",
                  "country": "US"
                },
                "items": [
                  {
                    "product_id": "A29",
                    "quantity": 120,
                    "artwork": [
                      {
                        "placement": "front",
                        "url": "https://example.com/art.png",
                        "width_px": 3600,
                        "height_px": 4800
                      }
                    ]
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Replay of an earlier identical request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Order"
                }
              }
            }
          },
          "201": {
            "description": "Order created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Order"
                }
              }
            }
          },
          "401": {
            "description": "api_key_required or api_key_invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          },
          "402": {
            "description": "payment_required, insufficient_balance, payment_failed, payment_requires_authentication, payment_token_amount_too_low, payment_token_expired, payment_token_deactivated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          },
          "403": {
            "description": "live_orders_disabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          },
          "409": {
            "description": "idempotency_key_reused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          },
          "410": {
            "description": "quote_expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          },
          "422": {
            "description": "print_file_check_failed, max_cost_exceeded, items_do_not_match_quote, artwork_required, payment_method_invalid, payment_token_invalid and similar",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      },
      "get": {
        "tags": [
          "Order"
        ],
        "operationId": "listOrders",
        "summary": "List your orders",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Orders",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "orders": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "api_key_required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/orders/{order_id}": {
      "get": {
        "tags": [
          "Order"
        ],
        "operationId": "getOrder",
        "summary": "Order status and tracking",
        "description": "status is draft, in_production, shipped, delivered or canceled. payment shows method, status (unpaid, succeeded, refunded, failed) and the Stripe payment_intent_id. tracking appears once shipped. events lists every change.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "order_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Order",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Order"
                }
              }
            }
          },
          "404": {
            "description": "order_not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/orders/{order_id}/submit": {
      "post": {
        "tags": [
          "Order"
        ],
        "operationId": "submitOrder",
        "summary": "Pay for and start production on a draft order",
        "description": "Charges now, before production. Body is optional: payment (same as create) and max_cost_usd. A paid order is never charged twice.",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "payment": {
                    "$ref": "#/components/schemas/PaymentRequest"
                  },
                  "max_cost_usd": {
                    "type": "number"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "order_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Order",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Order"
                }
              }
            }
          },
          "402": {
            "description": "payment_required, insufficient_balance, payment_failed and similar. The order stays a draft.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          },
          "409": {
            "description": "order_not_draft",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/orders/{order_id}/cancel": {
      "post": {
        "tags": [
          "Order"
        ],
        "operationId": "cancelOrder",
        "summary": "Cancel an order and refund it",
        "description": "Works for draft and in_production orders. Refunds the full amount to the original payment method (Stripe refund) or back to the balance. Safe to repeat: it never refunds twice. Shipped and delivered orders return 409 order_not_cancelable.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "order_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Canceled order",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Order"
                }
              }
            }
          },
          "409": {
            "description": "order_not_cancelable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          },
          "502": {
            "description": "refund_failed (retryable)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/payments": {
      "get": {
        "tags": [
          "Payment"
        ],
        "operationId": "getPaymentOptions",
        "summary": "How to pay Madely",
        "description": "The accepted payment methods, when you are charged, the Stripe profile id to grant Shared Payment Tokens to, and sandbox test helpers. No API key.",
        "responses": {
          "200": {
            "description": "Payment options",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "not_found or unknown_product (error envelope with a fix)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/v1/payment-methods": {
      "get": {
        "tags": [
          "Payment"
        ],
        "operationId": "listPaymentMethods",
        "summary": "List saved cards",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Cards on file",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "not_found or unknown_product (error envelope with a fix)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Payment"
        ],
        "operationId": "addPaymentMethod",
        "summary": "Save a card on file",
        "description": "Links a Stripe PaymentMethod (pm_...) to a Stripe Customer for this account. Orders are then charged off-session with payment {method:\"card_on_file\"}. Sandbox: send {\"payment_method_id\":\"pm_card_visa\"}. In real test mode, create the PaymentMethod with a SetupIntent first (POST /v1/payment-methods/setup-sessions).",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "payment_method_id"
                ],
                "properties": {
                  "payment_method_id": {
                    "type": "string",
                    "pattern": "^pm_"
                  },
                  "make_default": {
                    "type": "boolean",
                    "default": true
                  }
                }
              },
              "example": {
                "payment_method_id": "pm_card_visa"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Saved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "422": {
            "description": "payment_method_id_required, payment_method_not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/payment-methods/setup-sessions": {
      "post": {
        "tags": [
          "Payment"
        ],
        "operationId": "createSetupSession",
        "summary": "Start saving a card (Stripe SetupIntent)",
        "description": "Returns a SetupIntent id and client_secret. Confirm it with Stripe (Stripe.js, Link or your wallet), then POST /v1/payment-methods with the resulting pm_ id.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "SetupIntent",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "not_found or unknown_product (error envelope with a fix)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/balance": {
      "get": {
        "tags": [
          "Payment"
        ],
        "operationId": "getBalance",
        "summary": "Prepaid balance and ledger",
        "description": "balance_usd plus the last 20 entries: top_up, order_debit, order_refund.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Balance",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "currency": {
                      "type": "string"
                    },
                    "balance_usd": {
                      "type": "number"
                    },
                    "ledger": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "not_found or unknown_product (error envelope with a fix)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/balance/top-ups": {
      "post": {
        "tags": [
          "Payment"
        ],
        "operationId": "topUpBalance",
        "summary": "Add to the prepaid balance by card",
        "description": "amount_usd is a whole number of dollars from 10 to 5000 (limits are placeholders). Paid by card_on_file or agent_token, never by the balance. Idempotency-Key required so a retry never charges twice.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "madely-smoketest-topup-001"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "amount_usd"
                ],
                "properties": {
                  "amount_usd": {
                    "type": "integer",
                    "minimum": 10,
                    "maximum": 5000
                  },
                  "payment": {
                    "$ref": "#/components/schemas/PaymentRequest"
                  }
                }
              },
              "example": {
                "amount_usd": 200,
                "payment": {
                  "method": "card_on_file"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Replay",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "201": {
            "description": "Topped up",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "402": {
            "description": "payment_failed, payment_required and similar",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          },
          "422": {
            "description": "invalid_top_up_amount, payment_method_invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/webhooks/stripe": {
      "post": {
        "tags": [
          "Sandbox"
        ],
        "operationId": "stripeWebhook",
        "summary": "SANDBOX: Stripe webhook receiver (Stripe calls this, not agents)",
        "description": "Verifies the Stripe-Signature header (t=...,v1=HMAC-SHA256 of \"t.rawbody\", 5 minute tolerance) with STRIPE_WEBHOOK_SECRET. Handles payment_intent.succeeded, payment_intent.payment_failed, charge.refunded and shared_payment.granted_token.deactivated. Events are deduplicated by id.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "webhook_signature_invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          },
          "503": {
            "description": "webhook_not_configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        },
        "x-sandbox-only": true,
        "security": []
      }
    },
    "/v1/sandbox/shared-payment-tokens": {
      "post": {
        "tags": [
          "Sandbox"
        ],
        "operationId": "mintSandboxPaymentToken",
        "summary": "SANDBOX: Mint a test Shared Payment Token",
        "description": "Mirrors Stripe's test helper for Shared Payment Tokens. In production your agent grants the token itself, from the customer's wallet, to Madely's Stripe profile.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "max_amount_cents"
                ],
                "properties": {
                  "max_amount_cents": {
                    "type": "integer",
                    "minimum": 50
                  },
                  "payment_method": {
                    "type": "string",
                    "default": "pm_card_visa"
                  },
                  "expires_in_seconds": {
                    "type": "integer",
                    "default": 3600
                  }
                }
              },
              "example": {
                "max_amount_cents": 12500
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "shared_payment_token": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        },
        "x-sandbox-only": true
      }
    },
    "/v1/sandbox/stripe/deliver-events": {
      "post": {
        "tags": [
          "Sandbox"
        ],
        "operationId": "deliverMockStripeEvents",
        "summary": "SANDBOX: Deliver pending mock Stripe webhook events",
        "description": "Signs the mock events and sends them through the real webhook handler. Mock Stripe only.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Delivered",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "409": {
            "description": "mock_only",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        },
        "x-sandbox-only": true
      }
    },
    "/v1/orders/{order_id}/tracking": {
      "get": {
        "tags": [
          "Order"
        ],
        "operationId": "getEtsyTracking",
        "summary": "Tracking for one Etsy order",
        "description": "shipped, carrier, etsy_carrier_name (a name Etsy accepts, or \"other\"), tracking_number, tracking_url, acknowledged. Copy it into the order in the seller's own Etsy account, then acknowledge it.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "order_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Tracking",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "not_found or unknown_product (error envelope with a fix)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/orders/{order_id}/tracking/ack": {
      "post": {
        "tags": [
          "Order"
        ],
        "operationId": "ackEtsyTracking",
        "summary": "Mark tracking as copied to Etsy",
        "description": "Idempotent. The shipment then stops appearing in GET /v1/orders?source=etsy&status=shipped (add include_acknowledged=true to see it).",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "order_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Acknowledged",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "not_found or unknown_product (error envelope with a fix)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/stores/{store_id}/etsy/orders-csv": {
      "post": {
        "tags": [
          "Order"
        ],
        "operationId": "importEtsyOrdersCsv",
        "summary": "Import Etsy's Order Items CSV",
        "description": "Body {\"csv\":\"...\"}. Same checks and same idempotency as POST /v1/orders: upload twice and nothing is duplicated.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "store_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Imported",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "not_found or unknown_product (error envelope with a fix)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/stores/{store_id}/etsy/tracking.csv": {
      "get": {
        "tags": [
          "Order"
        ],
        "operationId": "exportEtsyTrackingCsv",
        "summary": "Tracking as a CSV to add in Etsy",
        "description": "Un-acknowledged shipments by default; include_acknowledged=true for all.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "store_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "CSV",
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "not_found or unknown_product (error envelope with a fix)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/stores/{store_id}/webhook": {
      "put": {
        "tags": [
          "Order"
        ],
        "operationId": "setOrderWebhook",
        "summary": "Optional: get order.shipped pushed to your agent",
        "description": "https url only. Returns a signing secret once. Polling the tracking feed always works too.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "store_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Webhook set",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "not_found or unknown_product (error envelope with a fix)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/sandbox/orders/{order_id}/advance": {
      "post": {
        "tags": [
          "Sandbox"
        ],
        "operationId": "advanceTestOrder",
        "summary": "SANDBOX: Move a test order to its next status",
        "description": "draft, in_production, shipped (adds fake tracking), delivered.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "order_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Order",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Order"
                }
              }
            }
          },
          "404": {
            "description": "not_found or unknown_product (error envelope with a fix)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        },
        "x-sandbox-only": true
      }
    },
    "/pricing.json": {
      "get": {
        "tags": [
          "Discover"
        ],
        "operationId": "getPricingJson",
        "summary": "Whole price list as one JSON file",
        "description": "Every product with product_id, blank_cost_usd, flat_fee_usd, price_usd, plus the tiers. ETag = price version. No API key.",
        "responses": {
          "200": {
            "description": "Price list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "not_found or unknown_product (error envelope with a fix)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/catalog.jsonld": {
      "get": {
        "tags": [
          "Discover"
        ],
        "operationId": "getCatalogJsonLd",
        "summary": "Whole catalog as schema.org JSON-LD",
        "description": "An ItemList of Product with Offer for every product.",
        "responses": {
          "200": {
            "description": "JSON-LD",
            "content": {
              "application/ld+json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "not_found or unknown_product (error envelope with a fix)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/feeds/products.ndjson": {
      "get": {
        "tags": [
          "Discover"
        ],
        "operationId": "getProductsNdjson",
        "summary": "One product per line (NDJSON)",
        "responses": {
          "200": {
            "description": "NDJSON",
            "content": {
              "application/x-ndjson": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "not_found or unknown_product (error envelope with a fix)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/feeds/products.csv": {
      "get": {
        "tags": [
          "Discover"
        ],
        "operationId": "getProductsCsv",
        "summary": "Product price feed as CSV",
        "responses": {
          "200": {
            "description": "CSV",
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "not_found or unknown_product (error envelope with a fix)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/mcp": {
      "post": {
        "tags": [
          "Discover"
        ],
        "operationId": "mcp",
        "summary": "MCP server (JSON-RPC 2.0 over HTTP)",
        "description": "Model Context Protocol endpoint. Tools: list_products, get_product, get_print_spec, validate_print_file (alias check_print_file), get_quote, create_order, get_order, get_pricing_tiers and the payment tools. Same behavior as the REST API. Same behavior as the REST API.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "jsonrpc": "2.0",
                "id": 1,
                "method": "tools/list"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON-RPC response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "not_found or unknown_product (error envelope with a fix)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unknown_product",
                    "message": "No product with id or sku \"ZZZ\".",
                    "param": "items[0].product_id",
                    "fix": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "hint": "Call GET /v1/products?q=<words> and use product_id from the result.",
                    "docs": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "docs_url": "https://api.madely.ai/llms-full.txt#unknown_product",
                    "retryable": false,
                    "retry_after": null,
                    "request_id": "req_1a2b3c4d5e"
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "A sandbox key from POST /v1/sandbox/keys, or the public test key \"madely_sandbox_public\". Test mode only."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message",
              "hint",
              "retryable"
            ],
            "properties": {
              "code": {
                "type": "string",
                "description": "Stable machine-readable code."
              },
              "message": {
                "type": "string",
                "description": "One plain sentence."
              },
              "param": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The field that caused it, e.g. items[0].quantity."
              },
              "fix": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The exact action to take next (same text as hint; kept for older agents)."
              },
              "hint": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "What is wrong and how to fix it. Read this first."
              },
              "docs_url": {
                "type": "string",
                "format": "uri",
                "description": "Page that explains this code (same URL as docs)."
              },
              "retry_after": {
                "type": [
                  "integer",
                  "null"
                ],
                "description": "Seconds to wait before retrying (set on 429); null otherwise."
              },
              "docs": {
                "type": "string",
                "format": "uri"
              },
              "retryable": {
                "type": "boolean",
                "description": "true if the same request may succeed later."
              },
              "request_id": {
                "type": "string"
              },
              "details": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              }
            }
          }
        }
      },
      "Product": {
        "type": "object",
        "properties": {
          "product_id": {
            "type": "string"
          },
          "sku": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "print_method": {
            "type": "string"
          },
          "blank_cost_usd": {
            "type": "number"
          },
          "flat_fee_usd": {
            "type": "number"
          },
          "price_usd": {
            "type": "integer",
            "description": "Whole dollars per item."
          },
          "price_cents": {
            "type": "integer"
          },
          "currency": {
            "type": "string",
            "const": "USD"
          },
          "price_confidence": {
            "type": "string",
            "enum": [
              "checked",
              "provisional"
            ],
            "description": "\"checked\" = compared with current public market prices. \"provisional\" = formula price that can change."
          },
          "print_spec": {
            "type": [
              "object",
              "null"
            ],
            "description": "On GET /v1/products/{id}: the full print spec (see PrintSpec). In lists: a summary {source, verified, canvas_px, inches, dpi, placements, url}; add ?expand=print_spec for the full spec. null = no spec yet."
          },
          "template_urls": {
            "type": [
              "object",
              "null"
            ],
            "description": "png, svg, pdf and spec_json URLs."
          },
          "image_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "images": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "production_time": {
            "type": "string"
          },
          "links": {
            "type": "object"
          }
        }
      },
      "PrintSpec": {
        "type": "object",
        "description": "Full schema: /schemas/print-spec.schema.json. Key fields: canvas_px, inches, dpi, bleed, trim_box_px, safe_zone, print_zones, color_mode, accepted_formats, max_file_mb, background, orientation, generation_hint, source, field_sources, template_urls.",
        "properties": {
          "sku": {
            "type": "string"
          },
          "source": {
            "type": "string",
            "enum": [
              "measured",
              "Madely product specs",
              "industry standard, to verify"
            ]
          },
          "canvas_px": {
            "type": "object",
            "properties": {
              "width": {
                "type": "integer"
              },
              "height": {
                "type": "integer"
              }
            }
          },
          "dpi": {
            "type": "integer"
          },
          "generation_hint": {
            "type": "object",
            "properties": {
              "prompt_suffix": {
                "type": "string"
              },
              "size": {
                "type": "string"
              }
            }
          }
        }
      },
      "ProductList": {
        "type": "object",
        "properties": {
          "price_version": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "total": {
            "type": "integer"
          },
          "count": {
            "type": "integer"
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ]
          },
          "products": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Product"
            }
          }
        }
      },
      "Tiers": {
        "type": "object",
        "properties": {
          "price_version": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "rule": {
            "type": "string"
          },
          "tiers": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "tier_id": {
                  "type": "string"
                },
                "min_monthly_items": {
                  "type": "integer"
                },
                "max_monthly_items": {
                  "type": [
                    "integer",
                    "null"
                  ]
                },
                "min_margin_usd": {
                  "type": "number"
                },
                "max_discount_usd": {
                  "type": "number"
                }
              }
            }
          }
        }
      },
      "QuoteRequest": {
        "type": "object",
        "required": [
          "items",
          "ship_to"
        ],
        "properties": {
          "items": {
            "type": "array",
            "minItems": 1,
            "maxItems": 100,
            "items": {
              "type": "object",
              "required": [
                "product_id",
                "quantity"
              ],
              "properties": {
                "product_id": {
                  "type": "string",
                  "description": "product_id (or sku) from /v1/products."
                },
                "quantity": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 10000
                },
                "options": {
                  "type": "object",
                  "description": "Free-form color/size note. Echoed, not priced, in v0."
                }
              }
            }
          },
          "ship_to": {
            "type": "object",
            "required": [
              "country",
              "zip"
            ],
            "properties": {
              "country": {
                "type": "string",
                "enum": [
                  "US"
                ]
              },
              "zip": {
                "type": "string",
                "pattern": "^\\d{5}(-\\d{4})?$"
              }
            }
          },
          "committed_monthly_items": {
            "type": "integer",
            "minimum": 0,
            "description": "Optional. Items per month you commit to, to price at a published tier."
          }
        }
      },
      "Quote": {
        "type": "object",
        "properties": {
          "quote_id": {
            "type": "string"
          },
          "price_version": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "lines": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "product_id": {
                  "type": "string"
                },
                "quantity": {
                  "type": "integer"
                },
                "blank_cost_usd": {
                  "type": "number"
                },
                "flat_fee_usd": {
                  "type": "number"
                },
                "unit_price_usd": {
                  "type": "integer"
                },
                "standard_unit_price_usd": {
                  "type": "integer"
                },
                "line_total_usd": {
                  "type": "integer"
                }
              }
            }
          },
          "items_usd": {
            "type": "integer"
          },
          "items_all_whole_dollars": {
            "type": "boolean"
          },
          "tier_applied": {
            "type": "object"
          },
          "shipping": {
            "type": "object",
            "description": "Carrier cost passed through. v0 uses a flat mock estimate."
          },
          "total_usd": {
            "type": "number"
          },
          "estimated_ship_date": {
            "type": "string",
            "format": "date"
          },
          "ship_date_basis": {
            "type": "string"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "FileCheck": {
        "type": "object",
        "properties": {
          "product_id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "pass",
              "warn",
              "fail"
            ]
          },
          "checks": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "pass",
                    "warn",
                    "fail"
                  ]
                },
                "detail": {
                  "type": "string"
                },
                "fix": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              }
            }
          }
        }
      },
      "OrderRequest": {
        "type": "object",
        "required": [
          "quote_id",
          "external_id",
          "items",
          "ship_to"
        ],
        "properties": {
          "quote_id": {
            "type": "string"
          },
          "external_id": {
            "type": "string",
            "maxLength": 100,
            "description": "Your own order id. Sandbox: must start with \"madely-smoketest-\"."
          },
          "submit": {
            "type": "boolean",
            "default": false,
            "description": "true = pay now and start production. false = draft; pay later with /submit."
          },
          "max_cost_usd": {
            "type": "number",
            "description": "Refuse the order and the charge if the total is above this."
          },
          "payment": {
            "$ref": "#/components/schemas/PaymentRequest"
          },
          "ship_to": {
            "type": "object"
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "product_id",
                "quantity",
                "artwork"
              ],
              "properties": {
                "product_id": {
                  "type": "string"
                },
                "quantity": {
                  "type": "integer"
                },
                "artwork": {
                  "type": "array",
                  "minItems": 1,
                  "items": {
                    "type": "object",
                    "required": [
                      "url"
                    ],
                    "properties": {
                      "placement": {
                        "type": "string"
                      },
                      "url": {
                        "type": "string",
                        "format": "uri"
                      },
                      "width_px": {
                        "type": "integer"
                      },
                      "height_px": {
                        "type": "integer"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "PaymentRequest": {
        "type": "object",
        "description": "How to pay. Omit to use the balance if it covers the order, else the card on file.",
        "properties": {
          "method": {
            "type": "string",
            "enum": [
              "agent_token",
              "card_on_file",
              "balance",
              "auto"
            ],
            "default": "auto"
          },
          "shared_payment_token": {
            "type": "string",
            "pattern": "^spt_",
            "description": "Stripe Shared Payment Token granted to Madely's Stripe profile. Needed for agent_token. Single-use; its max_amount must cover the total."
          },
          "payment_method_id": {
            "type": "string",
            "description": "Saved card to use for card_on_file. Defaults to the default card."
          }
        }
      },
      "Order": {
        "type": "object",
        "properties": {
          "order_id": {
            "type": "string"
          },
          "mode": {
            "type": "string",
            "const": "test"
          },
          "external_id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "in_production",
              "shipped",
              "delivered",
              "canceled"
            ]
          },
          "needs_attention": {
            "type": "boolean",
            "description": "true if Stripe reported a payment failure after the charge."
          },
          "quote_id": {
            "type": "string"
          },
          "total_usd": {
            "type": "number"
          },
          "estimated_ship_date": {
            "type": "string"
          },
          "tracking": {
            "type": [
              "object",
              "null"
            ]
          },
          "events": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "lines": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "payment": {
            "type": "object"
          }
        }
      }
    },
    "responses": {
      "TooManyRequests": {
        "description": "Rate limited (public test link: sandbox write calls per address per hour). Wait for Retry-After seconds. Reads are not limited.",
        "headers": {
          "Retry-After": {
            "schema": {
              "type": "integer"
            },
            "description": "Seconds to wait."
          },
          "RateLimit-Limit": {
            "schema": {
              "type": "integer"
            }
          },
          "RateLimit-Remaining": {
            "schema": {
              "type": "integer"
            }
          },
          "RateLimit-Reset": {
            "schema": {
              "type": "integer"
            },
            "description": "Seconds until the window resets."
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    }
  },
  "security": []
}