On this page

Delete channels

Remove a channel permanently or soft-delete it (keeping historical data in App Context storage) with delete() or deleteChannel().

Both methods produce the same result. Call delete() on a Channel object or deleteChannel() on the Chat object with the channel ID.

Requires App Context

Enable App Context for your keyset in the Admin Portal.

Method signature

icon

Under the hood


These methods take the following parameters:

  • delete()

    1channel.delete({
    2 soft?: boolean
    3}): Promise<true | Channel>
  • deleteChannel()

    1chat.deleteChannel(
    2 id: string,
    3 {
    4 soft?: boolean
    5 }
    6): Promise<true | Channel>

Input

ParameterRequired in delete()Required in deleteChannel()Description
id
Type: string
Default:
n/a
No
Yes
Unique channel identifier.
soft
Type: boolean
Default:
false
No
No
Define if you want to permanently remove channel metadata. The channel metadata gets permanently deleted from the App Context storage by default. If you set this parameter to true, the Channel object gets the deleted status, and you can still restore/get its data.

Output

TypeDescription
Promise<true> or Promise<Channel>
For hard delete, a confirmation that the channel metadata was permanently deleted. For soft delete, an updated channel instance with the status field set to deleted.

Errors

Whenever the channel ID is required, and you try to delete a channel without providing its ID, you will receive the ID is required error.

Sample code

Permanently delete the support channel metadata.

  • delete()

    1// reference the "channel" object
    2const channel = await chat.getChannel("support")
    3// invoke the "delete()" method. By default, the "soft" parameter is set to "false" and can be skipped.
    4await channel.delete()
  • deleteChannel()

    1// reference the "chat" object and invoke the "deleteChannel()" method. By default, the "soft" parameter is set to "false" and can be skipped.
    2const channel = await chat.deleteChannel(
    3 "support",
    4)

Other examples

Archive (soft delete) the channel with the ID of support, keeping its data in the App Context storage.

  • delete()

    1const channel = await chat.getChannel("support")
    2await channel.delete(
    3 {
    4 soft: true
    5 }
    6)
  • deleteChannel()

    1await chat.deleteChannel(
    2 "support",
    3 {
    4 soft: true
    5 }
    6)
Last updated on