Message identifier in a chat#
The message identifier (idMessage) is a marker that GREEN-API assigns to every message. It is assigned to incoming and outgoing messages and allows you to find a specific message in a chat. Example: 1769676078000.
Important
The message identifier does NOT need to be generated by yourself. It is generated by the system automatically and is returned by various GREEN-API methods.
Uniqueness of the identifier#
The identifier is unique within one chat.
Within an instance and within the messenger, idMessage values are not unique: identical identifiers may occur in different chats.
- To build an identifier that is unique within an instance, use the combination of
chatIdandidMessage, for example:
-10000000000000_1769676078000
- When using several instances, a unique identifier is defined by the full combination of
idInstance+idMessage+chatId, for example:
4100123456_100000000_1769676078000
Identifiers are valid within a session
After an instance is re-authorized, synchronization with the messenger is performed anew, and identifiers may be generated differently. Therefore, idMessage values are valid only within the current session.
How to find out the identifier#
The identifier can be obtained when sending, through the journal methods or in an incoming notification in the idMessage field. Example of a SendMessage method response:
{
"idMessage": "1769676078000"
}
How to use the identifier#
The message identifier is used to find a specific message in a chat:
- get a message from the journal — using the GetMessage method by the
chatIdandidMessagepair; - edit a message — using the EditMessage method;
- delete a message — using the DeleteMessage method;
- quote a message - using the sending methods.