API Documentation

Server API

Backend

The Server API is designed for backend services and provides project-level access. Each API key is scoped to a specific project and can access all environments within that project.

Endpoint

GEThttps://www.tinytoggle.com/api/v1/server/environments/{envId}/flags

Retrieve all flags for a specific environment

Authentication

Header:X-API-KEY

Your API key must be included in the request header

Response Example

{
  "enable_unicorn_mode": true,
  "coffee_consumption_limit": 42,
  "debug_mode": false,
  "feature_launch_date": "2024-04-01",
  "max_pizza_slices": 8,
  "secret_sauce_recipe": "classified",
  "enable_rainbow_text": true,
  "maintenance_mode": false,
  "cat_pictures_count": 9000,
  "enable_dark_mode": true
}

Rate Limiting

Each successful call counts as one "read" against your monthly quota. Rate limits and quota resets are per user.

HeaderValueDescription
RateLimit-Limit1000000Maximum reads per cycle
RateLimit-Remaining999999Reads remaining in current cycle
RateLimit-Reset1728000Seconds until quota resets
If you exceed your quota, you'll receive a 429 Too Many Requests response until your cycle resets.

Code Examples

Find your API URLs and code snippets in your project page
Navigate to projects once logged in, select your project and environment to view your API URLs and code snippets.

Client API

Frontend

The Client API is optimized for frontend applications and provides environment-level access. Each client key is scoped to a specific environment and is read-only. Responses are cached using Vercel Blob storage for optimal performance.

Endpoint

GEThttps://www.tinytoggle.com/api/v1/client/flags

Retrieve all flags for the environment associated with the client key

Authentication

Header:X-API-KEY

Your client key must be included in the request header

Response Example

The cached response contains your feature flags:

{
  "enable_confetti_on_login": true,
  "max_daily_cat_gifs": 42,
  "theme_color": "unicorn_purple",
  "enable_easter_eggs": true,
  "debug_mode": false,
  "feature_launch_date": "2024-04-01",
  "max_pizza_slices": 8,
  "secret_sauce_recipe": "classified",
  "enable_rainbow_text": true,
  "maintenance_mode": false
}

Caching & Quota

Each successful call to the client API counts as one "read" against your cycle quota. Fetching the JSON blob from the CDN does not count.

HeaderValueDescription
Cache-Controlpublic, s-maxage=60, stale-while-revalidate=30CDN and browser caching directives
Vercel-CDN-Cache-Controlpublic, s-maxage=60Vercel-specific CDN caching
Surrogate-Keyflags-{environment_id}Cache invalidation key
Within 60s, repeat calls are served entirely from cache (no quota debit). After 60s, the next request debits your quota and returns the newest snapshot URL.