Manage site users
This guide manages site users — the people who sign in to your app. It is not for cloud users, organization memberships, invitations, or Console-synchronized site access.
Choose an interface#
You can create, read, update, delete, list, and search site users in TaruviBase Console, JavaScript, Python, Refine, and the REST API.
By default, lists exclude cloud users, superusers, inactive users, and deleted users. To include them, use that interface's filters.
Reading a user that doesn't exist returns 404; check the site and username.
Deletion is a soft delete, and users can't delete themselves.
Who can manage users#
Any signed-in user of the site can list and read site users. Creating, updating, and deleting them needs one of:
- Organization access: an organization owner, admin, or member, or an API key one of them created.
- A Super Admin app role in one of the site's apps.
Anyone else gets 403 with code FORBIDDEN and a message such as
You do not have permission to create users. The JavaScript SDK rejects with
ForbiddenError, the Python SDK raises AuthorizationError, and Refine's
create, update, and delete hooks fail with ForbiddenError.
Only a superuser can change or delete a superuser, and a Super Admin app role can't change members of your organization. Nobody can make a user a superuser, staff member, or cloud user through the API: those fields are ignored. Assigning roles to existing users needs organization access; see Assign user access.
Create and manage users#
Use an authenticated client that can manage users. These examples use the taruvi
client from JavaScript SDK or the client from
Python SDK. Updates don't change passwords; users reset
their own with Forgot Password on the hosted sign-in page. Deleted users
can't be restored through the Console or API; to recover one, contact TaruviBase support with
the user's details.
- JavaScript SDK
- Python SDK
- Refine
- REST API
- TaruviBase Console
Run the creation sample on a server with TARUVI_NEW_USER_PASSWORD set in
its environment.
import {User} from '@taruvi/sdk';
const users = new User(taruvi);
const initialPassword = process.env.TARUVI_NEW_USER_PASSWORD;
if (!initialPassword) throw new Error("Set TARUVI_NEW_USER_PASSWORD");
await users.createUser({
username: "onboarding-user",
password: initialPassword,
confirm_password: initialPassword,
first_name: "Onboarding",
last_name: "User",
});
await users.list({search: "onboarding", page: 1, page_size: 20});
await users.getUser("onboarding-user");
await users.updateUser("onboarding-user", {first_name: "Onboarding"});
await users.getUserApps("onboarding-user");
await users.getUser("me");
Set TARUVI_NEW_USER_PASSWORD in the script's environment.
import os
initial_password = os.environ["TARUVI_NEW_USER_PASSWORD"]
client.users.create({
"username": "onboarding-user",
"password": initial_password,
"confirm_password": initial_password,
})
client.users.list(search="onboarding", page=1, page_size=20)
client.users.get("onboarding-user")
client.users.update("onboarding-user", {"first_name": "Onboarding"})
client.users.apps("onboarding-user")
client.auth.get_current_user()
Register userDataProvider(taruvi) under user as shown in the
Refine setup. Use these
hooks inside the authenticated app. User IDs in requests are usernames,
even though returned records also have an id field.
After creating onboarding-user, read the list, that user, the signed-in
user, and the selected user's apps:
import {useList, useOne} from '@refinedev/core';
import type {UserApp, UserData} from '@taruvi/sdk';
useList<UserData>({
dataProviderName: 'user',
resource: 'users',
filters: [{field: 'search', operator: 'eq', value: 'onboarding'}],
pagination: {currentPage: 1, pageSize: 20},
});
useOne<UserData>({
dataProviderName: 'user', resource: 'users', id: 'onboarding-user',
});
useOne<UserData>({
dataProviderName: 'user', resource: 'users', id: 'me',
});
useList<UserApp>({
dataProviderName: 'user', resource: 'apps',
meta: {username: 'onboarding-user'}, pagination: {mode: 'off'},
});
After the queries complete, useList exposes entries in result.data, and
useOne exposes the user in result.
For creation, initialPassword is the new user's password collected by your
application. Submit each mutation from its corresponding event handler.
import {useCreate, useUpdate} from '@refinedev/core';
const {mutate: createUser} = useCreate();
const {mutate: updateUser} = useUpdate();
// Call from an event handler.
createUser({
dataProviderName: 'user',
resource: 'users',
values: {
username: 'onboarding-user',
first_name: 'Onboarding',
last_name: 'User',
password: initialPassword,
confirm_password: initialPassword,
},
});
// Call from an event handler.
updateUser({
dataProviderName: 'user', resource: 'users', id: 'onboarding-user',
values: {first_name: 'Onboarding'},
});
After a successful mutation, repeat the user read and confirm the saved values. See the creation quickstart for the setup and verification steps.
/api/users/Headers
AuthorizationApi-Key $TARUVI_API_KEY
Query parameters
page1page_size20search$TARUVI_USER_SEARCHorderingusername
View cURL
curl -G "$TARUVI_SITE_URL/api/users/" \
-H "Authorization: Api-Key $TARUVI_API_KEY" \
--data-urlencode 'page=1' \
--data-urlencode 'page_size=20' \
--data-urlencode "search=$TARUVI_USER_SEARCH" \
--data-urlencode 'ordering=username'
200
/api/users/Headers
AuthorizationApi-Key $TARUVI_API_KEYContent-Typeapplication/json
Request body
{
"username": "$TARUVI_USERNAME",
"email": "$TARUVI_USER_EMAIL",
"password": "$TARUVI_NEW_USER_PASSWORD",
"confirm_password": "$TARUVI_NEW_USER_PASSWORD",
"first_name": "$TARUVI_USER_FIRST_NAME",
"last_name": "$TARUVI_USER_LAST_NAME"
}
View cURL
curl -X POST "$TARUVI_SITE_URL/api/users/" \
-H "Authorization: Api-Key $TARUVI_API_KEY" \
-H "Content-Type: application/json" \
--data-binary @- <<JSON
{
"username": "$TARUVI_USERNAME",
"email": "$TARUVI_USER_EMAIL",
"password": "$TARUVI_NEW_USER_PASSWORD",
"confirm_password": "$TARUVI_NEW_USER_PASSWORD",
"first_name": "$TARUVI_USER_FIRST_NAME",
"last_name": "$TARUVI_USER_LAST_NAME"
}
JSON
201
/api/users/$TARUVI_USERNAME/Headers
AuthorizationApi-Key $TARUVI_API_KEY
View cURL
curl "$TARUVI_SITE_URL/api/users/$TARUVI_USERNAME/" \
-H "Authorization: Api-Key $TARUVI_API_KEY"
200
/api/users/$TARUVI_USERNAME/Headers
AuthorizationApi-Key $TARUVI_API_KEYContent-Typeapplication/json
Request body
{
"first_name": "$TARUVI_USER_FIRST_NAME"
}
View cURL
curl -X PUT "$TARUVI_SITE_URL/api/users/$TARUVI_USERNAME/" \
-H "Authorization: Api-Key $TARUVI_API_KEY" \
-H "Content-Type: application/json" \
--data-binary @- <<JSON
{
"first_name": "$TARUVI_USER_FIRST_NAME"
}
JSON
200
/api/users/me/Headers
AuthorizationApi-Key $TARUVI_API_KEY
View cURL
curl "$TARUVI_SITE_URL/api/users/me/" \
-H "Authorization: Api-Key $TARUVI_API_KEY"
200
Select the target site, open Users, select Add User, then complete Create New User. Search or edit the resulting site user from the same screen. Fill in any custom attribute fields your site defines.
Use Assign user access to read roles and apps or assign roles to an existing user.
Remove a site user#
- Affected resource and cascade: Verify the selected site user and every dependent application record before continuing.
- Reversibility: Deleted users can't be restored through the Console or API. Treat deletion as permanent.
- Authorization: Deleting users needs organization access or a Super Admin app role in one of the site's apps, and only a superuser can delete a superuser. Confirm you are on the right site.
- Backup or export: Export the user's record first if you may need it.
- Confirmation: Confirm the exact user and site before deleting.
- Success response and postcondition: Confirm the delete response, refresh the list, and verify the user no longer appears in the selected site.
- Recovery: To recover a deleted user, contact TaruviBase support with the exported record.
Delete the site user only after completing the checks above.
- JavaScript SDK
- Python SDK
- Refine
- REST API
- TaruviBase Console
import {User} from '@taruvi/sdk';
const users = new User(taruvi);
await users.deleteUser("onboarding-user");
client.users.delete("onboarding-user")
Complete the confirmation checks above before submitting the deletion.
import {useDelete} from '@refinedev/core';
const {mutate: deleteUser} = useDelete();
// Call from an event handler.
deleteUser({
dataProviderName: 'user',
resource: 'users',
id: 'onboarding-user',
mutationMode: 'pessimistic',
});
/api/users/$TARUVI_USERNAME/Headers
AuthorizationApi-Key $TARUVI_API_KEY
View cURL
curl -X DELETE "$TARUVI_SITE_URL/api/users/$TARUVI_USERNAME/" \
-H "Authorization: Api-Key $TARUVI_API_KEY"
200Runtime returns 200; the pinned OpenAPI contract declares 204.
Select Delete User and confirm Delete.
Refresh the site's user list and confirm the deleted user no longer appears.
For other problems, see troubleshooting.