fix(controlplane): keep only explicit policies on API tokens

Merged
JI
19d ago
+28-8

When an API token is created with an explicit policy set (APITokenWithPolicies), the token now carries only those policies, whatever its scope. Before, organization-scoped tokens also got the organization-level policies (API token management and registered integrations) added on top of the explicit set.

Tokens created without an explicit policy set keep the current behavior: the default policies, plus the organization-level policies for organization-scoped tokens.

Callers that create organization-scoped tokens with an explicit policy set and need the organization-level policies must now pass them explicitly.

Closes #3822

AI disclosure: this change was produced with the assistance of Claude Code.