Developers » Working with the Long Poll server, part 2
3. Event Structure (part 2)
CodeExtra fieldsEvent description
80$count (integer)
New unread messages counter in the left menu equals $count.
114$peer_id (integer)
$sound (integer)
$disabled_until (integer)
Notification settings changed where $peer_id is a chat/users ID, $sound is either 1 (sound notifications on) or 0 (sound notifications off), $disabled_until shows notifications disabled for a certain period (-1: forever, 0: enabled, other: timestamp for when it should be switched on).

3.1. Extra Message Fields
Extra fields for a message object:
  • $peer_id (integer) destination ID. For user: user id. For group chat: "2000000000" + chat id. For community: community -id or community id + "1000000000" (for version = 0).
  • $timestamp(integer) message sent time in Unixtime;
  • $subject(string) message subject;
  • $text(string) message text;
  • [$attachments](array) attachments, if mode = 2 was chosen;
  • [$random_id] (integer) random_id, if the parameter was transferred to messages.send. It may contain 0 if no value was set.

If a message is unavailable for some reason, extra_fields may not return or only $peer_id may return. For events 1, 2, and 3, in most cases only $peer_id returns. For event 4, in most cases the full set of fields returns. If a message was restored, for events 1 and 3 (removing SPAM or DELETED flags), in most cases the full set of fields will be returned.
4. Message Flags
Each message has a flag, which is a value received by summing up any of the following parameters.
+1UNREADMessage is unread
+2OUTBOXMessage is outgoing
+4REPLIEDMessage was answered
+8IMPORTANTMessage is marked as important
+16CHATMessage sent via chat
+32FRIENDSMessage sent by a friend
+64SPAMMessage marked as "Spam"
+128DELTDMessage was deleted
+256FIXEDMessage was user-checked for spam
+512MEDIAMessage has media content
+65536HIDDENGreeting message from a community. A dialog with such message should not be raisen in the list (show it only when a dialog has been opened directly). Flag is unavailable for versions < 2.
5. Dialog Flags
Each dialog has flags, which are values received by summing up any of the following parameters. Flags are set only for community dialogs. Flags are set only for community dialogs.
+1 IMPORTANT Important dialog
+2 UNANSWERED Dialog without a community reply. Note that for versions <2 flag is inverted and corresponds to an unanswered dialog.
6. Attachments
If mode contains the flag 2 along with text and the message topic, a JSON-object may be passed. This object contains media attachments or other additional information. Descriptions of the object fields are listed below.

Be aware that in some cases the answer may contain additional attachments, the names of which are not listed in this table. Ignore them and don't try to work with them.
Field nameValueDescription
attach{$i}_type photo, video, audio, doc, wall, sticker, link $i attachment type, where i > 0.
attach{$i} {$owner_id}_{$item_id} $i attachment ID, where i > 0.
fwd {$user_id}_{$msg_id},{$user_id}_{$msg2_id},... IDs of attached messages.
from {$user_id} User ID of who sent the message if the message is from a chat
geo {$geo_id} Attached map ID. View this attachment only as a sign that a geographic mark was attached to the message.
geo_provider {$geo_provider_id} Cartography service ID. View this attachment only as a sign that a geographic mark was attached to the message.
title{$subject}Message's subject.
attach{$i}_product_id {product_id} Sticker ID.
attach{$i}_photo {$owner_id}_{$item_id} Photo string ID for link preview (for attach{$i}_type = link).
attach{$i}_title {$title} Link name (for attach{$i}_type = link).
attach{$i}_desc {$description} Link description (for attach{$i}_type = link).
attach{$i}_url {$url} URL (for attach{$i}_type = link).
emoji 1 Message contains emoji.
from_admin {$user_id} ID of the administrator who sent the message. It is returned for messages sent from a community (only for community administrators).
source_act chat_create, chat_title_update, chat_photo_update, chat_invite_user, chat_kick_user Service action name with multiple dialogs. Possible values:
  • chat_create create chat;
  • chat_title_update change chat name;
  • chat_photo_update change chat photo;
  • chat_invite_user invite user to chat;
  • chat_kick_user kick out user from chat.
source_mid {$user_id} User ID to whom the service action concerns (for source_act=chat_invite_user and source_act=chat_kick_user).
7. Platforms
If mode contains flag 64, then in messages with code 8 (friend is offline), extra data $extra will return in the third field. From this you can get the platform ID $platform_id = $extra & 0xFF ( = $extra % 256), from which the user got online. This ID can be used, for example, to determine whether the online status was updated from a mobile device (IDs 1 - 5).
1 mobile Mobile website version or unidentified mobile app
2 iphone Official app for iPhone
3 ipad Official app for iPad
4 android Official app for Android
5 wphone Official app for Windows Phone
6 windows Official app for Windows 8
7 web Full website version or unidentified apps

8. Event Examples
The message with message_id=123456 in the dialog with user user_id=54321 has been deleted:

The message with message_id=654321 in the chat with peer_id=2000000202 (chat_id=202) has been read:

In 1464950873 Unixtime the message with message_id=654321 and text "Hello" (without attachment) has been received user 123456 in the chat with peer_id=2000000202:
[4,654321,8193,2000000202,1464950873,"Hello.",{"from":"123456 "}]

New message from user with user_id=123456 with text "hello" and two attachments (photo and audio):
[4,2105994,561,123456,1496404246,"hello",{"attach1_type":"photo","attach1":"123456_417336473","attach2_type":"audio","attach2":"123456_456239018","title":" ... "}]

In the chat with ''chat_id'''=202 (peer_id=2000000202) all incoming message before local_id=1619361 have been read:

User with user_id=12345 has become online via iPhone:

User with user_id=123456 has started to type message in the dialog: