Skip to content

feat(developers): API keys and webhooks move to each organization's Developers tab (#1440) - #1444

Merged
thinkclay merged 3 commits into
mainfrom
claude/org-developers-1440-41707d
Nov 25, 2026
Merged

thinkclay merged 3 commits into
mainfrom
claude/org-developers-1440-41707d

Conversation

@thinkclay

@thinkclay thinkclay commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1440. Part of epic #1442.

API keys and webhooks belong to an organization, but they lived in Office, which admits only the platform office role, so an employer admin couldn't manage their own. They now sit on a Developers tab on each organization (/employers/org/[slug]/developers), with API keys and Webhooks views. This is the same move #1312 made for Applications.

Up to date (2026-11-25): Scaffald/sdk#44 is merged and packages/sdk points at sdk main 72220d537. origin/main (incl. #1443, the Admin section) is merged in, not rebased; conflicts in drawer/config.ts and OfficeDeveloperLinks.tsx were resolved keeping both sides. After the merge, Office's developer links hold only OAuth apps → /admin/oauth-apps. Re-ran pnpm check, nx run scf-core:test (1859/1859), pnpm prepush (281 gated) and the browser check.

What changed

App

  • Routes ROUTES.EMPLOYERS.ORG.DETAIL.DEVELOPERS (+ API_KEYS, WEBHOOKS, WEBHOOKS.CREATE, WEBHOOKS.DETAIL) and route files under (protected)/employers/org/[slug]/developers/. buildOrgSubItems adds org-<slug>-developers beside Teams and Logs. It lights on every page under the prefix (tested in section-tabs.test.ts).
  • DeveloperPortal now takes organizationId and canManage. The webhook list and create screens moved to features/developers/, plus a new webhook detail screen: status, delivery stats, events, recent deliveries, and delete. The old list row pushed /office/webhooks/:id, which had no route file, so every tap was a 404.
  • Every call passes organization_id from the slug, so a member of two organizations manages each one separately and never sees "pass organization_id".
  • Create, re-scope, revoke and delete are shown only to the org's admins: the owner, anyone holding its admin role, or a team_admin on any of its teams (features/developers/access.ts). Everyone else gets a read-only list.
  • Redirects: /office/api-keys and /office/webhooks/* render LegacyDevelopersRedirect, and the Office layout skips its role gate for them (isLegacyDevelopersPath), as it does for isLegacyHiringPath. A user in one organization goes to the same screen on it (/office/webhooks/<id> goes to that webhook's detail). Users in several organizations, or none, go to My Organizations. Office's own links to the two pages are removed.

Api (packages/supabase/functions/api)

  • lib/org-developer-roles.ts is one membership/admin rule, read from teams, ownership and org-scoped roles. Before, api-keys read teams only, so the owner on no team (the seeded orgAdmin, reviewer-employer) was refused every key call. Webhooks read org-scoped roles only, so a team_admin without one couldn't create a webhook.
  • GET /v1/api-keys?organization_id= filters to one org (403 if you aren't in it), and rows carry organization_id.
  • Creating a key or a webhook, and deleting a webhook, now require admin, matching key revoke. The issue states that rule; the api only enforced it for revoke and update.
  • New GET /v1/webhooks/{id} and GET /v1/webhooks/{id}/deliveries. The SDK's retrieve and listDeliveries already called them, but the api never served them. The list and detail responses no longer include the signing secret.
  • Reads and writes go through the service client after the explicit check, each query pinned to the organization it authorized. The tables' RLS admits team members only (api_keys) or org-role holders only (webhooks), which would lock owners and team_admins out again. No migration.

SDK (Scaffald/sdk#44): optional organization_id on apiKeys.list, webhooks.list, CreateApiKeyParams and CreateWebhookParams.

Tests (real local DB, real HTTP to the api function)

  • New, gated: tests/routers/org-developers-rest.test.ts
    • The orgAdmin persona (owner + org admin, no team, no office role) lists, creates and revokes its keys, and creates, lists, opens (detail + deliveries) and deletes a webhook.
    • A team_admin of two organizations, without the office role or any org-scoped role: an unnamed create gets 400 for keys and webhooks, each org lists only its own key and webhook, and revoke/delete works in both.
    • A plain team member can list but gets 403 on create, revoke and delete.
    • An outsider gets 403 naming another org, an empty webhook list, and 404 on another org's webhook and its deliveries.
  • api-keys-org-authz-rest.test.ts: the "plain member" is now a fresh persona on a team. The seeds give nikola the org-scoped admin role, which counts as admin under the shared rule.
  • Unit: org-developer-roles.test.ts (api), features/developers/__tests__/{access,legacy-paths}.test.ts, section-tabs.test.ts.

Checks

  • pnpm check ✅
  • nx run scf-core:test ✅ 1828/1828 on Node 22.20.0 (.nvmrc). On Node 26, 13 unrelated storage tests fail on its experimental localStorage global.
  • pnpm prepush ✅, gated api suite 281 passed. The shared edge runtime on this machine is mounted from a stale sweep5 worktree, so the gated run used this branch's api on :8014 (*_TEST_API_BASE). Against the stale runtime, 9 unrelated suites (invites, stage history, office jobs, stripe settings) fail; all of them pass against this branch.
  • pnpm radium:check ❌ with 3 violations, none in files this PR touches: packages/ui missing the [theme] dimension (LegendIndicator, useTheme, colors docs) and the @hookform/resolvers 5.x pin. .radium/app-expo.md gains the org-owned-data rule.
  • SDK: pnpm test 787 passed, pnpm typecheck clean.

Browser verification

Local web (expo start --web, api from this branch), signed in as [email protected]: owner and org admin of Apex Mechanical, no office role, on no team.

  • /office/api-keys redirected to /employers/org/apex-mechanical/developers/api-keys.
  • In employer mode, the org strip reads Apex Mechanical Inc. · Teams · Work Logs · Developers with Developers lit, and /developers opens on API keys.
  • Created an API key (one-time key dialog), saw it listed as Active, and revoked it: "API Key Revoked" toast, tab counts Active 0 / Revoked 1.
  • /office/webhooks/create redirected to the org's create page. Created a webhook (secret shown once), saw it in the list, opened its detail (status Active, 0 deliveries, events job.created, "Nothing has been delivered…"), and deleted it (confirm prompt, "Webhook deleted", empty list).
  • Console: only the expected port-split "backend mismatch" warning (api on :8014) and the known Every authenticated page load fires its first SDK queries with the anon key and 401s #964 anon-key 401 burst on full loads.

Overlap with #1443 (#1439, Admin section)

Both PRs touch OfficeDeveloperLinks.tsx (#1443 re-points OAuth apps, this PR removes the API keys and Webhooks entries), routes.ts, drawer/config.ts, section-tabs.test.ts and the locale routes.json files, in different blocks. Whichever merges second keeps both sides. #1443's moved-paths test already leaves /office/api-keys and /office/webhooks alone.

Not in this PR

  • useOrgBySlug (used by the other org pages) has the bug fixed here in useOrgDevelopers: before the user resolves, the disabled query reports isLoading: false, so the page can flash "not found".
  • The API key usage overlay in DeveloperPortal still uses a hard-coded #ffffff background, which is wrong in dark mode.

🤖 Generated with Claude Code

…evelopers tab (#1440)

API keys and webhooks belong to an organization, but they sat in Office,
which admits only the platform `office` role, so an employer admin could not
manage their own. They now live on the organization, the way #1312 moved
Applications to /hiring.

App
- /employers/org/[slug]/developers with API keys and Webhooks views, and a
  Developers tab beside Teams and Logs (ROUTES.EMPLOYERS.ORG.DETAIL.DEVELOPERS).
  The organization comes from the slug and is sent with every call.
- DeveloperPortal takes organizationId and canManage. Create, re-scope and
  revoke are offered only to the organization's admins (owner, org `admin`
  role, or team_admin on any of its teams); everyone else gets a read-only list.
- The webhook list, create and a new detail screen (status, stats, events,
  recent deliveries, delete) moved to features/developers. The old list row
  pushed /office/webhooks/:id, which had no route file and was a 404.
- /office/api-keys and /office/webhooks/* redirect for every signed-in user:
  the Office layout skips its role gate for them (isLegacyDevelopersPath), as
  it does for the hiring paths. One organization goes straight to the same
  screen on it; several or none go to My Organizations. Office's own links to
  them are gone.

Api
- lib/org-developer-roles.ts: one rule for membership and admin, read from
  teams, ownership and org-scoped roles. api-keys read teams only, so the
  owner on no team (the seeded orgAdmin) was refused every call; webhooks read
  org-scoped roles only, so a team_admin without one could not create a webhook.
- GET /v1/api-keys takes ?organization_id= and returns organization_id.
- Creating a key or a webhook, and deleting a webhook, now need admin, like
  revoking a key already did.
- GET /v1/webhooks/{id} and /{id}/deliveries, which the SDK called and the api
  never served. List and detail no longer carry the signing secret.

SDK pointer: Scaffald/sdk#44 (organization_id on list and create).

Tests: tests/routers/org-developers-rest.test.ts (gated) covers the orgAdmin
persona, a team_admin of two organizations without the office role, a plain
member and an outsider. api-keys-org-authz-rest.test.ts uses a fresh plain
member: the seeds give nikola the org-scoped admin role.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

📊 Performance Benchmark Results

    CPU | AMD EPYC 9V74 80-Core Processor
Runtime | Deno 2.9.8 (x86_64-unknown-linux-gnu)

file:///home/runner/work/SaaS/SaaS/packages/supabase/functions/api/__tests__/benchmarks/rest-vs-trpc.bench.ts

| benchmark                                     | time/iter (avg) |        iter/s |      (min … max)      |      p75 |      p99 |     p995 |
| --------------------------------------------- | --------------- | ------------- | --------------------- | -------- | -------- | -------- |

group jobs-list
REST: GET /v1/jobs (paginated list):   → Average response time: 82.52ms
REST: GET /v1/jobs (paginated list):   → Average response time: 80.66ms
REST: GET /v1/jobs (paginated list):   → Average response time: 77.89ms
REST: GET /v1/jobs (paginated list):   → Average response time: 83.25ms
REST: GET /v1/jobs (paginated list):   → Average response time: 79.29ms
| REST: GET /v1/jobs (paginated list)           |           3.1 s |           0.3 | (   3.1 s …    3.2 s) |    3.1 s |    3.2 s |    3.2 s |

group job-details
REST: GET /v1/jobs/:id (single job):   → Average response time: 75.59ms
REST: GET /v1/jobs/:id (single job):   → Average response time: 78.15ms
REST: GET /v1/jobs/:id (single job):   → Average response time: 79.58ms
REST: GET /v1/jobs/:id (single job):   → Average response time: 80.57ms
REST: GET /v1/jobs/:id (single job):   → Average response time: 79.15ms
| REST: GET /v1/jobs/:id (single job)           |           3.1 s |           0.3 | (   3.1 s …    3.2 s) |    3.1 s |    3.2 s |    3.2 s |

group application-create
REST: POST /v1/applications (create):   → Average response time: 96.99ms
REST: POST /v1/applications (create):   → Average response time: 73.29ms
REST: POST /v1/applications (create):   → Average response time: 75.63ms
REST: POST /v1/applications (create):   → Average response time: 74.13ms
REST: POST /v1/applications (create):   → Average response time: 75.62ms
| REST: POST /v1/applications (create)          |           5.0 s |           0.2 | (   4.9 s …    5.0 s) |    5.0 s |    5.0 s |    5.0 s |

group concurrency
REST: Concurrent GET /v1/jobs (10 parallel):   → Throughput: 25.68 req/s
REST: Concurrent GET /v1/jobs (10 parallel):   → Average time per batch: 389.47ms
REST: Concurrent GET /v1/jobs (10 parallel):   → Throughput: 25.35 req/s
REST: Concurrent GET /v1/jobs (10 parallel):   → Average time per batch: 394.41ms
REST: Concurrent GET /v1/jobs (10 parallel):   → Throughput: 20.74 req/s
REST: Concurrent GET /v1/jobs (10 parallel):   → Average time per batch: 482.24ms
REST: Concurrent GET /v1/jobs (10 parallel):   → Throughput: 21.76 req/s
REST: Concurrent GET /v1/jobs (10 parallel):   → Average time per batch: 459.56ms
REST: Concurrent GET /v1/jobs (10 parallel):   → Throughput: 21.05 req/s
REST: Concurrent GET /v1/jobs (10 parallel):   → Average time per batch: 475.02ms
| REST: Concurrent GET /v1/jobs (10 parallel)   |           7.9 s |           0.1 | (   7.1 s …    8.3 s) |    8.2 s |    8.3 s |    8.3 s |

group filtered-queries
REST: GET /v1/jobs with multiple filters:   → Average response time: 77.11ms
REST: GET /v1/jobs with multiple filters:   → Average response time: 80.07ms
REST: GET /v1/jobs with multiple filters:   → Average response time: 83.71ms
REST: GET /v1/jobs with multiple filters:   → Average response time: 80.56ms
REST: GET /v1/jobs with multiple filters:   → Average response time: 79.33ms
| REST: GET /v1/jobs with multiple filters      |           3.4 s |           0.3 | (   3.2 s …    4.0 s) |    3.3 s |    4.0 s |    4.0 s |


@github-actions

Copy link
Copy Markdown
Contributor

📊 Performance Benchmark Results

    CPU | Intel(R) Xeon(R) 6975P-C
Runtime | Deno 2.9.8 (x86_64-unknown-linux-gnu)

file:///home/runner/work/SaaS/SaaS/packages/supabase/functions/api/__tests__/benchmarks/rest-vs-trpc.bench.ts

| benchmark                                     | time/iter (avg) |        iter/s |      (min … max)      |      p75 |      p99 |     p995 |
| --------------------------------------------- | --------------- | ------------- | --------------------- | -------- | -------- | -------- |

group jobs-list
REST: GET /v1/jobs (paginated list):   → Average response time: 60.46ms
REST: GET /v1/jobs (paginated list):   → Average response time: 58.47ms
REST: GET /v1/jobs (paginated list):   → Average response time: 57.60ms
REST: GET /v1/jobs (paginated list):   → Average response time: 59.05ms
REST: GET /v1/jobs (paginated list):   → Average response time: 58.34ms
| REST: GET /v1/jobs (paginated list)           |           2.6 s |           0.4 | (   2.6 s …    2.6 s) |    2.6 s |    2.6 s |    2.6 s |

group job-details
REST: GET /v1/jobs/:id (single job):   → Average response time: 54.28ms
REST: GET /v1/jobs/:id (single job):   → Average response time: 55.33ms
REST: GET /v1/jobs/:id (single job):   → Average response time: 54.61ms
REST: GET /v1/jobs/:id (single job):   → Average response time: 56.81ms
REST: GET /v1/jobs/:id (single job):   → Average response time: 53.88ms
| REST: GET /v1/jobs/:id (single job)           |           2.5 s |           0.4 | (   2.5 s …    2.5 s) |    2.5 s |    2.5 s |    2.5 s |

group application-create
REST: POST /v1/applications (create):   → Average response time: 54.47ms
REST: POST /v1/applications (create):   → Average response time: 71.56ms
REST: POST /v1/applications (create):   → Average response time: 54.13ms
REST: POST /v1/applications (create):   → Average response time: 54.91ms
REST: POST /v1/applications (create):   → Average response time: 55.00ms
| REST: POST /v1/applications (create)          |           4.2 s |           0.2 | (   3.9 s …    4.8 s) |    4.0 s |    4.8 s |    4.8 s |

group concurrency
REST: Concurrent GET /v1/jobs (10 parallel):   → Throughput: 36.19 req/s
REST: Concurrent GET /v1/jobs (10 parallel):   → Average time per batch: 276.34ms
REST: Concurrent GET /v1/jobs (10 parallel):   → Throughput: 18.49 req/s
REST: Concurrent GET /v1/jobs (10 parallel):   → Average time per batch: 540.79ms
REST: Concurrent GET /v1/jobs (10 parallel):   → Throughput: 31.11 req/s
REST: Concurrent GET /v1/jobs (10 parallel):   → Average time per batch: 321.49ms
REST: Concurrent GET /v1/jobs (10 parallel):   → Throughput: 31.24 req/s
REST: Concurrent GET /v1/jobs (10 parallel):   → Average time per batch: 320.10ms
REST: Concurrent GET /v1/jobs (10 parallel):   → Throughput: 32.02 req/s
REST: Concurrent GET /v1/jobs (10 parallel):   → Average time per batch: 312.33ms
| REST: Concurrent GET /v1/jobs (10 parallel)   |           6.6 s |           0.2 | (   5.9 s …    8.1 s) |    6.2 s |    8.1 s |    8.1 s |

group filtered-queries
REST: GET /v1/jobs with multiple filters:   → Average response time: 76.56ms
REST: GET /v1/jobs with multiple filters:   → Average response time: 60.81ms
REST: GET /v1/jobs with multiple filters:   → Average response time: 59.73ms
REST: GET /v1/jobs with multiple filters:   → Average response time: 59.49ms
REST: GET /v1/jobs with multiple filters:   → Average response time: 60.75ms
| REST: GET /v1/jobs with multiple filters      |           2.7 s |           0.4 | (   2.6 s …    2.7 s) |    2.7 s |    2.7 s |    2.7 s |


…type-check (#1440)

The openapi routes declared only their success response, so every
c.json(..., 401/403/404/500) was a type error: three on main, two more from
the detail and deliveries routes this PR added. Each route now declares the
errors it returns, and the success returns name their 200. webhooks.ts goes
from 5 type errors to 0, so its TYPECHECK_BASELINE entry (3) is removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

📊 Performance Benchmark Results

    CPU | AMD EPYC 9V74 80-Core Processor
Runtime | Deno 2.9.8 (x86_64-unknown-linux-gnu)

file:///home/runner/work/SaaS/SaaS/packages/supabase/functions/api/__tests__/benchmarks/rest-vs-trpc.bench.ts

| benchmark                                     | time/iter (avg) |        iter/s |      (min … max)      |      p75 |      p99 |     p995 |
| --------------------------------------------- | --------------- | ------------- | --------------------- | -------- | -------- | -------- |

group jobs-list
REST: GET /v1/jobs (paginated list):   → Average response time: 90.02ms
REST: GET /v1/jobs (paginated list):   → Average response time: 96.65ms
REST: GET /v1/jobs (paginated list):   → Average response time: 93.79ms
REST: GET /v1/jobs (paginated list):   → Average response time: 89.45ms
REST: GET /v1/jobs (paginated list):   → Average response time: 89.16ms
| REST: GET /v1/jobs (paginated list)           |           3.4 s |           0.3 | (   3.3 s …    3.6 s) |    3.4 s |    3.6 s |    3.6 s |

group job-details
REST: GET /v1/jobs/:id (single job):   → Average response time: 87.94ms
REST: GET /v1/jobs/:id (single job):   → Average response time: 84.27ms
REST: GET /v1/jobs/:id (single job):   → Average response time: 85.29ms
REST: GET /v1/jobs/:id (single job):   → Average response time: 85.18ms
REST: GET /v1/jobs/:id (single job):   → Average response time: 129.47ms
| REST: GET /v1/jobs/:id (single job)           |           3.4 s |           0.3 | (   3.2 s …    4.1 s) |    3.2 s |    4.1 s |    4.1 s |

group application-create
REST: POST /v1/applications (create):   → Average response time: 86.50ms
REST: POST /v1/applications (create):   → Average response time: 86.58ms
REST: POST /v1/applications (create):   → Average response time: 88.90ms
REST: POST /v1/applications (create):   → Average response time: 89.04ms
REST: POST /v1/applications (create):   → Average response time: 88.28ms
| REST: POST /v1/applications (create)          |           5.7 s |           0.2 | (   5.6 s …    5.7 s) |    5.7 s |    5.7 s |    5.7 s |

group concurrency
REST: Concurrent GET /v1/jobs (10 parallel):   → Throughput: 23.26 req/s
REST: Concurrent GET /v1/jobs (10 parallel):   → Average time per batch: 429.92ms
REST: Concurrent GET /v1/jobs (10 parallel):   → Throughput: 23.56 req/s
REST: Concurrent GET /v1/jobs (10 parallel):   → Average time per batch: 424.47ms
REST: Concurrent GET /v1/jobs (10 parallel):   → Throughput: 19.32 req/s
REST: Concurrent GET /v1/jobs (10 parallel):   → Average time per batch: 517.57ms
REST: Concurrent GET /v1/jobs (10 parallel):   → Throughput: 20.34 req/s
REST: Concurrent GET /v1/jobs (10 parallel):   → Average time per batch: 491.63ms
REST: Concurrent GET /v1/jobs (10 parallel):   → Throughput: 21.26 req/s
REST: Concurrent GET /v1/jobs (10 parallel):   → Average time per batch: 470.33ms
| REST: Concurrent GET /v1/jobs (10 parallel)   |           8.4 s |           0.1 | (   7.8 s …    8.8 s) |    8.7 s |    8.8 s |    8.8 s |

group filtered-queries
REST: GET /v1/jobs with multiple filters:   → Average response time: 130.12ms
REST: GET /v1/jobs with multiple filters:   → Average response time: 80.85ms
REST: GET /v1/jobs with multiple filters:   → Average response time: 78.10ms
REST: GET /v1/jobs with multiple filters:   → Average response time: 76.47ms
REST: GET /v1/jobs with multiple filters:   → Average response time: 77.20ms
| REST: GET /v1/jobs with multiple filters      |           3.2 s |           0.3 | (   3.1 s …    3.2 s) |    3.2 s |    3.2 s |    3.2 s |


@thinkclay
thinkclay merged commit 99acd40 into main Nov 25, 2026
15 checks passed
@thinkclay
thinkclay deleted the claude/org-developers-1440-41707d branch November 25, 2026 22:41
thinkclay added a commit that referenced this pull request Nov 26, 2026
Office/Admin/Developers split (epic #1442: #1443, #1444, #1445, #1446)
and worker invites with reminders (#1430, #1438; migrations 400, 401).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(developers): API keys and webhooks are per-organization but sit behind Office's staff-only gate — move them to the employer side

1 participant