API keys overview
Manage your APIs
Scopes define what permissions an API key has when making requests to your API. You can create and define custom scopes when you register your API in Kinde, then assign them for each API key you create.
This topic is about strategies and considerations when assigning scopes to API keys.
The scopes you set will be related to what your app is and does. These are just some examples for AI apps.
read:ai_chats
write:ai_chat
read:ai_analytics
write:ai_analytics
read:ai_workflows
API keys are immutable, so you can’t update the scopes of an existing API key. You can only create a new API key with the desired scopes.
When your application receives a token, validate that it has the required scopes:
function hasRequiredScope(scopes, requiredScope) { return Array.isArray(scopes) && scopes.includes(requiredScope);}
// Example usage (after verifying the API key)if (!hasRequiredScope(verification.scopes, "write:users")) { return res.status(403).json({ error: "Insufficient scope" });}