﻿{
  "openapi": "3.1.0",
  "info": {
    "title": "Green Monkey Hair Intelligence API",
    "version": "0.2.0-beta",
    "description": "Governed hair-wellness intelligence for AI agents, paid per request in USDC via x402 on Base Mainnet."
  },
  "servers": [
    {
      "url": "https://api-greenmonkey.org"
    }
  ],
  "tags": [
    {
      "name": "Free",
      "description": "Free safety and health endpoints"
    },
    {
      "name": "x402",
      "description": "Paid endpoints using x402 exact payments"
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "tags": ["Free"],
        "summary": "Service health",
        "responses": {
          "200": {
            "description": "Service is available"
          }
        }
      }
    },
    "/v1/safety-check": {
      "post": {
        "tags": ["Free"],
        "summary": "Evaluate safety and track eligibility",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProfileInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Safety decision"
          },
          "400": {
            "description": "Invalid profile"
          }
        }
      }
    },
    "/v1/recommend": {
      "post": {
        "tags": ["x402"],
        "summary": "Product Recommendation Intelligence",
        "description": "Returns a governed product recommendation, rationale and purchase URL.",
        "x-x402": {
          "scheme": "exact",
          "price": "0.10 USDC",
          "network": "eip155:8453",
          "asset": "USDC"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProfileInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Paid recommendation delivered"
          },
          "402": {
            "description": "Payment required. Read the PAYMENT-REQUIRED header."
          },
          "400": {
            "description": "Invalid profile"
          }
        }
      }
    },
    "/v1/hair-transform-90/build": {
      "post": {
        "tags": ["x402"],
        "summary": "Personalised 90-Day Routine Builder",
        "description": "Returns a governed 12-week routine with Routine Agent personalisation and independent QA.",
        "x-x402": {
          "scheme": "exact",
          "price": "0.08 USDC",
          "network": "eip155:8453",
          "asset": "USDC"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProfileInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Paid 90-day routine delivered"
          },
          "402": {
            "description": "Payment required. Read the PAYMENT-REQUIRED header."
          },
          "400": {
            "description": "Invalid profile"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ProfileInput": {
        "type": "object",
        "required": [
          "age_group",
          "pregnancy",
          "breastfeeding",
          "medication_context",
          "multiple_supplements",
          "iron_status_concern",
          "urgent_hair_or_scalp_red_flag",
          "wants_inside_support",
          "hair_pattern",
          "primary_goal",
          "country_code"
        ],
        "properties": {
          "age_group": {
            "type": "string",
            "example": "30_44"
          },
          "pregnancy": {
            "type": "boolean"
          },
          "breastfeeding": {
            "type": "boolean"
          },
          "medication_context": {
            "type": "string",
            "example": "no"
          },
          "multiple_supplements": {
            "type": "boolean"
          },
          "iron_status_concern": {
            "type": "boolean"
          },
          "urgent_hair_or_scalp_red_flag": {
            "type": "boolean"
          },
          "wants_inside_support": {
            "type": "boolean"
          },
          "hair_pattern": {
            "type": "string",
            "example": "wavy"
          },
          "primary_goal": {
            "type": "string",
            "example": "volume"
          },
          "country_code": {
            "type": "string",
            "example": "DE"
          }
        },
        "additionalProperties": false
      }
    }
  }
}
