{
  "openapi": "3.1.0",
  "info": {
    "title": "ai.dosa.dev Catalog API",
    "version": "1.1.0",
    "description": "CORS-enabled API for the AI Dosa curated catalog of AI coding tools. Public catalog read endpoints require no authentication; authenticated endpoints use the first-party aat_session cookie and document least-privilege scopes mirrored in /.well-known/oauth-protected-resource (RFC 9728). All errors return structured JSON.",
    "license": {
      "name": "Attribution requested - link the tool detail page when citing"
    }
  },
  "servers": [
    {
      "url": "https://ai.dosa.dev"
    }
  ],
  "paths": {
    "/api/v1/tools": {
      "get": {
        "operationId": "searchTools",
        "summary": "Search and filter catalog tools, or fetch one tool by slug",
        "security": [
          {}
        ],
        "x-required-scopes": [
          "catalog:read"
        ],
        "parameters": [
          {
            "name": "slug",
            "in": "query",
            "required": false,
            "description": "Return exactly one tool ({ tool }) instead of a list. 404 if unknown.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Free-text search over name, slug, company, tags, summary, best-for and key features. Exact slug/name matches rank first.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "description": "Category slug or name, e.g. \"cli-agents\". Names also match as a case-insensitive substring.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "pricing",
            "in": "query",
            "required": false,
            "description": "Pricing model: \"free\", \"open-source\", or an exact value such as \"freemium\".",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tag",
            "in": "query",
            "required": false,
            "description": "Filter to tools with a tag equal to or containing this value (case-insensitive).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Page size.",
            "schema": {
              "type": "integer",
              "default": 25,
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "Number of results to skip.",
            "schema": {
              "type": "integer",
              "default": 0,
              "minimum": 0,
              "maximum": 10000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of tools, or a single tool when `slug` is given.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "required": [
                        "total",
                        "limit",
                        "offset",
                        "tools"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "limit": {
                          "type": "integer"
                        },
                        "offset": {
                          "type": "integer"
                        },
                        "tools": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/CatalogTool"
                          }
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "tool"
                      ],
                      "properties": {
                        "tool": {
                          "$ref": "#/components/schemas/CatalogTool"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Unknown slug.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "405": {
            "description": "HTTP method not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/vote": {
      "post": {
        "operationId": "castToolVote",
        "summary": "Submit a Zap upvote for a tool (authenticated)",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "x-required-scopes": [
          "votes:write"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "tool_id",
                  "cf_token"
                ],
                "properties": {
                  "tool_id": {
                    "type": "string",
                    "description": "Canonical tool identifier (lowercase company-name key)."
                  },
                  "cf_token": {
                    "type": "string",
                    "description": "Cloudflare Turnstile verification token."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Vote recorded."
          },
          "400": {
            "description": "Invalid tool_id or duplicate vote.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Invalid origin or Turnstile verification failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "503": {
            "description": "Voting temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/stacks": {
      "get": {
        "operationId": "listUserStacks",
        "summary": "List stacks owned by the authenticated user",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "x-required-scopes": [
          "stacks:read"
        ],
        "responses": {
          "200": {
            "description": "Authenticated user stacks."
          },
          "401": {
            "description": "Authentication required.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createUserStack",
        "summary": "Create a new AI tool stack",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "x-required-scopes": [
          "stacks:write"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "title"
                ],
                "properties": {
                  "title": {
                    "type": "string",
                    "maxLength": 80,
                    "description": "Display title for the stack."
                  },
                  "description": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 280,
                    "description": "Optional short description."
                  },
                  "slug": {
                    "type": "string",
                    "maxLength": 60,
                    "description": "Optional URL slug (auto-generated from title when omitted)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Stack created."
          },
          "400": {
            "description": "Invalid stack payload.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Invalid request origin.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "409": {
            "description": "Per-user stack limit reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/favorites/{slug}": {
      "put": {
        "operationId": "addFavorite",
        "summary": "Save a tool to the authenticated user favorites",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "x-required-scopes": [
          "favorites:write"
        ],
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Tool already saved in favorites."
          },
          "201": {
            "description": "Tool saved to favorites."
          },
          "400": {
            "description": "Invalid tool slug.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Invalid request origin.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "removeFavorite",
        "summary": "Remove a tool from the authenticated user favorites",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "x-required-scopes": [
          "favorites:write"
        ],
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Tool removed from favorites."
          },
          "401": {
            "description": "Authentication required.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Invalid request origin.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/follows/{slug}": {
      "put": {
        "operationId": "followTool",
        "summary": "Follow a tool for updates",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "x-required-scopes": [
          "follows:write"
        ],
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Tool already followed."
          },
          "201": {
            "description": "Tool followed."
          },
          "400": {
            "description": "Invalid tool slug.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "Authentication required.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Invalid request origin.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/notifications/prefs": {
      "get": {
        "operationId": "getNotificationPrefs",
        "summary": "Read notification preferences for the authenticated user",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "x-required-scopes": [
          "notifications:write"
        ],
        "responses": {
          "200": {
            "description": "Current notification preferences."
          },
          "401": {
            "description": "Authentication required.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "sessionCookie": {
        "type": "apiKey",
        "in": "cookie",
        "name": "aat_session",
        "description": "First-party session cookie issued after GitHub, Google, or email OTP sign-in. Declared least-privilege scopes are published at https://ai.dosa.dev/.well-known/oauth-protected-resource (RFC 9728).",
        "x-scopes": {
          "catalog:read": "Read public AI coding tools catalog, LLM pricing models, and metadata.",
          "stacks:read": "Read the authenticated user AI tool stacks.",
          "stacks:write": "Create, update, fork, and delete the authenticated user AI tool stacks.",
          "favorites:write": "Add or remove tools in the authenticated user favorites list.",
          "follows:write": "Follow or unfollow tools for release and update notifications.",
          "votes:write": "Submit tool upvotes (Zaps) and community switch votes.",
          "profile:write": "Update the authenticated user handle and public profile settings.",
          "notifications:write": "Read and update email digest and notification preferences."
        }
      }
    },
    "schemas": {
      "CatalogTool": {
        "type": "object",
        "required": [
          "slug",
          "name",
          "category",
          "detailUrl",
          "markdownUrl"
        ],
        "properties": {
          "slug": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "company": {
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "categorySlug": {
            "type": "string"
          },
          "pricing": {
            "type": "string"
          },
          "pricingDetail": {
            "type": [
              "string",
              "null"
            ]
          },
          "summary": {
            "type": "string"
          },
          "bestFor": {
            "type": [
              "string",
              "null"
            ]
          },
          "notIdealFor": {
            "type": [
              "string",
              "null"
            ]
          },
          "verdict": {
            "type": [
              "string",
              "null"
            ]
          },
          "keyFeatures": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "officialUrl": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "detailUrl": {
            "type": "string",
            "format": "uri"
          },
          "markdownUrl": {
            "type": "string",
            "format": "uri"
          },
          "lastUpdated": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "ApiError": {
        "type": "object",
        "required": [
          "error",
          "code",
          "message",
          "hint",
          "docs"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Short error summary (backwards-compatible field)."
          },
          "code": {
            "type": "string",
            "description": "Stable machine-readable error code."
          },
          "message": {
            "type": "string",
            "description": "Human- and agent-readable error message."
          },
          "hint": {
            "type": "string",
            "description": "Actionable resolution hint for recovering from the error."
          },
          "docs": {
            "type": "string",
            "format": "uri",
            "description": "Link to the API specification or documentation."
          }
        }
      }
    }
  }
}