How to specify org when creating a user using kinde management api

I want to create two organisations for my app Admins and Users. I want to create users only via api so I disabled auto signup. Now tell me - 1. How can I create a user in the Admins organisation? The default organisation is Users 2. How can I query users by name and email and sort them like I used to do in Auth0. 3. Can I list users along with their roles and permissions? Currently I am sending an additional request to fetch permissions. 4. How to make sure a user only exists in one organisation? 5. Is there any api limit cap, I want to fetch users to query in my app dashboard, or I should keep users synced with my database. 6. How can I setup OnUserCreate, OnUserLogin, OnUserLogout events/hooks?
7 Replies
onderay
onderay11mo ago
Great questions @vikaspachar To specify an organization when creating a user using the Kinde Management API, you would typically include the organization code (org_code) in the API endpoint URL. 1. Would Admins be able to auto sign up? 2. Can query users by id, butnot name/email. Maybe can try getting all users and handle querying/filtering/sorting in the code rather than making requests to the api. I will pass this feedback along to the team. 3. Not, I will pass this feedback along to the team. 4. Yes, when you get the user from getUser or via sdk token you can check which orgs they belong to (its a list - so just check there is only one in that list) 5. Do most of the manipulation from within your own db and update values on Kinde as needed. 6. Not yet, but we will be rolling out Webhooks in the next 4 weeks.
vikaspachar
vikaspacharOP11mo ago
ThansU for responding. I am using
const client = await createKindeManagementAPIClient();

const {created, id} = await client.usersApi.createUser({
createUserRequest: {
profile: {
givenName: firstName,
familyName: lastName,
},
identities: [
{
type: "email",
details: {
email,
},
},
],
},
});
const client = await createKindeManagementAPIClient();

const {created, id} = await client.usersApi.createUser({
createUserRequest: {
profile: {
givenName: firstName,
familyName: lastName,
},
identities: [
{
type: "email",
details: {
email,
},
},
],
},
});
to create a user, where can I pass org_code to create the user in that orgnization
onderay
onderay11mo ago
And this is working for you?
vikaspachar
vikaspacharOP11mo ago
yes of course, but I am struggling with defining org_code
onderay
onderay11mo ago
What is the problem you are facing with defining org_code?
vikaspachar
vikaspacharOP11mo ago
Tell me exactly where and hoe to define org_code I tried https://{businessName}.kinde.com/api/v1/user?org_code=... but it does not working
viv (kinde)
viv (kinde)11mo ago
Hi @vikaspachar - there are two endpoints you can use, either POST /api/v1/organizations/{org_code}/users (https://kinde.com/api/docs/#add-organization-users) or POST api/v1/user - if you send "organization_code":"org_123" in the body, it will add your user to the correct organization ☺️
Want results from more Discord servers?
Add your server