Skip to content

Self-serve API keys #36

Closed
Closed

Description

@maaland

Why

Agents should set themselves up with no human involved, but usage still needs bounds: abuse control now, metering later.

What to build

  • POST /api/keys creates a key and returns it at once: { "key": "sp_…", "limits": { "scansPerDay": 10 } }. No sign-up form.
  • Key creation is rate-limited per IP so keys can't be farmed.
  • Keys are stored hashed; only the prefix is ever shown again. A key can be revoked.
  • Each request made with a key is logged (key, endpoint, time) for usage counts.
  • A daily new-scan limit per key (10 to start). Returning a recent scan (under a day old) doesn't count.
  • Lives behind the existing Store-style interfaces; nothing Vercel-specific in core.

Decided 2026-10-12:

  • The daily new-scan allowance is one mechanism shared with Website gating: anonymous allowance and bot check #41: a counter per subject, either an API key (10 new scans a day) or an anonymous website visitor (3 a day, used in Website gating: anonymous allowance and bot check #41).
  • At most 3 new keys a day per IP.
  • IPs are never stored raw: only a keyed hash (secret in an env var). Usage rows are kept for 30 days.
  • The holder revokes a key with DELETE /api/keys/current, sending the key. There are no accounts yet.
  • This issue builds the keys and the allowance; HTTP scan API #37 (HTTP scan API) is the first endpoint that spends it.

Done when

  • Creating, using, exceeding the limit (429 with a clear message and reset time) and revoking are tested (using and exceeding at the allowance level; HTTP scan API #37 adds the endpoint).
  • Creating a fourth key from one IP in a day gets a 429.
  • Keys never appear in logs or responses after creation.
  • Migration added for keys and usage tables (row level security on, like the existing tables).

Activity

  1. drippa-ai commented on Oct 12, 2026

    @drippa-ai

    Drippa Sign-Off: Self-serve API key creation and revocation for agents

    ✅ Delivers ticket #36 — 5 of 5 outcomes

    Open in Drippa

    What was promised

    • ✅ Self-serve API keys #36 An agent can create an API key with no sign-up and gets it back at once, with its daily limit of 10 new scans.
    • ✅ Self-serve API keys #36 A fourth key from the same address in one day is refused with a clear message and the time it resets.
    • ✅ Self-serve API keys #36 The holder can revoke a key by sending it, and a revoked key stops working.
    • ✅ Self-serve API keys #36 The key itself is never shown again after creation, and caller addresses are kept only as a keyed hash.
    • ✅ Self-serve API keys #36 Each request made with a key is recorded against the key for usage counts, without storing the key.

    Not tested in the browser: behaviour change with no page to click.

    Full review on the pull request


    Updated by Drippa • 2026-10-12 18:28 UTC

  2. added a commit that references this issue on Oct 12, 2026
    0bca04e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions