User Management
Caddie provides various endpoints for managing and updating users.
List users
Lists all users across all organization, requires cross-organization permissions.
fetch('http://localhost:3000/api/auth/admin/list-users', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'X-API-KEY': '',
},
})
Update user
Update users using the /admin/update-user endpoint. Passing the userId is required, but the other fields are optional and can be updated.
fetch('https://localhost:3000/api/auth/admin/update-user', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
userId: '',
data: { // all fields are optional
"name": "",
"email": "",
"emailVerified": true, // boolean, defaults to false
"banned": false, // boolean, defaults to false
"banReason": ""
}
})
})
Change user's role within organization
By default, new users are assigned the "member" role within an organization. However, you can expand their permissions by granting them an "admin" role within an organization. As an organization admin, they are able to be granted API keys for backend access.
fetch('http://localhost:3000/api/auth/organization/update-member-role', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-KEY': '',
},
body: JSON.stringify({
"role": '', //'member' or 'admin'
"memberId": '',
"organizationId": ''
})
})
Revoke a user's access to an agent
fetch("http://localhost:3000/api/agent/id-of-agent/users", {
method: "DELETE",
headers: {
'Content-Type': 'application/json',
'X-API-KEY': '',
'X-ORGANIZATION-ID': ''
},
body: { //optionally pass userId or email, but at least 1 of them is required
userId: '',
email: ''
}
})
Field schema for valid inputs: you must pass at least one of the following:
- userId: string
- email: string, must be valid email address
Delete user
fetch('http://localhost:3000/api/auth/admin/remove-user', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-KEY': '',
},
body: JSON.stringify({
userId: ''
})
})