Skip to content

Commit f7cebc1

Browse files
Merge pull request #465 from kinde-oss/Feat/Account-API
Feat/account api Dave has reviewed
2 parents 20757ff + a17be9c commit f7cebc1

File tree

4 files changed

+111
-2
lines changed

4 files changed

+111
-2
lines changed

src/content/docs/billing/get-started/self-serve-portal-setup.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ sidebar:
55
order: 8
66
relatedArticles:
77
- a2668524-5842-4c68-ab50-30b7e8c3e842
8+
- f36bce4a-52bb-4785-865b-6b33356f9838
89
---
910

1011
If you want your customers (organizations or individual users) to manage their own plans, including upgrades and downgrades, payment information, team members, etc., set up the self-service portal to allow this.
1112

1213
Aside from account management, the self-serve portal is for orgs to self-manage teams and business information, and individuals to manage their user profile.
1314

14-
See [Self-serve portal](/build/set-up-options/self-serve-portal-for-orgs/) for information on setting it up.
15+
- [Self-serve portal for orgs](/build/set-up-options/self-serve-portal-for-orgs/)
16+
- [Self-serve portal for users](/build/set-up-options/self-serve-portal-for-users/)
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
page_id: f36bce4a-52bb-4785-865b-6b33356f9838
3+
title: Enable self-serve portal for users
4+
sidebar:
5+
order: 8
6+
relatedArticles:
7+
- beebe908-27f8-4be6-b74c-05fc8ff5dfb5
8+
- a2668524-5842-4c68-ab50-30b7e8c3e842
9+
---
10+
11+
You can configure a self-serve portal to enable users to be able to self-manage functions provided by Kinde. For example, you can allow users to update their profile, as well as their billing subscription and payment details (if you have billing set up). If you have a B2C business, you might want to set this up.
12+
13+
A self-serve portal means your customers can make basic account changes without contacting you for support. This can save time and money.
14+
15+
## Configure the user self-serve portal
16+
17+
1. Go to **Settings > Environment > Self-serve portal**.
18+
2. Enter the **Return URL** that you want users to land on when they exit the portal, e.g. your app dashboard. This can also be used as a fallback URL if you decide to use the SDK method of dynamically generting the URL (see below).
19+
3. In the **User profile** section, select the functions you want the user to be able to manage. If you select **Billing**, they can manage their plan as well as payment methods.
20+
4. Select **Save**.
21+
22+
## Generate the self-serve portal link
23+
24+
Access to the portal is granted via a one-time link. There are two main ways to generate this link:
25+
26+
- **Using the user's access token** (recommended)
27+
- **Using the Kinde Management API**
28+
29+
Both methods are able to generate the portal link on the fly. For example, when a user clicks an "Account" button in your app.
30+
31+
### Generate a self-serve portal link with a Kinde SDK
32+
33+
If you're using the Kinde React SDK, you can use the `<PortalLink />` component, which both generates the link and redirects the user:
34+
35+
```jsx
36+
import {PortalLink} from "@kinde-oss/kinde-auth-react";
37+
38+
<PortalLink>Account</PortalLink>;
39+
```
40+
41+
### Generate a self-serve portal link without a Kinde SDK
42+
43+
If you're not using a Kinde SDK, you can manually call the Account API:
44+
45+
```js
46+
const response = await fetch("/api/v1/account_api/portal_link", {
47+
headers: {
48+
Authorization: `Bearer ${userAccessToken}`
49+
}
50+
});
51+
const data = await response.json();
52+
window.location = data.url;
53+
```
54+
55+
Optional parameters:
56+
57+
- `return_url` – where to redirect the user after exiting the portal.
58+
- `sub_nav` – specify the portal section to open (e.g., `organization_billing`, `profile`).
59+
60+
### Manage the self-serve portal link using the Kinde Management API
61+
62+
This option is useful for server-side applications or if you're using Kinde billing features without Kinde Authentication.
63+
64+
Make a request to the `POST /api/v1/portal/generate_url` endpoint using an M2M token.
65+
66+
**Request body**
67+
68+
```js
69+
{
70+
"user_id": "kp_1234567890", // The ID of the user for whom you want to generate the portal link
71+
"organization_code": "org_123456789", // Optional: the organization code for which the portal link is generated
72+
"return_url": "https://yourapp.com/dashboard", // Optional: where to redirect the user after exiting the portal
73+
"sub_nav": "profile" // Optional: specify the portal section to open (e.g., `organization_billing`, `profile`)
74+
}
75+
```
76+
77+
This will return a one-time portal link for the specified user.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
page_id: b338c2df-0bba-4d47-bcac-0fe540aef3c2
3+
title: About Kinde's Account API
4+
sidebar:
5+
order: 1
6+
relatedArticles:
7+
- 50284476-2442-414c-af20-01ed3ef4ca4e
8+
- 51899f7f-3436-46e0-9a1b-6ecc3603a0df
9+
---
10+
11+
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.
12+
13+
## Examples for using the Account API
14+
15+
- `properties` - show a specific promotion for users in certain regions or industries
16+
- `feature flags` - roll out beta features for a subset of users
17+
- `permissions` - only give access to certtain parts of your app based on permissions
18+
- `roles` - restrict access to functions by role, e.g. admins.
19+
20+
## Access the Account API
21+
22+
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).
23+
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.
24+
25+
If you want an endpoint added to the [Account API library](https://docs.kinde.com/kinde-apis/frontend/), contact us via [email protected].

src/data/sidebarData.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,15 @@ const sidebarData = [
7979
collapsed: false
8080
},
8181
{
82-
label: "Kinde API",
82+
label: "Kinde Management API",
8383
autogenerate: {directory: "developer-tools/kinde-api"},
8484
collapsed: false
8585
},
86+
{
87+
label: "Account API",
88+
autogenerate: {directory: "developer-tools/account-api"},
89+
collapsed: false
90+
},
8691
{label: "Your APIs", autogenerate: {directory: "developer-tools/your-apis"}, collapsed: false}
8792
]
8893
},

0 commit comments

Comments
 (0)