Sub-Accounts

Sub-Accounts in Partner API

The Partner (Sub-Accounts) API allows you to manage sub-accounts, which are commonly used for multi-tenant platforms or partner integrations. This guide provides an overview of available endpoints and how to use them with the CBK SDK.

1. Partner User Management

Create a Partner User

Use this endpoint to create a new partner user with basic information such as name and email address.

const user = await cbk.partner.user.create({ name: 'Partner User', email: 'user@example.com' });

javascript

  • name: Full name of the user.
  • email: User’s email address.

Fetch a Partner User

This endpoint allows you to retrieve detailed information about a specific partner user by providing their unique identifier.

const user = await cbk.partner.user.fetch(userId);

javascript

  • Retrieves a partner user by their userId.

Update a Partner User

Use this endpoint to update specific fields of a partner user, such as their name or email address.

const updatedUser = await cbk.partner.user.update(userId, { name: 'Updated Name' });

javascript

  • Modifies user information.

Delete a Partner User

This endpoint allows you to permanently delete a partner user and all associated data from the system.

await cbk.partner.user.delete(userId);

javascript

  • Removes a partner user permanently.

List Partner Users

Use this endpoint to retrieve a paginated list of all partner users in your system.

const users = await cbk.partner.user.list({ take: 50 });

javascript

  • Lists all partner users with pagination.

2. Partner User Token Management

Create a Partner User Token

Use this endpoint to create an authentication token for a partner user, enabling them to access authorized resources and services.

const token = await cbk.partner.user.token.create(userId);

javascript

  • Generates an access token for the user.

List Partner User Tokens

This endpoint allows you to retrieve a list of all authentication tokens associated with a specific partner user.

const tokens = await cbk.partner.user.token.list(userId);

javascript

  • Retrieves all tokens associated with a user.

Delete a Partner User Token

Use this endpoint to delete a specific authentication token for a partner user, effectively revoking their access to authorized resources.

await cbk.partner.user.token.delete(userId, tokenId);

javascript

  • Revokes a specific token.

Conclusion

This guide outlines how to manage sub-accounts and their tokens within Chatbotkit using the Partner API. Proper use of these endpoints facilitates efficient management of multi-tenant environments.