Views: 3654
Last Modified: 23.03.2022

Sending personal notification

Revision Get current information about current API revision (platform version) – im.revision.get : 18

Attention: restCommand function is used here for illustration purposes only. It is taken from the EchoBot example. You can send a REST command with your own function, or use the BX24.callMethod or bitrix24-php-sdk methods.

Parameters

Parameter Example Required Description Revision
USER_ID 1 Yes User ID, notification recipient 18
MESSAGE Personal notification Yes Notification text 18
MESSAGE_OUT Personal notification text for email No Notification text for email. When not specified, uses the field MESSAGE 18
TAG TEST No Notification tag, unique within the system. Other notifications will be deleted upon adding notification with existing tag. 18
SUB_TAG SUB|TEST No Additional tag, without duplication check. 18
ATTACH No Attachment 18

Related links

How to handle attachments


Called method and response

PHP

$result = restCommand('im.notify.personal.add', Array(

   'USER_ID' => 1,
   'MESSAGE' => 'Personal notification',
   'MESSAGE_OUT' => 'Personal notification text for email',
   'TAG' => 'TEST',
   'SUB_TAG' => 'SUB|TEST',
   'ATTACH' => ''
  
), $_REQUEST["auth"]);

Response example

{
	"result": 123
}
Execution result: notification ID or error.


Response example on error

{
    "error": "USER_ID_EMPTY",
    "error_description": "Recipient ID not specified"
}

Key description:

  • error – error code
  • error_description – brief error description

Possible error codes

Код Description
USER_ID_EMPTY Recipient ID not specified
MESSAGE_EMPTY Message text is empty
ATTACH_ERROR Attachment object validation error
ATTACH_OVERSIZE Maximum allowed attachment size exceeded (30 Kb)



Courses developed by Bitrix24