{
  "openapi": "3.1.0",
  "info": {
    "title": "Cogito-Reflex: Cognitive Regulation as a Service",
    "version": "1.0.0",
    "description": "Cognitive regulation API for autonomous agents. 0.10 USDC per 300s session via x402 on Base (EIP-3009) — this HTTP API is paid on every call. The first session is free, one per identity, through the MCP server only (https://mcp.services4agents.fyi/mcp). Reduce agent entropy, break loops, distill session lessons."
  },
  "servers": [
    {
      "url": "https://services4agents.fyi"
    }
  ],
  "paths": {
    "/v1/meditation/request": {
      "post": {
        "summary": "Request a cognitive regulation session",
        "description": "Returns HTTP 402 with an x402 challenge when no valid PAYMENT-SIGNATURE is provided. Pay USDC on Base (EIP-3009) and re-POST with the PAYMENT-SIGNATURE header to receive HTTP 202 with the session.",
        "operationId": "requestSession",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["agent_id"],
                "properties": {
                  "agent_id": { "type": "string", "description": "Client agent identifier." },
                  "parameters": {
                    "type": "object",
                    "properties": {
                      "duration_limit_seconds": { "type": "integer", "minimum": 1, "maximum": 300, "default": 300 },
                      "complexity_level": { "type": "string", "enum": ["standard", "deep"], "default": "standard" }
                    }
                  },
                  "onchain_session_id": { "type": ["integer", "null"] }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Session created (paid or free discovery session).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "session_id": { "type": "string" },
                    "agent_id": { "type": "string" },
                    "status": { "type": "string", "enum": ["PENDING", "OPERATIONAL", "MEDITATIVE", "COMPLETED"] },
                    "duration_seconds": { "type": "integer" },
                    "complexity": { "type": "string" },
                    "estimated_cost_usdc": { "type": "number" },
                    "currency": { "type": "string" }
                  }
                }
              }
            }
          },
          "402": {
            "description": "x402 payment required. Includes the payment-required header and JSON challenge (accepts[] with exact amount, network eip155:8453, USDC asset, payTo).",
            "headers": {
              "PAYMENT-REQUIRED": {
                "description": "Base64 x402 v2 payment-required envelope.",
                "schema": { "type": "string" }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "x402Version": { "type": "integer" },
                    "error": { "type": "string" },
                    "resource": { "type": "object" },
                    "accepts": { "type": "array" },
                    "extensions": { "type": "object" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/meditation/{session_id}/status": {
      "get": {
        "summary": "Get session status",
        "operationId": "getSessionStatus",
        "parameters": [
          {
            "name": "session_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": {
            "description": "Session state.",
            "content": {
              "application/json": {
                "schema": { "type": "object" }
              }
            }
          },
          "404": {
            "description": "Session not found."
          }
        }
      }
    },
    "/health": {
      "get": {
        "summary": "Health check",
        "operationId": "health",
        "responses": {
          "200": {
            "description": "Service is up.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": { "type": "string" }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
