WorkOS Docs Homepage
FGA
API referenceDashboardSign In
OverviewOverviewQuick StartQuick StartCore ConceptsResource TypesResource TypesResourcesResourcesRoles and PermissionsRoles and PermissionsAssignmentsAssignmentsAccess ControlAccess ChecksAccess ChecksResource DiscoveryResource DiscoveryIntegrationsAuthKit IntegrationAuthKit IntegrationIdP Role AssignmentIdP Role Assignment
API Reference
API Reference
Events
Events
Integrations
Integrations
Migrate to WorkOS
Migrate to WorkOS
SDKs
SDKs

AuthKit Integration

Use FGA with AuthKit for role-aware sessions and seamless authorization.

On this page

  • Introduction
  • What’s in the session token
  • Two layers of authorization
  • When roles change

Introduction

FGA integrates with AuthKit to provide two layers of authorization. Organization-level roles and permissions are embedded directly in the session token for instant checks. Resource-scoped permissions are checked through the Authorization API.

What’s in the session token

When a user authenticates, their session token includes organization-level role information:

{
sub: "user_01HXYZ..."
org_id: "org_01HXYZ..."
role: "org_member"
permissions: ["org:view", "workspace:view", "project:view"]
}

Your application can check these permissions directly from the token without making API calls.

Why only organization-level roles?

Resource-scoped roles are intentionally excluded from the JWT:

  • Token size – Users might have roles on hundreds of resources, bloating the JWT beyond practical limits
  • Freshness – Resource assignments change frequently; stale tokens would cause mismatches
  • Performance – Larger tokens mean slower requests and verification

For resource-level permissions, use the Authorization API – it’s fast and always current.

Two layers of authorization

Organization layer (JWT) – Check the token directly for org-wide features like navigation and settings. Instant, no API call needed.

Resource layer (API) – Call the Authorization API for specific resource access. Checks the full permission hierarchy including inheritance.

Can this user edit this project?
1. Quick check: Does the JWT include project:edit for all projects?
→ If yes, authorized (no API call)
2. Otherwise: Call the API for this specific project
→ Checks direct assignments and inheritance

When roles change

API checks reflect changes immediately.

JWT permissions require a session refresh since the token was issued at sign-in. Resource roles aren’t in the JWT, so API checks always return current data.

IdP Role AssignmentMap identity provider groups to organization roles while preserving resource-scoped access
Up next
© WorkOS, Inc.
FeaturesAuthKitSingle Sign-OnDirectory SyncAdmin PortalFine-Grained Authorization
DevelopersDocumentationChangelogAPI Status
ResourcesBlogPodcastPricingSecuritySupport
CompanyAboutCustomersCareersLegalPrivacy
© WorkOS, Inc.