API Keys#
Create and manage API keys programmatically. Keys are prefixed gc_ and stored as HMAC-SHA256 hashes. The raw key is returned once on creation and cannot be retrieved again.
/v1/keysCreate a new API key. Returns the full raw key. Store it immediately.
Request body
{
"name": string // required — human-readable label (1–100 chars)
}Response
{
"key": string, // full raw key — shown ONCE, store securely
"key_id": string, // 16-char hex ID for management
"name": string,
"created_at": string // ISO 8601 UTC
}curl -X POST https://api.gotcontext.ai/v1/keys \
-H "Authorization: Bearer YOUR_CLERK_JWT" \
-H "Content-Type: application/json" \
-d '{"name": "Production server"}'Error responses
/v1/keysList all API keys for the authenticated user. Returns masked key values. The raw key cannot be retrieved after creation.
Response
{
"keys": [
{
"key_id": string,
"name": string,
"masked_key": string, // e.g. "gc_****ab12"
"created_at": string, // ISO 8601 UTC
"last_used": string|null,
"status": "active" | "revoked"
}
]
}curl https://api.gotcontext.ai/v1/keys \
-H "Authorization: Bearer YOUR_CLERK_JWT"/v1/keys/:idRevoke an API key by ID. Takes effect immediately. The key is rejected by the auth middleware within milliseconds.
Response
{
"success": true,
"key_id": string
}curl -X DELETE https://api.gotcontext.ai/v1/keys/YOUR_KEY_ID \
-H "Authorization: Bearer YOUR_CLERK_JWT"Error responses
Billing#
Billing is handled by Polar. The checkout and portal endpoints return redirect URLs. Do not call these from server-side code without a user session.
/v1/billing/checkoutCreate a Polar checkout session to upgrade to Pro. Returns a URL to redirect the user to.
Request body
{
"plan": "pro" // currently the only valid value
}Response
{
"checkout_url": string // redirect the user to this URL
}curl -X POST https://api.gotcontext.ai/v1/billing/checkout \
-H "Authorization: Bearer YOUR_CLERK_JWT" \
-H "Content-Type: application/json" \
-d '{"plan": "pro"}'Error responses
/v1/billing/portalGet the Polar customer portal URL to manage subscription, payment method, and invoices.
Response
{
"portal_url": string // redirect the user to this URL
}curl -X POST https://api.gotcontext.ai/v1/billing/portal \
-H "Authorization: Bearer YOUR_CLERK_JWT"Error responses
CLI Output Compressor (git diff, pytest, npm)#
/v1/filter-cliCompress verbose CLI output such as git diffs, test results, and npm install logs. Automatically detects the command type and applies type-specific compression. Typical savings: 80-99% on verbose output.
Request body
{
"output": string, // required — raw CLI output to compress (min 1 char)
"command_hint": string|null // optional — hint: "git_diff", "test_output", etc.
// auto-detected if omitted
}Response
{
"filtered": string, // compressed CLI output
"original_chars": number,
"filtered_chars": number,
"savings_pct": number, // e.g. 92.3
"detected_type": string|null // e.g. "git_diff", "pytest"
}curl -X POST https://api.gotcontext.ai/v1/filter-cli \
-H "Authorization: Bearer gc_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"output": "diff --git a/src/main.py b/src/main.py\n...",
"command_hint": "git_diff"
}'Error responses
Lifetime Token Savings (account)#
/v1/savingsRetrieve your cumulative compression savings across all time. Shows total compressions, tokens processed, tokens saved, and an estimated dollar amount saved based on mid-range model pricing.
Response
{
"total_compressions": number,
"total_tokens_in": number,
"total_tokens_saved": number,
"savings_pct": number, // e.g. 87.2
"estimated_cost_saved_usd": number, // e.g. 12.45
// Pricing basis: Opus 4.7 input rates ($5/MTok), valued at compression-time.
// See /pricing for current rates. No model-specific breakdown is returned here.
}curl https://api.gotcontext.ai/v1/savings \
-H "Authorization: Bearer gc_your_key_here"Error responses
Per-Account Semantic-Cache Similarity Thresholdv1.4.0#
The semantic-cache uses cosine similarity to match near-duplicate requests. Research (Portkey + Tianpan, April 2026) shows correct-hit and incorrect-hit similarity distributions overlap between ~0.85 and ~0.92, so a single global threshold is wrong for every non-median workload. Two endpoints let each tenant tune their own cutoff.
/v1/settings/semantic-cache-thresholdRead your current cosine-similarity cutoff. source=user means you've set an override; source=global means the server-wide default applies.
Request body
— no body —Response
{
"threshold": 0.95,
"source": "global" // "user" | "global"
}curl https://api.gotcontext.ai/v1/settings/semantic-cache-threshold \
-H "Authorization: Bearer gc_your_key_here"Error responses
/v1/settings/semantic-cache-thresholdSet or clear your per-tenant cutoff. Pass threshold: null to reset to the server default. Otherwise cosine similarity in [0.80, 0.99].
Request body
{ "threshold": 0.92 }Response
{
"threshold": 0.92,
"source": "user"
}curl -X PUT https://api.gotcontext.ai/v1/settings/semantic-cache-threshold \
-H "Authorization: Bearer gc_your_key_here" \
-H "Content-Type: application/json" \
-d '{"threshold": 0.92}'Error responses
Cache-Hit Source Breakdown (exact vs semantic)v1.4.0#
GET /v1/usage/by-cache responses now include a by_source object that splits the cache hits by which mechanism matched: the request-hash fastpath (exact) vs. the embedding-distance fallback (semantic). The invariant exact_hits + semantic_hits == semantic_cache.hitsholds across the response window.
{
"period_days": 30,
"semantic_cache": { "hits": 15, "misses": 35, "hit_rate": 0.30, … },
"by_source": {
"exact_hits": 12,
"semantic_hits": 3,
"misses": 35
},
…
}Dashboards that rendered only the combined hitscounter previously hid which half of the cache was doing the work. The breakdown lets operators see whether a workload is benefiting from fingerprinting (exact) or from embedding-based near-duplicate matching (semantic), and tune the per-tenant threshold (above) accordingly.
Email Deliverabilityv1.28.0#
gotcontext sends transactional emails for account events: welcome, team invites, API key expiry warnings, per-project budget alerts, and usage digests. v1.28.0 adds automatic suppression when a delivery fails permanently.
When Resend reports a hard bounce or spam complaint against your address, POST /webhooks/resend receives the event (Svix-verified), sets users.email_opt_out = true for that address, and stops all subsequent sends. This prevents repeated delivery to an address that has rejected mail, which protects sender reputation for every account on the platform.
What triggers suppression:
- Hard bounce: the destination mail server permanently rejected the address (user does not exist, domain does not accept mail). Resend event type:
email.bouncedwithbounce_type: permanent. - Spam complaint: the recipient marked the email as spam. Resend event type:
email.complained.
Soft bounces (temporary failures, full inbox) do not trigger suppression.
Re-enabling notifications: if your address was suppressed in error (mis-delivered bounce report, overly aggressive spam filter), email support@gotcontext.ai to clear the opt-out flag. There is no self-serve toggle in the dashboard yet. Tracked for a future settings release.
Manual opt-out is available at GET /v1/unsubscribe?token=<signed-token>. Every transactional email includes a signed unsubscribe link in its footer. Visiting it sets email_opt_out = true for that user without requiring authentication.