Check if an API key has the required scope for an operation.
This function implements the three-tier permission model:
The API key ID from context.userPayload.apiKeyId
The scope path required (e.g., 'view:run', 'agent:execute')
The authenticated user from context.userPayload.userRecord
Additional options for scope checking
ScopeAuthResult with authorization details
AuthorizationError if access is denied and throwOnDenied is true
// In a resolverasync runView(@Ctx() ctx: AppContext): Promise<ViewResult> { await CheckAPIKeyScope( ctx.userPayload.apiKeyId, 'view:run', ctx.userPayload.userRecord, { resource: 'User' } ); // ... proceed with operation} Copy
// In a resolverasync runView(@Ctx() ctx: AppContext): Promise<ViewResult> { await CheckAPIKeyScope( ctx.userPayload.apiKeyId, 'view:run', ctx.userPayload.userRecord, { resource: 'User' } ); // ... proceed with operation}
Check if an API key has the required scope for an operation.
This function implements the three-tier permission model: