Users
The Vectara Python SDK provides methods to manage users in your account, including listing, creating, retrieving, updating, deleting, and resetting passwords. The UsersClient (synchronous) and AsyncUsersClient (asynchronous) support these operations, with options to filter by corpus access, assign roles, and configure timeouts. Usernames must be percent-encoded for API calls.
Note: User management operations require OAuth authentication, not API keys.
This guide assumes you have a corpus called my-docs. If you haven't created a corpus yet, follow
the Quick Start guide to set up your first corpus.
List usersβ
LIST USERS BY CORPUS ACCESS
Code example with python syntax.1
List all users in the account, optionally filtering by corpus access.
corpus_key(str, optional): Filter users with access to this corpus.limit(int, optional): Max number of users per page.page_key(str, optional): Fetch next page of results.request_timeout(int, optional): Timeout in seconds.
Returns:
Iterator of user objects, each with:
usernameemaildescriptionapi_rolesenabled
Error handling:
403 Forbidden: Insufficient OAuth permissions.404 Not Found: Corpus does not exist (if filtering bycorpus_key).500 Internal Server Error: API unavailable.
Create a Userβ
CREATE A USER WITH ROLES
Code example with python syntax.1
Create a new user with an email, optional username, description, and API roles.
email(str): User's email address (required)username(str, optional): Login username (email is default)description(str, optional): Free-form user descriptionapi_roles(list[str], optional): Assigned roles (corpus_admin,query_writer)
Returns:
User object with:
usernameemailapi_rolesenabled
Error handling:
400 Bad Request: Missing required fields or invalid email.409 Conflict: Username or email already exists.403 Forbidden: Insufficient OAuth permissions.
Retrieve a Userβ
GET USER DETAILS
Code example with python syntax.1
Get details for a specific user by their username (percent-encoded if needed).
username(str): Username, percent-encoded (throughurllib.parse.quote())
Returns:
User object with fields:
usernameemailapi_rolesenableddescription
Error handling:
404 Not Found: User does not exist.403 Forbidden: Insufficient OAuth permissions.
Update a Userβ
UPDATE USER ROLES
Code example with python syntax.1
Update a userβs status or roles, such as enabling/disabling or changing permissions.
username(str): Percent-encoded username (required)enabled(bool, optional): Enable or disable user accountapi_roles(list[str], optional): Update rolesdescription(str, optional): Update user description
Returns:
Updated user object with:
usernameapi_rolesenableddescription
Error handling:
404 Not Found: User does not exist.403 Forbidden: Insufficient OAuth permissions.400 Bad Request: Invalid update parameters.
Delete a Userβ
DELETE A USER
Code example with python syntax.1
Delete a user from the account by their username (percent-encoded).
username(str): Percent-encoded username
Returns:
None (success is silent)
Error handling:
404 Not Found: User does not exist.403 Forbidden: Insufficient OAuth permissions.
Reset a passwordβ
RESET USER PASSWORD
Code example with python syntax.1
Reset a userβs password, sending a reset email to their registered address.
username(str): Percent-encoded username
Returns: User object for whom the reset was sent:
usernameemail
Error handling:
404 Not Found: User does not exist.403 Forbidden: Insufficient OAuth permissions.