Skip to main content

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

ParameterType
configClientConfig

Returns

ChannelsClient

Inherited from

BaseClient.constructor

Properties

PropertyModifierType
apiTokenreadonlystring
baseUrl?readonlystring
customFetch?readonlyCustomFetch
defaultVersionreadonly"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

ParameterTypeDescription
argsAddChannelUserArgsThe 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

ParameterTypeDescription
argsAddChannelUsersArgsThe 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

ParameterTypeDescription
idstringThe 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

ParameterTypeDescription
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 | nullOptional channel color.
args.defaultGroups?string[] | null-
args.defaultRecipients?number[] | null-
args.description?string | nullOptional channel description.
args.icon?number | null-
args.id?string-
args.isFavorited?boolean | null-
args.namestringThe channel name.
args.public?boolean | nullOptional flag to make the channel public.
args.userIds?number[] | nullOptional array of user IDs to add to the channel.
args.workspaceIdnumberThe 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

ParameterTypeDescription
idstringThe channel ID.

Returns

Promise<{ status: "ok"; }>


favoriteChannel()

favoriteChannel(id: string): Promise<{
status: "ok";
}>;

Favorites a channel.

Parameters

ParameterTypeDescription
idstringThe 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

ParameterTypeDescription
idstringThe 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

ParameterTypeDescription
args{ archived?: boolean | null; workspaceId: number; }The arguments for getting channels.
args.archived?boolean | nullOptional flag to include archived channels.
args.workspaceIdnumberThe 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

ParameterTypeDescription
argsRemoveChannelUserArgsThe 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

ParameterTypeDescription
argsRemoveChannelUsersArgsThe 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

ParameterTypeDescription
idstringThe channel ID.

Returns

Promise<{ status: "ok"; }>


unfavoriteChannel()

unfavoriteChannel(id: string): Promise<{
status: "ok";
}>;

Unfavorites a channel.

Parameters

ParameterTypeDescription
idstringThe 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

ParameterTypeDescription
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 | nullOptional new channel color.
args.defaultGroups?string[] | null-
args.defaultRecipients?number[] | null-
args.description?string | nullOptional new channel description.
args.icon?number | null-
args.idstringThe channel ID.
args.isFavorited?boolean | null-
args.namestringOptional new channel name.
args.public?boolean | nullOptional 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

ParameterTypeDescription
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.idstringThe channel ID.

Returns

Promise<{ status: "ok"; }>