QuashFlags

Runtime HTTP API

Evaluate a feature flag from your backend with an HTTPS GET. HTTP is the supported integration contract: no QuashFlags SDK, package or background process is required.

First evaluation

  1. In Flags, create new-feature. Leave its default off for the response shown below.
  2. In API Keys, create a named key. Copy it once into your server's secret store and expose it through environment variables for example: QUASHFLAGS_API_KEY.
  3. Run one of the examples below. Use a key and flag from the same organization and deployment. For local development, substitute your local API origin for the hosted origin.

Send X-API-Key on every runtime request. This organization-wide credential is not a user login token. Never put it in a URL, source control, logs, browser JavaScript or a shipped mobile app. Public clients should call your backend. To rotate, deploy a replacement key before revoking the old one.

cURL

curl --fail-with-body --max-time 2 \
  -H "X-API-Key: ${QUASHFLAGS_API_KEY:?Set the server API key first}" \
  'https://api.quashflags.com/v1/flags/new-feature'

JavaScript fetch (Node.js 20+, ES module)


const apiKey = process.env.QUASHFLAGS_API_KEY;
if (!apiKey) throw new Error("Set QUASHFLAGS_API_KEY");

const response = await fetch("https://api.quashflags.com/v1/flags/new-feature", {
  headers: { "X-API-Key": apiKey },
  signal: AbortSignal.timeout(2000), redirect: "error"
});
if (!response.ok) throw new Error(`Flag lookup returned ${response.status}`);

const flag = await response.json();
if (flag.key !== "new-feature" || typeof flag.enabled !== "boolean") {
  throw new Error("Unexpected flag response");
}

console.log(flag.enabled);

.NET HttpClient (console application)


using System;
using System.Net.Http;
using System.Text.Json;

var apiKey = Environment.GetEnvironmentVariable("QUASHFLAGS_API_KEY")
    ?? throw new InvalidOperationException("Set QUASHFLAGS_API_KEY");

using var client = new HttpClient(new HttpClientHandler { AllowAutoRedirect = false })
    { Timeout = TimeSpan.FromSeconds(2) };
client.DefaultRequestHeaders.Add("X-API-Key", apiKey);

using var response = await client.GetAsync("https://api.quashflags.com/v1/flags/new-feature");
response.EnsureSuccessStatusCode();

using var flag = JsonDocument.Parse(await response.Content.ReadAsStringAsync());
Console.WriteLine(flag.RootElement.GetProperty("enabled").GetBoolean());

In a long-running service, reuse a client for this origin or inject one through IHttpClientFactory.

Python 3 (standard library)

import json
import os
from http.client import HTTPSConnection

conn = HTTPSConnection("api.quashflags.com", timeout=2)
try:
    conn.request("GET", "/v1/flags/new-feature", headers={
        "X-API-Key": os.environ["QUASHFLAGS_API_KEY"]
    })
    response = conn.getresponse()
    if response.status != 200:
        raise RuntimeError(f"Flag lookup returned {response.status}")

    flag = json.load(response)
    if flag["key"] != "new-feature" or not isinstance(flag["enabled"], bool):
        raise ValueError("Unexpected flag response")

    print(flag["enabled"])
finally:
    conn.close()

Endpoints and responses

GET /v1/flags/{key} returns a JSON object with a string key and Boolean enabled. Off is a successful evaluation:

{"key":"new-feature","enabled":false}

GET /v1/flags returns the organization's evaluations in a flags array. An empty organization returns {"flags":[]}. Use the bulk endpoint to refresh several flags in a single request.

{"flags":[{"key":"new-feature","enabled":false}]}

Both endpoints accept an optional query parameter, for example ?environment=staging. A matching override wins (trimmed, case-insensitive environment name); omitted, blank or unmatched environments use the flag's configured default. An environment name is not an access boundary.

Failures and freshness

401 Unauthorized
The key is missing, invalid or revoked. Check the deployment, header and secret; do not retry unchanged credentials or continue serving a cached organization's values.
404 Not Found (single flag)
Check the key spelling and organization. Discard any cached entry for this lookup. A missing flag is not a successful false response.
Network failure, timeout, 5xx or malformed success body
Do not overwrite a known-good value with an error. Use a bounded last-known-good value if your feature can tolerate it; otherwise use an explicit application fallback. Record status and age, never the credential.

The examples surface failures so you can choose policy at the call site. For an unreleased checkout, keep the old checkout on failure; for a kill switch, the safe fallback might be the opposite Boolean. Flag evaluation is not authorization.

Set deadlines within your request budget (two seconds above is an example, not a service guarantee; Python's timeout applies to socket operations). Avoid retry loops on the user request path. For frequent reads, refresh a private process-local cache periodically with jitter. For example, refresh every 30 seconds and discard values older than five minutes only if that delay is acceptable. Partition by deployment, credential scope, environment and flag; clear on credential changes. Cache only validated successes, never share through a public proxy, and never assume instant updates, invalidation or offline delivery.