Subscription

The subscription object contains information about the room and the user in relation to it. This is stored in the rocketchat_subscription collection on MongoDB.

Interface

interface ISubscription {
	u: Pick<IUser, '_id' | 'username' | 'name'>;
	v?: Pick<IUser, '_id' | 'username' | 'name'>;
	rid: RoomID;
	open: boolean;
	ts: Date;

	name: string;

	alert?: boolean;
	unread: number;
	t: RoomType;
	ls: Date;
	f?: boolean;
	lr: Date;
	hideUnreadStatus?: true;
	hideMentionStatus?: true;
	teamMain?: boolean;
	teamId?: string;

	userMentions: number;
	groupMentions: number;

	broadcast?: true;
	tunread?: Array<string>;
	tunreadGroup?: Array<string>;
	tunreadUser?: Array<string>;

	prid?: RoomID;

	roles?: IRole['_id'][];

	onHold?: boolean;
	encrypted?: boolean;
	E2EKey?: string;
	E2ESuggestedKey?: string;
	unreadAlert?: 'default' | 'all' | 'mentions' | 'nothing';

	fname?: string;

	code?: unknown;
	archived?: boolean;
	audioNotificationValue?: string;
	desktopNotifications?: 'all' | 'mentions' | 'nothing';
	mobilePushNotifications?: 'all' | 'mentions' | 'nothing';
	emailNotifications?: 'all' | 'mentions' | 'nothing';
	userHighlights?: string[];
	blocked?: unknown;
	blocker?: unknown;
	autoTranslate?: boolean;
	autoTranslateLanguage?: string;
	disableNotifications?: boolean;
	muteGroupMentions?: boolean;
	ignored?: IUser['_id'][];

	department?: unknown;

	desktopPrefOrigin?: 'subscription' | 'user';
	mobilePrefOrigin?: 'subscription' | 'user';
	emailPrefOrigin?: 'subscription' | 'user';

	/* @deprecated */
	customFields?: Record<string, any>;
}

You can check the ISubscription interface here.

Subscription object

Example object

{
  "_id": "GuZJ5YcMHe4iRDbMm",
  "open": true,
  "alert": true,
  "unread": 1,
  "userMentions": 1,
  "groupMentions": 0,
  "ts": {
    "$date": "2023-02-06T14:17:44.985Z"
  },
  "rid": "GENERAL",
  "name": "general",
  "t": "c",
  "u": {
    "_id": "6LMJ5Lu5YsBaqsJvE",
    "username": "user1"
  },
  "_updatedAt": {
    "$date": "2023-02-06T14:17:44.985Z"
  }
}

Fields

Parameter

Data type

Description

_id

String

Unique identifier for the subscription.

u

Object

Information about the user associated with the subscription (_id, username, name).

v

Object

Information about the visitor associated with the subscription (_id, username, name).

rid

String

The room ID associated with the subscription.

open

Boolean

Indicates if the room is open for the user(it defaults to false on direct messages). Clients use this to determine whether the user can see this subscription in their list since you can hide rooms from being visible without leaving them.

ts

Date

The timestamp the room was created at, so this should equal the room's ts field.

name

String

Name of the subscription.

alert

Boolean

Indicates if there is an alert for the subscription to be displayed to the user.

unread

Number

Number of unread messages in the subscription. NOTE: The unread counter value depends on your settings in the Administration > Workspace > Settings > General.

t

String

Type of room associated with the subscription (e.g., "c" for channel, "d" for direct message. See Room Schema Definition).

ls

Date

Timestamp of the last seen activity in the subscription.

f

Boolean

Indicates if the subscription is a favorite.

lr

Date

Timestamp of the last reply in a thread.

hideUnreadStatus

Boolean

Whether the subscribed room should be marked as containing unread messages in the UI or not.

hideMentionStatus

Boolean

Indicates if the mention status is hidden.

teamMain

Boolean

Whether this subscription points to the main room of a team or not.

teamId

String

(Optional) ID of the team associated with the subscription, if the subscription points to a team room.

userMentions

Number

Number of unread mentions to the user in the room.

groupMentions

Number

Number of unread mentions to a group which the user is part of (e.g @all, @here).

broadcast

Boolean

Indicates if the subscription is a broadcast.

tunread

Array of string

(Optional) List of IDs of unread threads.

tunreadGroup

Array of string

(Optional) List of thread IDs that contain an unread mention to a group that the user is part of.

tunreadUser

Array of string

(Optional) List of thread IDs that contain an unread mention to the user.

prid

String

Parent room ID. This will only be available if this is a subscription to a discussion.

roles

Array of string

An array of role IDs associated with the subscription.

onHold

Boolean

(Omnichannel) Whether or not this room has been put on hold.

encrypted

Boolean

Indicates if the subscription is encrypted.

E2EKey

String

Encryption key for the subscription.

E2ESuggestedKey

String

Suggested encryption key for the subscription.

unreadAlert

String

Type of alert for unread messages in the subscription (default, all, mentions, nothing).

fname

String

Friendly name of the subscription.

code

unknown

Unknown data type.

archived

Boolean

Indicates if the subscription is archived.

audioNotificationValue

String

Value for audio notifications.

desktopNotifications

String

Desktop notification preferences for the subscription (all, mentions, nothing).

mobilePushNotifications

String

Mobile push notification preferences for the subscription (all, mentions, nothing).

emailNotifications

String

Email notification preferences for the subscription (all, mentions, nothing).

userHighlights

Array of string

An array of user IDs to highlight in the subscription.

blocked

unknown

Unknown data type.

blocker

unknown

Unknown data type.

autoTranslate

Boolean

Indicates if auto-translation is enabled for the subscription.

autoTranslateLanguage

String

Language code for auto-translation in the subscription.

disableNotifications

Boolean

Indicates if notifications are disabled for the subscription.

muteGroupMentions

Boolean

Indicates if group mentions are muted for the subscription.

ignored

Array of string

An array of user IDs to ignore in the subscription.

department

unknown

Unknown data type.

desktopPrefOrigin

String

Origin of the desktop preference (subscription or user).

mobilePrefOrigin

String

Origin of the mobile preference (subscription or user).

emailPrefOrigin

String

Origin of the email preference (subscription or user).

customFields

Record<string, any>

Custom fields associated with the subscription.

Notes about customFields:

  • customFields inherits from room's custom fields for channels (Room Type: c = chanel) and groups (Room Type: p = group) and changes with room's custom fields.

  • customFields inherits from user's custom fields for direct messages (Room Type: d = direct) and changes with user's custom fields. Note that users of DM rooms will have own custom fields.