{
  "openapi": "3.1.0",
  "info": {
    "title": "TrustLayer API",
    "version": "1.0.0",
    "description": "Decentralized identity verification — human, trust score, and risk level.",
    "contact": { "url": "https://trstlyr.com" },
    "license": { "name": "MIT" }
  },
  "servers": [{ "url": "https://klzwvxcxjzhtgqpfyglc.supabase.co/functions/v1", "description": "Production" }],
  "components": {
    "securitySchemes": { "bearerAuth": { "type": "http", "scheme": "bearer", "bearerFormat": "TrustLayer API Key" } },
    "schemas": {
      "VerifyResponse": {
        "type": "object",
        "required": ["is_human", "trust_score", "risk"],
        "properties": {
          "is_human": { "type": "boolean" },
          "trust_score": { "type": "integer", "minimum": 0, "maximum": 100 },
          "risk": { "type": "string", "enum": ["low", "medium", "high"] }
        }
      },
      "Profile": {
        "type": "object",
        "properties": {
          "handle": { "type": "string" },
          "trust_score": { "type": "integer" },
          "verifiers": { "type": "integer" },
          "proofs": { "type": "integer" },
          "badges": { "type": "array", "items": { "type": "string" } }
        }
      },
      "Error": { "type": "object", "properties": { "error": { "type": "string" } } }
    }
  },
  "paths": {
    "/v1-verify": {
      "post": {
        "summary": "Verify a decentralized identity",
        "security": [{ "bearerAuth": [] }],
        "requestBody": {
          "required": true,
          "content": { "application/json": { "schema": { "type": "object", "required": ["identity_id"], "properties": { "identity_id": { "type": "string" } } } } }
        },
        "responses": {
          "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/VerifyResponse" } } } },
          "401": { "description": "Invalid API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "402": { "description": "Quota exceeded" },
          "429": { "description": "Rate limit exceeded" }
        }
      }
    },
    "/public-profile": {
      "get": {
        "summary": "Look up a public trust profile",
        "parameters": [
          { "in": "query", "name": "handle", "schema": { "type": "string" } },
          { "in": "query", "name": "platform", "schema": { "type": "string", "enum": ["x", "facebook", "linkedin", "github"] } },
          { "in": "query", "name": "social", "schema": { "type": "string" } }
        ],
        "responses": {
          "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Profile" } } } },
          "404": { "description": "Not claimed" }
        }
      }
    },
    "/badge-svg": {
      "get": {
        "summary": "Embeddable trust score badge (SVG)",
        "parameters": [
          { "in": "query", "name": "handle", "required": true, "schema": { "type": "string" } },
          { "in": "query", "name": "style", "schema": { "type": "string", "enum": ["flat", "dark"] } }
        ],
        "responses": { "200": { "description": "SVG image", "content": { "image/svg+xml": {} } } }
      }
    }
  }
}