Push Notifications API

Overview of push notifications API methods

post
Send Push Notification

https://api.codemash.io/:version/notifications/push
Send a mobile notification message.
Request
Response
Request
Path Parameters
version
required
string
The version of API endpoint. Current latest v1.
Headers
Authorization
required
string
Your project's secret key.
x-cm-projectid
required
string
Your project's ID. Can be passed as query parameter.
Body Parameters
templateId
required
string
ID of push notification template to use.
roles
optional
array
Roles of users to set as recipients.
users
optional
array
Array of user IDs to be set as recipients.
devices
optional
array
Array of device IDs to be set as recipients.
isNonPushable
optional
boolean
If set as true, creates a silent notification without popping up at recipient's device.
tokens
optional
object
Key value pair (string: string) object of custom tokens.
postpone
optional
integer
Amount of milliseconds to postpone sending the notification.
respectTimeZone
optional
boolean
If creating a postponed notification and recipient's devices has timezone set, then postpones according to device's timezone.
Response
200: OK
Returns an ID of created notification group.
{
Result: ""
}
401: Unauthorized
Returns if the user does not have a valid permission to call this method.
500: Internal Server Error
.NET
Node
.NET
var client = new CodeMashClient(apiKey, projectId);
var pushService = new CodeMashPushService(client);
var response = await pushService.SendPushNotificationAsync(
new SendPushNotificationRequest
{
TemplateId = Guid.Parse("{TEMPLATE_ID}"),
Users = new List<string> { "{USER_ID}" }
}
);
Node

get
Get Notification

https://api.codemash.io/:version/notifications/push/:id
Gets a push notification.
Request
Response
Request
Path Parameters
version
required
string
The version of API endpoint. Current latest v1.
id
required
string
ID of a notification to get.
Headers
Authorization
required
string
Your project's secret key.
x-cm-projectid
required
string
Your project's ID. Can be passed as query parameter.
Response
200: OK
Returns an ID of created notification group.
{
Result: ""
}
401: Unauthorized
Returns if the user does not have a valid permission to call this method.
500: Internal Server Error
.NET
Node
.NET
var client = new CodeMashClient(apiKey, projectId);
var pushService = new CodeMashPushService(client);
var response = await pushService.GetNotificationAsync(
new GetNotificationRequest
{
Id = "{NOTIFICATION_ID}"
}
);
Node

get
Get Notifications

https://api.codemash.io/:version/notifications/push
Gets many push notifications.
Request
Response
Request
Path Parameters
version
required
string
The version of API endpoint. Current latest v1.
Headers
Authorization
required
string
Your project's secret key.
x-cm-projectid
required
string
Your project's ID. Can be passed as query parameter.
Query Parameters
userId
optional
string
ID of a user whose notifications to get.
deviceId
optional
string
ID of a device whose notifications to get.
Response
200: OK
Returns an ID of created notification group.
{
Result: ""
}
401: Unauthorized
Returns if the user does not have a valid permission to call this method.
500: Internal Server Error
.NET
.NET
var client = new CodeMashClient(apiKey, projectId);
var pushService = new CodeMashPushService(client);
var response = await pushService.GetNotificationsAsync(
new GetNotificationsRequest
{
UserId = "{USER_ID}"
}
);

If you do not specify user ID or device ID, method will return notifications directed to calling user. To get any user's or device's notifications, the calling user need's to have appropriate permission for that.

get
Get Notifications Count

https://api.codemash.io/:version/notifications/push/count
Gets total and total unread notifications.
Request
Response
Request
Path Parameters
version
required
string
The version of API endpoint. Current latest v1.
Headers
Authorization
required
string
Your project's secret key.
x-cm-projectid
required
string
Your project's ID. Can be passed as query parameter.
Query Parameters
userId
optional
string
ID of a user whose notifications to get.
deviceId
optional
string
ID of a device whose notifications to get.
Response
200: OK
Returns an ID of created notification group.
{
"result": {
"totalCount": 20,
"totalUnread": 2
}
}
401: Unauthorized
Returns if the user does not have a valid permission to call this method.
500: Internal Server Error
.NET
.NET
var client = new CodeMashClient(apiKey, projectId);
var pushService = new CodeMashPushService(client);
var response = await pushService.GetNotificationsCountAsync(
new GetNotificationsCountRequest
{
UserId = "{USER_ID}"
}
);

If you do not specify user ID or device ID, method will return notifications directed to calling user. To get any user's or device's notifications, the calling user need's to have appropriate permission for that.

patch
Read Notification

https://api.codemash.io/:version/notifications/push/:notificationId/read
Marks a particular push notification as read.
Request
Response
Request
Path Parameters
version
required
string
The version of API endpoint. Current latest v1.
id
required
string
ID of a notification to delete.
Headers
Authorization
required
string
Your project's secret key.
x-cm-projectid
required
string
Your project's ID. Can be passed as query parameter.
Body Parameters
notificationId
required
string
ID of notification to mark as read.
userId
optional
string
ID of user at which this notification was directed.
deviceId
optional
string
ID of device at which this notification was directed.
Response
200: OK
Returns an ID of created notification group.
{
Result: ""
}
401: Unauthorized
Returns if the user does not have a valid permission to call this method.
500: Internal Server Error
.NET
.NET
var client = new CodeMashClient(apiKey, projectId);
var pushService = new CodeMashPushService(client);
var response = await pushService.ReadNotificationAsync(
new MarkNotificationAsReadRequest
{
NotificationId = "{NOTIFICATION_ID}"
}
);

If you do not specify user ID or device ID, method will assume that notification was directed to a calling user. If you want to set other user's notification as read, you need to have appropriate permission for that.

delete
Delete Notification

https://api.codemash.io/:version/notifications/push/:id
Deletes a particular push notification.
Request
Response
Request
Path Parameters
version
required
string
The version of API endpoint. Current latest v1.
id
required
string
ID of a notification to delete.
Headers
Authorization
required
string
Your project's secret key.
x-cm-projectid
required
string
Your project's ID. Can be passed as query parameter.
Response
200: OK
Returns an ID of created notification group.
{
Result: ""
}
401: Unauthorized
Returns if the user does not have a valid permission to call this method.
500: Internal Server Error
.NET
.NET
var client = new CodeMashClient(apiKey, projectId);
var pushService = new CodeMashPushService(client);
var response = await pushService.DeleteNotificationAsync(
new DeleteNotificationRequest
{
Id = "{NOTIFICATION_ID}"
}
);