Skip to content
  • SDKs and APIs
  • Kinde Management API

Call the Kinde Management API from JavaScript Backends

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.

  • A Kinde M2M application with Management API access and the required scopes — see the quickstart guide
  • A JavaScript backend project such as the Kinde Next.js SDK
  • Node.js 20 or higher

1. Install the package

Link to this section
Terminal window
npm i @kinde/management-api-js

2. Set environment variables

Link to this section
  1. Add 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.

    Terminal window
    KINDE_DOMAIN=https://<your_subdomain>.kinde.com
    KINDE_MANAGEMENT_CLIENT_ID=<your_m2m_client_id>
    KINDE_MANAGEMENT_CLIENT_SECRET=<your_m2m_client_secret>
  2. 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>",
    });

3. Initialize and call the API

Link to this section
  1. 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);
  1. 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);
  2. 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 } }
    ]
    }
  3. 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.