Get started with site users
Create a site user — someone who signs in to your app — and read the new record back. Select the target site first. Organization membership is a separate Console workflow.
Before you start#
Use an account with organization access to the site or a Super Admin app role
in one of its apps. Configure the JavaScript SDK,
Python SDK, or Refine integration.
The Refine example uses hosted sign-in and userDataProvider(taruvi) registered
under the name user.
Create and verify a user#
- JavaScript SDK
- Python SDK
- Refine
- REST API
- TaruviBase Console
Run this script on a server. Set TARUVI_SITE_URL, TARUVI_APP_SLUG,
TARUVI_SESSION_TOKEN, and TARUVI_NEW_USER_PASSWORD in its environment.
The session must belong to the account managing users.
import {Client, User} from '@taruvi/sdk';
const taruvi = new Client({
apiUrl: process.env.TARUVI_SITE_URL!,
appSlug: process.env.TARUVI_APP_SLUG!,
token: process.env.TARUVI_SESSION_TOKEN!,
});
const users = new User(taruvi);
const initialPassword = process.env.TARUVI_NEW_USER_PASSWORD;
if (!initialPassword) throw new Error("Set TARUVI_NEW_USER_PASSWORD");
const created = await users.createUser({
username: "onboarding-user",
password: initialPassword,
confirm_password: initialPassword,
first_name: "Onboarding",
last_name: "User",
});
const verified = await users.getUser(created.data.username);
console.log(verified.data.username);
The browser client ignores token; use hosted sign-in instead of supplying
a session through the constructor.
Set TARUVI_SITE_URL, TARUVI_APP_SLUG, TARUVI_SESSION_TOKEN, and
TARUVI_NEW_USER_PASSWORD in the script's environment. The session must belong
to the account managing users.
import os
from taruvi import Client
with Client(
os.environ["TARUVI_SITE_URL"],
os.environ["TARUVI_APP_SLUG"],
mode="sync",
api_key=None,
jwt=None,
session_token=os.environ["TARUVI_SESSION_TOKEN"],
) as client:
initial_password = os.environ["TARUVI_NEW_USER_PASSWORD"]
created = client.users.create({
"username": "onboarding-user",
"password": initial_password,
"confirm_password": initial_password,
"first_name": "Onboarding",
"last_name": "User",
})
verified = client.users.get(created["data"]["username"])
print(verified["data"]["username"])
Use these hooks inside your authenticated Refine app. initialPassword is the
new user's password collected by your application, separate from the
administrator's hosted sign-in.
import {useCreate} from '@refinedev/core';
const {mutate: createUser} = useCreate();
// 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,
},
});
After creation succeeds, read the new user. Its username is in the hook's
result.username once the query succeeds:
import {useOne} from '@refinedev/core';
import type {UserData} from '@taruvi/sdk';
useOne<UserData>({
dataProviderName: 'user',
resource: 'users',
id: 'onboarding-user',
});
/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
- Open the target site in TaruviBase Console.
- Open Users, select Add User, and fill in Create New User.
- Verify the new record appears in the site-user list.
Verify the result#
Confirm the read returns the username you created in the selected site
(onboarding-user in the SDK and Refine examples). Replace the example
username and email before creating a real account. If creation fails
validation, fix the rejected value and try again. Share the initial password
with the user securely; never put it in source control, a ticket, or a screenshot.
Continue with site users to list, update, and remove users, or assign user access to grant a role. For unresolved failures, see troubleshooting.