Room Tagging

Users can add tags to rooms. Tags are namespaced strings used to label rooms. A room may have multiple tags. Tags are only visible to the user that set them but are shared across all their devices.

Events

The tags on a room are received as single m.tag event in the account_data section of a room. The content of the m.tag event is a tags key whose value is an object mapping the name of each tag to another object.

The JSON object associated with each tag gives information about the tag, e.g how to order the rooms with a given tag.

Ordering information is given under the order key as a number between 0 and 1. The numbers are compared such that 0 is displayed first. Therefore a room with an order of 0.2 would be displayed before a room with an order of 0.7. If a room has a tag without an order key then it should appear after the rooms with that tag that have an order key.

The name of a tag MUST NOT exceed 255 bytes.

The tag namespace is defined as follows:

Several special names are listed in the specification: The following tags are defined in the m.* namespace:

m.tag


Informs the client of tags on a room.

Event type: Message event

Content

Name Type Description
tags {string: Tag} The tags on the room and their contents.
Tag
Name Type Description
order number A number in a range [0,1] describing a relative position of the room under the given tag.

Examples

{
  "content": {
    "tags": {
      "u.work": {
        "order": 0.9
      }
    }
  },
  "type": "m.tag"
}

Client Behaviour

GET /_matrix/client/v3/user/{userId}/rooms/{roomId}/tags


List the tags set by a user on a room.

Rate-limited: No
Requires authentication: Yes

Request

Request parameters

path parameters
Name Type Description
roomId string Required: The ID of the room to get tags for.
userId string Required: The id of the user to get tags for. The access token must be authorized to make requests for this user ID.

Responses

Status Description
200 The list of tags for the user for the room.

200 response

Name Type Description
tags {string: Tag}
Tag
Name Type Description
order number A number in a range [0,1] describing a relative position of the room under the given tag.
{
  "tags": {
    "m.favourite": {
      "order": 0.1
    },
    "u.Customers": {},
    "u.Work": {
      "order": 0.7
    }
  }
}

PUT /_matrix/client/v3/user/{userId}/rooms/{roomId}/tags/{tag}


Add a tag to the room.

Rate-limited: No
Requires authentication: Yes

Request

Request parameters

path parameters
Name Type Description
roomId string Required: The ID of the room to add a tag to.
tag string Required: The tag to add.
userId string Required: The id of the user to add a tag for. The access token must be authorized to make requests for this user ID.

Request body

Name Type Description
order number A number in a range [0,1] describing a relative position of the room under the given tag.

Request body example

{
  "order": 0.25
}

Responses

Status Description
200 The tag was successfully added.

200 response

{}

DELETE /_matrix/client/v3/user/{userId}/rooms/{roomId}/tags/{tag}


Remove a tag from the room.

Rate-limited: No
Requires authentication: Yes

Request

Request parameters

path parameters
Name Type Description
roomId string Required: The ID of the room to remove a tag from.
tag string Required: The tag to remove.
userId string Required: The id of the user to remove a tag for. The access token must be authorized to make requests for this user ID.

Responses

Status Description
200 The tag was successfully removed.

200 response

{}