{
  "openapi": "3.1.0",
  "info": {
    "title": "Product Resolver",
    "version": "0.1.0",
    "description": "Agent-callable printer consumables resolver. The first MVP resolves ink, toner, drum units, and ink bottles from messy purchase intent."
  },
  "servers": [
    {
      "url": "https://productresolver.com"
    }
  ],
  "components": {
    "securitySchemes": {
      "ProductResolverApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "Authorization",
        "description": "Use Authorization: Bearer <Product Resolver API key> for neutral_paid calls."
      }
    }
  },
  "paths": {
    "/resolve": {
      "get": {
        "summary": "Resolve printer consumables intent",
        "parameters": [
          {
            "name": "intent",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "mode",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["affiliate_supported", "neutral_paid"],
              "default": "affiliate_supported"
            }
          },
          {
            "name": "region",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "default": "US"
            }
          },
          {
            "name": "quantity",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Resolved product intent"
          },
          "400": {
            "description": "The intent could not be resolved"
          },
          "401": {
            "description": "neutral_paid requires a valid Product Resolver API key"
          },
          "402": {
            "description": "The Product Resolver API key has no neutral credits remaining"
          }
        }
      },
      "post": {
        "summary": "Resolve printer consumables intent",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["intent"],
                "properties": {
                  "intent": {
                    "type": "string"
                  },
                  "mode": {
                    "type": "string",
                    "enum": ["affiliate_supported", "neutral_paid"],
                    "default": "affiliate_supported"
                  },
                  "region": {
                    "type": "string",
                    "default": "US"
                  },
                  "quantity": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "preference": {
                    "type": "string",
                    "enum": ["lowest_risk", "lowest_cost", "high_yield", "oem", "compatible", "bulk"]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Resolved product intent"
          },
          "400": {
            "description": "The intent could not be resolved"
          },
          "401": {
            "description": "neutral_paid requires a valid Product Resolver API key"
          },
          "402": {
            "description": "The Product Resolver API key has no neutral credits remaining"
          }
        }
      }
    },
    "/go": {
      "get": {
        "summary": "Validated outbound click redirect",
        "description": "Redirects to a merchant or configured affiliate-network URL only after validating the merchant and destination. Intended for first-party click tracking and disclosure workflows.",
        "parameters": [
          {
            "name": "merchant",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": ["amazon_business", "staples_business", "walmart_business"]
            }
          },
          {
            "name": "url",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uri"
            }
          }
        ],
        "responses": {
          "302": {
            "description": "Redirect to the validated outbound destination"
          },
          "400": {
            "description": "The redirect was blocked"
          }
        }
      }
    },
    "/billing/checkout": {
      "post": {
        "summary": "Create a Stripe checkout session for neutral API credits",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["pack_id"],
                "properties": {
                  "pack_id": {
                    "type": "string",
                    "enum": ["starter_500", "builder_2000", "operator_10000"]
                  },
                  "email": {
                    "type": "string",
                    "format": "email"
                  }
                }
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "required": ["pack_id"],
                "properties": {
                  "pack_id": {
                    "type": "string",
                    "enum": ["starter_500", "builder_2000", "operator_10000"]
                  },
                  "email": {
                    "type": "string",
                    "format": "email"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "303": {
            "description": "Redirect to Stripe Checkout"
          },
          "400": {
            "description": "Unknown credit pack"
          },
          "503": {
            "description": "Stripe checkout is not configured"
          }
        }
      }
    },
    "/billing/balance": {
      "get": {
        "summary": "Check neutral API credit balance",
        "security": [
          {
            "ProductResolverApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Remaining neutral credits for the supplied API key"
          },
          "401": {
            "description": "Missing or invalid API key"
          }
        }
      }
    },
    "/api/stripe/webhook": {
      "post": {
        "summary": "Stripe webhook receiver",
        "description": "Handles checkout.session.completed and credits the customer's Product Resolver API key.",
        "responses": {
          "200": {
            "description": "Webhook received"
          },
          "400": {
            "description": "Webhook verification or payload failed"
          },
          "503": {
            "description": "Webhook secret is not configured"
          }
        }
      }
    },
    "/status": {
      "get": {
        "summary": "Get safe runtime status",
        "description": "Returns catalog, monetization, pricing, and live-data readiness flags without exposing secret environment values.",
        "responses": {
          "200": {
            "description": "Runtime status summary"
          }
        }
      }
    },
    "/catalog": {
      "get": {
        "summary": "List seeded supported printer models",
        "responses": {
          "200": {
            "description": "Catalog summary"
          }
        }
      }
    },
    "/agent.json": {
      "get": {
        "summary": "Get agent discovery manifest",
        "responses": {
          "200": {
            "description": "Agent discovery metadata"
          }
        }
      }
    },
    "/health": {
      "get": {
        "summary": "Health check",
        "responses": {
          "200": {
            "description": "Safe health summary"
          }
        }
      }
    },
    "/about": {
      "get": {
        "summary": "About Product Resolver",
        "responses": {
          "200": {
            "description": "Human-readable product overview"
          }
        }
      }
    },
    "/developers": {
      "get": {
        "summary": "Developer documentation and paid API entry point",
        "responses": {
          "200": {
            "description": "Human-readable developer page with API examples, billing link, and discovery endpoints"
          }
        }
      }
    },
    "/.well-known/agent.json": {
      "get": {
        "summary": "Standard agent discovery manifest",
        "responses": {
          "200": {
            "description": "Agent discovery metadata"
          }
        }
      }
    },
    "/.well-known/ai-plugin.json": {
      "get": {
        "summary": "Plugin-style discovery manifest",
        "responses": {
          "200": {
            "description": "Plugin discovery metadata"
          }
        }
      }
    },
    "/methodology": {
      "get": {
        "summary": "Resolver ranking methodology",
        "responses": {
          "200": {
            "description": "Human-readable ranking and disclosure methodology"
          }
        }
      }
    },
    "/guides": {
      "get": {
        "summary": "Printer consumables buying guides",
        "responses": {
          "200": {
            "description": "Human-readable guide index"
          }
        }
      }
    },
    "/guides/amazon-printer-supplies": {
      "get": {
        "summary": "Amazon printer supplies guide index",
        "responses": {
          "200": {
            "description": "Human-readable Amazon printer supplies guide index"
          }
        }
      }
    },
    "/guides/amazon-printer-supplies/hp-148a-148x": {
      "get": {
        "summary": "HP 148A and 148X Amazon buying guide",
        "responses": {
          "200": {
            "description": "Human-readable Amazon buying guide for HP 148A and 148X toner"
          }
        }
      }
    },
    "/guides/printer-toner-compatibility": {
      "get": {
        "summary": "Printer toner compatibility guide",
        "responses": {
          "200": {
            "description": "Human-readable toner compatibility guide"
          }
        }
      }
    },
    "/guides/high-yield-toner": {
      "get": {
        "summary": "High-yield toner buying guide",
        "responses": {
          "200": {
            "description": "Human-readable high-yield toner guide"
          }
        }
      }
    },
    "/privacy": {
      "get": {
        "summary": "Privacy page",
        "responses": {
          "200": {
            "description": "Human-readable privacy policy"
          }
        }
      }
    },
    "/terms": {
      "get": {
        "summary": "Terms page",
        "responses": {
          "200": {
            "description": "Human-readable terms"
          }
        }
      }
    },
    "/disclosure": {
      "get": {
        "summary": "Affiliate disclosure page",
        "responses": {
          "200": {
            "description": "Human-readable affiliate disclosure"
          }
        }
      }
    },
    "/mcp": {
      "get": {
        "summary": "Agent-readable tool metadata",
        "responses": {
          "200": {
            "description": "Tool metadata"
          }
        }
      }
    }
  }
}
