Devices API

Overview of mobile devices API methods

post
Register Device

https://api.codemash.io/:version/notifications/push/devices
Registers a device without a token. Devices without a token won't receive 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.
Body Parameters
userId
optional
string
ID of a user.
timeZone
optional
string
Timezone of a device in a tz database format.
meta
optional
object
Key value pair (string: string) object for custom data.
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.RegisterDeviceAsync(
new RegisterDeviceRequest
{
UserId = Guid.parse("{USER_ID}"),
TimeZone = "Etc/UTC",
Meta = new Dictionary<string, string>
{
{ "Os", "Android" }
}
}

post
Register Expo Token

https://api.codemash.io/:version/notifications/push/token/expo
Registers a device with a Expo token and creates a device if not yet created.
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
token
required
string
Token of a device provided by Expo.
deviceId
optional
string
ID of a device. If not provided, a new device will be added.
userId
optional
string
ID of a user.
timeZone
optional
string
Timezone of a device in a tz database format.
meta
optional
object
Key value pair (string: string) object for custom data.
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.RegisterExpoTokenAsync(
new RegisterDeviceExpoTokenRequest
{
UserId = Guid.parse("{USER_ID}"),
Token = "ExponentPushToken[**********************]",
TimeZone = "Etc/UTC",
Meta = new Dictionary<string, string>
{
{ "Os", "Android" }
}
}

get
Get Device

https://api.codemash.io/:version/notifications/push/devices/:id
Gets a device.
Request
Response
Request
Path Parameters
version
required
string
The version of API endpoint. Current latest v1.
id
required
string
ID of a device 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
.NET
var client = new CodeMashClient(apiKey, projectId);
var pushService = new CodeMashPushService(client);
var response = await pushService.GetDeviceAsync(
new GetDeviceRequest
{
Id = "{DEVICE_ID}"
}
);

get
Get Devices

https://api.codemash.io/:version/notifications/push/devices
Gets many devices.
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.
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.GetDevicesAsync(
new GetDevicesRequest()
);

delete
Delete Device

https://api.codemash.io/:version/notifications/push/devices/:id
Deletes a particular device.
Request
Response
Request
Path Parameters
version
required
string
The version of API endpoint. Current latest v1.
id
required
string
ID of a device 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.DeleteDeviceAsync(
new DeleteDeviceRequest
{
Id = "{DEVICE_ID}"
}
);

delete
Delete Device Token

https://api.codemash.io/:version/notifications/push/devices/:id/token
Deletes a token of particular device.
Request
Response
Request
Path Parameters
version
required
string
The version of API endpoint. Current latest v1.
id
required
string
ID of a device.
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.DeleteTokenAsync(
new DeleteDeviceTokenRequest
{
Id = "{DEVICE_ID}"
}
);

patch
Update Device Meta

https://api.codemash.io/:version/notifications/push/devices/:id/metadata
Updates a meta information of a particular device.
Request
Response
Request
Path Parameters
version
required
string
The version of API endpoint. Current latest v1.
id
required
string
ID of a device to update.
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
meta
optional
string
Key value pair (string: string) object of custom data.
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.UpdateDeviceMetaAsync(
new UpdateDeviceMetaRequest
{
Id = "{DEVICE_ID}",
Meta = new Dictionary<string, string>
{
{ "Os", "iOs" }
}
}
);

patch
Update Device Timezone

https://api.codemash.io/:version/notifications/push/devices/:id/timezone
Updates a timezone of a particular device.
Request
Response
Request
Path Parameters
version
required
string
The version of API endpoint. Current latest v1.
id
required
string
ID of a device to update.
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
timezone
optional
string
Timezone of a device in a tz database format.
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.UpdateDeviceTimeZoneAsync(
new UpdateDeviceTimeZoneRequest
{
Id = "{DEVICE_ID}",
TimeZone = "Etc/UTC",
}
);

patch
Update Device User

https://api.codemash.io/:version/notifications/push/devices/:id/timezone
Updates a user of a particular device.
Request
Response
Request
Path Parameters
version
required
string
The version of API endpoint. Current latest v1.
id
required
string
ID of a device to update.
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
userId
optional
string
ID of a new user.
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.UpdateDeviceUserRequest(
new UpdateDeviceUserRequest
{
Id = "{DEVICE_ID}",
UserId = Guid.Parse("{USER_ID}"),
}
);