Skip to main content

Users API

Users API

import { CodeBoltClient } from '@codebolt/clientsdk';

const client = new CodeBoltClient();

Quick Reference

MethodDescription
checkIfUserExistsLocallyChecks if a user exists locally in the system.
createUserCreates a new user account in the system.
getMessagesRetrieves saved messages from conversation history.
logoutLogs out the current authenticated user.
saveMessagesSaves message history for a specific agent.

Methods


checkIfUserExistsLocally

client.users.checkIfUserExistsLocally(data: CheckUserExistsRequest): Promise<object>

Checks if a user exists locally in the system.

Verifies whether a user with the specified credentials or identifier is already present in the local user store. Useful for preventing duplicate registrations during setup.

ParameterTypeRequiredDescription
dataCheckUserExistsRequestYesRequest containing user identification information

Returns: Promise<object> — A promise that resolves to an object with an 'exists' boolean flag

Full reference →


createUser

client.users.createUser(data: CreateUserRequest): Promise<User>

Creates a new user account in the system.

Registers a new local user with the provided credentials and profile information. The user will be available for authentication immediately after creation.

ParameterTypeRequiredDescription
dataCreateUserRequestYesRequest containing user creation details

Returns: Promise<User> — A promise that resolves to the created User object

Full reference →


getMessages

client.users.getMessages(params?: GetMessagesParams): Promise<unknown[]>

Retrieves saved messages from conversation history.

Returns previously saved message history, optionally filtered by agent or other criteria. Useful for restoring conversation context or displaying chat history in the UI.

ParameterTypeRequiredDescription
paramsGetMessagesParamsNoOptional query parameters for filtering messages

Returns: Promise<unknown[]> — A promise that resolves to an array of message objects

Full reference →


logout

client.users.logout(data?: LogoutRequest): Promise<void>

Logs out the current authenticated user.

Ends the current user session and invalidates authentication tokens. Optionally accepts logout request data for additional session handling.

ParameterTypeRequiredDescription
dataLogoutRequestNoOptional logout request parameters

Returns: Promise<void> — A promise that resolves when logout is complete

Full reference →


saveMessages

client.users.saveMessages(agentId: string, data: SaveMessagesRequest): Promise<void>

Saves message history for a specific agent.

Persists a batch of messages associated with an agent's conversation. This maintains conversation history across sessions and enables context retention for continued interactions.

ParameterTypeRequiredDescription
agentIdstringYesThe unique identifier of the agent
dataSaveMessagesRequestYesRequest containing messages to save

Returns: Promise<void> — A promise that resolves when messages have been saved

Full reference →