Add Update API Key endpoint documentation#126
Open
josephfeleke wants to merge 2 commits into
Open
Conversation
Add PATCH endpoint for updating API key name and permissions across org, pod, and inbox scopes. Add api_key_update permission to ApiKeyPermissions.
✨ API Changes# API Changelog n/a vs. n/a
## API Changes
### GET /v0/api-keys
- added the optional property 'api_keys/items/permissions/api_key_update' to the response with the '200' status
### POST /v0/api-keys
- added the new optional request property 'permissions/api_key_update'
- added the optional property 'permissions/api_key_update' to the response with the '200' status
### PATCH /v0/api-keys/{api_key_id}
- endpoint added
### GET /v0/inboxes/{inbox_id}/api-keys
- added the optional property 'api_keys/items/permissions/api_key_update' to the response with the '200' status
### POST /v0/inboxes/{inbox_id}/api-keys
- added the new optional request property 'permissions/api_key_update'
- added the optional property 'permissions/api_key_update' to the response with the '200' status
### PATCH /v0/inboxes/{inbox_id}/api-keys/{api_key_id}
- endpoint added
### GET /v0/pods/{pod_id}/api-keys
- added the optional property 'api_keys/items/permissions/api_key_update' to the response with the '200' status
### POST /v0/pods/{pod_id}/api-keys
- added the new optional request property 'permissions/api_key_update'
- added the optional property 'permissions/api_key_update' to the response with the '200' status
### PATCH /v0/pods/{pod_id}/api-keys/{api_key_id}
- endpoint added💡 Download |
- Add `message_delete`; remove non-existent `thread_read` and `thread_delete` (replaced by message_* permissions in the API months ago, docs lagged). - Document permissions semantics on Create and Update endpoints: - Omitted: inherit (Create) / no-op (Update) - null: make unrestricted (gated to unrestricted callers; 403 otherwise) - Populated: merge with stored, per-field escalation rejected - Add `ForbiddenError` (403) on Create and Update. - Note "at least one of name or permissions" requirement on Update.
Contributor
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="fern/definition/api-keys.yml">
<violation number="1" location="fern/definition/api-keys.yml:244">
P2: `ForbiddenError` is missing from the `create` and `update` endpoints in the pod-scoped and inbox-scoped API key files (`fern/definition/pods/api-keys.yml`, `fern/definition/inboxes/api-keys.yml`). Both scopes share the same request types whose docs describe 403 responses for permission escalation, so their error lists should be consistent with the org scope.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
| response: CreateApiKeyResponse | ||
| errors: | ||
| - global.ValidationError | ||
| - ForbiddenError |
Contributor
There was a problem hiding this comment.
P2: ForbiddenError is missing from the create and update endpoints in the pod-scoped and inbox-scoped API key files (fern/definition/pods/api-keys.yml, fern/definition/inboxes/api-keys.yml). Both scopes share the same request types whose docs describe 403 responses for permission escalation, so their error lists should be consistent with the org scope.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At fern/definition/api-keys.yml, line 244:
<comment>`ForbiddenError` is missing from the `create` and `update` endpoints in the pod-scoped and inbox-scoped API key files (`fern/definition/pods/api-keys.yml`, `fern/definition/inboxes/api-keys.yml`). Both scopes share the same request types whose docs describe 403 responses for permission escalation, so their error lists should be consistent with the org scope.</comment>
<file context>
@@ -210,6 +241,7 @@ service:
response: CreateApiKeyResponse
errors:
- global.ValidationError
+ - ForbiddenError
update:
</file context>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Documents the merged Update API Key endpoint and syncs the existing definition to the current API surface.
What changed in this PR
message_delete; removedthread_readandthread_delete(these were replaced bymessage_*permissions in the API back in March/April but the docs lagged).permissionsfield (omit /null/ populated object).ForbiddenError(403) added to Create and Update — surfaces when a caller tries to clear permissions or grant fields they don't themselves hold.nameorpermissions" note added on Update.A note on
nullin the TypeScript SDKThe API accepts
permissions: nullto clear restrictions and make a key unrestricted. This is reflected in the docstring on the field. Two relevant facts about how the SDKs render this:permissions=Noneworks idiomatically because Fern emitstyping.Optional[ApiKeyPermissions](which isT | None).permissions?: ApiKeyPermissions(i.e.T | undefined). Fern's YAML grammar doesn't express "nullable" —optional<T>is the closest construct, and it doesn't includenullin the resulting TS type.Net effect for TS users wanting to clear permissions: the runtime sends
nullcorrectly when givennull, but the compiler will complain unless they cast ({ permissions: null as any }). The docstring on the field tells them what to send, so this is a typing limitation, not a behavior limitation. Same shape as every other update endpoint in the SDK; not unique to this PR.If we later want first-class TS ergonomics on the clear path, the cleanest fix is an API change (replace the
nullsemantic with a sentinel field likeclear_permissions: true). That's out of scope here.Test plan
npx fern-api check— all checks pass.permissionShapeinsrc/schemas/api-key.ts.ForbiddenError,NotFoundError,ValidationError).resolveCreateApiKeyPermissionsandresolveUpdateApiKeyPermissions.