Skip to main content

WorkspaceUsersClient

Client for /api/v1.0/workspace_users/. The backend's add endpoint rejects non-empty name and channelIds — set neither.

Extends​

  • BaseClient

Constructors​

Constructor​

new WorkspaceUsersClient(config: ClientConfig): WorkspaceUsersClient;

Parameters​

ParameterType
configClientConfig

Returns​

WorkspaceUsersClient

Inherited from​

BaseClient.constructor

Properties​

PropertyModifierType
apiTokenreadonlystring
baseUrl?readonlystring
customFetch?readonlyCustomFetch
defaultVersionreadonly"v1.0"
headers?readonlyCustomHeaders

Methods​

addUser()​

addUser(args: {
email: string;
userType?: "USER" | "GUEST" | "ADMIN";
workspaceId: number;
}): Promise<{
avatarUrls?: | {
s195: string;
s35: string;
s60: string;
s640: string;
}
| null;
dateFormat?: string | null;
email?: string | null;
firstName?: string | null;
fullName: string;
id: number;
imageId?: string | null;
removed: boolean;
restricted?: boolean | null;
setupPending?: boolean | null;
shortName: string;
status?: | {
activeUntil?: string | null;
effects?: {
pauseActivity?: {
scope?: {
mode?: ... | ...;
};
};
pauseNotifications?: {
scope?: {
mode?: ... | ...;
};
};
};
emoji?: string | null;
message?: string | null;
}
| null;
theme?: number | null;
timeFormat?: string | null;
timezone: string;
userType: "USER" | "GUEST" | "ADMIN";
version: number;
}>;

Adds a person to a workspace.

Parameters​

ParameterTypeDescription
args{ email: string; userType?: "USER" | "GUEST" | "ADMIN"; workspaceId: number; }The arguments for adding a user.
args.emailstringThe user's email.
args.userType?"USER" | "GUEST" | "ADMIN"Optional user type (USER, GUEST, or ADMIN).
args.workspaceIdnumberThe workspace ID.

Returns​

Promise<{ avatarUrls?: | { s195: string; s35: string; s60: string; s640: string; } | null; dateFormat?: string | null; email?: string | null; firstName?: string | null; fullName: string; id: number; imageId?: string | null; removed: boolean; restricted?: boolean | null; setupPending?: boolean | null; shortName: string; status?: | { activeUntil?: string | null; effects?: { pauseActivity?: { scope?: { mode?: ... | ...; }; }; pauseNotifications?: { scope?: { mode?: ... | ...; }; }; }; emoji?: string | null; message?: string | null; } | null; theme?: number | null; timeFormat?: string | null; timezone: string; userType: "USER" | "GUEST" | "ADMIN"; version: number; }>

The created workspace user object.


getBaseUri()​

protected getBaseUri(): string;

Returns the base URI for an API request, with a guaranteed trailing slash so relative paths resolve cleanly through URL.

Returns​

string

Inherited from​

BaseClient.getBaseUri

getLinkBaseUrl()​

protected getLinkBaseUrl(): string | undefined;

Base URL for entity web links, or undefined to use getFullCommsURL's default web app. Trailing-slash normalization happens in getFullCommsURL, so the configured value is returned verbatim.

Returns​

string | undefined

Inherited from​

BaseClient.getLinkBaseUrl

getUserByEmail()​

getUserByEmail(args: GetUserByEmailArgs): Promise<
| {
avatarUrls?: | {
s195: string;
s35: string;
s60: string;
s640: string;
}
| null;
dateFormat?: string | null;
email?: string | null;
firstName?: string | null;
fullName: string;
id: number;
imageId?: string | null;
removed: boolean;
restricted?: boolean | null;
setupPending?: boolean | null;
shortName: string;
status?: | {
activeUntil?: string | null;
effects?: {
pauseActivity?: {
scope?: {
mode?: ...;
};
};
pauseNotifications?: {
scope?: {
mode?: ...;
};
};
};
emoji?: string | null;
message?: string | null;
}
| null;
theme?: number | null;
timeFormat?: string | null;
timezone: string;
userType: "USER" | "GUEST" | "ADMIN";
version: number;
}
| {
avatarUrls?: | {
s195: string;
s35: string;
s60: string;
s640: string;
}
| null;
firstName?: string | null;
fullName: string;
id: number;
imageId?: string | null;
removed: boolean;
restricted: true;
setupPending?: boolean | null;
shortName: string;
status?: | {
activeUntil?: string | null;
effects?: {
pauseActivity?: {
scope?: {
mode?: ...;
};
};
pauseNotifications?: {
scope?: {
mode?: ...;
};
};
};
emoji?: string | null;
message?: string | null;
}
| null;
version: number;
}>;

