Skip to content

feat: Surface agent registration id on API key validation#1644

Merged
m0tzy merged 2 commits into
mainfrom
madison/agent-api-keys
Jun 25, 2026
Merged

feat: Surface agent registration id on API key validation#1644
m0tzy merged 2 commits into
mainfrom
madison/agent-api-keys

Conversation

@m0tzy

@m0tzy m0tzy commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Adapts the SDK to workos/workos#63786, which expands the POST /api_keys/validations response with an optional top-level agent_registration_id — present only when the validated API key is assigned to an agent registration, omitted otherwise.

workos.apiKeys.createValidation now surfaces this as an optional agentRegistrationId:

  • ValidateApiKeyResponse gains agentRegistrationId?: string (and the serialized type gains agent_registration_id?).
  • The deserializer conditionally spreads the field, so it is omitted (not null) for non-agent keys — mirroring the server's "present only when set" semantics and matching the existing optional-field convention (e.g. stripeCustomerId in the organization serializer).

The shared ApiKey object (list/create/get) is unchanged; the new field lives on the validation response only.

Testing

  • jest src/api-keys — 11 pass (added: agent-assigned key returns the registration id; non-agent key omits the field; existing cases untouched)
  • tsc --noEmit, eslint, and prettier --check all clean

Closes AUTH-6624

🤖 Generated with Claude Code

POST /api_keys/validations now returns an optional agent_registration_id,
present only when the validated key is assigned to an agent registration.
createValidation surfaces it as an optional agentRegistrationId, omitted for
non-agent keys.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@linear-code

linear-code Bot commented Jun 25, 2026

Copy link
Copy Markdown

AUTH-6624

@m0tzy m0tzy changed the title feat(api-keys): Surface agent registration id on key validation feat: Surface agent registration id on key validation Jun 25, 2026
@m0tzy m0tzy changed the title feat: Surface agent registration id on key validation feat: Surface agent registration id on API key validation Jun 25, 2026
@m0tzy m0tzy requested a review from a team June 25, 2026 14:15
The agent registration id value used the agent_registration_ prefix; the real
prefix is agent_reg_. Field names are unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@m0tzy m0tzy marked this pull request as ready for review June 25, 2026 21:30
@m0tzy m0tzy requested review from a team as code owners June 25, 2026 21:30
@m0tzy m0tzy requested a review from mattolson June 25, 2026 21:30

@devin-ai-integration devin-ai-integration 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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@greptile-apps

greptile-apps Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR surfaces agent registration ids from API key validation responses. The main changes are:

  • Adds optional agentRegistrationId response typing.
  • Maps agent_registration_id in the validation deserializer.
  • Adds tests for present and omitted agent registration ids.

Confidence Score: 5/5

The change is narrowly scoped to API key validation response typing and deserialization.

The updated validation response contract maps the new optional server field to the SDK response shape while preserving omitted-field behavior for non-agent keys. The changed tests cover both present and absent agent_registration_id cases, and the shared ApiKey shape remains outside the new field’s scope.

None.

T-Rex T-Rex Logs

What T-Rex did

  • Ran the initial API key validation contract tests to establish baseline behavior; the run exited with code 1 and showed inputHasAgentRegistrationId: true while outputHasAgentRegistrationId: false.
  • Ran the API key validation agent registration tests after changes; the run exited with code 0 and now shows outputHasAgentRegistrationId: true with the camelCase agent key.
  • Executed the targeted API key test suite for the src/api-keys path to validate agent-assigned and non-agent validation responses; the run exited with code 0.

View all artifacts

T-Rex Ran code and verified through T-Rex

Reviews (1): Last reviewed commit: "fix(api-keys): Use correct agent_reg_ pr..." | Re-trigger Greptile

@m0tzy m0tzy merged commit b03cdd0 into main Jun 25, 2026
8 checks passed
@m0tzy m0tzy deleted the madison/agent-api-keys branch June 25, 2026 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants