{
  "openapi": "3.1.0",
  "info": {
    "title": "Robyn AnyGas API",
    "version": "3.1.0",
    "summary": "Gasless, cross-chain relay for AI agents.",
    "description": "Move value across 22 EVM chains + Stellar with one signed intent and no native gas. A relayer fronts the gas and is repaid from the token being moved. Read endpoints need no credentials; execution takes a Permit2 / EIP-712 signature. Zero-config: base URL defaults are baked into the SDKs. Also available as an MCP server (npx anygas-mcp) and a hosted MCP endpoint (https://api.anygas.xyz/mcp).",
    "contact": { "name": "Robyn AnyGas", "url": "https://anygas.xyz" },
    "license": { "name": "Service terms", "url": "https://anygas.xyz/svc/api/terms" }
  },
  "servers": [{ "url": "https://api.anygas.xyz/svc", "description": "Production gateway" }],
  "tags": [
    { "name": "routing", "description": "Cross-chain gasless routing (best-of-N)" },
    { "name": "gasless", "description": "Same-chain gasless pay / execution" },
    { "name": "status", "description": "Health & mesh" },
    { "name": "concierge", "description": "AI concierge" }
  ],
  "paths": {
    "/api/route/chains": {
      "get": {
        "tags": ["status"],
        "summary": "The gasless mesh",
        "description": "Supported chains (22 EVM node ids + Stellar), directed route count, relayer + Permit2 addresses, and the routing engine.",
        "operationId": "getMesh",
        "responses": { "200": { "description": "Mesh snapshot", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Mesh" } } } } }
      }
    },
    "/api/route/quote": {
      "get": {
        "tags": ["routing"],
        "summary": "Quote a gasless cross-chain route",
        "description": "Best-of-N quote (LI.FI / Bungee / deBridge ranked by net output; Allbridge for Stellar). Read-only.",
        "operationId": "quoteRoute",
        "parameters": [
          { "name": "fromChain", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Source chain id, or \"stellar\"", "example": "42161" },
          { "name": "toChain", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Destination chain id, or \"stellar\"", "example": "8453" },
          { "name": "token", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Token symbol or address", "example": "USDC" },
          { "name": "amount", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Human amount or base units", "example": "25" },
          { "name": "toAddress", "in": "query", "required": false, "schema": { "type": "string" }, "description": "Recipient on the destination chain" }
        ],
        "responses": { "200": { "description": "Ranked best route", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Quote" } } } } }
      }
    },
    "/api/route/execute": {
      "post": {
        "tags": ["routing"],
        "summary": "Execute a signed gasless route",
        "description": "Submit a Permit2 / EIP-712 signed intent. Robyn fronts all gas on both legs and is repaid from the token. Returns a route id to track.",
        "operationId": "executeRoute",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ExecuteRequest" } } } },
        "responses": { "200": { "description": "Route accepted", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/RouteReceipt" } } } } }
      }
    },
    "/api/route/status": {
      "get": {
        "tags": ["routing"],
        "summary": "Track a route",
        "operationId": "routeStatus",
        "parameters": [{ "name": "id", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Route id from execute" }],
        "responses": { "200": { "description": "Route status", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/RouteReceipt" } } } } }
      }
    },
    "/api/gasless/info": {
      "get": {
        "tags": ["gasless"],
        "summary": "Gasless config",
        "description": "Relayer config, chain id, verified tokens, markup/fee parameters for same-chain gasless pay.",
        "operationId": "gaslessInfo",
        "responses": { "200": { "description": "Config", "content": { "application/json": { "schema": { "type": "object", "additionalProperties": true } } } } }
      }
    },
    "/api/status": {
      "get": {
        "tags": ["status"],
        "summary": "Operational status",
        "description": "Public, sanitized health: overall state, per-node up/down (22 EVM + Stellar), bridge rails, endpoints, and route count.",
        "operationId": "getStatus",
        "responses": { "200": { "description": "Status snapshot", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Status" } } } } }
      }
    },
    "/api/ask": {
      "post": {
        "tags": ["concierge"],
        "summary": "Ask the AI concierge",
        "description": "Natural-language questions about Robyn AnyGas; the concierge can call the read endpoints to answer.",
        "operationId": "ask",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["question"], "properties": { "question": { "type": "string", "example": "What chains can I move USDC between gaslessly?" } } } } } },
        "responses": { "200": { "description": "Answer", "content": { "application/json": { "schema": { "type": "object", "properties": { "answer": { "type": "string" } } } } } } }
      }
    },
    "/api/terms": {
      "get": { "tags": ["status"], "summary": "Terms of Service", "operationId": "terms", "responses": { "200": { "description": "HTML terms" } } }
    }
  },
  "components": {
    "schemas": {
      "Mesh": {
        "type": "object",
        "properties": {
          "nodes": { "type": "integer", "example": 23 },
          "chains": { "type": "array", "items": { "type": "integer" }, "description": "EVM chain ids" },
          "routableNonEvm": { "type": "array", "items": { "type": "string" }, "example": ["stellar"] },
          "directedRoutes": { "type": "integer", "example": 478 },
          "relayer": { "type": "string" },
          "permit2": { "type": "string" },
          "engine": { "type": "string" }
        }
      },
      "Quote": {
        "type": "object",
        "properties": {
          "gasless": { "type": "boolean", "example": true },
          "bridge": { "type": "string", "example": "bungee/across" },
          "bestOf": { "type": "integer", "example": 3 },
          "compared": { "type": "array", "items": { "type": "object", "additionalProperties": true } },
          "robynRouteFeeBps": { "type": "integer", "example": 25 },
          "durationSec": { "type": "number" }
        },
        "additionalProperties": true
      },
      "ExecuteRequest": {
        "type": "object",
        "required": ["fromChain", "fromToken", "amount", "toChain", "toToken", "mode"],
        "properties": {
          "fromChain": { "type": "string", "example": "42161" },
          "fromToken": { "type": "string" },
          "amount": { "type": "string", "description": "base units" },
          "toChain": { "type": "string", "example": "8453" },
          "toToken": { "type": "string" },
          "toAddress": { "type": "string" },
          "mode": { "type": "string", "enum": ["permit2", "permit", "allowance"], "example": "permit2" },
          "permit2": { "type": "object", "description": "Permit2 signature bundle (owner, permitted{token,amount}, nonce, deadline, signature)", "additionalProperties": true }
        }
      },
      "RouteReceipt": {
        "type": "object",
        "properties": {
          "id": { "type": "string", "example": "rt_..." },
          "status": { "type": "string", "example": "BRIDGING", "description": "BRIDGING | DONE | FAILED" },
          "bridge": { "type": "string" },
          "srcTx": { "type": "string", "nullable": true },
          "destTx": { "type": "string", "nullable": true }
        },
        "additionalProperties": true
      },
      "Status": {
        "type": "object",
        "properties": {
          "status": { "type": "string", "enum": ["operational", "degraded", "down", "unknown"] },
          "ts": { "type": "integer" },
          "nodes": { "type": "object", "properties": { "up": { "type": "integer" }, "total": { "type": "integer" }, "evm": { "type": "array", "items": { "type": "object", "properties": { "chainId": { "type": "integer" }, "name": { "type": "string" }, "up": { "type": "boolean" } } } }, "stellar": { "type": "object", "properties": { "up": { "type": "boolean" } } } } },
          "rails": { "type": "array", "items": { "type": "object", "properties": { "name": { "type": "string" }, "up": { "type": "boolean" } } } },
          "routes": { "type": "integer", "nullable": true },
          "endpoints": { "type": "array", "items": { "type": "object", "properties": { "name": { "type": "string" }, "up": { "type": "boolean" } } } }
        }
      }
    }
  }
}