Gets a user by email.

Parameters​

ParameterTypeDescription
argsGetUserByEmailArgsThe arguments for getting a user by email.

Returns​

Promise< | { avatarUrls?: | { s195: string; s35: string; s60: string; s640: string; } | null; dateFormat?: string | null; email?: string | null; firstName?: string | null; fullName: string; id: number; imageId?: string | null; removed: boolean; restricted?: boolean | null; setupPending?: boolean | null; shortName: string; status?: | { activeUntil?: string | null; effects?: { pauseActivity?: { scope?: { mode?: ...; }; }; pauseNotifications?: { scope?: { mode?: ...; }; }; }; emoji?: string | null; message?: string | null; } | null; theme?: number | null; timeFormat?: string | null; timezone: string; userType: "USER" | "GUEST" | "ADMIN"; version: number; } | { avatarUrls?: | { s195: string; s35: string; s60: string; s640: string; } | null; firstName?: string | null; fullName: string; id: number; imageId?: string | null; removed: boolean; restricted: true; setupPending?: boolean | null; shortName: string; status?: | { activeUntil?: string | null; effects?: { pauseActivity?: { scope?: { mode?: ...; }; }; pauseNotifications?: { scope?: { mode?: ...; }; }; }; emoji?: string | null; message?: string | null; } | null; version: number; }>

The workspace user object, reduced to the restricted shape when the viewer may not see the user's full profile.

Example​

const user = await api.workspaceUsers.getUserByEmail({
workspaceId: 123,
email: 'user@example.com',
})

getUserById()​

getUserById(args: GetUserByIdArgs): Promise<
| {
avatarUrls?: | {
s195: string;
s35: string;
s60: string;
s640: string;
}
| null;
dateFormat?: string | null;
email?: string | null;
firstName?: string | null;
fullName: string;
id: number;
imageId?: string | null;
removed: boolean;
restricted?: boolean | null;
setupPending?: boolean | null;
shortName: string;
status?: | {
activeUntil?: string | null;
effects?: {
pauseActivity?: {
scope?: {
mode?: ...;
};
};
pauseNotifications?: {
scope?: {
mode?: ...;
};
};
};
emoji?: string | null;
message?: string | null;
}
| null;
theme?: number | null;
timeFormat?: string | null;
timezone: string;
userType: "USER" | "GUEST" | "ADMIN";
version: number;
}
| {
avatarUrls?: | {
s195: string;
s35: string;
s60: string;
s640: string;
}
| null;
firstName?: string | null;
fullName: string;
id: number;
imageId?: string | null;
removed: boolean;
restricted: true;
setupPending?: boolean | null;
shortName: string;
status?: | {
activeUntil?: string | null;
effects?: {
pauseActivity?: {
scope?: {
mode?: ...;
};
};
pauseNotifications?: {
scope?: {
mode?: ...;
};
};
};
emoji?: string | null;
message?: string | null;
}
| null;
version: number;
}>;

Gets a user by id.

Parameters​

ParameterTypeDescription
argsGetUserByIdArgsThe arguments for getting a user by ID.

Returns​

Promise< | { avatarUrls?: | { s195: string; s35: string; s60: string; s640: string; } | null; dateFormat?: string | null; email?: string | null; firstName?: string | null; fullName: string; id: number; imageId?: string | null; removed: boolean; restricted?: boolean | null; setupPending?: boolean | null; shortName: string; status?: | { activeUntil?: string | null; effects?: { pauseActivity?: { scope?: { mode?: ...; }; }; pauseNotifications?: { scope?: { mode?: ...; }; }; }; emoji?: string | null; message?: string | null; } | null; theme?: number | null; timeFormat?: string | null; timezone: string; userType: "USER" | "GUEST" | "ADMIN"; version: number; } | { avatarUrls?: | { s195: string; s35: string; s60: string; s640: string; } | null; firstName?: string | null; fullName: string; id: number; imageId?: string | null; removed: boolean; restricted: true; setupPending?: boolean | null; shortName: string; status?: | { activeUntil?: string | null; effects?: { pauseActivity?: { scope?: { mode?: ...; }; }; pauseNotifications?: { scope?: { mode?: ...; }; }; }; emoji?: string | null; message?: string | null; } | null; version: number; }>

The workspace user object, reduced to the restricted shape when the viewer may not see the user's full profile.

Example​

const user = await api.workspaceUsers.getUserById({ workspaceId: 123, userId: 456 })
console.log(user.fullName, isRestrictedWorkspaceUser(user) ? null : user.email)

getUserInfo()​

getUserInfo(args: GetUserInfoArgs): Promise<Record<string, unknown>>;

