WorkspacesClient
Client for /api/v1/workspaces/. Workspace IDs are integers. The backend
currently rejects any color other than 1 on add/update.
Extends
BaseClient
Constructors
Constructor
new WorkspacesClient(config: ClientConfig): WorkspacesClient;
Parameters
| Parameter | Type |
|---|---|
config | ClientConfig |
Returns
WorkspacesClient
Inherited from
BaseClient.constructor
Properties
| Property | Modifier | Type |
|---|---|---|
apiToken | readonly | string |
baseUrl? | readonly | string |
customFetch? | readonly | CustomFetch |
defaultVersion | readonly | "v1" |
Methods
createWorkspace()
createWorkspace(name: string): Promise<{
avatarId?: string | null;
avatarUrls?: | {
s195: string;
s35: string;
s60: string;
s640: string;
}
| null;
created: Date;
creator: number;
defaultConversation?: string | null;
id: number;
name: string;
plan?: string | null;
}>;
Creates a new workspace.
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | The name of the new workspace. |
Returns
Promise<{
avatarId?: string | null;
avatarUrls?: | {
s195: string;
s35: string;
s60: string;
s640: string;
}
| null;
created: Date;
creator: number;
defaultConversation?: string | null;
id: number;
name: string;
plan?: string | null;
}>
The created workspace object.
Example
const workspace = await api.workspaces.createWorkspace('My Team')
console.log('Created:', workspace.name)
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
getDefaultWorkspace()
getDefaultWorkspace(): Promise<{
avatarId?: string | null;
avatarUrls?: | {
s195: string;
s35: string;
s60: string;
s640: string;
}
| null;
created: Date;
creator: number;
defaultConversation?: string | null;
id: number;
name: string;
plan?: string | null;
}>;
Gets the user's default workspace.
Returns
Promise<{
avatarId?: string | null;
avatarUrls?: | {
s195: string;
s35: string;
s60: string;
s640: string;
}
| null;
created: Date;
creator: number;
defaultConversation?: string | null;
id: number;
name: string;
plan?: string | null;
}>
The default workspace object.
Example
const workspace = await api.workspaces.getDefaultWorkspace()
console.log(workspace.name)
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
getPublicChannels()
getPublicChannels(id: number): Promise<{
archived: boolean;
color?: number | null;
created: Date;
creator: number;
defaultGroups?: string[] | null;
defaultRecipients?: number[] | null;
description?: string | null;
filters?: Record<string, string> | null;
icon?: number | null;
id: string;
isFavorited?: boolean | null;
name: string;
public: boolean;
url: string;
useDefaultRecipients?: boolean | null;
userIds?: number[] | null;
version: number;
workspaceId: number;
}[]>;
Gets the public channels of a workspace.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | number | The workspace ID. |
Returns
Promise<{
archived: boolean;
color?: number | null;
created: Date;
creator: number;
defaultGroups?: string[] | null;
defaultRecipients?: number[] | null;
description?: string | null;
filters?: Record<string, string> | null;
icon?: number | null;
id: string;
isFavorited?: boolean | null;
name: string;
public: boolean;
url: string;
useDefaultRecipients?: boolean | null;
userIds?: number[] | null;
version: number;
workspaceId: number;
}[]>
An array of public channel objects.
Example
const channels = await api.workspaces.getPublicChannels(123)
channels.forEach(ch => console.log(ch.name))
getWorkspace()
getWorkspace(id: number): Promise<{
avatarId?: string | null;
avatarUrls?: | {
s195: string;
s35: string;
s60: string;
s640: string;
}
| null;
created: Date;
creator: number;
defaultConversation?: string | null;
id: number;
name: string;
plan?: string | null;
}>;
Gets a single workspace object by id.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | number | The workspace ID. |
Returns
Promise<{
avatarId?: string | null;
avatarUrls?: | {
s195: string;
s35: string;
s60: string;
s640: string;
}
| null;
created: Date;
creator: number;
defaultConversation?: string | null;
id: number;
name: string;
plan?: string | null;
}>
The workspace object.
Example
const workspace = await api.workspaces.getWorkspace(123)
console.log(workspace.name)
getWorkspaces()
getWorkspaces(): Promise<{
avatarId?: string | null;
avatarUrls?: | {
s195: string;
s35: string;
s60: string;
s640: string;
}
| null;
created: Date;
creator: number;
defaultConversation?: string | null;
id: number;
name: string;
plan?: string | null;
}[]>;
Gets all the user's workspaces.
Returns
Promise<{
avatarId?: string | null;
avatarUrls?: | {
s195: string;
s35: string;
s60: string;
s640: string;
}
| null;
created: Date;
creator: number;
defaultConversation?: string | null;
id: number;
name: string;
plan?: string | null;
}[]>
An array of all workspaces the user belongs to.
Example
const workspaces = await api.workspaces.getWorkspaces()
workspaces.forEach(ws => console.log(ws.name))
removeWorkspace()
removeWorkspace(id: number): Promise<void>;
Removes a workspace and all its data (not recoverable).
Parameters
| Parameter | Type | Description |
|---|---|---|
id | number | The workspace ID. |
Returns
Promise<void>
Example
await api.workspaces.removeWorkspace(123)
updateWorkspace()
updateWorkspace(id: number, name: string): Promise<{
avatarId?: string | null;
avatarUrls?: | {
s195: string;
s35: string;
s60: string;
s640: string;
}
| null;
created: Date;
creator: number;
defaultConversation?: string | null;
id: number;
name: string;
plan?: string | null;
}>;
Updates an existing workspace.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | number | The workspace ID. |
name | string | The new name for the workspace. |
Returns
Promise<{
avatarId?: string | null;
avatarUrls?: | {
s195: string;
s35: string;
s60: string;
s640: string;
}
| null;
created: Date;
creator: number;
defaultConversation?: string | null;
id: number;
name: string;
plan?: string | null;
}>
The updated workspace object.
Example
const workspace = await api.workspaces.updateWorkspace(123, 'New Team Name')