Skip to main content

Manage Tag Information Data

The SDK provides a tag management system that allows developers to assign tags to conversations for better categorization and management. These tag details are synchronized to the server.

This document introduces the tag management-related interfaces provided by the SDK, including:

tip

For details on how to use tags to manage conversations, see Managing Conversations with Tags.

Create a Tag

Call the addTag method to create a new tag for the current user. Each user can create up to 20 tags.

Interface

RongIMLib.addTag(tag)


#### Parameter Description

| Parameter | Type | Required | Description |
|:--- |:--- |:--- |:--- |
| tag | [ITagParam] | Yes | Tag information, including tag ID and tag name |


#### Example Code

```js
const tag = {
tagId: 'tagId',
tagName: 'tagName',
};
const res = await RongIMLib.addTag(tag);
console.log('Tag creation result:', res);


## Delete a Tag \{#removeTag}

Call the [removeTag](https://doc.rongcloud.cn/apidoc/im-web/latest/zh_CN/modules.html#removeTag) method to delete a specified tag.


#### Interface

```js
RongIMLib.removeTag(tagId)


#### Parameter Description

| Parameter | Type | Required | Description |
|:--- |:--- |:--- |:--- |
| tagId | string | Yes | The ID of the tag to be deleted |


#### Example Code

```js
const tagId = 'tagId';
const res = await RongIMLib.removeTag(tagId);
console.log('Tag deletion result:', res);


## Edit a Tag \{#updateTag}

Call the [updateTag](https://doc.rongcloud.cn/apidoc/im-web/latest/zh_CN/modules.html#updateTag) method to modify the name of an existing tag.


#### Interface

```js
RongIMLib.updateTag(tag)


#### Parameter Description

| Parameter | Type | Required | Description |
|:--- |:--- |:--- |:--- |
| tag | [ITagParam] | Yes | Tag information. |


#### Example Code

```js
const tag = {
tagId: 'tagId',
tagName: 'tagName',
};
const res = await RongIMLib.updateTag(tag);
console.log('Tag editing result:', res);


## Get Tag List \{#getTags}

Call the [getTags](https://doc.rongcloud.cn/apidoc/im-web/latest/zh_CN/modules.html#getTags) method to retrieve the list of tags created by the current user.


#### Interface

```js
RongIMLib.getTags()


#### Parameter Description

None


#### Example Code

```js
const res = await RongIMLib.getTags();
console.log('Tag list retrieval result:', res);
<!-- links -->
[ITagParam]: https://doc.rongcloud.cn/apidoc/im-web/latest/zh_CN/interfaces/ITagParam.html