Gets the user's info in the context of the workspace.

Parameters​

ParameterTypeDescription
argsGetUserInfoArgsThe arguments for getting user info.

Returns​

Promise<Record<string, unknown>>

Information about the user in the workspace context.


getUserLocalTime()​

getUserLocalTime(args: GetUserLocalTimeArgs): Promise<string>;

Gets the user's local time (e.g., "2017-05-10 07:55:40").

Parameters​

ParameterTypeDescription
argsGetUserLocalTimeArgsThe arguments for getting user local time.

Returns​

Promise<string>

The user's local time as a string.

Example​

const localTime = await api.workspaceUsers.getUserLocalTime({
workspaceId: 123,
userId: 456,
})
console.log('User local time:', localTime)

getUsersByIds()​

getUsersByIds(args: GetUsersByIdsArgs): Promise<Record<number,
| {
avatarUrls?: | {
s195: string;
s35: string;
s60: string;
s640: string;
}
| null;
dateFormat?: string | null;
email?: string | null;
firstName?: string | null;
fullName: string;
id: number;
imageId?: string | null;
removed: boolean;
restricted?: boolean | null;
setupPending?: boolean | null;
shortName: string;
status?: | {
activeUntil?: string | null;
effects?: {
pauseActivity?: {
scope?: ... | ...;
};
pauseNotifications?: {
scope?: ... | ...;
};
};
emoji?: string | null;
message?: string | null;
}
| null;
theme?: number | null;
timeFormat?: string | null;
timezone: string;
userType: "USER" | "GUEST" | "ADMIN";
version: number;
}
| {
avatarUrls?: | {
s195: string;
s35: string;
s60: string;
s640: string;
}
| null;
firstName?: string | null;
fullName: string;
id: number;
imageId?: string | null;
removed: boolean;
restricted: true;
setupPending?: boolean | null;
shortName: string;
status?: | {
activeUntil?: string | null;
effects?: {
pauseActivity?: {
scope?: ... | ...;
};
pauseNotifications?: {
scope?: ... | ...;
};
};
emoji?: string | null;
message?: string | null;
}
| null;
version: number;
}
| null>>;

Gets several users by id, one request per 100 ids. Prefer it over calling getUserById once per user.

Parameters​

ParameterTypeDescription
argsGetUsersByIdsArgsThe arguments for getting users by ID.

Returns​

Promise<Record<number, | { avatarUrls?: | { s195: string; s35: string; s60: string; s640: string; } | null; dateFormat?: string | null; email?: string | null; firstName?: string | null; fullName: string; id: number; imageId?: string | null; removed: boolean; restricted?: boolean | null; setupPending?: boolean | null; shortName: string; status?: | { activeUntil?: string | null; effects?: { pauseActivity?: { scope?: ... | ...; }; pauseNotifications?: { scope?: ... | ...; }; }; emoji?: string | null; message?: string | null; } | null; theme?: number | null; timeFormat?: string | null; timezone: string; userType: "USER" | "GUEST" | "ADMIN"; version: number; } | { avatarUrls?: | { s195: string; s35: string; s60: string; s640: string; } | null; firstName?: string | null; fullName: string; id: number; imageId?: string | null; removed: boolean; restricted: true; setupPending?: boolean | null; shortName: string; status?: | { activeUntil?: string | null; effects?: { pauseActivity?: { scope?: ... | ...; }; pauseNotifications?: { scope?: ... | ...; }; }; emoji?: string | null; message?: string | null; } | null; version: number; } | null>>

The users keyed by id, each reduced to the restricted shape when the viewer may not see the full profile. An id the workspace has no record of maps to null, where getUserById would fail.

Throws​

If any request fails, discarding the users already loaded.

Example​

const users = await api.workspaceUsers.getUsersByIds({ workspaceId: 123, userIds: [456, 789] })
console.log(users[456]?.fullName ?? 'Unknown user')

getWorkspaceUserIds()​

getWorkspaceUserIds(workspaceId: number): Promise<number[]>;

Returns a list of workspace user IDs for the given workspace id.

Parameters​

ParameterTypeDescription
workspaceIdnumberThe workspace ID.

Returns​

Promise<number[]>

An array of user IDs.


getWorkspaceUsers()​

getWorkspaceUsers(args: GetWorkspaceUsersArgs): Promise<{
avatarUrls?: | {
s195: string;
s35: string;
s60: string;
s640: string;
}
| null;
dateFormat?: string | null;
email?: string | null;
firstName?: string | null;
fullName: string;
id: number;
imageId?: string | null;
removed: boolean;
restricted?: boolean | null;
setupPending?: boolean | null;
shortName: string;
status?: | {
activeUntil?: string | null;
effects?: {
pauseActivity?: {
scope?: {
mode?: ...;
};
};
pauseNotifications?: {
scope?: {
mode?: ...;
};
};
};
emoji?: string | null;
message?: string | null;
}
| null;
theme?: number | null;
timeFormat?: string | null;
timezone: string;
userType: "USER" | "GUEST" | "ADMIN";
version: number;
}[]>;

