WorkOS Knowledge Patch
Use this skill when implementing, upgrading, or reviewing a WorkOS
integration. Identify the SDK language and version, framework version, and
WorkOS products in use before changing code. Apply migration hazards first,
then open only the references needed for the task.
Reference index
| Reference |
Topics |
| Node SDK migrations and contracts |
Runtime requirements, v9/v10 migrations, pagination, events, errors, webhooks, Vault, request behavior |
| AuthKit for Next.js |
App Router setup, callbacks, cookies, proxy or middleware, response headers, sessions, tokens, PKCE |
| AuthKit for React |
Provider configuration, hosted redirects, auth state, organization switching, refresh hooks, token helpers |
| API and SDK contracts |
Public-client PKCE, Python async client, Go v6 packages, OpenAPI contract |
| Authentication and sessions |
Users, identity data, applications, sessions, invitations, email, OAuth configuration, authentication methods |
| Authorization and features |
Authorization resources, roles, assignments, permissions, groups, API keys, Feature Flags |
| SSO, Directory Sync, domains, and widgets |
SSO lifecycle and providers, directory attributes, Entra groups, domains, embedded administration |
| Platform products and operations |
Connect, MCP, CLI, Pipes, Radar, Vault BYOK, Audit Logs, email delivery, analytics, Stripe, Agents |
Triage the integration
- Read the package manifest for the exact SDK and framework versions.
- Inventory the WorkOS products and dashboard configuration used by the app.
- Apply breaking migrations and removed contracts before adding features.
- Preserve raw payloads, OAuth state, cookies, and framework-internal response
headers exactly where the selected integration requires them.
- Verify redirect and logout URIs, allowed origins, cookie domains,
authentication endpoints, providers, and organization settings in the
dashboard.
Breaking changes and deprecations
Migrate Node SDK v9
- Run Node.js 22.11 or newer; v9 no longer supports Node.js 20.
- Replace the removed legacy FGA package with authorization resources,
organization roles, and role-assignment APIs. FGA was deprecated in v8.4.
- Rename client access from
portal to adminPortal.
- Keep the established Authorization method names. v9.1.1 reverted generated
renames and fixed the endpoint used by
listEffectivePermissionsByExternalId.
Migrate Node SDK v10
- Treat
Group.createdAt and Group.updatedAt as Date objects rather than
strings.
- Construct webhooks with the WorkOS client:
new Webhooks(workos).
- Remove
search from listResources calls.
- Consume
vault.listObjects as an auto-paginatable collection of object
summaries. Generated Vault key and object fields are camel-cased.
Enforce AuthKit Next.js v3 callback state
- Remove
WORKOS_ENABLE_PKCE; PKCE and sealed OAuth state are always enabled.
- Preserve the short-lived
wos-auth-verifier cookie through the callback.
- Treat a missing verifier as
Auth cookie missing and a mismatch as
OAuth state mismatch. Do not restore the removed URL-state-only fallback.
Select the Next.js request hook
- On Next.js 16 or newer, define root-level
proxy.ts with authkitProxy.
- On Next.js 15 or earlier, define
middleware.ts with authkitMiddleware.
- Exclude
/_next/static, /_next/image, favicon.ico, and other static
paths from broad matchers.
AuthKit Next.js quick reference
Configure the App Router flow
Provide a client ID, API key, public redirect URI, and a session-cookie password
of at least 32 characters. Implement the callback as an App Router route
handler:
// app/callback/route.ts
import { handleAuth } from '@workos-inc/authkit-nextjs';
export const GET = handleAuth({ returnPathname: '/dashboard' });
Set a default Logout URI in the WorkOS dashboard before using sign-out. For
reverse proxies or dynamic deployments, review baseURL and the proxy or
middleware redirectUri override.
Preserve proxy response semantics
When composing custom proxy logic, call authkit(request), then pass every
response through handleAuthkitHeaders(request, headers, options). For
rewrites, use partitionAuthkitHeaders and applyResponseHeaders. Never expose
or forward injected x-workos-* request values.
Enable route protection with middlewareAuth.enabled; place public routes in
unauthenticatedPaths, and use signUpPaths for protected routes that should
show the sign-up screen.
Read and refresh authentication
- Use
withAuth() in server components.
- Import
AuthKitProvider and useAuth from
@workos-inc/authkit-nextjs/components in client components.
- Pass
ensureSignedIn: true when authentication is mandatory.
- Remove the access token from server
initialAuth before passing it to the
provider.
- Use
refreshSession on the server and
refreshAuth({ organizationId }) on the client.
- Use
useAccessToken for expiry-aware access and explicit refresh state.
Use eagerAuth: true only when an access token must exist on the first client
render. It transfers the token through a 30-second, initial-page-load-only
cookie that client JavaScript consumes and deletes; apply normal XSS controls.
AuthKit React quick reference
Configure AuthKitProvider with the public client ID, dashboard redirect URI,
and allowed application origin. In production, set apiHostname to an owned
Authentication API domain. devMode stores tokens in local storage and is
automatic only on localhost and 127.0.0.1.
Use useAuth() for the user, organization, roles, permissions, feature flags,
impersonator, authentication method, tokens, and organization switching. Catch
LoginRequiredError when getAccessToken() is called while signed out.
Public-client PKCE quick reference
Browser, mobile, and CLI applications can construct the Node client with only a
client ID. Generate the authorization URL and verifier together, retain the
verifier in secure platform storage across restarts, and supply it during code
exchange:
const workos = new WorkOS({ clientId: 'client_...' });
const { url, codeVerifier } =
await workos.userManagement.getAuthorizationUrlWithPKCE({
provider: 'authkit',
redirectUri: 'myapp://callback',
clientId: 'client_...',
});
const tokens = await workos.userManagement.authenticateWithCode({
code: authorizationCode,
codeVerifier,
clientId: 'client_...',
});
Confidential clients may use the same flow with an API key; the exchange then
sends both the client secret and verifier.
Authorization quick reference
- Model scoped access with authorization resources and resource-scoped custom
roles; pass
resource_type_slug when creating an organization role.
- Pass
role_slug on invitations.
- Filter assignment lists by
resource and role_slug.
- Inspect assignment
source to distinguish direct grants from group grants.
- Expect organization memberships to hold multiple roles from AuthKit, SSO, or
Directory Sync.
- Use the Feature Flags runtime client for local evaluation when an API request
per decision is undesirable.
Webhook and data-integrity checklist
- Verify webhook signatures against raw request bytes. Do not decode,
normalize, or reserialize the payload first.
- Handle API-key deletion as
api_key.revoked, not api_key.deleted.
- Accept typed organization-role, permission, feature-flag, Vault, group, and
domain-verification-failure events, including
vault.byok_key.verification_completed.
- Read
resourceTypeSlug from deserialized role events.
- Preserve SSO context on authentication events and
verification_prefix on
organization domains.
- Preserve typed server and authentication error data.
- Use exported
ConflictException.code and the complete
isAuthenticationErrorData guard.
- Treat the normalized provider value as
GitHubOAuth, not GithubOAuth.
Product selection quick reference
- Use AuthKit for hosted user authentication, including MCP authorization.
- Use Standalone OAuth to add OAuth while retaining an existing authentication
system.
- Use Connect for delegated application authorization and organization
selection.
- Use Pipes for end-user third-party connections or a deployable MCP server
that grants time-limited connection access.
- Use Radar for signup risk controls and SMS challenges.
- Use Vault BYOK with AWS KMS or Azure Key Vault for customer-managed keys.
Final verification
Before shipping, verify runtime compatibility, SDK response types, dashboard
configuration, callback cookies and state, redirect behavior, session refresh,
raw-body webhook verification, pagination shapes, retry behavior, and the exact
event names consumed by the application.
1---2name: workos-knowledge-patch3description: WorkOS4license: MIT5---678# WorkOS Knowledge Patch910Use this skill when implementing, upgrading, or reviewing a WorkOS11integration. Identify the SDK language and version, framework version, and12WorkOS products in use before changing code. Apply migration hazards first,13then open only the references needed for the task.1415## Reference index1617| Reference | Topics |18| --- | --- |19| [Node SDK migrations and contracts](references/node-sdk-migrations.md) | Runtime requirements, v9/v10 migrations, pagination, events, errors, webhooks, Vault, request behavior |20| [AuthKit for Next.js](references/authkit-nextjs.md) | App Router setup, callbacks, cookies, proxy or middleware, response headers, sessions, tokens, PKCE |21| [AuthKit for React](references/authkit-react.md) | Provider configuration, hosted redirects, auth state, organization switching, refresh hooks, token helpers |22| [API and SDK contracts](references/api-and-sdk-contracts.md) | Public-client PKCE, Python async client, Go v6 packages, OpenAPI contract |23| [Authentication and sessions](references/authentication-and-sessions.md) | Users, identity data, applications, sessions, invitations, email, OAuth configuration, authentication methods |24| [Authorization and features](references/authorization-and-features.md) | Authorization resources, roles, assignments, permissions, groups, API keys, Feature Flags |25| [SSO, Directory Sync, domains, and widgets](references/sso-directory-and-widgets.md) | SSO lifecycle and providers, directory attributes, Entra groups, domains, embedded administration |26| [Platform products and operations](references/platform-products.md) | Connect, MCP, CLI, Pipes, Radar, Vault BYOK, Audit Logs, email delivery, analytics, Stripe, Agents |2728## Triage the integration29301. Read the package manifest for the exact SDK and framework versions.312. Inventory the WorkOS products and dashboard configuration used by the app.323. Apply breaking migrations and removed contracts before adding features.334. Preserve raw payloads, OAuth state, cookies, and framework-internal response34 headers exactly where the selected integration requires them.355. Verify redirect and logout URIs, allowed origins, cookie domains,36 authentication endpoints, providers, and organization settings in the37 dashboard.3839## Breaking changes and deprecations4041### Migrate Node SDK v94243- Run Node.js 22.11 or newer; v9 no longer supports Node.js 20.44- Replace the removed legacy FGA package with authorization resources,45 organization roles, and role-assignment APIs. FGA was deprecated in v8.4.46- Rename client access from `portal` to `adminPortal`.47- Keep the established Authorization method names. v9.1.1 reverted generated48 renames and fixed the endpoint used by49 `listEffectivePermissionsByExternalId`.5051### Migrate Node SDK v105253- Treat `Group.createdAt` and `Group.updatedAt` as `Date` objects rather than54 strings.55- Construct webhooks with the WorkOS client: `new Webhooks(workos)`.56- Remove `search` from `listResources` calls.57- Consume `vault.listObjects` as an auto-paginatable collection of object58 summaries. Generated Vault key and object fields are camel-cased.5960### Enforce AuthKit Next.js v3 callback state6162- Remove `WORKOS_ENABLE_PKCE`; PKCE and sealed OAuth state are always enabled.63- Preserve the short-lived `wos-auth-verifier` cookie through the callback.64- Treat a missing verifier as `Auth cookie missing` and a mismatch as65 `OAuth state mismatch`. Do not restore the removed URL-state-only fallback.6667### Select the Next.js request hook6869- On Next.js 16 or newer, define root-level `proxy.ts` with `authkitProxy`.70- On Next.js 15 or earlier, define `middleware.ts` with `authkitMiddleware`.71- Exclude `/_next/static`, `/_next/image`, `favicon.ico`, and other static72 paths from broad matchers.7374## AuthKit Next.js quick reference7576### Configure the App Router flow7778Provide a client ID, API key, public redirect URI, and a session-cookie password79of at least 32 characters. Implement the callback as an App Router route80handler:8182```ts83// app/callback/route.ts84import { handleAuth } from '@workos-inc/authkit-nextjs';8586export const GET = handleAuth({ returnPathname: '/dashboard' });87```8889Set a default Logout URI in the WorkOS dashboard before using sign-out. For90reverse proxies or dynamic deployments, review `baseURL` and the proxy or91middleware `redirectUri` override.9293### Preserve proxy response semantics9495When composing custom proxy logic, call `authkit(request)`, then pass every96response through `handleAuthkitHeaders(request, headers, options)`. For97rewrites, use `partitionAuthkitHeaders` and `applyResponseHeaders`. Never expose98or forward injected `x-workos-*` request values.99100Enable route protection with `middlewareAuth.enabled`; place public routes in101`unauthenticatedPaths`, and use `signUpPaths` for protected routes that should102show the sign-up screen.103104### Read and refresh authentication105106- Use `withAuth()` in server components.107- Import `AuthKitProvider` and `useAuth` from108 `@workos-inc/authkit-nextjs/components` in client components.109- Pass `ensureSignedIn: true` when authentication is mandatory.110- Remove the access token from server `initialAuth` before passing it to the111 provider.112- Use `refreshSession` on the server and113 `refreshAuth({ organizationId })` on the client.114- Use `useAccessToken` for expiry-aware access and explicit refresh state.115116Use `eagerAuth: true` only when an access token must exist on the first client117render. It transfers the token through a 30-second, initial-page-load-only118cookie that client JavaScript consumes and deletes; apply normal XSS controls.119120## AuthKit React quick reference121122Configure `AuthKitProvider` with the public client ID, dashboard redirect URI,123and allowed application origin. In production, set `apiHostname` to an owned124Authentication API domain. `devMode` stores tokens in local storage and is125automatic only on `localhost` and `127.0.0.1`.126127Use `useAuth()` for the user, organization, roles, permissions, feature flags,128impersonator, authentication method, tokens, and organization switching. Catch129`LoginRequiredError` when `getAccessToken()` is called while signed out.130131## Public-client PKCE quick reference132133Browser, mobile, and CLI applications can construct the Node client with only a134client ID. Generate the authorization URL and verifier together, retain the135verifier in secure platform storage across restarts, and supply it during code136exchange:137138```ts139const workos = new WorkOS({ clientId: 'client_...' });140const { url, codeVerifier } =141 await workos.userManagement.getAuthorizationUrlWithPKCE({142 provider: 'authkit',143 redirectUri: 'myapp://callback',144 clientId: 'client_...',145 });146147const tokens = await workos.userManagement.authenticateWithCode({148 code: authorizationCode,149 codeVerifier,150 clientId: 'client_...',151});152```153154Confidential clients may use the same flow with an API key; the exchange then155sends both the client secret and verifier.156157## Authorization quick reference158159- Model scoped access with authorization resources and resource-scoped custom160 roles; pass `resource_type_slug` when creating an organization role.161- Pass `role_slug` on invitations.162- Filter assignment lists by `resource` and `role_slug`.163- Inspect assignment `source` to distinguish direct grants from group grants.164- Expect organization memberships to hold multiple roles from AuthKit, SSO, or165 Directory Sync.166- Use the Feature Flags runtime client for local evaluation when an API request167 per decision is undesirable.168169## Webhook and data-integrity checklist170171- Verify webhook signatures against raw request bytes. Do not decode,172 normalize, or reserialize the payload first.173- Handle API-key deletion as `api_key.revoked`, not `api_key.deleted`.174- Accept typed organization-role, permission, feature-flag, Vault, group, and175 domain-verification-failure events, including176 `vault.byok_key.verification_completed`.177- Read `resourceTypeSlug` from deserialized role events.178- Preserve SSO context on authentication events and `verification_prefix` on179 organization domains.180- Preserve typed server and authentication error data.181- Use exported `ConflictException.code` and the complete182 `isAuthenticationErrorData` guard.183- Treat the normalized provider value as `GitHubOAuth`, not `GithubOAuth`.184185## Product selection quick reference186187- Use AuthKit for hosted user authentication, including MCP authorization.188- Use Standalone OAuth to add OAuth while retaining an existing authentication189 system.190- Use Connect for delegated application authorization and organization191 selection.192- Use Pipes for end-user third-party connections or a deployable MCP server193 that grants time-limited connection access.194- Use Radar for signup risk controls and SMS challenges.195- Use Vault BYOK with AWS KMS or Azure Key Vault for customer-managed keys.196197## Final verification198199Before shipping, verify runtime compatibility, SDK response types, dashboard200configuration, callback cookies and state, redirect behavior, session refresh,201raw-body webhook verification, pagination shapes, retry behavior, and the exact202event names consumed by the application.