Kinde Management API Quickstart Guide
SDKs and APIs
The @kinde/management-api-js package is a JavaScript SDK that wraps the Kinde Management API. Instead of manually handling token exchange and raw HTTP requests, you import typed functions for each resource and call them directly.
This package is for server-side use only. It requires your M2M client secret, which must never be exposed in browser or client-side code.
npm i @kinde/management-api-jspnpm add @kinde/management-api-jsyarn add @kinde/management-api-jsbun add @kinde/management-api-jsAdd the following to your project’s .env file. You can find these values on the Details page in your Kinde M2M application. Read the quickstart guide.
KINDE_DOMAIN=https://<your_subdomain>.kinde.comKINDE_MANAGEMENT_CLIENT_ID=<your_m2m_client_id>KINDE_MANAGEMENT_CLIENT_SECRET=<your_m2m_client_secret>You can also pass configuration directly to init() if you prefer not to use environment variables:
import { init } from "@kinde/management-api-js";
init({ kindeDomain: "https://<your_subdomain>.kinde.com", clientId: "<your_m2m_client_id>", clientSecret: "<your_m2m_client_secret>",});Import and call init() once before making any API calls — this sets up the SDK with your environment variables.
import { init } from "@kinde/management-api-js";
init();Fetch a list of all users in your Kinde business:
import { Users, init } from "@kinde/management-api-js";
init();
const { users } = await Users.getUsers();console.log(users);To fetch a specific user by ID, pass an object with the user’s id:
import { Users, init } from "@kinde/management-api-js";
init();
const userData = await Users.getUserData({ id: "kp_xxx" });console.log(userData);Use Users.createUser() to create a new user. Pass an identities array with one or more identity objects:
import { Users, init } from "@kinde/management-api-js";
init();
const newUser = await Users.createUser({ profile: { given_name: "James", family_name: "Bond", }, identities: [ { type: "email", is_verified: true, details: { email: "jamesbond@mi6.com" }, }, { type: "username", details: { username: "jamesbond007" }, }, ],});
console.log(newUser.id);A successful response includes the new user’s ID and a created flag for each identity:
{ "id": "kp_1234", "created": true, "identities": [ { "type": "email", "result": { "created": true } }, { "type": "username", "result": { "created": true } } ]}Go to your Kinde dashboard > Users and you should see the new user in the list.
Now that you have the SDK set up, you can start calling the Management API to automate account actions.