{
  "openapi": "3.1.0",
  "info": {
    "title": "Sigildex API",
    "description": "Agent-first skill discovery API. Search 78K+ SKILL.md files ranked by relevance, trust, and freshness. Pay per query via x402 (USDC on Base) or use the free tier (5 queries/day per IP).",
    "version": "0.1.0",
    "contact": {
      "name": "Sigildex",
      "url": "https://sigildex.ai"
    },
    "license": {
      "name": "ISC"
    }
  },
  "servers": [
    {
      "url": "https://sigildex.ai",
      "description": "Production"
    }
  ],
  "paths": {
    "/discover": {
      "post": {
        "operationId": "discoverSkills",
        "summary": "Search for agent skills",
        "description": "Search 78K+ skills by natural language query. Returns ranked results with trust signals. Costs $0.002 via x402 after 5 free/day per IP.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DiscoverRequest"
              },
              "example": {
                "query": "PDF text extraction with OCR support",
                "limit": 5
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Ranked skill results",
            "headers": {
              "X-RateLimit-Limit": { "$ref": "#/components/headers/X-RateLimit-Limit" },
              "X-RateLimit-Remaining": { "$ref": "#/components/headers/X-RateLimit-Remaining" },
              "X-RateLimit-Reset": { "$ref": "#/components/headers/X-RateLimit-Reset" }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DiscoverResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" },
                "example": {
                  "error": {
                    "code": "INVALID_REQUEST",
                    "message": "Missing required field: query",
                    "is_retriable": false,
                    "retry_after_seconds": null
                  }
                }
              }
            }
          },
          "402": {
            "description": "Payment required — free tier exhausted, pay via x402",
            "headers": {
              "X-RateLimit-Limit": { "$ref": "#/components/headers/X-RateLimit-Limit" },
              "X-RateLimit-Remaining": { "$ref": "#/components/headers/X-RateLimit-Remaining" },
              "X-RateLimit-Reset": { "$ref": "#/components/headers/X-RateLimit-Reset" }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" },
                "example": {
                  "error": {
                    "code": "PAYMENT_REQUIRED",
                    "message": "Free tier limit exceeded: 5 queries/day. Pay via x402 for unlimited access.",
                    "is_retriable": true,
                    "retry_after_seconds": 3600
                  }
                }
              }
            }
          }
        }
      }
    },
    "/inspect": {
      "post": {
        "operationId": "inspectSkill",
        "summary": "Get full skill details and SKILL.md content",
        "description": "Returns full SKILL.md content, metadata, and trust signals for a specific skill. Free with a valid query_id from a paid /discover call (1-hour TTL). Otherwise costs $0.002 via x402.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InspectRequest"
              },
              "example": {
                "skill_id": "550e8400-e29b-41d4-a716-446655440000",
                "query_id": "q_7f3a2b1c9e4d"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Full skill details with SKILL.md content",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InspectResponse"
                }
              }
            }
          },
          "402": {
            "description": "Payment required",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          },
          "404": {
            "description": "Skill not found",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" },
                "example": {
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "Skill not found.",
                    "is_retriable": false,
                    "retry_after_seconds": null
                  }
                }
              }
            }
          }
        }
      }
    },
    "/health": {
      "get": {
        "operationId": "getHealth",
        "summary": "Service health check",
        "description": "Returns service status, number of indexed skills, and uptime. No payment or rate limiting.",
        "responses": {
          "200": {
            "description": "Service is healthy",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                },
                "example": {
                  "status": "ok",
                  "skills_indexed": 78322,
                  "uptime_seconds": 86400
                }
              }
            }
          }
        }
      }
    },
    "/mcp": {
      "post": {
        "operationId": "mcpTransport",
        "summary": "MCP server endpoint",
        "description": "Streamable HTTP transport for the Model Context Protocol. Supports stateless JSON-RPC 2.0. Tools: discover_skills, inspect_skill. Same pricing as REST endpoints.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "description": "JSON-RPC 2.0 request"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON-RPC 2.0 response"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "DiscoverRequest": {
        "type": "object",
        "required": ["query"],
        "properties": {
          "query": {
            "type": "string",
            "description": "Natural language search query"
          },
          "limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 30,
            "default": 10,
            "description": "Maximum number of results to return"
          },
          "filters": {
            "type": "object",
            "properties": {
              "source": {
                "type": "string",
                "enum": ["all", "github", "clawhub"],
                "default": "all",
                "description": "Filter results by source registry"
              },
              "min_stars": {
                "type": "integer",
                "minimum": 0,
                "description": "Minimum stars/community signal"
              },
              "updated_after": {
                "type": "string",
                "format": "date",
                "description": "Only return skills updated after this date (ISO 8601)"
              }
            }
          }
        }
      },
      "DiscoverResponse": {
        "type": "object",
        "properties": {
          "query_id": {
            "type": "string",
            "description": "Unique query identifier. Use with /inspect for free follow-up (1-hour TTL)."
          },
          "results": {
            "type": "array",
            "items": { "$ref": "#/components/schemas/SkillResult" }
          },
          "meta": {
            "type": "object",
            "properties": {
              "total_results": { "type": "integer" },
              "limit": { "type": "integer" },
              "search_time_ms": { "type": "integer" }
            }
          }
        }
      },
      "SkillResult": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Skill UUID — use with /inspect"
          },
          "name": { "type": "string" },
          "description": { "type": "string" },
          "score": {
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "description": "Relevance score (0-1)"
          },
          "source": {
            "type": "string",
            "enum": ["github", "clawhub"]
          },
          "source_url": {
            "type": "string",
            "format": "uri"
          },
          "signals": { "$ref": "#/components/schemas/Signals" },
          "install": {
            "type": "string",
            "description": "One-line install command"
          }
        }
      },
      "Signals": {
        "type": "object",
        "properties": {
          "stars": { "type": "integer", "nullable": true },
          "installs": { "type": "integer", "nullable": true },
          "downloads": { "type": "integer", "nullable": true },
          "last_updated": { "type": "string", "format": "date", "nullable": true },
          "publisher": { "type": "string" },
          "publisher_type": { "type": "string", "nullable": true },
          "publisher_verified": { "type": "boolean" }
        }
      },
      "InspectRequest": {
        "type": "object",
        "required": ["skill_id"],
        "properties": {
          "skill_id": {
            "type": "string",
            "format": "uuid",
            "description": "Skill UUID from discover results"
          },
          "query_id": {
            "type": "string",
            "description": "Query ID from a paid /discover call. If valid, inspect is free."
          }
        }
      },
      "InspectResponse": {
        "type": "object",
        "properties": {
          "id": { "type": "string", "format": "uuid" },
          "name": { "type": "string" },
          "description": { "type": "string" },
          "content": {
            "type": "string",
            "description": "Full SKILL.md content"
          },
          "source": { "type": "string", "enum": ["github", "clawhub"] },
          "source_url": { "type": "string", "format": "uri" },
          "signals": { "$ref": "#/components/schemas/Signals" },
          "install": { "type": "string" },
          "query_id": {
            "type": "string",
            "nullable": true,
            "description": "Echoed back if provided"
          }
        }
      },
      "HealthResponse": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": ["ok"]
          },
          "skills_indexed": { "type": "integer" },
          "uptime_seconds": { "type": "integer" }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "RATE_LIMITED",
                  "PAYMENT_REQUIRED",
                  "PAYMENT_FAILED",
                  "PAYMENT_UNAVAILABLE",
                  "INVALID_REQUEST",
                  "NOT_FOUND",
                  "INTERNAL_ERROR"
                ]
              },
              "message": { "type": "string" },
              "is_retriable": { "type": "boolean" },
              "retry_after_seconds": {
                "type": "integer",
                "nullable": true
              }
            }
          }
        }
      }
    },
    "headers": {
      "X-RateLimit-Limit": {
        "description": "Free tier daily limit",
        "schema": { "type": "integer", "example": 5 }
      },
      "X-RateLimit-Remaining": {
        "description": "Remaining free queries today",
        "schema": { "type": "integer", "example": 3 }
      },
      "X-RateLimit-Reset": {
        "description": "Unix timestamp when the rate limit resets (midnight UTC)",
        "schema": { "type": "integer", "example": 1712793600 }
      }
    },
    "securitySchemes": {
      "x402": {
        "type": "apiKey",
        "in": "header",
        "name": "payment-signature",
        "description": "x402 payment signature. Agents with x402-enabled HTTP clients (e.g. @x402/fetch) handle this automatically. See https://x402.org for protocol details."
      }
    }
  },
  "security": [
    {},
    { "x402": [] }
  ]
}
