Users
User CRUD. Every method here resolves with (or lists) the same UserRecord shape — see The UserRecord shape below.
Creating a user
Only email, firstName, lastName and password are mandatory. Everything else is optional:
const user = await kasookoo.createUser({
email: "[email protected]",
firstName: "New",
lastName: "User",
password: "Password123!",
})// user →
{
id: "6a689e321b2f56106f6c5f8f",
email: "[email protected]",
phone_number: null, // omitted above, so null
first_name: "New",
last_name: "User",
role: "customer", // defaulted — omitted above
caller_id: null, // omitted above, so null
organization_id: "699305e39108f01fe9a037d6",
}The optional fields, if you want them:
const user = await kasookoo.createUser({
email: "[email protected]",
firstName: "New",
lastName: "Agent",
password: "Password123!",
phoneNumber: "+15550123456", // optional
role: "agent", // optional — free-form, any string; defaults to "customer" if omitted
callerId: "+15550123456", // optional — caller ID for outbound calls placed as this user
})Updating a user
updateUser expects the full set of fields, not a partial update:
await kasookoo.updateUser(user.id, {
email: "[email protected]",
phoneNumber: "+15550123456",
firstName: "Updated",
lastName: "User",
role: "driver",
callerId: "+15550123456", // optional
})Deleting a user
await kasookoo.deleteUser(user.id) // resolves with nothing if success else throws an errorFetching a single user
const user = await kasookoo.getUser(user.id) Listing users
const { items, pagination } = await kasookoo.getUsers({ role: "customer", search: "waseem", skip: 0, limit: 100 })role, search, skip and limit are all optional — omit everything to list all users. Read-only, nothing is cached. items is an array of UserRecord.
The UserRecord shape
UserRecord shapeReturned by createUser, updateUser, getUser, and as each item of getUsers' items array — identical shape everywhere:
interface UserRecord {
id: string
email: string
phone_number: string | null // null if never set
first_name: string
last_name: string
role: string // free-form — not restricted to a fixed set
caller_id: string | null // null if never set
organization_id: string
}Updated 15 days ago
Did this page help you?
