{
  "openapi": "3.1.0",
  "info": {
    "title": "SaaS Pricing Archive API",
    "version": "1.0.0",
    "description": "Historical pricing pages and extracted plan data for SaaS companies.\n\n**Auth.** Every operation except `GET /v1/stats` and `POST /v1/signup` needs `Authorization: Bearer spa_<key>`. Get a key from `POST /v1/signup`.\n\n**Envelope.** JSON success bodies are `{\"data\": ..., \"meta\": {\"request_id\", \"timestamp\"}}`. List endpoints add a sibling `pagination` object. The CSV export and raw snapshot bodies are not wrapped. Errors are `{\"error\": {\"code\", \"message\", \"status\"}}`.\n\n**Limits.** Monthly calls per UTC calendar month: free 1,000, Starter 10,000, Pro 50,000, Enterprise unlimited. Authenticated responses carry X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset.\n\n**Tiers.** Free: pricing for the top 100 companies, latest record only, plus full pricing, history and changes for `attio.com`. Starter: every company, history and changes back one year (all of `attio.com`), CSV export. Pro: full history, watchlist up to 50 companies. Enterprise: unlimited calls and watchlist, raw snapshots.",
    "contact": {
      "url": "https://saaspricingarchive.com"
    }
  },
  "servers": [
    {
      "url": "https://saaspricingarchive.com"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Stats",
      "description": "Public archive totals."
    },
    {
      "name": "Companies",
      "description": "Company metadata. Not tier-gated."
    },
    {
      "name": "Pricing",
      "description": "Extracted pricing records."
    },
    {
      "name": "Categories",
      "description": "Category listing and filtering."
    },
    {
      "name": "Export",
      "description": "Bulk CSV export."
    },
    {
      "name": "Snapshots",
      "description": "Stored raw pricing pages. Enterprise only."
    },
    {
      "name": "Watchlist",
      "description": "Companies followed for change alerts. Pro and Enterprise."
    },
    {
      "name": "Account",
      "description": "Signup, keys, usage and billing."
    }
  ],
  "paths": {
    "/v1/stats": {
      "get": {
        "operationId": "getStats",
        "tags": [
          "Stats"
        ],
        "summary": "Archive totals",
        "description": "Public. No API key and no rate limit, so no X-RateLimit-* headers. Cached for an hour.",
        "security": [],
        "responses": {
          "200": {
            "description": "Archive totals.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "meta"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Stats"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "500": {
            "description": "Database error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "internal_server_error": {
                    "value": {
                      "error": {
                        "code": "internal_server_error",
                        "message": "An unexpected error occurred.",
                        "status": 500
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/companies": {
      "get": {
        "operationId": "listCompanies",
        "tags": [
          "Companies"
        ],
        "summary": "List or search companies",
        "description": "Every tier, every company. Company metadata is not tier-gated; pricing data is. Without `q`, ordered by crawl priority then name. With `q`, ordered by full-text rank.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Full-text search (Postgres `plainto_tsquery('english', q)`) over company name and domain.",
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "description": "Category name in any case, or the `slug` from `/v1/categories`.",
            "schema": {
              "type": "string",
              "maxLength": 100
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "description": "1-based page number.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of companies.",
            "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": {
                  "type": "object",
                  "required": [
                    "data",
                    "meta",
                    "pagination"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Company"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    },
                    "pagination": {
                      "$ref": "#/components/schemas/PagePagination"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or unknown API key (src/api/middleware/auth.ts). Sent before rate limiting, so no X-RateLimit-* headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_api_key": {
                    "value": {
                      "error": {
                        "code": "missing_api_key",
                        "message": "Provide your API key in the Authorization: Bearer <key> header.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key_format": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key_format",
                        "message": "Invalid API key format.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key",
                        "message": "Invalid API key.",
                        "status": 401
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`account_inactive` comes from auth (no X-RateLimit-* headers).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "account_inactive": {
                    "value": {
                      "error": {
                        "code": "account_inactive",
                        "message": "This account is inactive. Contact support.",
                        "status": 403
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Query string failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "validation_error": {
                    "value": {
                      "error": {
                        "code": "validation_error",
                        "message": "per_page: Number must be less than or equal to 100",
                        "status": 400
                      }
                    }
                  }
                }
              }
            },
            "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"
              }
            }
          },
          "429": {
            "description": "Monthly call limit for the tier is used up (src/api/middleware/rate-limit.ts). Counted per UTC calendar month. Retry-After is the seconds left until the month ends.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "rate_limit_exceeded": {
                    "value": {
                      "error": {
                        "code": "rate_limit_exceeded",
                        "message": "Monthly API call limit reached. Upgrade at https://saaspricingarchive.com/pricing",
                        "status": 429
                      }
                    }
                  }
                }
              }
            },
            "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"
              },
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            }
          },
          "500": {
            "description": "Unhandled server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "internal_server_error": {
                    "value": {
                      "error": {
                        "code": "internal_server_error",
                        "message": "An unexpected error occurred.",
                        "status": 500
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Redis has failed more than 5 times in a row and the rate limiter is failing closed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "service_unavailable": {
                    "value": {
                      "error": {
                        "code": "service_unavailable",
                        "message": "Rate limiting service temporarily unavailable. Try again shortly.",
                        "status": 503
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/companies/{id}": {
      "get": {
        "operationId": "getCompany",
        "tags": [
          "Companies"
        ],
        "summary": "Get a company",
        "description": "Every tier, every company. Company metadata is not tier-gated.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Company UUID, or its exact domain (for example `slack.com`). A value matching the UUID pattern is looked up by id, anything else by `domain` (exact, case-sensitive match).",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 253
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The company.",
            "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": {
                  "type": "object",
                  "required": [
                    "data",
                    "meta"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Company"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or unknown API key (src/api/middleware/auth.ts). Sent before rate limiting, so no X-RateLimit-* headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_api_key": {
                    "value": {
                      "error": {
                        "code": "missing_api_key",
                        "message": "Provide your API key in the Authorization: Bearer <key> header.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key_format": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key_format",
                        "message": "Invalid API key format.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key",
                        "message": "Invalid API key.",
                        "status": 401
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`account_inactive` comes from auth (no X-RateLimit-* headers).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "account_inactive": {
                    "value": {
                      "error": {
                        "code": "account_inactive",
                        "message": "This account is inactive. Contact support.",
                        "status": 403
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`id` longer than 253 characters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "validation_error": {
                    "value": {
                      "error": {
                        "code": "validation_error",
                        "message": "Company ID or domain is required and must be under 253 characters.",
                        "status": 400
                      }
                    }
                  }
                }
              }
            },
            "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"
              }
            }
          },
          "404": {
            "description": "No company with that id or domain.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "not_found": {
                    "value": {
                      "error": {
                        "code": "not_found",
                        "message": "Company not found.",
                        "status": 404
                      }
                    }
                  }
                }
              }
            },
            "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"
              }
            }
          },
          "429": {
            "description": "Monthly call limit for the tier is used up (src/api/middleware/rate-limit.ts). Counted per UTC calendar month. Retry-After is the seconds left until the month ends.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "rate_limit_exceeded": {
                    "value": {
                      "error": {
                        "code": "rate_limit_exceeded",
                        "message": "Monthly API call limit reached. Upgrade at https://saaspricingarchive.com/pricing",
                        "status": 429
                      }
                    }
                  }
                }
              }
            },
            "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"
              },
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            }
          },
          "500": {
            "description": "Unhandled server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "internal_server_error": {
                    "value": {
                      "error": {
                        "code": "internal_server_error",
                        "message": "An unexpected error occurred.",
                        "status": 500
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Redis has failed more than 5 times in a row and the rate limiter is failing closed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "service_unavailable": {
                    "value": {
                      "error": {
                        "code": "service_unavailable",
                        "message": "Rate limiting service temporarily unavailable. Try again shortly.",
                        "status": 503
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/companies/{id}/pricing": {
      "get": {
        "operationId": "getLatestPricing",
        "tags": [
          "Pricing"
        ],
        "summary": "Latest pricing record",
        "description": "The most recent pricing record for the company, from any source, with its plans. Cached for an hour.\n\nTiers: Free: companies with `is_top_100 = true`, plus `attio.com`. Any other company returns 403 `tier_required`. Starter, Pro and Enterprise: every company.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Company UUID, or its exact domain (for example `slack.com`). A value matching the UUID pattern is looked up by id, anything else by `domain` (exact, case-sensitive match).",
            "schema": {
              "type": "string",
              "minLength": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Latest pricing record.",
            "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": {
                  "type": "object",
                  "required": [
                    "data",
                    "meta"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/PricingRecord"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or unknown API key (src/api/middleware/auth.ts). Sent before rate limiting, so no X-RateLimit-* headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_api_key": {
                    "value": {
                      "error": {
                        "code": "missing_api_key",
                        "message": "Provide your API key in the Authorization: Bearer <key> header.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key_format": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key_format",
                        "message": "Invalid API key format.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key",
                        "message": "Invalid API key.",
                        "status": 401
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`tier_required`: a free key asked for a company outside the top 100 other than `attio.com`. `account_inactive` comes from auth (no X-RateLimit-* headers).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "tier_required": {
                    "value": {
                      "error": {
                        "code": "tier_required",
                        "message": "Free tier only includes the top 100 SaaS companies. Upgrade to Starter for every company we track. https://saaspricingarchive.com/pricing",
                        "status": 403
                      }
                    }
                  },
                  "account_inactive": {
                    "value": {
                      "error": {
                        "code": "account_inactive",
                        "message": "This account is inactive. Contact support.",
                        "status": 403
                      }
                    }
                  }
                }
              }
            },
            "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"
              }
            }
          },
          "404": {
            "description": "Unknown company, or the company has no pricing record yet.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "no_pricing_data": {
                    "value": {
                      "error": {
                        "code": "not_found",
                        "message": "No pricing data found for 'slack.com'.",
                        "status": 404
                      }
                    }
                  },
                  "company_not_found": {
                    "value": {
                      "error": {
                        "code": "not_found",
                        "message": "Company not found.",
                        "status": 404
                      }
                    }
                  }
                }
              }
            },
            "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"
              }
            }
          },
          "429": {
            "description": "Monthly call limit for the tier is used up (src/api/middleware/rate-limit.ts). Counted per UTC calendar month. Retry-After is the seconds left until the month ends.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "rate_limit_exceeded": {
                    "value": {
                      "error": {
                        "code": "rate_limit_exceeded",
                        "message": "Monthly API call limit reached. Upgrade at https://saaspricingarchive.com/pricing",
                        "status": 429
                      }
                    }
                  }
                }
              }
            },
            "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"
              },
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            }
          },
          "500": {
            "description": "Unhandled server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "internal_server_error": {
                    "value": {
                      "error": {
                        "code": "internal_server_error",
                        "message": "An unexpected error occurred.",
                        "status": 500
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Redis has failed more than 5 times in a row and the rate limiter is failing closed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "service_unavailable": {
                    "value": {
                      "error": {
                        "code": "service_unavailable",
                        "message": "Rate limiting service temporarily unavailable. Try again shortly.",
                        "status": 503
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/companies/{id}/pricing/history": {
      "get": {
        "operationId": "getPricingHistory",
        "tags": [
          "Pricing"
        ],
        "summary": "Pricing history",
        "description": "Every pricing record for the company, newest first, cursor-paginated on `captured_at`.\n\nTiers: Free reads the full history of `attio.com` with no date floor and gets 403 `tier_required` for every other company. Starter sees at most one year back: `from` is raised to one year before now when it is earlier or omitted, except on `attio.com`, which every tier reads in full. Pro and Enterprise: full history.\n\nChecks run in this order: company exists (404), tier (403), then query validation (400).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Company UUID, or its exact domain (for example `slack.com`). A value matching the UUID pattern is looked up by id, anything else by `domain` (exact, case-sensitive match).",
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "Inclusive lower bound on `captured_at`. A bare `YYYY-MM-DD` means 00:00:00.000 UTC that day. Otherwise an ISO 8601 datetime with `Z` or a UTC offset (seconds optional). Impossible dates such as `2024-02-30` are rejected.",
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date"
                },
                {
                  "type": "string",
                  "format": "date-time"
                }
              ]
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "Inclusive upper bound on `captured_at`. A bare `YYYY-MM-DD` includes the whole of that UTC day. Otherwise an ISO 8601 datetime with `Z` or a UTC offset.",
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date"
                },
                {
                  "type": "string",
                  "format": "date-time"
                }
              ]
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "`pagination.next_cursor` from the previous page: the `captured_at` of its last record. Any ISO 8601 datetime with `Z` or a UTC offset is accepted. Returns records captured strictly before it.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of pricing records.",
            "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": {
                  "type": "object",
                  "required": [
                    "data",
                    "meta",
                    "pagination"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PricingRecord"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    },
                    "pagination": {
                      "$ref": "#/components/schemas/CursorPagination"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or unknown API key (src/api/middleware/auth.ts). Sent before rate limiting, so no X-RateLimit-* headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_api_key": {
                    "value": {
                      "error": {
                        "code": "missing_api_key",
                        "message": "Provide your API key in the Authorization: Bearer <key> header.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key_format": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key_format",
                        "message": "Invalid API key format.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key",
                        "message": "Invalid API key.",
                        "status": 401
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`tier_required`: free key on any company other than `attio.com`. `account_inactive` comes from auth (no X-RateLimit-* headers).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "tier_required": {
                    "value": {
                      "error": {
                        "code": "tier_required",
                        "message": "Historical pricing data requires a Starter plan or higher. Free keys can read the full history of attio.com. Upgrade at https://saaspricingarchive.com/pricing",
                        "status": 403
                      }
                    }
                  },
                  "account_inactive": {
                    "value": {
                      "error": {
                        "code": "account_inactive",
                        "message": "This account is inactive. Contact support.",
                        "status": 403
                      }
                    }
                  }
                }
              }
            },
            "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"
              }
            }
          },
          "400": {
            "description": "Query string failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "validation_error": {
                    "value": {
                      "error": {
                        "code": "validation_error",
                        "message": "from: Invalid date",
                        "status": 400
                      }
                    }
                  }
                }
              }
            },
            "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"
              }
            }
          },
          "404": {
            "description": "No company with that id or domain.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "not_found": {
                    "value": {
                      "error": {
                        "code": "not_found",
                        "message": "Company not found.",
                        "status": 404
                      }
                    }
                  }
                }
              }
            },
            "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"
              }
            }
          },
          "429": {
            "description": "Monthly call limit for the tier is used up (src/api/middleware/rate-limit.ts). Counted per UTC calendar month. Retry-After is the seconds left until the month ends.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "rate_limit_exceeded": {
                    "value": {
                      "error": {
                        "code": "rate_limit_exceeded",
                        "message": "Monthly API call limit reached. Upgrade at https://saaspricingarchive.com/pricing",
                        "status": 429
                      }
                    }
                  }
                }
              }
            },
            "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"
              },
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            }
          },
          "500": {
            "description": "Unhandled server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "internal_server_error": {
                    "value": {
                      "error": {
                        "code": "internal_server_error",
                        "message": "An unexpected error occurred.",
                        "status": 500
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Redis has failed more than 5 times in a row and the rate limiter is failing closed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "service_unavailable": {
                    "value": {
                      "error": {
                        "code": "service_unavailable",
                        "message": "Rate limiting service temporarily unavailable. Try again shortly.",
                        "status": 503
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/companies/{id}/pricing/changes": {
      "get": {
        "operationId": "getPricingChanges",
        "tags": [
          "Pricing"
        ],
        "summary": "Pricing changes",
        "description": "Pricing records that are a verified change, newest first. By default every record here has `price_change` of `confirmed` (the currency amounts on the stored page moved against the previous capture) or `plans_changed_prices_unchanged` (amounts held and a plan name left the page). Both come from comparing the two stored pages, so every default record has `price_change_basis` of `page_comparison`.\n\nRecords we could not judge are left out by default. Pass `include_unverified=true` to add them, marked `price_change` = `unverified` and `price_change_basis` = null. A record is unverified when it is the company's first record, when the prices on either page could not be read, or when one page was not stored and the stored plans differ. Most Internet Archive history from before April 2026 has no stored page, so most of it is unverified and only appears with the flag. Records judged unchanged (`price_change` = `none`) are never returned here. `/history` has every record.\n\nNew records are judged automatically after each crawl finishes. The weekly crawl starts Sundays at 02:00 UTC, and judging runs once crawling and extraction are done, which usually means within a few hours. A record from the latest crawl that is still unverified after that is usually one we cannot judge.\n\nTime window: the same history the tier gets on `/history`. Starter: records from the last year. Pro and Enterprise: the whole archive, back to 2021. On `attio.com` every tier, free included, gets the whole archive.\n\nTiers: Free reads `attio.com` and gets 403 `tier_required` for every other company.\n\nChecks run in this order: company exists (404), tier (403), then query validation (400).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Company UUID, or its exact domain (for example `slack.com`). A value matching the UUID pattern is looked up by id, anything else by `domain` (exact, case-sensitive match).",
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "`pagination.next_cursor` from the previous page: the `captured_at` of its last record. Any ISO 8601 datetime with `Z` or a UTC offset is accepted. Returns records captured strictly before it.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          },
          {
            "name": "include_unverified",
            "in": "query",
            "required": false,
            "description": "`true` also returns records we could not judge, marked `price_change` = `unverified` with a null `price_change_basis`. `false` (the default) returns verified changes only. Any other value is a 400 `validation_error`. Free keys can pass it on `attio.com` like any other tier.",
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ],
              "default": "false"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of change records.",
            "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": {
                  "type": "object",
                  "required": [
                    "data",
                    "meta",
                    "pagination"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PricingRecord"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    },
                    "pagination": {
                      "$ref": "#/components/schemas/CursorPagination"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or unknown API key (src/api/middleware/auth.ts). Sent before rate limiting, so no X-RateLimit-* headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_api_key": {
                    "value": {
                      "error": {
                        "code": "missing_api_key",
                        "message": "Provide your API key in the Authorization: Bearer <key> header.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key_format": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key_format",
                        "message": "Invalid API key format.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key",
                        "message": "Invalid API key.",
                        "status": 401
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`tier_required`: free key on any company other than `attio.com`. `account_inactive` comes from auth (no X-RateLimit-* headers).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "tier_required": {
                    "value": {
                      "error": {
                        "code": "tier_required",
                        "message": "Historical pricing data requires a Starter plan or higher. Free keys can read the full history of attio.com. Upgrade at https://saaspricingarchive.com/pricing",
                        "status": 403
                      }
                    }
                  },
                  "account_inactive": {
                    "value": {
                      "error": {
                        "code": "account_inactive",
                        "message": "This account is inactive. Contact support.",
                        "status": 403
                      }
                    }
                  }
                }
              }
            },
            "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"
              }
            }
          },
          "400": {
            "description": "Query string failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "validation_error": {
                    "value": {
                      "error": {
                        "code": "validation_error",
                        "message": "cursor: Invalid datetime",
                        "status": 400
                      }
                    }
                  },
                  "invalid_include_unverified": {
                    "value": {
                      "error": {
                        "code": "validation_error",
                        "message": "include_unverified: Invalid enum value. Expected 'true' | 'false', received 'yes'",
                        "status": 400
                      }
                    }
                  }
                }
              }
            },
            "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"
              }
            }
          },
          "404": {
            "description": "No company with that id or domain.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "not_found": {
                    "value": {
                      "error": {
                        "code": "not_found",
                        "message": "Company not found.",
                        "status": 404
                      }
                    }
                  }
                }
              }
            },
            "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"
              }
            }
          },
          "429": {
            "description": "Monthly call limit for the tier is used up (src/api/middleware/rate-limit.ts). Counted per UTC calendar month. Retry-After is the seconds left until the month ends.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "rate_limit_exceeded": {
                    "value": {
                      "error": {
                        "code": "rate_limit_exceeded",
                        "message": "Monthly API call limit reached. Upgrade at https://saaspricingarchive.com/pricing",
                        "status": 429
                      }
                    }
                  }
                }
              }
            },
            "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"
              },
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            }
          },
          "500": {
            "description": "Unhandled server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "internal_server_error": {
                    "value": {
                      "error": {
                        "code": "internal_server_error",
                        "message": "An unexpected error occurred.",
                        "status": 500
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Redis has failed more than 5 times in a row and the rate limiter is failing closed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "service_unavailable": {
                    "value": {
                      "error": {
                        "code": "service_unavailable",
                        "message": "Rate limiting service temporarily unavailable. Try again shortly.",
                        "status": 503
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/categories": {
      "get": {
        "operationId": "listCategories",
        "tags": [
          "Categories"
        ],
        "summary": "List categories",
        "description": "Every category with at least one company, alphabetical, with a company count. Every tier. Cached for 24 hours.",
        "responses": {
          "200": {
            "description": "All categories.",
            "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": {
                  "type": "object",
                  "required": [
                    "data",
                    "meta"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Category"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or unknown API key (src/api/middleware/auth.ts). Sent before rate limiting, so no X-RateLimit-* headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_api_key": {
                    "value": {
                      "error": {
                        "code": "missing_api_key",
                        "message": "Provide your API key in the Authorization: Bearer <key> header.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key_format": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key_format",
                        "message": "Invalid API key format.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key",
                        "message": "Invalid API key.",
                        "status": 401
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`account_inactive` comes from auth (no X-RateLimit-* headers).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "account_inactive": {
                    "value": {
                      "error": {
                        "code": "account_inactive",
                        "message": "This account is inactive. Contact support.",
                        "status": 403
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Monthly call limit for the tier is used up (src/api/middleware/rate-limit.ts). Counted per UTC calendar month. Retry-After is the seconds left until the month ends.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "rate_limit_exceeded": {
                    "value": {
                      "error": {
                        "code": "rate_limit_exceeded",
                        "message": "Monthly API call limit reached. Upgrade at https://saaspricingarchive.com/pricing",
                        "status": 429
                      }
                    }
                  }
                }
              }
            },
            "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"
              },
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            }
          },
          "500": {
            "description": "Unhandled server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "internal_server_error": {
                    "value": {
                      "error": {
                        "code": "internal_server_error",
                        "message": "An unexpected error occurred.",
                        "status": 500
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Redis has failed more than 5 times in a row and the rate limiter is failing closed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "service_unavailable": {
                    "value": {
                      "error": {
                        "code": "service_unavailable",
                        "message": "Rate limiting service temporarily unavailable. Try again shortly.",
                        "status": 503
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/categories/{slug}/companies": {
      "get": {
        "operationId": "listCompaniesByCategory",
        "tags": [
          "Categories"
        ],
        "summary": "Companies in a category",
        "description": "Companies whose category slugs to `slug`, ordered by crawl priority then name. Every tier; this is company metadata, not pricing. A page past the end returns 200 with an empty `data` array; only an empty first page is a 404.",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "A `slug` from `/v1/categories`. Lowercased before matching.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "description": "1-based page number.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of companies.",
            "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": {
                  "type": "object",
                  "required": [
                    "data",
                    "meta",
                    "pagination"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Company"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    },
                    "pagination": {
                      "$ref": "#/components/schemas/PagePagination"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or unknown API key (src/api/middleware/auth.ts). Sent before rate limiting, so no X-RateLimit-* headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_api_key": {
                    "value": {
                      "error": {
                        "code": "missing_api_key",
                        "message": "Provide your API key in the Authorization: Bearer <key> header.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key_format": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key_format",
                        "message": "Invalid API key format.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key",
                        "message": "Invalid API key.",
                        "status": 401
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`account_inactive` comes from auth (no X-RateLimit-* headers).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "account_inactive": {
                    "value": {
                      "error": {
                        "code": "account_inactive",
                        "message": "This account is inactive. Contact support.",
                        "status": 403
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Slug over 100 characters, or query string failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "validation_error": {
                    "value": {
                      "error": {
                        "code": "validation_error",
                        "message": "Category slug must be between 1 and 100 characters.",
                        "status": 400
                      }
                    }
                  }
                }
              }
            },
            "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"
              }
            }
          },
          "404": {
            "description": "No company has this category (first page empty).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "not_found": {
                    "value": {
                      "error": {
                        "code": "not_found",
                        "message": "Category not found.",
                        "status": 404
                      }
                    }
                  }
                }
              }
            },
            "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"
              }
            }
          },
          "429": {
            "description": "Monthly call limit for the tier is used up (src/api/middleware/rate-limit.ts). Counted per UTC calendar month. Retry-After is the seconds left until the month ends.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "rate_limit_exceeded": {
                    "value": {
                      "error": {
                        "code": "rate_limit_exceeded",
                        "message": "Monthly API call limit reached. Upgrade at https://saaspricingarchive.com/pricing",
                        "status": 429
                      }
                    }
                  }
                }
              }
            },
            "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"
              },
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            }
          },
          "500": {
            "description": "Unhandled server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "internal_server_error": {
                    "value": {
                      "error": {
                        "code": "internal_server_error",
                        "message": "An unexpected error occurred.",
                        "status": 500
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Redis has failed more than 5 times in a row and the rate limiter is failing closed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "service_unavailable": {
                    "value": {
                      "error": {
                        "code": "service_unavailable",
                        "message": "Rate limiting service temporarily unavailable. Try again shortly.",
                        "status": 503
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/export/pricing.csv": {
      "get": {
        "operationId": "exportPricingCsv",
        "tags": [
          "Export"
        ],
        "summary": "Export pricing as CSV",
        "description": "Streams pricing records as CSV (RFC 4180 quoting, CRLF line endings), one row per plan per record, ordered by `captured_at` then record id ascending. Records with no plans produce no rows.\n\nColumns: `company_domain, company_name, category, captured_at, source_type, extraction_model, plan_name, price_monthly, price_annual_per_month, currency, pricing_model, unit_price, unit_label, minimum_monthly, is_highlighted, feature_count, record_id`. Nulls are empty fields.\n\nTiers: Starter or higher; free gets 403 `tier_required`. Starter sees at most one year back (`since` is raised to one year before now), `attio.com` included. Pro and Enterprise: full archive.\n\nCost: 25 calls against the monthly limit (Enterprise is not metered). Also capped at 5 exports per user per UTC day.\n\nOnce streaming starts the status is already 200. A database failure mid-stream aborts the connection, so a truncated download shows up as a broken transfer, not a short file.",
        "parameters": [
          {
            "name": "since",
            "in": "query",
            "required": false,
            "description": "Inclusive, from 00:00:00.000 UTC on this date. Must be `YYYY-MM-DD` and a real calendar date (`2024-13-01` and `2024-02-30` are rejected with 400).",
            "schema": {
              "type": "string",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
            }
          },
          {
            "name": "until",
            "in": "query",
            "required": false,
            "description": "Inclusive of the whole UTC day. Must be `YYYY-MM-DD` and a real calendar date (`2024-13-01` and `2024-02-30` are rejected with 400).",
            "schema": {
              "type": "string",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
            }
          },
          {
            "name": "company",
            "in": "query",
            "required": false,
            "description": "Company domain (exact match). Repeat the parameter for several companies.",
            "style": "form",
            "explode": true,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          {
            "name": "source_type",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "live_crawl",
                "wayback_bootstrap"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "CSV stream.",
            "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-Disposition": {
                "description": "`attachment; filename=\"saas-pricing-archive-YYYY-MM-DD.csv\"` (UTC date of the request).",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or unknown API key (src/api/middleware/auth.ts). Sent before rate limiting, so no X-RateLimit-* headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_api_key": {
                    "value": {
                      "error": {
                        "code": "missing_api_key",
                        "message": "Provide your API key in the Authorization: Bearer <key> header.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key_format": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key_format",
                        "message": "Invalid API key format.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key",
                        "message": "Invalid API key.",
                        "status": 401
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`tier_required`: free key. `account_inactive` comes from auth (no X-RateLimit-* headers).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "tier_required": {
                    "value": {
                      "error": {
                        "code": "tier_required",
                        "message": "This endpoint requires a Starter plan or higher. Upgrade at https://saaspricingarchive.com/pricing",
                        "status": 403
                      }
                    }
                  },
                  "account_inactive": {
                    "value": {
                      "error": {
                        "code": "account_inactive",
                        "message": "This account is inactive. Contact support.",
                        "status": 403
                      }
                    }
                  }
                }
              }
            },
            "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"
              }
            }
          },
          "400": {
            "description": "Query string failed validation, including an impossible `since`/`until` date. Checked before streaming starts.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "validation_error": {
                    "value": {
                      "error": {
                        "code": "validation_error",
                        "message": "since: must be an ISO date (YYYY-MM-DD)",
                        "status": 400
                      }
                    }
                  },
                  "validation_error_calendar": {
                    "value": {
                      "error": {
                        "code": "validation_error",
                        "message": "since: must be a real calendar date",
                        "status": 400
                      }
                    }
                  }
                }
              }
            },
            "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"
              }
            }
          },
          "429": {
            "description": "Monthly call limit for the tier is used up (src/api/middleware/rate-limit.ts). Counted per UTC calendar month. Retry-After is the seconds left until the month ends. `export_daily_limit_exceeded`: more than 5 exports today (UTC). No Retry-After on this one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "rate_limit_exceeded": {
                    "value": {
                      "error": {
                        "code": "rate_limit_exceeded",
                        "message": "Monthly API call limit reached. Upgrade at https://saaspricingarchive.com/pricing",
                        "status": 429
                      }
                    }
                  },
                  "export_daily_limit_exceeded": {
                    "value": {
                      "error": {
                        "code": "export_daily_limit_exceeded",
                        "message": "Daily export limit of 5 reached. Try again tomorrow (UTC).",
                        "status": 429
                      }
                    }
                  }
                }
              }
            },
            "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"
              },
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            }
          },
          "500": {
            "description": "Unhandled server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "internal_server_error": {
                    "value": {
                      "error": {
                        "code": "internal_server_error",
                        "message": "An unexpected error occurred.",
                        "status": 500
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Redis has failed more than 5 times in a row and the rate limiter is failing closed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "service_unavailable": {
                    "value": {
                      "error": {
                        "code": "service_unavailable",
                        "message": "Rate limiting service temporarily unavailable. Try again shortly.",
                        "status": 503
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/companies/{id}/snapshots": {
      "get": {
        "operationId": "listSnapshots",
        "tags": [
          "Snapshots"
        ],
        "summary": "List raw snapshots",
        "description": "Metadata for the stored raw pages of a company, newest first. Never includes the body.\n\nTiers: Enterprise only; every other tier gets 403 `tier_required`.\n\nChecks run in this order: tier (403), company exists (404), then query validation (400).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Company UUID, or its exact domain (for example `slack.com`). A value matching the UUID pattern is looked up by id, anything else by `domain` (exact, case-sensitive match).",
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Opaque `pagination.next_cursor` from the previous page.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of snapshot metadata.",
            "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": {
                  "type": "object",
                  "required": [
                    "data",
                    "meta",
                    "pagination"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/SnapshotMetadata"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    },
                    "pagination": {
                      "$ref": "#/components/schemas/CursorPagination"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or unknown API key (src/api/middleware/auth.ts). Sent before rate limiting, so no X-RateLimit-* headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_api_key": {
                    "value": {
                      "error": {
                        "code": "missing_api_key",
                        "message": "Provide your API key in the Authorization: Bearer <key> header.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key_format": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key_format",
                        "message": "Invalid API key format.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key",
                        "message": "Invalid API key.",
                        "status": 401
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`tier_required`: not Enterprise. `account_inactive` comes from auth (no X-RateLimit-* headers).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "tier_required": {
                    "value": {
                      "error": {
                        "code": "tier_required",
                        "message": "Raw HTML snapshot access requires an Enterprise plan. Upgrade at https://saaspricingarchive.com/pricing",
                        "status": 403
                      }
                    }
                  },
                  "account_inactive": {
                    "value": {
                      "error": {
                        "code": "account_inactive",
                        "message": "This account is inactive. Contact support.",
                        "status": 403
                      }
                    }
                  }
                }
              }
            },
            "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"
              }
            }
          },
          "400": {
            "description": "Query string failed validation, or the cursor does not decode.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "validation_error": {
                    "value": {
                      "error": {
                        "code": "validation_error",
                        "message": "cursor is invalid or malformed.",
                        "status": 400
                      }
                    }
                  }
                }
              }
            },
            "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"
              }
            }
          },
          "404": {
            "description": "No company with that id or domain.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "not_found": {
                    "value": {
                      "error": {
                        "code": "not_found",
                        "message": "Company not found.",
                        "status": 404
                      }
                    }
                  }
                }
              }
            },
            "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"
              }
            }
          },
          "429": {
            "description": "Monthly call limit for the tier is used up (src/api/middleware/rate-limit.ts). Counted per UTC calendar month. Retry-After is the seconds left until the month ends.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "rate_limit_exceeded": {
                    "value": {
                      "error": {
                        "code": "rate_limit_exceeded",
                        "message": "Monthly API call limit reached. Upgrade at https://saaspricingarchive.com/pricing",
                        "status": 429
                      }
                    }
                  }
                }
              }
            },
            "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"
              },
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            }
          },
          "500": {
            "description": "Unhandled server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "internal_server_error": {
                    "value": {
                      "error": {
                        "code": "internal_server_error",
                        "message": "An unexpected error occurred.",
                        "status": 500
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Redis has failed more than 5 times in a row and the rate limiter is failing closed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "service_unavailable": {
                    "value": {
                      "error": {
                        "code": "service_unavailable",
                        "message": "Rate limiting service temporarily unavailable. Try again shortly.",
                        "status": 503
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/companies/{id}/snapshots/{snapshotId}": {
      "get": {
        "operationId": "getSnapshot",
        "tags": [
          "Snapshots"
        ],
        "summary": "Get a raw snapshot body",
        "description": "The stored page exactly as captured. `text/html` for every source except `vendor_api`, which is the vendor's JSON. Not wrapped in the JSON envelope.\n\nTiers: Enterprise only; every other tier gets 403 `tier_required`.\n\nCost: 10 calls against the monthly limit for metered tiers (Enterprise is not metered, so this is inert today).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Company UUID, or its exact domain (for example `slack.com`). A value matching the UUID pattern is looked up by id, anything else by `domain` (exact, case-sensitive match).",
            "schema": {
              "type": "string",
              "minLength": 1
            }
          },
          {
            "name": "snapshotId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The raw document.",
            "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-Length": {
                "description": "Body length in bytes.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-Snapshot-Id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "X-Snapshot-Captured-At": {
                "schema": {
                  "type": "string",
                  "format": "date-time"
                }
              }
            },
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              },
              "application/json": {
                "schema": {
                  "description": "The vendor's published JSON, as stored (vendor_api snapshots only)."
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or unknown API key (src/api/middleware/auth.ts). Sent before rate limiting, so no X-RateLimit-* headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_api_key": {
                    "value": {
                      "error": {
                        "code": "missing_api_key",
                        "message": "Provide your API key in the Authorization: Bearer <key> header.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key_format": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key_format",
                        "message": "Invalid API key format.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key",
                        "message": "Invalid API key.",
                        "status": 401
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`tier_required`: not Enterprise. `account_inactive` comes from auth (no X-RateLimit-* headers).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "tier_required": {
                    "value": {
                      "error": {
                        "code": "tier_required",
                        "message": "Raw HTML snapshot access requires an Enterprise plan. Upgrade at https://saaspricingarchive.com/pricing",
                        "status": 403
                      }
                    }
                  },
                  "account_inactive": {
                    "value": {
                      "error": {
                        "code": "account_inactive",
                        "message": "This account is inactive. Contact support.",
                        "status": 403
                      }
                    }
                  }
                }
              }
            },
            "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"
              }
            }
          },
          "400": {
            "description": "`snapshotId` is not a UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "validation_error": {
                    "value": {
                      "error": {
                        "code": "validation_error",
                        "message": "snapshotId must be a valid UUID.",
                        "status": 400
                      }
                    }
                  }
                }
              }
            },
            "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"
              }
            }
          },
          "404": {
            "description": "Unknown company, or no snapshot with that id belongs to this company.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "company_not_found": {
                    "value": {
                      "error": {
                        "code": "not_found",
                        "message": "Company not found.",
                        "status": 404
                      }
                    }
                  },
                  "snapshot_not_found": {
                    "value": {
                      "error": {
                        "code": "not_found",
                        "message": "Snapshot not found.",
                        "status": 404
                      }
                    }
                  }
                }
              }
            },
            "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"
              }
            }
          },
          "429": {
            "description": "Monthly call limit for the tier is used up (src/api/middleware/rate-limit.ts). Counted per UTC calendar month. Retry-After is the seconds left until the month ends.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "rate_limit_exceeded": {
                    "value": {
                      "error": {
                        "code": "rate_limit_exceeded",
                        "message": "Monthly API call limit reached. Upgrade at https://saaspricingarchive.com/pricing",
                        "status": 429
                      }
                    }
                  }
                }
              }
            },
            "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"
              },
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            }
          },
          "500": {
            "description": "Unhandled server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "internal_server_error": {
                    "value": {
                      "error": {
                        "code": "internal_server_error",
                        "message": "An unexpected error occurred.",
                        "status": 500
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Redis has failed more than 5 times in a row and the rate limiter is failing closed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "service_unavailable": {
                    "value": {
                      "error": {
                        "code": "service_unavailable",
                        "message": "Rate limiting service temporarily unavailable. Try again shortly.",
                        "status": 503
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/watchlist": {
      "get": {
        "operationId": "getWatchlist",
        "tags": [
          "Watchlist"
        ],
        "summary": "List followed companies",
        "description": "Companies the caller follows for change alerts, most recently followed first.\n\nTiers: Pro and Enterprise; free and Starter get 403 `tier_required`. Pro can follow up to 50 companies, Enterprise has no cap.",
        "responses": {
          "200": {
            "description": "The watchlist.",
            "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": {
                  "type": "object",
                  "required": [
                    "data",
                    "meta"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Watchlist"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or unknown API key (src/api/middleware/auth.ts). Sent before rate limiting, so no X-RateLimit-* headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_api_key": {
                    "value": {
                      "error": {
                        "code": "missing_api_key",
                        "message": "Provide your API key in the Authorization: Bearer <key> header.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key_format": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key_format",
                        "message": "Invalid API key format.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key",
                        "message": "Invalid API key.",
                        "status": 401
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`tier_required`: not Pro or Enterprise. `account_inactive` comes from auth (no X-RateLimit-* headers).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "tier_required": {
                    "value": {
                      "error": {
                        "code": "tier_required",
                        "message": "Change alerts require a Pro plan or higher. Upgrade at https://saaspricingarchive.com/pricing",
                        "status": 403
                      }
                    }
                  },
                  "account_inactive": {
                    "value": {
                      "error": {
                        "code": "account_inactive",
                        "message": "This account is inactive. Contact support.",
                        "status": 403
                      }
                    }
                  }
                }
              }
            },
            "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"
              }
            }
          },
          "429": {
            "description": "Monthly call limit for the tier is used up (src/api/middleware/rate-limit.ts). Counted per UTC calendar month. Retry-After is the seconds left until the month ends.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "rate_limit_exceeded": {
                    "value": {
                      "error": {
                        "code": "rate_limit_exceeded",
                        "message": "Monthly API call limit reached. Upgrade at https://saaspricingarchive.com/pricing",
                        "status": 429
                      }
                    }
                  }
                }
              }
            },
            "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"
              },
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            }
          },
          "500": {
            "description": "Unhandled server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "internal_server_error": {
                    "value": {
                      "error": {
                        "code": "internal_server_error",
                        "message": "An unexpected error occurred.",
                        "status": 500
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Redis has failed more than 5 times in a row and the rate limiter is failing closed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "service_unavailable": {
                    "value": {
                      "error": {
                        "code": "service_unavailable",
                        "message": "Rate limiting service temporarily unavailable. Try again shortly.",
                        "status": 503
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "addToWatchlist",
        "tags": [
          "Watchlist"
        ],
        "summary": "Follow a company",
        "description": "Idempotent: following a company already on the list returns 200.\n\nTiers: Pro and Enterprise; free and Starter get 403 `tier_required`. Pro can follow up to 50 companies, Enterprise has no cap.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "company"
                ],
                "properties": {
                  "company": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Company UUID or exact domain."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The followed company.",
            "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": {
                  "type": "object",
                  "required": [
                    "data",
                    "meta"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/WatchlistAdded"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Body failed validation. `bad_request`: malformed JSON, or an empty body sent with `Content-Type: application/json`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "validation_error": {
                    "value": {
                      "error": {
                        "code": "validation_error",
                        "message": "company: Required",
                        "status": 400
                      }
                    }
                  },
                  "bad_request": {
                    "value": {
                      "error": {
                        "code": "bad_request",
                        "message": "The request could not be parsed.",
                        "status": 400
                      }
                    }
                  }
                }
              }
            },
            "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"
              }
            }
          },
          "401": {
            "description": "Missing, malformed or unknown API key (src/api/middleware/auth.ts). Sent before rate limiting, so no X-RateLimit-* headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_api_key": {
                    "value": {
                      "error": {
                        "code": "missing_api_key",
                        "message": "Provide your API key in the Authorization: Bearer <key> header.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key_format": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key_format",
                        "message": "Invalid API key format.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key",
                        "message": "Invalid API key.",
                        "status": 401
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`tier_required`: not Pro or Enterprise. `watchlist_limit_reached`: a Pro key already follows 50 companies. `account_inactive` comes from auth (no X-RateLimit-* headers).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "tier_required": {
                    "value": {
                      "error": {
                        "code": "tier_required",
                        "message": "Change alerts require a Pro plan or higher. Upgrade at https://saaspricingarchive.com/pricing",
                        "status": 403
                      }
                    }
                  },
                  "watchlist_limit_reached": {
                    "value": {
                      "error": {
                        "code": "watchlist_limit_reached",
                        "message": "Your plan allows following up to 50 companies. Remove one first, or upgrade to Enterprise for unlimited.",
                        "status": 403
                      }
                    }
                  },
                  "account_inactive": {
                    "value": {
                      "error": {
                        "code": "account_inactive",
                        "message": "This account is inactive. Contact support.",
                        "status": 403
                      }
                    }
                  }
                }
              }
            },
            "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"
              }
            }
          },
          "404": {
            "description": "No company with that id or domain.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "not_found": {
                    "value": {
                      "error": {
                        "code": "not_found",
                        "message": "Company not found.",
                        "status": 404
                      }
                    }
                  }
                }
              }
            },
            "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"
              }
            }
          },
          "413": {
            "description": "Request body over the server's size limit. Fastify body-parse failures (src/api/middleware/error-handler.ts) happen before auth, so they come back ahead of any 401 and without X-RateLimit-* headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "payload_too_large": {
                    "value": {
                      "error": {
                        "code": "payload_too_large",
                        "message": "The request body is too large.",
                        "status": 413
                      }
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "Body sent with a Content-Type the server has no parser for. Fastify body-parse failures (src/api/middleware/error-handler.ts) happen before auth, so they come back ahead of any 401 and without X-RateLimit-* headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "unsupported_media_type": {
                    "value": {
                      "error": {
                        "code": "unsupported_media_type",
                        "message": "Send the body as application/json.",
                        "status": 415
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Monthly call limit for the tier is used up (src/api/middleware/rate-limit.ts). Counted per UTC calendar month. Retry-After is the seconds left until the month ends.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "rate_limit_exceeded": {
                    "value": {
                      "error": {
                        "code": "rate_limit_exceeded",
                        "message": "Monthly API call limit reached. Upgrade at https://saaspricingarchive.com/pricing",
                        "status": 429
                      }
                    }
                  }
                }
              }
            },
            "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"
              },
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            }
          },
          "500": {
            "description": "Unhandled server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "internal_server_error": {
                    "value": {
                      "error": {
                        "code": "internal_server_error",
                        "message": "An unexpected error occurred.",
                        "status": 500
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Redis has failed more than 5 times in a row and the rate limiter is failing closed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "service_unavailable": {
                    "value": {
                      "error": {
                        "code": "service_unavailable",
                        "message": "Rate limiting service temporarily unavailable. Try again shortly.",
                        "status": 503
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/watchlist/{companyId}": {
      "delete": {
        "operationId": "removeFromWatchlist",
        "tags": [
          "Watchlist"
        ],
        "summary": "Unfollow a company",
        "description": "Idempotent: unfollowing a company that exists but is not on the list still returns 204. A company that does not exist returns 404.\n\nTiers: Pro and Enterprise; free and Starter get 403 `tier_required`. Pro can follow up to 50 companies, Enterprise has no cap.",
        "parameters": [
          {
            "name": "companyId",
            "in": "path",
            "required": true,
            "description": "Company UUID, or its exact domain (for example `slack.com`). A value matching the UUID pattern is looked up by id, anything else by `domain` (exact, case-sensitive match).",
            "schema": {
              "type": "string",
              "minLength": 1
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Removed, or was not on the list.",
            "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"
              }
            }
          },
          "400": {
            "description": "`bad_request`: malformed JSON, or an empty body sent with `Content-Type: application/json`. Fastify body-parse failures (src/api/middleware/error-handler.ts) happen before auth, so they come back ahead of any 401 and without X-RateLimit-* headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "bad_request": {
                    "value": {
                      "error": {
                        "code": "bad_request",
                        "message": "The request could not be parsed.",
                        "status": 400
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or unknown API key (src/api/middleware/auth.ts). Sent before rate limiting, so no X-RateLimit-* headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_api_key": {
                    "value": {
                      "error": {
                        "code": "missing_api_key",
                        "message": "Provide your API key in the Authorization: Bearer <key> header.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key_format": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key_format",
                        "message": "Invalid API key format.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key",
                        "message": "Invalid API key.",
                        "status": 401
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`tier_required`: not Pro or Enterprise. `account_inactive` comes from auth (no X-RateLimit-* headers).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "tier_required": {
                    "value": {
                      "error": {
                        "code": "tier_required",
                        "message": "Change alerts require a Pro plan or higher. Upgrade at https://saaspricingarchive.com/pricing",
                        "status": 403
                      }
                    }
                  },
                  "account_inactive": {
                    "value": {
                      "error": {
                        "code": "account_inactive",
                        "message": "This account is inactive. Contact support.",
                        "status": 403
                      }
                    }
                  }
                }
              }
            },
            "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"
              }
            }
          },
          "404": {
            "description": "No company with that id or domain.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "not_found": {
                    "value": {
                      "error": {
                        "code": "not_found",
                        "message": "Company not found.",
                        "status": 404
                      }
                    }
                  }
                }
              }
            },
            "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"
              }
            }
          },
          "413": {
            "description": "Request body over the server's size limit. Fastify body-parse failures (src/api/middleware/error-handler.ts) happen before auth, so they come back ahead of any 401 and without X-RateLimit-* headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "payload_too_large": {
                    "value": {
                      "error": {
                        "code": "payload_too_large",
                        "message": "The request body is too large.",
                        "status": 413
                      }
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "Body sent with a Content-Type the server has no parser for. Fastify body-parse failures (src/api/middleware/error-handler.ts) happen before auth, so they come back ahead of any 401 and without X-RateLimit-* headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "unsupported_media_type": {
                    "value": {
                      "error": {
                        "code": "unsupported_media_type",
                        "message": "Send the body as application/json.",
                        "status": 415
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Monthly call limit for the tier is used up (src/api/middleware/rate-limit.ts). Counted per UTC calendar month. Retry-After is the seconds left until the month ends.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "rate_limit_exceeded": {
                    "value": {
                      "error": {
                        "code": "rate_limit_exceeded",
                        "message": "Monthly API call limit reached. Upgrade at https://saaspricingarchive.com/pricing",
                        "status": 429
                      }
                    }
                  }
                }
              }
            },
            "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"
              },
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            }
          },
          "500": {
            "description": "Unhandled server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "internal_server_error": {
                    "value": {
                      "error": {
                        "code": "internal_server_error",
                        "message": "An unexpected error occurred.",
                        "status": 500
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Redis has failed more than 5 times in a row and the rate limiter is failing closed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "service_unavailable": {
                    "value": {
                      "error": {
                        "code": "service_unavailable",
                        "message": "Rate limiting service temporarily unavailable. Try again shortly.",
                        "status": 503
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/account": {
      "get": {
        "operationId": "getAccount",
        "tags": [
          "Account"
        ],
        "summary": "Get account and usage",
        "description": "The caller's tier, key prefix and usage this UTC month. Every tier.",
        "responses": {
          "200": {
            "description": "Account details.",
            "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": {
                  "type": "object",
                  "required": [
                    "data",
                    "meta"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Account"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or unknown API key (src/api/middleware/auth.ts). Sent before rate limiting, so no X-RateLimit-* headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_api_key": {
                    "value": {
                      "error": {
                        "code": "missing_api_key",
                        "message": "Provide your API key in the Authorization: Bearer <key> header.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key_format": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key_format",
                        "message": "Invalid API key format.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key",
                        "message": "Invalid API key.",
                        "status": 401
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`account_inactive` comes from auth (no X-RateLimit-* headers).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "account_inactive": {
                    "value": {
                      "error": {
                        "code": "account_inactive",
                        "message": "This account is inactive. Contact support.",
                        "status": 403
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Monthly call limit for the tier is used up (src/api/middleware/rate-limit.ts). Counted per UTC calendar month. Retry-After is the seconds left until the month ends.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "rate_limit_exceeded": {
                    "value": {
                      "error": {
                        "code": "rate_limit_exceeded",
                        "message": "Monthly API call limit reached. Upgrade at https://saaspricingarchive.com/pricing",
                        "status": 429
                      }
                    }
                  }
                }
              }
            },
            "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"
              },
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            }
          },
          "500": {
            "description": "Unhandled server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "internal_server_error": {
                    "value": {
                      "error": {
                        "code": "internal_server_error",
                        "message": "An unexpected error occurred.",
                        "status": 500
                      }
                    }
                  },
                  "internal_server_error_route": {
                    "value": {
                      "error": {
                        "code": "internal_server_error",
                        "message": "Failed to load account data.",
                        "status": 500
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Redis has failed more than 5 times in a row and the rate limiter is failing closed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "service_unavailable": {
                    "value": {
                      "error": {
                        "code": "service_unavailable",
                        "message": "Rate limiting service temporarily unavailable. Try again shortly.",
                        "status": 503
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/account/keys": {
      "post": {
        "operationId": "rotateApiKey",
        "tags": [
          "Account"
        ],
        "summary": "Rotate API key",
        "description": "Issues a new key and invalidates the current one immediately. The plaintext key is in this response only. No request body. Every tier.",
        "responses": {
          "201": {
            "description": "New key.",
            "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": {
                  "type": "object",
                  "required": [
                    "data",
                    "meta"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/NewApiKey"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "`bad_request`: malformed JSON, or an empty body sent with `Content-Type: application/json`. Fastify body-parse failures (src/api/middleware/error-handler.ts) happen before auth, so they come back ahead of any 401 and without X-RateLimit-* headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "bad_request": {
                    "value": {
                      "error": {
                        "code": "bad_request",
                        "message": "The request could not be parsed.",
                        "status": 400
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or unknown API key (src/api/middleware/auth.ts). Sent before rate limiting, so no X-RateLimit-* headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_api_key": {
                    "value": {
                      "error": {
                        "code": "missing_api_key",
                        "message": "Provide your API key in the Authorization: Bearer <key> header.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key_format": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key_format",
                        "message": "Invalid API key format.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key",
                        "message": "Invalid API key.",
                        "status": 401
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`account_inactive` comes from auth (no X-RateLimit-* headers).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "account_inactive": {
                    "value": {
                      "error": {
                        "code": "account_inactive",
                        "message": "This account is inactive. Contact support.",
                        "status": 403
                      }
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request body over the server's size limit. Fastify body-parse failures (src/api/middleware/error-handler.ts) happen before auth, so they come back ahead of any 401 and without X-RateLimit-* headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "payload_too_large": {
                    "value": {
                      "error": {
                        "code": "payload_too_large",
                        "message": "The request body is too large.",
                        "status": 413
                      }
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "Body sent with a Content-Type the server has no parser for. Fastify body-parse failures (src/api/middleware/error-handler.ts) happen before auth, so they come back ahead of any 401 and without X-RateLimit-* headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "unsupported_media_type": {
                    "value": {
                      "error": {
                        "code": "unsupported_media_type",
                        "message": "Send the body as application/json.",
                        "status": 415
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Monthly call limit for the tier is used up (src/api/middleware/rate-limit.ts). Counted per UTC calendar month. Retry-After is the seconds left until the month ends.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "rate_limit_exceeded": {
                    "value": {
                      "error": {
                        "code": "rate_limit_exceeded",
                        "message": "Monthly API call limit reached. Upgrade at https://saaspricingarchive.com/pricing",
                        "status": 429
                      }
                    }
                  }
                }
              }
            },
            "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"
              },
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            }
          },
          "500": {
            "description": "Unhandled server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "internal_server_error": {
                    "value": {
                      "error": {
                        "code": "internal_server_error",
                        "message": "An unexpected error occurred.",
                        "status": 500
                      }
                    }
                  },
                  "internal_server_error_route": {
                    "value": {
                      "error": {
                        "code": "internal_server_error",
                        "message": "Failed to rotate API key.",
                        "status": 500
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Redis has failed more than 5 times in a row and the rate limiter is failing closed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "service_unavailable": {
                    "value": {
                      "error": {
                        "code": "service_unavailable",
                        "message": "Rate limiting service temporarily unavailable. Try again shortly.",
                        "status": 503
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/account/billing-portal": {
      "post": {
        "operationId": "createBillingPortalSession",
        "tags": [
          "Account"
        ],
        "summary": "Open Stripe billing portal",
        "description": "Returns a Stripe Billing Portal URL for managing the subscription. Needs a Stripe customer, which exists once the account has gone through `POST /v1/upgrade` checkout. No request body.",
        "responses": {
          "200": {
            "description": "Portal session URL.",
            "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": {
                  "type": "object",
                  "required": [
                    "data",
                    "meta"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/BillingPortal"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "`no_subscription`: the account has no Stripe customer. `bad_request`: malformed JSON, or an empty body sent with `Content-Type: application/json`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "no_subscription": {
                    "value": {
                      "error": {
                        "code": "no_subscription",
                        "message": "No billing account found. Upgrade to a paid plan first via POST /v1/upgrade.",
                        "status": 400
                      }
                    }
                  },
                  "bad_request": {
                    "value": {
                      "error": {
                        "code": "bad_request",
                        "message": "The request could not be parsed.",
                        "status": 400
                      }
                    }
                  }
                }
              }
            },
            "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"
              }
            }
          },
          "401": {
            "description": "Missing, malformed or unknown API key (src/api/middleware/auth.ts). Sent before rate limiting, so no X-RateLimit-* headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_api_key": {
                    "value": {
                      "error": {
                        "code": "missing_api_key",
                        "message": "Provide your API key in the Authorization: Bearer <key> header.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key_format": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key_format",
                        "message": "Invalid API key format.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key",
                        "message": "Invalid API key.",
                        "status": 401
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`account_inactive` comes from auth (no X-RateLimit-* headers).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "account_inactive": {
                    "value": {
                      "error": {
                        "code": "account_inactive",
                        "message": "This account is inactive. Contact support.",
                        "status": 403
                      }
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request body over the server's size limit. Fastify body-parse failures (src/api/middleware/error-handler.ts) happen before auth, so they come back ahead of any 401 and without X-RateLimit-* headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "payload_too_large": {
                    "value": {
                      "error": {
                        "code": "payload_too_large",
                        "message": "The request body is too large.",
                        "status": 413
                      }
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "Body sent with a Content-Type the server has no parser for. Fastify body-parse failures (src/api/middleware/error-handler.ts) happen before auth, so they come back ahead of any 401 and without X-RateLimit-* headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "unsupported_media_type": {
                    "value": {
                      "error": {
                        "code": "unsupported_media_type",
                        "message": "Send the body as application/json.",
                        "status": 415
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Monthly call limit for the tier is used up (src/api/middleware/rate-limit.ts). Counted per UTC calendar month. Retry-After is the seconds left until the month ends.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "rate_limit_exceeded": {
                    "value": {
                      "error": {
                        "code": "rate_limit_exceeded",
                        "message": "Monthly API call limit reached. Upgrade at https://saaspricingarchive.com/pricing",
                        "status": 429
                      }
                    }
                  }
                }
              }
            },
            "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"
              },
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            }
          },
          "500": {
            "description": "Server error, or Stripe could not create the portal session.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "internal_server_error": {
                    "value": {
                      "error": {
                        "code": "internal_server_error",
                        "message": "An unexpected error occurred.",
                        "status": 500
                      }
                    }
                  },
                  "internal_server_error_route": {
                    "value": {
                      "error": {
                        "code": "internal_server_error",
                        "message": "Failed to load account data.",
                        "status": 500
                      }
                    }
                  },
                  "billing_portal_error": {
                    "value": {
                      "error": {
                        "code": "billing_portal_error",
                        "message": "Failed to create billing portal session. Please try again.",
                        "status": 500
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Redis has failed more than 5 times in a row and the rate limiter is failing closed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "service_unavailable": {
                    "value": {
                      "error": {
                        "code": "service_unavailable",
                        "message": "Rate limiting service temporarily unavailable. Try again shortly.",
                        "status": 503
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/signup": {
      "post": {
        "operationId": "signup",
        "tags": [
          "Account"
        ],
        "summary": "Create a free account",
        "description": "Public, no API key. Creates a free-tier account and returns its API key, which is also emailed. Limited to 5 attempts per client IP per hour (every attempt counts, including failed ones). Not subject to the monthly call limit, so no X-RateLimit-* headers.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SignupRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Account created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "meta"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/SignupResponse"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Body failed validation. `bad_request`: malformed JSON, or an empty body sent with `Content-Type: application/json`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "validation_error": {
                    "value": {
                      "error": {
                        "code": "validation_error",
                        "message": "email: Must be a valid email address",
                        "status": 400
                      }
                    }
                  },
                  "bad_request": {
                    "value": {
                      "error": {
                        "code": "bad_request",
                        "message": "The request could not be parsed.",
                        "status": 400
                      }
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "An account with this email already exists.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "email_already_registered": {
                    "value": {
                      "error": {
                        "code": "email_already_registered",
                        "message": "An account with this email already exists. If you lost your API key, generate a new one via POST /v1/account/keys.",
                        "status": 409
                      }
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request body over the server's size limit. Fastify body-parse failures (src/api/middleware/error-handler.ts) happen before auth, so they come back ahead of any 401 and without X-RateLimit-* headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "payload_too_large": {
                    "value": {
                      "error": {
                        "code": "payload_too_large",
                        "message": "The request body is too large.",
                        "status": 413
                      }
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "Body sent with a Content-Type the server has no parser for. Fastify body-parse failures (src/api/middleware/error-handler.ts) happen before auth, so they come back ahead of any 401 and without X-RateLimit-* headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "unsupported_media_type": {
                    "value": {
                      "error": {
                        "code": "unsupported_media_type",
                        "message": "Send the body as application/json.",
                        "status": 415
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "More than 5 signup attempts from this IP in the current hour window.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "signup_rate_limit": {
                    "value": {
                      "error": {
                        "code": "signup_rate_limit",
                        "message": "Too many signup attempts. Try again in 60 minutes.",
                        "status": 429
                      }
                    }
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            }
          },
          "500": {
            "description": "Unhandled server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "internal_server_error": {
                    "value": {
                      "error": {
                        "code": "internal_server_error",
                        "message": "An unexpected error occurred.",
                        "status": 500
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "The signup rate limiter cannot reach Redis and fails closed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "service_unavailable": {
                    "value": {
                      "error": {
                        "code": "service_unavailable",
                        "message": "Unable to process signup at this time. Please try again later.",
                        "status": 503
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/upgrade": {
      "post": {
        "operationId": "createUpgradeCheckout",
        "tags": [
          "Account"
        ],
        "summary": "Start a paid-plan checkout",
        "description": "Returns a Stripe Checkout URL for moving the caller to a higher paid tier. The tier changes when Stripe confirms payment, not when this call returns.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpgradeRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Checkout session.",
            "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": {
                  "type": "object",
                  "required": [
                    "data",
                    "meta"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/UpgradeResponse"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Body failed validation, or `invalid_upgrade`: the requested tier is not above the current one. `bad_request`: malformed JSON, or an empty body sent with `Content-Type: application/json`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "validation_error": {
                    "value": {
                      "error": {
                        "code": "validation_error",
                        "message": "tier: tier must be one of: starter, pro, enterprise",
                        "status": 400
                      }
                    }
                  },
                  "invalid_upgrade": {
                    "value": {
                      "error": {
                        "code": "invalid_upgrade",
                        "message": "You are already on the 'pro' plan. Choose a higher tier to upgrade.",
                        "status": 400
                      }
                    }
                  },
                  "bad_request": {
                    "value": {
                      "error": {
                        "code": "bad_request",
                        "message": "The request could not be parsed.",
                        "status": 400
                      }
                    }
                  }
                }
              }
            },
            "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"
              }
            }
          },
          "401": {
            "description": "Missing, malformed or unknown API key (src/api/middleware/auth.ts). Sent before rate limiting, so no X-RateLimit-* headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_api_key": {
                    "value": {
                      "error": {
                        "code": "missing_api_key",
                        "message": "Provide your API key in the Authorization: Bearer <key> header.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key_format": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key_format",
                        "message": "Invalid API key format.",
                        "status": 401
                      }
                    }
                  },
                  "invalid_api_key": {
                    "value": {
                      "error": {
                        "code": "invalid_api_key",
                        "message": "Invalid API key.",
                        "status": 401
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`account_inactive` comes from auth (no X-RateLimit-* headers).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "account_inactive": {
                    "value": {
                      "error": {
                        "code": "account_inactive",
                        "message": "This account is inactive. Contact support.",
                        "status": 403
                      }
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request body over the server's size limit. Fastify body-parse failures (src/api/middleware/error-handler.ts) happen before auth, so they come back ahead of any 401 and without X-RateLimit-* headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "payload_too_large": {
                    "value": {
                      "error": {
                        "code": "payload_too_large",
                        "message": "The request body is too large.",
                        "status": 413
                      }
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "Body sent with a Content-Type the server has no parser for. Fastify body-parse failures (src/api/middleware/error-handler.ts) happen before auth, so they come back ahead of any 401 and without X-RateLimit-* headers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "unsupported_media_type": {
                    "value": {
                      "error": {
                        "code": "unsupported_media_type",
                        "message": "Send the body as application/json.",
                        "status": 415
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Monthly call limit for the tier is used up (src/api/middleware/rate-limit.ts). Counted per UTC calendar month. Retry-After is the seconds left until the month ends.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "rate_limit_exceeded": {
                    "value": {
                      "error": {
                        "code": "rate_limit_exceeded",
                        "message": "Monthly API call limit reached. Upgrade at https://saaspricingarchive.com/pricing",
                        "status": 429
                      }
                    }
                  }
                }
              }
            },
            "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"
              },
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            }
          },
          "500": {
            "description": "`checkout_error`: Stripe Checkout session creation failed. Unhandled server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "internal_server_error": {
                    "value": {
                      "error": {
                        "code": "internal_server_error",
                        "message": "An unexpected error occurred.",
                        "status": 500
                      }
                    }
                  },
                  "checkout_error": {
                    "value": {
                      "error": {
                        "code": "checkout_error",
                        "message": "Failed to create checkout session. Please try again.",
                        "status": 500
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Redis has failed more than 5 times in a row and the rate limiter is failing closed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "service_unavailable": {
                    "value": {
                      "error": {
                        "code": "service_unavailable",
                        "message": "Rate limiting service temporarily unavailable. Try again shortly.",
                        "status": 503
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "spa_ followed by 40 hex characters"
      }
    },
    "schemas": {
      "Meta": {
        "type": "object",
        "required": [
          "request_id",
          "timestamp"
        ],
        "properties": {
          "request_id": {
            "type": "string",
            "pattern": "^req_[0-9a-f]{12}$",
            "examples": [
              "req_3f9a1c0b7d2e"
            ]
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "description": "Server time the response was built."
          }
        },
        "additionalProperties": false
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message",
              "status"
            ],
            "properties": {
              "code": {
                "type": "string",
                "description": "Machine-readable error code. Each operation lists the codes it can send."
              },
              "message": {
                "type": "string"
              },
              "status": {
                "type": "integer",
                "description": "Same as the HTTP status code."
              }
            },
            "additionalProperties": false
          }
        },
        "additionalProperties": false
      },
      "PagePagination": {
        "type": "object",
        "required": [
          "total",
          "page",
          "per_page",
          "next_cursor"
        ],
        "properties": {
          "total": {
            "type": "integer",
            "minimum": 0
          },
          "page": {
            "type": "integer",
            "minimum": 1
          },
          "per_page": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "The next page number as a string (pass it back as `page`), or null on the last page.",
            "examples": [
              "2"
            ]
          }
        },
        "additionalProperties": false
      },
      "CursorPagination": {
        "type": "object",
        "required": [
          "limit",
          "next_cursor",
          "has_more"
        ],
        "properties": {
          "limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "Pass back as `cursor` to get the next page. Null when `has_more` is false."
          },
          "has_more": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "Stats": {
        "type": "object",
        "required": [
          "total_companies",
          "companies_with_data",
          "total_records",
          "last_crawl",
          "earliest_record"
        ],
        "properties": {
          "total_companies": {
            "type": "integer",
            "minimum": 0,
            "description": "Every row in the companies table, including retired companies and ones never captured."
          },
          "companies_with_data": {
            "type": "integer",
            "minimum": 0,
            "description": "Companies with at least one pricing record."
          },
          "total_records": {
            "type": "integer",
            "minimum": 0
          },
          "last_crawl": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Completion time of the most recent completed crawl run."
          },
          "earliest_record": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Oldest `captured_at` in the archive."
          }
        },
        "additionalProperties": false
      },
      "Company": {
        "type": "object",
        "required": [
          "id",
          "name",
          "domain",
          "pricing_url",
          "category",
          "is_top_100",
          "tier_access_rank",
          "total_snapshots",
          "first_captured",
          "last_captured",
          "pricing_changes_detected",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "domain": {
            "type": "string",
            "examples": [
              "slack.com"
            ]
          },
          "pricing_url": {
            "type": "string"
          },
          "category": {
            "type": [
              "string",
              "null"
            ]
          },
          "is_top_100": {
            "type": "boolean",
            "description": "Free-tier keys can read pricing only for companies where this is true, plus `attio.com`, which they can read in full."
          },
          "tier_access_rank": {
            "type": [
              "integer",
              "null"
            ]
          },
          "total_snapshots": {
            "type": "integer",
            "minimum": 0
          },
          "first_captured": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "last_captured": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "pricing_changes_detected": {
            "type": "integer",
            "minimum": 0
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false
      },
      "Plan": {
        "type": "object",
        "required": [
          "name",
          "price_monthly",
          "price_annual_per_month",
          "price_unit",
          "features",
          "limits",
          "is_highlighted"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1
          },
          "price_monthly": {
            "type": [
              "number",
              "null"
            ],
            "description": "Per-month price when billed monthly, in `currency`. Null for metered or contact-sales plans, and for plans whose page showed only annual billing."
          },
          "price_annual_per_month": {
            "type": [
              "number",
              "null"
            ],
            "description": "Per-month price when billed annually. On a page that showed only annual prices this is the only price set."
          },
          "price_unit": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the price is per, such as `seat` or `GB/month`. Null for a flat price."
          },
          "features": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "limits": {
            "type": "object",
            "additionalProperties": true,
            "description": "Free-form limits as extracted from the page."
          },
          "is_highlighted": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "PricingRecord": {
        "type": "object",
        "required": [
          "id",
          "company_id",
          "captured_at",
          "price_change",
          "price_change_basis",
          "source_url",
          "source_type",
          "currency",
          "free_tier_exists",
          "enterprise_plan_exists",
          "billing_models",
          "extraction_confidence",
          "plans"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "company_id": {
            "type": "string",
            "format": "uuid"
          },
          "captured_at": {
            "type": "string",
            "format": "date-time"
          },
          "price_change": {
            "type": "string",
            "enum": [
              "confirmed",
              "none",
              "plans_changed_prices_unchanged",
              "unverified"
            ],
            "description": "`confirmed`: currency amounts on the stored page moved against the previous capture. `none`: they did not. `plans_changed_prices_unchanged`: amounts held and a plan name left the page (rename or removal). `unverified`: no judgement could be made. New records are judged after each crawl, so a recent record can be unverified for a few hours before it settles. `/changes` leaves `unverified` out unless `include_unverified=true`."
          },
          "price_change_basis": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "page_comparison",
              "stored_record",
              null
            ],
            "description": "`page_comparison`: the two stored pages were compared. `stored_record`: no page survived and the judgement rests on plan data alone. Null exactly when `price_change` is `unverified`."
          },
          "source_url": {
            "type": "string"
          },
          "source_type": {
            "type": "string",
            "enum": [
              "live_crawl",
              "wayback_bootstrap",
              "vendor_api"
            ]
          },
          "currency": {
            "type": "string",
            "description": "ISO 4217 code of the currency the page showed. An archived copy can come back in another currency (Pipedrive's 2026 Wayback captures are CAD), so compare prices within one currency.",
            "examples": [
              "USD"
            ]
          },
          "free_tier_exists": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "enterprise_plan_exists": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "billing_models": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "extraction_confidence": {
            "type": "number"
          },
          "plans": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Plan"
            }
          }
        },
        "additionalProperties": false
      },
      "Category": {
        "type": "object",
        "required": [
          "name",
          "slug",
          "company_count"
        ],
        "properties": {
          "name": {
            "type": "string",
            "examples": [
              "Data & Infrastructure"
            ]
          },
          "slug": {
            "type": "string",
            "examples": [
              "data-infrastructure"
            ],
            "description": "Lowercased name with every run of non `[a-z0-9]` characters replaced by `-` and leading/trailing dashes trimmed."
          },
          "company_count": {
            "type": "integer",
            "minimum": 0
          }
        },
        "additionalProperties": false
      },
      "SnapshotMetadata": {
        "type": "object",
        "required": [
          "id",
          "captured_at",
          "source_type",
          "source_url",
          "byte_length",
          "html_hash"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "captured_at": {
            "type": "string",
            "format": "date-time"
          },
          "source_type": {
            "type": "string"
          },
          "source_url": {
            "type": "string"
          },
          "byte_length": {
            "type": "integer",
            "minimum": 0,
            "description": "Size of the stored body in bytes."
          },
          "html_hash": {
            "type": "string",
            "description": "SHA-256 of the stored body."
          }
        },
        "additionalProperties": false
      },
      "WatchlistEntry": {
        "type": "object",
        "required": [
          "id",
          "name",
          "domain",
          "category",
          "followed_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "domain": {
            "type": "string"
          },
          "category": {
            "type": [
              "string",
              "null"
            ]
          },
          "followed_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false
      },
      "Watchlist": {
        "type": "object",
        "required": [
          "companies"
        ],
        "properties": {
          "companies": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WatchlistEntry"
            }
          }
        },
        "additionalProperties": false
      },
      "WatchlistAdded": {
        "type": "object",
        "required": [
          "id",
          "name",
          "domain"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "domain": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "Tier": {
        "type": "string",
        "enum": [
          "free",
          "starter",
          "pro",
          "enterprise"
        ]
      },
      "Account": {
        "type": "object",
        "required": [
          "id",
          "email",
          "tier",
          "api_key_prefix",
          "usage",
          "stripe_customer_id",
          "is_active",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "email": {
            "type": "string"
          },
          "tier": {
            "$ref": "#/components/schemas/Tier"
          },
          "api_key_prefix": {
            "type": "string",
            "pattern": "^spa_[0-9a-f]{8}\\.\\.\\.$",
            "examples": [
              "spa_1a2b3c4d..."
            ]
          },
          "usage": {
            "type": "object",
            "required": [
              "monthly_calls",
              "monthly_limit",
              "calls_reset_at",
              "remaining"
            ],
            "properties": {
              "monthly_calls": {
                "type": "integer",
                "minimum": 0,
                "description": "Calls counted this UTC month on the key's current tier, including this one. Each tier keeps its own count, so after a plan change this shows the new tier's count. Enterprise is counted but never limited."
              },
              "monthly_limit": {
                "type": [
                  "integer",
                  "null"
                ],
                "description": "1000 free, 10000 starter, 50000 pro, null for enterprise (unlimited)."
              },
              "calls_reset_at": {
                "type": "string",
                "format": "date-time",
                "description": "Start of the next UTC month (00:00:00.000Z on the 1st), when the monthly counter resets."
              },
              "remaining": {
                "type": [
                  "integer",
                  "null"
                ],
                "description": "Null for enterprise."
              }
            },
            "additionalProperties": false
          },
          "stripe_customer_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "is_active": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false
      },
      "NewApiKey": {
        "type": "object",
        "required": [
          "api_key",
          "prefix",
          "message",
          "created_at"
        ],
        "properties": {
          "api_key": {
            "type": "string",
            "pattern": "^spa_[0-9a-f]{40}$",
            "description": "Plaintext key. Returned once and never stored."
          },
          "prefix": {
            "type": "string",
            "pattern": "^spa_[0-9a-f]{8}\\.\\.\\.$"
          },
          "message": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false
      },
      "BillingPortal": {
        "type": "object",
        "required": [
          "portal_url"
        ],
        "properties": {
          "portal_url": {
            "type": "string",
            "format": "uri"
          }
        },
        "additionalProperties": false
      },
      "SignupRequest": {
        "type": "object",
        "required": [
          "email"
        ],
        "properties": {
          "email": {
            "type": "string",
            "format": "email",
            "maxLength": 254,
            "description": "Stored lowercased."
          }
        },
        "additionalProperties": true
      },
      "SignupResponse": {
        "type": "object",
        "required": [
          "api_key",
          "tier",
          "message"
        ],
        "properties": {
          "api_key": {
            "type": "string",
            "pattern": "^spa_[0-9a-f]{40}$",
            "description": "Plaintext key, also emailed. Not shown again."
          },
          "tier": {
            "type": "string",
            "const": "free"
          },
          "message": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "UpgradeRequest": {
        "type": "object",
        "required": [
          "tier"
        ],
        "properties": {
          "tier": {
            "type": "string",
            "enum": [
              "starter",
              "pro",
              "enterprise"
            ],
            "description": "Must rank above the caller's current tier (free < starter < pro < enterprise)."
          },
          "success_url": {
            "type": "string",
            "format": "uri",
            "maxLength": 2048,
            "description": "Where Stripe sends the user after paying. Hostname must be on the server's allowed redirect list (by default `saaspricingarchive.com` and its subdomains). Defaults to `https://saaspricingarchive.com/docs/?checkout=success#ep-account`."
          },
          "cancel_url": {
            "type": "string",
            "format": "uri",
            "maxLength": 2048,
            "description": "Same domain rule as `success_url`. Defaults to `https://saaspricingarchive.com/#pricing`."
          }
        },
        "additionalProperties": true
      },
      "UpgradeResponse": {
        "type": "object",
        "required": [
          "checkout_url",
          "tier"
        ],
        "properties": {
          "checkout_url": {
            "type": "string",
            "format": "uri",
            "description": "Stripe Checkout session URL."
          },
          "tier": {
            "type": "string",
            "enum": [
              "starter",
              "pro",
              "enterprise"
            ]
          }
        },
        "additionalProperties": false
      }
    },
    "headers": {
      "X-RateLimit-Limit": {
        "description": "Monthly call limit for the key's tier: 1000 free, 10000 starter, 50000 pro, `unlimited` for enterprise.",
        "schema": {
          "type": "string",
          "examples": [
            "1000",
            "unlimited"
          ]
        }
      },
      "X-RateLimit-Remaining": {
        "description": "Calls left this UTC month. `unlimited` for enterprise, `unknown` when the counter store had a transient failure and the request was let through.",
        "schema": {
          "type": "string",
          "examples": [
            "998",
            "unlimited",
            "unknown"
          ]
        }
      },
      "X-RateLimit-Reset": {
        "description": "Unix timestamp (seconds) of the start of next UTC month, when the counter resets.",
        "schema": {
          "type": "string",
          "pattern": "^[0-9]+$"
        }
      },
      "Retry-After": {
        "description": "Seconds to wait before retrying.",
        "schema": {
          "type": "string",
          "pattern": "^[0-9]+$"
        }
      }
    }
  }
}
