Skip to content

feat(server): add public environment api-keys management endpoints - #7007

Draft
ErickRDev wants to merge 2 commits into
masterfrom
erickr/NAN-6478-add-public-env-api-keys-management-routes
Draft

feat(server): add public environment api-keys management endpoints#7007
ErickRDev wants to merge 2 commits into
masterfrom
erickr/NAN-6478-add-public-env-api-keys-management-routes

Conversation

@ErickRDev

@ErickRDev ErickRDev commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Add POST and DELETE /environment/api-keys to the public API so account-key holders can manage per-environment API keys programmatically.

  • New PostPublicApiKey / DeletePublicApiKey endpoint types, wired into PublicApiEndpoints.
  • New controllers under controllers/environment/, both validating target environment belongs to the account (res.locals.account) before touching customerKeyService.
  • Extract the create-key error mapping from the private createApiKey controller into sendCreateEnvironmentKeyError so both paths share the same error handling principles.

Review in cubic

@ErickRDev ErickRDev self-assigned this Aug 3, 2026
@linear-code

linear-code Bot commented Aug 3, 2026

Copy link
Copy Markdown

NAN-6478

@ErickRDev
ErickRDev force-pushed the erickr/NAN-6478-add-public-env-api-keys-management-routes branch from 87676fc to 4110c01 Compare August 3, 2026 15:03
@ErickRDev ErickRDev changed the title feat(api): add public envirnmont api-keys management endpoints feat(server): add public environment api-keys management endpoints Aug 3, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed against the latest diff

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/server/lib/controllers/environment/deleteApiKey.ts
Comment thread packages/server/lib/routes.public.ts
Comment thread packages/server/lib/controllers/environment/postApiKey.ts
Comment thread packages/types/lib/environment/api/index.ts Outdated
Comment thread packages/server/lib/controllers/environment/postApiKey.ts
Comment thread packages/server/lib/controllers/environment/sendCreateEnvironmentKeyError.ts Outdated
@ErickRDev
ErickRDev requested review from TBonnin and kaposke August 3, 2026 15:25
@ErickRDev
ErickRDev force-pushed the erickr/NAN-6478-add-public-env-api-keys-management-routes branch from 4110c01 to 6bbfb9c Compare August 3, 2026 16:17
Add POST and DELETE /environment/api-keys to the public API so account-key
holders can manage per-environment API keys programmatically.

- New PostPublicApiKey / DeletePublicApiKey endpoint types, wired into
  PublicApiEndpoints.
- New controllers under controllers/environment/, both validating target
  environment belongs to the account (res.locals.account) before
  touching customerKeyService.
- Extract the create-key error mapping from the private createApiKey
  controller into sendCreateEnvironmentKeyError so both paths share the
  same error handling principles.
@ErickRDev
ErickRDev force-pushed the erickr/NAN-6478-add-public-env-api-keys-management-routes branch from 6bbfb9c to 50ef9ac Compare August 3, 2026 23:52
Comment thread packages/server/lib/controllers/shared/environments/postApiKey.ts
report(error);
res.status(500).send({ error: { code: 'server_error', message: 'Failed to create API key' } });
}
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need a separate function?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need is a strong word. We don't need it, but IMHO it's a nice way to make the controller logic cleaner and thus easier to understand at a glance.

I used the same pattern in #6973; see shared/environments/postEnvironment.ts in that PR.

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.

2 participants