{
  "openapi": "3.1.0",
  "info": {
    "title": "distinct-baguette Purchase API",
    "description": "Bot-friendly purchase API for the distinct-baguette Polymarket trading bot ($249 USD one-time). No API key required. Designed for autonomous agents. Full product details at https://distinct-baguette.com/llms.txt",
    "version": "1.0.0",
    "contact": {
      "email": "distinct-baguette@protonmail.com",
      "url": "https://distinct-baguette.com"
    },
    "x-llms-txt": "https://distinct-baguette.com/llms.txt",
    "x-llms-full-txt": "https://distinct-baguette.com/llms-full.txt"
  },
  "servers": [
    {
      "url": "https://distinct-baguette.com",
      "description": "Production"
    }
  ],
  "paths": {
    "/api/buy": {
      "post": {
        "operationId": "createPayment",
        "summary": "Create a crypto payment request to purchase the bot",
        "description": "Creates a crypto payment invoice for the distinct-baguette Polymarket trading bot. Returns a wallet address and exact amount to send. The download link (full source, 6.8 GB data, configs, docs) is emailed automatically once payment confirms on-chain (typically 1–5 minutes). If a payment was already created for this email in the last 30 minutes, the existing one is returned.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["email"],
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email",
                    "description": "Email address where the download link will be sent after payment confirms.",
                    "example": "buyer@example.com"
                  },
                  "asset": {
                    "type": "string",
                    "description": "Preferred crypto asset. Accepted: USDC, USDT, ETH, BTC, POL. Defaults to USDC on Polygon (lowest fees, ~$0.01 gas).",
                    "example": "USDC",
                    "default": "USDC"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Payment request created. Send exactly amountReadable of asset on blockchain to address.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentResponse"
                },
                "example": {
                  "address": "0xABC123def456...",
                  "amount": "249010100",
                  "amountReadable": "249.010100",
                  "decimals": 6,
                  "asset": "usdc",
                  "assetName": "USD Coin",
                  "blockchain": "Polygon",
                  "priceUsd": 249,
                  "orderId": "550e8400-e29b-41d4-a716-446655440000",
                  "paymentId": "660e8400-e29b-41d4-a716-446655440001"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request — missing or malformed email.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          },
          "409": {
            "description": "Sold out — no stock available.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "checkPaymentStatus",
        "summary": "Check payment confirmation status",
        "description": "Poll to check if the on-chain payment has confirmed. Once status is 'success', the download link has been emailed. Recommended polling interval: 30 seconds. Payment expires after ~60 minutes if unpaid.",
        "parameters": [
          {
            "name": "paymentId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The paymentId returned from POST /api/buy."
          },
          {
            "name": "orderId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The orderId returned from POST /api/buy. Recommended: include this to enable fallback fulfillment if the webhook was missed."
          }
        ],
        "responses": {
          "200": {
            "description": "Current payment status.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatusResponse"
                },
                "examples": {
                  "pending": {
                    "value": { "status": "pending", "txid": null }
                  },
                  "success": {
                    "value": { "status": "success", "txid": "0xabc123..." }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing paymentId.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "PaymentResponse": {
        "type": "object",
        "description": "Send exactly amountReadable of asset on blockchain to address. No memo required.",
        "required": ["address", "amount", "amountReadable", "decimals", "asset", "assetName", "blockchain", "priceUsd", "orderId", "paymentId"],
        "properties": {
          "address": {
            "type": "string",
            "description": "Wallet address to send payment to. EVM address for USDC/ETH/POL on Polygon."
          },
          "amount": {
            "type": "string",
            "description": "Exact token amount in smallest denomination (use with decimals for token transfer libraries)."
          },
          "amountReadable": {
            "type": "string",
            "description": "Human-readable amount to send. Send this exact value — no rounding."
          },
          "decimals": {
            "type": "integer",
            "description": "Token decimal places. E.g. 6 for USDC."
          },
          "asset": {
            "type": "string",
            "description": "Token code in lowercase. E.g. 'usdc'."
          },
          "assetName": {
            "type": "string",
            "description": "Token full name. E.g. 'USD Coin'."
          },
          "blockchain": {
            "type": "string",
            "description": "Blockchain name. E.g. 'Polygon'."
          },
          "priceUsd": {
            "type": "number",
            "description": "Price in USD."
          },
          "orderId": {
            "type": "string",
            "format": "uuid",
            "description": "Internal order identifier. Pass to GET /api/buy as orderId for fallback fulfillment."
          },
          "paymentId": {
            "type": "string",
            "format": "uuid",
            "description": "Payment processor identifier. Pass to GET /api/buy as paymentId to poll status."
          }
        }
      },
      "StatusResponse": {
        "type": "object",
        "required": ["status"],
        "properties": {
          "status": {
            "type": "string",
            "enum": ["new", "pending", "success", "canceled", "expired"],
            "description": "'new' = awaiting payment. 'pending' = payment seen on-chain, waiting for confirmations. 'success' = confirmed, download link emailed. 'canceled' = canceled. 'expired' = payment window expired (~60 min)."
          },
          "txid": {
            "type": "string",
            "nullable": true,
            "description": "On-chain transaction ID. Present once the transaction is detected."
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          }
        }
      }
    }
  }
}
