-
Notifications
You must be signed in to change notification settings - Fork 50
update: Kinde Account API doc #762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tamalchowdhury
wants to merge
2
commits into
main
Choose a base branch
from
tamal/new/update-kinde-account-api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
74 changes: 51 additions & 23 deletions
74
src/content/docs/developer-tools/account-api/about-account-api.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,54 +1,82 @@ | ||
| --- | ||
| page_id: b338c2df-0bba-4d47-bcac-0fe540aef3c2 | ||
| title: About Kinde's Account API | ||
| description: "Overview of Kinde's Account API for accessing user data like roles, permissions, profile, and billing entitlements using browser-scoped access tokens" | ||
| title: Use Kinde Account API to access user data from your app | ||
| description: "Access user roles, permissions, billing entitlements, and profile data from your app with Kinde's browser-scoped Account API." | ||
| sidebar: | ||
| order: 1 | ||
| label: Use Kinde Account API | ||
| relatedArticles: | ||
| - 50284476-2442-414c-af20-01ed3ef4ca4e | ||
| - 51899f7f-3436-46e0-9a1b-6ecc3603a0df | ||
| topics: | ||
| - developer-tools | ||
| - account-api | ||
| sdk: [] | ||
| languages: [] | ||
| - access-tokens | ||
| sdk: | ||
| - nextjs | ||
| languages: | ||
| - typescript | ||
| - javascript | ||
| audience: | ||
| - developers | ||
| complexity: intermediate | ||
| keywords: | ||
| - account api | ||
| - user access token | ||
| - roles | ||
| - permissions | ||
| - profile | ||
| - billing entitlements | ||
| - feature flags | ||
| - properties | ||
| updated: 2024-01-15 | ||
| - user profile | ||
| - roles and permissions | ||
| - browser-scoped token | ||
| - self-serve portal | ||
| updated: 2026-07-02 | ||
| featured: false | ||
| deprecated: false | ||
| ai_summary: Overview of Kinde's Account API for accessing user data like roles, permissions, profile, and billing entitlements using browser-scoped access tokens | ||
| ai_summary: "Overview of Kinde's Account API for retrieving user data from browser-scoped access tokens. Explains how the API uses a logged-in user's access token to fetch roles, permissions, profile information, billing entitlements, feature flags, and properties. Covers setup steps including obtaining an access token via a Kinde SDK or manual OAuth flow, and calling Account API endpoints with Bearer authentication. Describes common use cases such as gating features by billing entitlements, offloading large JWT claims, redirecting users to the self-serve portal, and accessing or revoking user sessions via the user_profile endpoint. Notes that most Account API data is read-only due to browser token security constraints, and points to the Kinde Management API for write operations. Intended for developers integrating user data access into frontend or full-stack applications." | ||
| --- | ||
|
|
||
| Kinde's [Account API](https://docs.kinde.com/kinde-apis/frontend/) uses a users access token to grab data like roles, permissions, profile, billing entitlements, etc. These details can be called from a browser as the call is scoped to the user who the token is for. | ||
| Kinde's [Account API](https://docs.kinde.com/kinde-apis/frontend/) uses a user's access token to retrieve data like roles, permissions, profile, billing entitlements, and more. You can call these endpoints from a browser because each request is scoped to the user the token represents. | ||
|
|
||
| <Aside> | ||
| <Aside title="Account API data is read-only"> | ||
|
|
||
| Some data is intentially not available via the Accounts API. For example, plan entitlements information for organizations. This is because Accounts API data is surfaced via a browser token and passing data this way is less secure. Access the Kinde Management API to access secure data. Or contact support for guidance. | ||
| Most of the data you can access via the Account API is read-only (except for a few OAuth methods). Account API data is surfaced through a browser token, and passing data this way is less secure. If you want to do more with the API, check out the [Kinde Management API](/developer-tools/kinde-api/connect-to-kinde-api/). | ||
|
|
||
| </Aside> | ||
|
tamalchowdhury marked this conversation as resolved.
|
||
|
|
||
| ## When to use the Kinde Account API | ||
| ## Use the Kinde Account API | ||
|
|
||
| - `properties` - show a specific promotion for users in certain regions or industries | ||
| - `feature flags` - roll out beta features for a subset of users | ||
| - `permissions` - only give access to certtain parts of your app based on permissions | ||
| - `roles` - restrict access to functions by role, e.g. admins. | ||
| - `entitlements` - to enable individual users to see plan entitlements | ||
| Kinde uses the logged-in user's access token to access the Account API. | ||
|
|
||
| ## Access the Account API | ||
| 1. Get the access token using the [relevant SDK](/developer-tools/about/our-sdks/) or manually if you are [using Kinde without an SDK](/developer-tools/about/using-kinde-without-an-sdk/). | ||
|
|
||
| 1. Get a user access token. This can be obtained when a user signs in via the methods you've setup in Kinde (e.g. Google, passwordless, etc). | ||
| 2. Call one of the Account API endpoints using the user access token in the Authorization header as a Bearer token. Typically, you can use the getToken command in the relevant SDK. | ||
| ```typescript title="Next.js example" | ||
| import { getKindeServerSession } from "@kinde-oss/kinde-auth-nextjs/server"; | ||
|
|
||
| If you want an endpoint added to the [Account API library](https://docs.kinde.com/kinde-apis/frontend/), contact us via support@kinde.com. | ||
| const { getAccessTokenRaw } = getKindeServerSession(); | ||
| const accessToken = await getAccessTokenRaw(); | ||
|
|
||
| console.log(accessToken); // use your access token | ||
| ``` | ||
|
|
||
| 2. Call the relevant Account API endpoint: | ||
|
|
||
| ```javascript title="JavaScript example" | ||
| fetch('https://<YOUR_DOMAIN>/account_api/v1/entitlements', { | ||
| headers: { | ||
| Authorization: `Bearer ${accessToken}` | ||
| } | ||
| }) | ||
| ``` | ||
|
|
||
| <Aside> | ||
| Replace `<YOUR_DOMAIN>` with either your [custom domain](/build/domains/pointing-your-domain/) (e.g., `auth.yourbusiness.com`) or your Kinde domain (`your_business.kinde.com`). | ||
| </Aside> | ||
|
|
||
| ## Use cases | ||
|
|
||
| - **Access user billing entitlements** - to gate product features based on the user's billing entitlements. | ||
| - **Access user properties, feature flags, roles, and permissions** - If your access token includes too many claims, offload some of them and access them via the Account API when needed. | ||
| - **Get the self-serve portal link** - to redirect the user to the self-serve portal so they can manage their account. See [Self-serve portal for users](/build/self-service-portal/self-serve-portal-for-users/). | ||
| - **Access and revoke user sessions** - You can obtain the latest user profile using the `user_profile` endpoint. You can also introspect the token or revoke it. | ||
|
|
||
| See the [Account API library](https://docs.kinde.com/kinde-apis/frontend/) for the full list of endpoints and their usage. If you want an endpoint to be added, contact us at support@kinde.com. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tamalchowdhury why is this restricted to just JS languages?