Skip to content

Issue scoped API keys per customer and environment

Generate prefixed keys restricted to specific endpoints, read-only routes, or workspaces—no custom auth database required.

Copy the prompt and paste it into the AI assistant you already use.

Checklist for scoped tenant API key design

  1. 01

    Follow least-privilege scoping

    Grant each customer or microservice key access strictly to the endpoints it actually calls.

  2. 02

    Embed distinct key prefixes

    Use separate prefixes for live vs test keys so developers and secret scanners recognize leaks fast.

  3. 03

    Attach tenant ID metadata

    Bind workspace_id and plan tier inside key metadata on creation rather than trusting request body IDs.

  4. 04

    Verify cross-tenant isolation

    Test that a key scoped to workspace A receives HTTP 403 when probing workspace B resources.

How it works in practice

Provisioned Tenant Key Policy

Prefix: ak_live_acme_ Tenant Metadata: { workspace_id: "ws_918", plan: "pro" } Allowed Endpoints: ["POST /v1/extract-sku", "GET /v1/jobs/*"] Denied: ["POST /v1/evals/*", "DELETE *"]

Gateway Enforcement

POST /v1/extract-sku -> 200 OK (tagged workspace=ws_918) POST /v1/evals/run -> 403 Forbidden {"error":"insufficient_key_scope"}

Every customer integration runs under least-privilege boundaries with zero custom auth tables or middleware.

Common questions

How do I avoid trusting a tenant_id sent inside the JSON body?

APIkit injects verified metadata stored on the API key itself directly into rate limits, logs, and connectors—ignoring spoofed body IDs.

Can I issue keys dynamically when a user signs up?

Yes. Call the key management endpoint from your signup flow to mint and display a scoped key automatically.

What format do generated API keys use?

Keys use high-entropy random tokens with distinct environment prefixes compatible with GitHub secret scanning.