ChannelsClient
Client for /api/v1/channels/. The SDK auto-generates an id on
createChannel when the caller doesn't supply one — pass your own id
to keep an optimistic-UI ID stable through the round-trip.
Extends
BaseClient
Constructors
Constructor
new ChannelsClient(config: ClientConfig): ChannelsClient;
Parameters
| Parameter | Type |
|---|---|
config | ClientConfig |
Returns
ChannelsClient
Inherited from
BaseClient.constructor
Properties
| Property | Modifier | Type |
|---|---|---|
apiToken | readonly | string |
baseUrl? | readonly | string |
customFetch? | readonly | CustomFetch |
defaultVersion | readonly | "v1" |
Methods
addUser()
addUser(args: AddChannelUserArgs): 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;
}>;
Adds a user to a channel.
Parameters
| Parameter | Type | Description |
|---|---|---|
args | AddChannelUserArgs | The arguments for adding a user. |
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;
}>
Example
await api.channels.addUser({ id: '7YpL3oZ4kZ9vP7Q1tR2sX44', userId: 101 })
addUsers()
addUsers(args: AddChannelUsersArgs): 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;
}>;
Adds multiple users to a channel.
Parameters
| Parameter | Type | Description |
|---|---|---|
args | AddChannelUsersArgs | The arguments for adding users. |
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;
}>
Example
await api.channels.addUsers({ id: '7YpL3oZ4kZ9vP7Q1tR2sX44', userIds: [101, 202] })
archiveChannel()
archiveChannel(id: string): Promise<{
status: "ok";
}>;
Archives a channel.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The channel ID. |
Returns
Promise<{
status: "ok";
}>
createChannel()
createChannel(args: {
color?: number | null;
defaultGroups?: string[] | null;
defaultRecipients?: number[] | null;
description?: string | null;
icon?: number | null;
id?: string;
isFavorited?: boolean | null;
name: string;
public?: boolean | null;
userIds?: number[] | null;
workspaceId: 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;
}>;
Creates a new channel. id is auto-generated if not supplied — pass your
own id to keep an optimistic-UI ID stable through the round-trip.
Parameters
| Parameter | Type | Description |
|---|---|---|
args | { color?: number | null; defaultGroups?: string[] | null; defaultRecipients?: number[] | null; description?: string | null; icon?: number | null; id?: string; isFavorited?: boolean | null; name: string; public?: boolean | null; userIds?: number[] | null; workspaceId: number; } | The arguments for creating a channel. |
args.color? | number | null | Optional channel color. |
args.defaultGroups? | string[] | null | - |
args.defaultRecipients? | number[] | null | - |
args.description? | string | null | Optional channel description. |
args.icon? | number | null | - |
args.id? | string | - |
args.isFavorited? | boolean | null | - |
args.name | string | The channel name. |
args.public? | boolean | null | Optional flag to make the channel public. |
args.userIds? | number[] | null | Optional array of user IDs to add to the channel. |
args.workspaceId | 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;
}>
The created channel object.
Example
const channel = await api.channels.createChannel({
workspaceId: 123,
name: 'Engineering',
description: 'Engineering team channel',
})
deleteChannel()
deleteChannel(id: string): Promise<{
status: "ok";
}>;
Permanently deletes a channel.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The channel ID. |
Returns
Promise<{
status: "ok";
}>
favoriteChannel()
favoriteChannel(id: string): Promise<{
status: "ok";
}>;
Favorites a channel.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The channel ID. |
Returns
Promise<{
status: "ok";
}>
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
getChannel()
getChannel(id: string): 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 a single channel object by id.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The channel 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;
}>
The channel object.
getChannels()
getChannels(args: {
archived?: boolean | null;
workspaceId: 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 all channels for a given workspace.
Parameters
| Parameter | Type | Description |
|---|---|---|
args | { archived?: boolean | null; workspaceId: number; } | The arguments for getting channels. |
args.archived? | boolean | null | Optional flag to include archived channels. |
args.workspaceId | 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 channel objects.
Example
const channels = await api.channels.getChannels({ workspaceId: 123 })
channels.forEach(ch => console.log(ch.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
removeUser()
removeUser(args: RemoveChannelUserArgs): 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;
}>;
Removes a user from a channel.
Parameters
| Parameter | Type | Description |
|---|---|---|
args | RemoveChannelUserArgs | The arguments for removing a user. |
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;
}>
removeUsers()
removeUsers(args: RemoveChannelUsersArgs): 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;
}>;
Removes multiple users from a channel.
Parameters
| Parameter | Type | Description |
|---|---|---|
args | RemoveChannelUsersArgs | The arguments for removing users. |
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;
}>
unarchiveChannel()
unarchiveChannel(id: string): Promise<{
status: "ok";
}>;
Unarchives a channel.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The channel ID. |
Returns
Promise<{
status: "ok";
}>
unfavoriteChannel()
unfavoriteChannel(id: string): Promise<{
status: "ok";
}>;
Unfavorites a channel.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The channel ID. |
Returns
Promise<{
status: "ok";
}>
updateChannel()
updateChannel(args: {
color?: number | null;
defaultGroups?: string[] | null;
defaultRecipients?: number[] | null;
description?: string | null;
icon?: number | null;
id: string;
isFavorited?: boolean | null;
name: string;
public?: boolean | null;
}): 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;
}>;
Partial update of an existing channel.
Parameters
| Parameter | Type | Description |
|---|---|---|
args | { color?: number | null; defaultGroups?: string[] | null; defaultRecipients?: number[] | null; description?: string | null; icon?: number | null; id: string; isFavorited?: boolean | null; name: string; public?: boolean | null; } | The arguments for updating a channel. |
args.color? | number | null | Optional new channel color. |
args.defaultGroups? | string[] | null | - |
args.defaultRecipients? | number[] | null | - |
args.description? | string | null | Optional new channel description. |
args.icon? | number | null | - |
args.id | string | The channel ID. |
args.isFavorited? | boolean | null | - |
args.name | string | Optional new channel name. |
args.public? | boolean | null | Optional flag to change channel visibility. |
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;
}>
The updated channel object.
updateFilters()
updateFilters(args: {
filterClosed: "all" | "only_open" | "only_closed";
id: string;
}): Promise<{
status: "ok";
}>;
Updates the channel's view filter (only_open / all / only_closed).
Parameters
| Parameter | Type | Description |
|---|---|---|
args | { filterClosed: "all" | "only_open" | "only_closed"; id: string; } | The arguments for updating the channel filter. |
args.filterClosed | "all" | "only_open" | "only_closed" | The new filter value. |
args.id | string | The channel ID. |
Returns
Promise<{
status: "ok";
}>