Returns a list of workspace user objects for the given workspace id.

Removed users are excluded by default; set args.includeRemoved to true to include them. The Comms API always returns removed users, so the filtering happens client-side.

Parameters​

ParameterTypeDescription
argsGetWorkspaceUsersArgsThe arguments for getting workspace users.

Returns​

Promise<{ avatarUrls?: | { s195: string; s35: string; s60: string; s640: string; } | null; dateFormat?: string | null; email?: string | null; firstName?: string | null; fullName: string; id: number; imageId?: string | null; removed: boolean; restricted?: boolean | null; setupPending?: boolean | null; shortName: string; status?: | { activeUntil?: string | null; effects?: { pauseActivity?: { scope?: { mode?: ...; }; }; pauseNotifications?: { scope?: { mode?: ...; }; }; }; emoji?: string | null; message?: string | null; } | null; theme?: number | null; timeFormat?: string | null; timezone: string; userType: "USER" | "GUEST" | "ADMIN"; version: number; }[]>

An array of workspace user objects.

Example​

const users = await api.workspaceUsers.getWorkspaceUsers({ workspaceId: 123 })
users.forEach(u => console.log(u.fullName, u.userType))

removeUser()​

removeUser(args: {
email?: string;
userId?: number;
workspaceId: number;
}): Promise<void>;

Removes a person from a workspace.

Parameters​

ParameterTypeDescription
args{ email?: string; userId?: number; workspaceId: number; }The arguments for removing a user.
args.email?stringOptional email of the user to remove.
args.userId?numberOptional user ID to remove (use either email or userId).
args.workspaceIdnumberThe workspace ID.

Returns​

Promise<void>


resendInvite()​

resendInvite(args: {
email: string;
userId?: number;
workspaceId: number;
}): Promise<void>;

Sends a new workspace invitation to the selected user.

Parameters​

ParameterTypeDescription
args{ email: string; userId?: number; workspaceId: number; }The arguments for resending an invite.
args.emailstringThe user's email.
args.userId?numberOptional user ID.
args.workspaceIdnumberThe workspace ID.

Returns​

Promise<void>


updateUser()​

updateUser(args: {
email?: string;
userId?: number;
userType: "USER" | "GUEST" | "ADMIN";
workspaceId: number;
}): Promise<{
avatarUrls?: | {
s195: string;
s35: string;
s60: string;
s640: string;
}
| null;
dateFormat?: string | null;
email?: string | null;
firstName?: string | null;
fullName: string;
id: number;
imageId?: string | null;
removed: boolean;
restricted?: boolean | null;
setupPending?: boolean | null;
shortName: string;
status?: | {
activeUntil?: string | null;
effects?: {
pauseActivity?: {
scope?: {
mode?: ... | ...;
};
};
pauseNotifications?: {
scope?: {
mode?: ... | ...;
};
};
};
emoji?: string | null;
message?: string | null;
}
| null;
theme?: number | null;
timeFormat?: string | null;
timezone: string;
userType: "USER" | "GUEST" | "ADMIN";
version: number;
}>;

Updates a person in a workspace.

Parameters​

ParameterTypeDescription
args{ email?: string; userId?: number; userType: "USER" | "GUEST" | "ADMIN"; workspaceId: number; }The arguments for updating a user.
args.email?stringOptional email of the user to update.
args.userId?numberOptional user ID to update (use either email or userId).
args.userType"USER" | "GUEST" | "ADMIN"The user type (USER, GUEST, or ADMIN).
args.workspaceIdnumberThe workspace ID.

Returns​

Promise<{ avatarUrls?: | { s195: string; s35: string; s60: string; s640: string; } | null; dateFormat?: string | null; email?: string | null; firstName?: string | null; fullName: string; id: number; imageId?: string | null; removed: boolean; restricted?: boolean | null; setupPending?: boolean | null; shortName: string; status?: | { activeUntil?: string | null; effects?: { pauseActivity?: { scope?: { mode?: ... | ...; }; }; pauseNotifications?: { scope?: { mode?: ... | ...; }; }; }; emoji?: string | null; message?: string | null; } | null; theme?: number | null; timeFormat?: string | null; timezone: string; userType: "USER" | "GUEST" | "ADMIN"; version: number; }>

The updated workspace user object.