{
  "openapi": "3.1.0",
  "info": {
    "title": "Paid API Playbook Checkout",
    "version": "1.0.0",
    "description": "One product, 5 USDC on Base. Buy it in one request at GET /product: read the 402, sign the exact terms, retry the same URL. One purchase includes one completed download. /api/checkout is the advanced path for pre-created orders."
  },
  "servers": [
    {
      "url": "https://makemoneyonlineaiagents.xyz"
    }
  ],
  "paths": {
    "/api/checkout": {
      "get": {
        "operationId": "readOfferOrderOrProduct",
        "description": "GET offer is public. GET order/product require the recovery bearer token. GET product challenges with x402 v2 and accepts PAYMENT-SIGNATURE; a successful settlement returns the private archive. One purchase includes one completed download: read the body fully and save it. An interrupted transfer does not consume the purchase; a completed one returns 410 afterwards.",
        "parameters": [
          {
            "name": "action",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "offer",
                "order",
                "product"
              ]
            }
          },
          {
            "name": "order_id",
            "in": "query",
            "description": "Required for order and product actions",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "PAYMENT-SIGNATURE",
            "in": "header",
            "description": "Base64 x402 v2 payment payload; only after an authorized 402 challenge",
            "schema": {
              "type": "string",
              "maxLength": 16384
            }
          }
        ],
        "security": [
          {
            "recoveryToken": []
          },
          {}
        ],
        "responses": {
          "200": {
            "description": "Offer, order status, or the purchased archive (one completed download per purchase)",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Offer"
                    },
                    {
                      "$ref": "#/components/schemas/OrderStatus"
                    },
                    {
                      "$ref": "#/components/schemas/Archive"
                    }
                  ]
                }
              }
            }
          },
          "202": {
            "description": "Settlement pending or needs operator reconciliation; do not pay again"
          },
          "400": {
            "description": "Malformed or mismatched payment"
          },
          "401": {
            "description": "Missing or invalid recovery token"
          },
          "402": {
            "description": "x402 v2 payment required; PAYMENT-REQUIRED header and JSON body",
            "headers": {
              "PAYMENT-REQUIRED": {
                "description": "Base64-encoded x402 v2 challenge",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/PaymentRequired"
                    },
                    {
                      "type": "object",
                      "required": [
                        "error"
                      ],
                      "properties": {
                        "error": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Unknown order or wrong recovery token"
          },
          "405": {
            "description": "Wrong method"
          },
          "409": {
            "description": "Payment already submitted; inspect order status"
          },
          "503": {
            "description": "Checkout disabled or temporarily unavailable"
          },
          "429": {
            "description": "Rate limit reached; retry after Retry-After seconds"
          },
          "410": {
            "description": "This purchase already completed its one download; buy again to download it once more"
          }
        }
      },
      "post": {
        "operationId": "createOrRecoverOrder",
        "description": "Create or recover exactly one order per recovery token; empty body. Save the token before making this request.",
        "parameters": [
          {
            "name": "action",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "orders"
              ]
            }
          }
        ],
        "security": [
          {
            "recoveryToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "Offer, order, or purchased archive; always no-store",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/CreatedOrder"
                    }
                  ]
                }
              }
            }
          },
          "202": {
            "description": "Settlement pending or needs operator reconciliation; do not pay again"
          },
          "400": {
            "description": "Malformed or mismatched payment"
          },
          "401": {
            "description": "Missing or invalid recovery token"
          },
          "402": {
            "description": "x402 v2 payment required; PAYMENT-REQUIRED header and JSON body",
            "headers": {
              "PAYMENT-REQUIRED": {
                "description": "Base64-encoded x402 v2 challenge",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/PaymentRequired"
                    },
                    {
                      "type": "object",
                      "required": [
                        "error"
                      ],
                      "properties": {
                        "error": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Unknown order or wrong recovery token"
          },
          "405": {
            "description": "Wrong method"
          },
          "409": {
            "description": "Payment already submitted; inspect order status"
          },
          "503": {
            "description": "Checkout disabled or temporarily unavailable"
          },
          "429": {
            "description": "Rate limit reached; retry after Retry-After seconds"
          }
        }
      }
    },
    "/product": {
      "get": {
        "operationId": "buyPaidApiPlaybook",
        "summary": "Buy and download the playbook in one request",
        "description": "Returns 402 with x402 v2 payment terms. Sign the exact authorization and retry this same URL with a PAYMENT-SIGNATURE header to receive the JSON archive. No token or pre-created order is required. One purchase includes one completed download; save X-Order-Id and X-Recovery-Token to resume an interrupted transfer.",
        "parameters": [
          {
            "name": "PAYMENT-SIGNATURE",
            "in": "header",
            "required": false,
            "description": "Base64 x402 v2 payment payload; send only after reading the 402 challenge",
            "schema": {
              "type": "string",
              "maxLength": 16384
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The purchased archive",
            "headers": {
              "X-Product-SHA256": {
                "description": "SHA-256 of the archive body",
                "schema": {
                  "type": "string"
                }
              },
              "X-Order-Id": {
                "description": "Order identifier for recovery",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "X-Recovery-Token": {
                "description": "Secret token that resumes an interrupted delivery once",
                "schema": {
                  "type": "string"
                }
              },
              "PAYMENT-RESPONSE": {
                "description": "Base64 settlement receipt",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Archive"
                }
              }
            }
          },
          "202": {
            "description": "Settlement unresolved; do not pay again, contact support with the order ID"
          },
          "400": {
            "description": "Payment payload malformed or terms do not match the challenge"
          },
          "402": {
            "description": "Payment required or rejected; terms in the PAYMENT-REQUIRED header",
            "headers": {
              "PAYMENT-REQUIRED": {
                "description": "Base64-encoded x402 v2 challenge",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentRequired"
                }
              }
            }
          },
          "409": {
            "description": "This authorization was already submitted and is unresolved"
          },
          "410": {
            "description": "This authorization already completed its one download"
          },
          "429": {
            "description": "Rate limit reached; retry after Retry-After seconds"
          },
          "503": {
            "description": "Checkout disabled or temporarily unavailable"
          }
        }
      }
    },
    "/offer": {
      "get": {
        "operationId": "readOffer",
        "summary": "Price, prerequisites and availability as JSON",
        "responses": {
          "200": {
            "description": "Current offer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Offer"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "recoveryToken": {
        "type": "http",
        "scheme": "bearer",
        "description": "Client-generated 32 random bytes encoded as 64 lowercase hex characters. Secret order recovery credential."
      }
    },
    "schemas": {
      "CreatedOrder": {
        "type": "object",
        "required": [
          "order_id",
          "status",
          "product_url",
          "status_url"
        ],
        "properties": {
          "order_id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "enum": [
              "awaiting_payment",
              "settling",
              "payment_review",
              "paid",
              "delivered"
            ]
          },
          "product_url": {
            "type": "string",
            "format": "uri"
          },
          "status_url": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "OrderStatus": {
        "type": "object",
        "required": [
          "order_id",
          "status",
          "product_id",
          "version",
          "sha256"
        ],
        "properties": {
          "order_id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "enum": [
              "awaiting_payment",
              "settling",
              "payment_review",
              "paid",
              "delivered"
            ]
          },
          "product_id": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "sha256": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          },
          "transaction": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "Archive": {
        "type": "object",
        "required": [
          "schema_version",
          "product_id",
          "version",
          "files"
        ],
        "properties": {
          "schema_version": {
            "type": "string"
          },
          "product_id": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "files": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "path",
                "encoding",
                "bytes",
                "sha256",
                "content"
              ],
              "properties": {
                "path": {
                  "type": "string"
                },
                "encoding": {
                  "const": "utf8"
                },
                "bytes": {
                  "type": "integer"
                },
                "sha256": {
                  "type": "string"
                },
                "content": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "Offer": {
        "type": "object",
        "required": [
          "product_id",
          "version",
          "title",
          "price",
          "checkout_enabled"
        ],
        "properties": {
          "product_id": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "price": {
            "type": "object",
            "properties": {
              "amount": {
                "const": "5"
              },
              "atomic_amount": {
                "const": "5000000"
              },
              "currency": {
                "const": "USDC"
              },
              "network": {
                "const": "eip155:8453"
              },
              "asset": {
                "type": "string"
              },
              "receiver": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "checkout_enabled": {
            "type": "boolean"
          },
          "support": {
            "type": "string"
          },
          "instructions": {
            "type": "string"
          },
          "schema": {
            "type": "string"
          }
        }
      },
      "PaymentRequired": {
        "type": "object",
        "required": [
          "x402Version",
          "resource",
          "accepts"
        ],
        "properties": {
          "x402Version": {
            "const": 2
          },
          "resource": {
            "type": "object"
          },
          "accepts": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      }
    }
  }
}
