sendpush
POST v1/simplepush/sendpush#
With this API, you can send instant push notifications to one or more of your users.
You can send push notifications to a maximum of 1000 users per request. If more than 1000 users are given, you get the MAX_PUSHES_PER_REQUEST_EXCEEDED error.
API requests
- Must be authenticated with HMAC Authentication. For HMAC Authentication, see the Authentication document.
- API URI : https://DIYALOG-SERVER-API-ENDPOINT/v1/simplepush/sendpush
- HTTP Request Type POST
- HTTP Content-Type application/json
Request Body#
| Schema |
|---|
| json object |
| to (String[]) The user (customer) number or numbers you want to send the push notification to. You can enter up to 1000 user numbers at a time. If you enter more, you get the MAX_PUSHES_PER_REQUEST_EXCEEDED error. |
| data (String) The payload data you want to send to the mobile device. You can send a string value or a stringified json object of up to 4 KB. This payload is delivered to the mobile device as a notification. You need to implement the handling of this data in your own mobile application. |
| senderApp (String) Specifies which application the notification is sent from. It is delivered to the mobile device as "senderApp" custom data. You can use it on the mobile device to distinguish notifications and handle them accordingly. |
| time_to_live (integer) Optional. Applies to Android and Huawei devices. Specifies how long (in seconds) the push notification should be kept if the device is offline. If this parameter is not sent, the system treats the notification as instant and sets this value to 0. |
| content_available (Boolean) Optional. (Applies to iOS devices.) The default value is false. When set to true, your app's notification handler is called even if the app is running in the background, allowing it to fetch updated content from the server or run another custom flow without alerting the user. For this, the Background Modes -> Remote Notifications capability must be enabled in your mobile application. |
| mutable_content (Boolean) Optional. (Applies to iOS devices.) The default value is false. When set to true, your app's Notification Service Extension is called even if the app is running in the background, allowing rich media attachments in your notification to be downloaded and displayed. For this, the Background Modes -> Remote Notifications capability must be enabled in your mobile application. |
| ios_notification(json object) Optional. (Applies to iOS devices.) The iOS notification content, used to send standard alert and sound notifications. Its parameters follow the notification parameters in the iOS notification documentation. See the Apple documentation for details. |
| title (String) The text you want to appear as the notification title, visible on iOS 8.2+ and Apple Watch. |
| body (String) The message content shown in the main notification popup on the lock screen and in other areas of iOS. |
| badge (integer) Optional. Set this parameter if you want a number to appear on the app icon. |
| sound (string) Optional. The name of the sound file to play when the notification arrives on the device. If it is not set, the notification popup appears silently. If the file does not exist on the device, the device's default notification sound plays. |
| category (String) Optional. Makes your app invoke the category you defined in its Notification Content Extension, if any. |
| thread_id (String) Optional. Lets you group multiple notifications by specifying a common thread_id. |
| interruption_level (String) Optional. Lets you set the importance and delivery timing of a notification on iOS 15+. The value can be one of 'Active', 'Critical', 'Passive', 'Time_Sensitive'. It is case-sensitive. The default value is 'Active'. |
| loc_key (String) Optional. The key of a string in your app's Localizable.strings file. This parameter can be used for localization. See the APNs Documentation for details. |
| loc_args (String[]) Optional. The strings that replace the %@ placeholders in the localized text matching the given loc_key. See the APNs Documentation for details. |
| title_loc_key (String) Optional. The key of a string in your app's Localizable.strings file. This parameter can be used for localization. See the APNs Documentation for details. |
| title_loc_args (String[]) Optional. The strings that replace the %@ placeholders in the localized text matching the given loc_key. See the APNs Documentation for details. |
Example Json Request Body :#
Responses#
| HTTP 200 Response |
|---|
| json object The API returns a json object as a response. Notifications are sent asynchronously, so the response does not tell you whether the notification was sent through APNS, FCM or HMS. However, user (customer) numbers you sent to this service that are not registered in the Diyalog system, or whose token is not in the system, are returned in the failed field of the response. |
| pushId (String) A unique id created in the Diyalog system for your request. You can use this id later to query the notifications delivered to your users. If you need to query the notifications you sent, store this id in your system. |
| success (Boolean) Indicates that the request was received successfully and the notification sending process has started. |
| info (json object) An object containing detailed information. |
| devices (integer) The number of users for whom the notification sending process was started successfully. |
| failed (json object array) An array with details of the users for whom the notification sending could not be started. It contains objects with the user number and error code. |
| customerNo (String) The user number to which the notification could not be sent |
| errorCode (String) The reason for the error. It can take the following values. USER_NOT_FOUND_IN_SYSTEM USER_PUSH_TOKEN_NOT_FOUND |
Example Response Body :#
| HTTP 500 Response |
|---|
| string When the API encounters a general error, it returns a response with the HTTP 500 status code. The API's error message is returned as text. |
If the maximum number of users is exceeded, the API request returns the following error.#
| HTTP 400 Response |
|---|
| string MAX_PUSHES_PER_REQUEST_EXCEEDED |
If the request fails HMAC validation, the following errors are returned as plain text. See Authentication.
| HTTP status | Message | Description |
|---|---|---|
| 400 | Required headers not found | One or more of the x-dlg-date, x-dlg-requester-userid or x-dlg-authorization headers are missing. |
| 400 | Authorization failed due to data format not valid | The x-dlg-authorization value after DLGA is not in the AccessKeyId:Signature form. |
| 400 | Date format is invalid. EEE, dd MMM yyyy HH:mm:ss Z is requied | The x-dlg-date value cannot be parsed in this format. The message text is returned as shown, including its spelling. |
| 401 | Authorization failed | The x-dlg-authorization header does not contain DLGA , the AccessKeyId is unknown, or the signature is not correct. |
| 401 | You have no permission on this operation. Contact your admin. | The signature is correct, but your access key has no push permission. |
| 403 | Request time may not be correct. | The x-dlg-date value differs from the server time by more than 15 minutes. |