Skip to content

Personal API keys and a public REST API #195

Open

Description

@imshashank

There is no way to script Orbit. The roadmap lists a public API under "Later", and the schema is further along than that suggests.

api_key in packages/db/src/schema/comms.ts already has everything a key needs: organisation, user, name, a hashed key, a display prefix, last used, expiry and revocation. Nothing reads it or writes it. The only match for apiKey anywhere else in the repository is a local variable in the Resend email transport, which is unrelated.

Why this is not covered by MCP

The MCP server is excellent for agents and wrong for scripts. It speaks a protocol designed for language models, it requires an OAuth dance with a consent screen and a passkey re-verification, and it exposes tools rather than resources. Nobody is going to run that from a cron job or a CI step.

The two should coexist. MCP for agents, keys and REST for scripts.

What to build

This is deliberately one issue because the pieces are useless separately, but it should land as several pull requests.

1. Key management.

  • Create a key in personal settings, scoped to one workspace, with a name and an optional expiry
  • Show the key exactly once, on creation, and never again. Store only the hash. @node-rs/argon2 is already a dependency and is what hashes passwords, so use the same thing rather than adding another hasher
  • A prefix column exists so a key can be identified in a list without revealing it. Use it, and design the prefix so a leaked key is greppable in logs and in public repositories
  • Revoke, and show last used, which is what tells somebody whether a key is safe to revoke

2. Authentication.

  • A bearer token on the API routes, resolving to a principal
  • last_used_at updated on use, but not on every single request, or a busy key becomes a write hotspot
  • Expired and revoked keys refused with a clear error
  • Rate limiting per key

3. The API itself.

  • Read and write for issues, comments, projects, sprints, docs, labels and states
  • Every route parses input with a Zod schema from packages/shared, like every existing route
  • Every route goes through packages/shared/src/policy. A key never grants more than its owner has. This is the single most important property. A member's key must not be able to read a team they are not on
  • Every mutation goes through packages/core, so it bumps sync_id, publishes to Redis and fans out to open tabs. An API write that does not appear in somebody's browser immediately is a bug
  • Pagination, filtering and a stable ordering
  • Consistent errors, using the typed domain errors in packages/shared/src/errors

4. Documentation.

  • An OpenAPI description, generated from the Zod schemas if that is practical rather than hand written and immediately stale
  • A page in docs/, alongside docs/mcp.md
  • Examples with curl

Decisions worth making on this thread first

  • Scopes. Should a key be read only, read write, or finer grained? The MCP grants already have orbit.read and orbit.write, so there is a precedent to follow and reusing it would be consistent.
  • Personal keys or workspace keys. The table has both organization_id and user_id, implying a personal key scoped to one workspace. That is the right default. Service accounts are a separate and larger question.
  • REST or GraphQL. REST, unless somebody makes a strong case. It matches the existing route handlers and the audience is scripts.

Files

  • packages/db/src/schema/comms.ts
  • apps/web/src/app/api/ for the routes, likely under a versioned prefix
  • packages/shared/src/policy
  • packages/core/
  • apps/web/src/app/(app)/settings/account/ for key management
  • docs/

This is a large piece of work

It is a good one to split across several people. Say which part you are taking.

Activity

  1. added
    enhancement
    help wanted
    p1 high
    area: auth
    roadmap
    dead code
    on Aug 8, 2026
  2. moved this to Backlog in Orbit roadmapon Aug 8, 2026
  3. added
    size: extra large
    points: 13
    on Aug 8, 2026
  4. imshashank commented on Sep 6, 2026

    @imshashank
    ContributorAuthor

    Split for whoever picks it up: the first PR is key creation, argon2 hashing, the greppable prefix, revoke, last-used, and bearer auth resolving to a principal with the owner's permissions; the second PR is the routes. Scopes reuse orbit.read and orbit.write from the MCP grants rather than inventing a third set.

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

    area: authdead codeenhancementhelp wantedp1 highpoints: 13roadmapsize: extra large

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions