Skip to main content

Authorization Overview

Control what each API key can access using role-based access control (RBAC). Assign roles and fine-grained permissions to your keys.
2 min read

Authorization controls what an authenticated key can do. While verification answers "is this key valid?", authorization answers "can this key perform this action?"

Unkey provides Role-Based Access Control (RBAC) that lets you:

  • Define permissions (like documents.read, billing.write)
  • Group permissions into roles (like admin, editor, viewer)
  • Attach roles or permissions directly to keys
  • Check permissions during verification

When to use this#

Multi-tenant SaaS

Different customers get different feature access. Enterprise keys can do more than free-tier keys.

Team permissions

Admin keys can delete resources, editor keys can modify, viewer keys can only read.

Feature flags

Only keys with beta.access permission can use new features.

Resource scoping

Keys can only access specific resources: project.123.read, project.456.write.

How it works#

Define permissions

Create permissions that map to actions in your app: documents.read, documents.write, users.delete.

Create roles (optional)

Group permissions into roles for easier management. An editor role might include documents.read and documents.write.

Attach to keys

When creating or updating keys, assign roles or direct permissions.

Check during verification

Pass a permission query when verifying. Unkey checks if the key has the required permissions.

Quick example#

Permissions vs Roles#

ConceptWhat it isExample
PermissionA specific actiondocuments.read, billing.manage
RoleA group of permissionsadmin = all permissions, viewer = read-only permissions

You can attach either (or both) directly to keys:

  • Attach roles when you want predefined access levels
  • Attach permissions directly for fine-grained control

Next steps#