Push API
Register a device's push token for the signed-in or anonymous user, and remove it at sign-out.
AAgent44Updated 2 min read
Devices belong to the key's app, and the key decides the push service: APNs for an iOS app's key, FCM for an Android app's. A web app's key gets a 400 ("Push notifications are for iOS and Android apps' keys") from both endpoints. Setup and what arrives on the device are in Push notifications.
POST /v1/push/devices#
Registers the device for the user in the identity headers (X-A44-User-Id, with X-A44-User-Hash when you use identity verification, or X-A44-Anonymous-Id; the user is created if they're new). When the key's workspace enforces identity verification, a user id without a valid signature is a 401, so nobody can register a device for someone else's notifications.
{ "token": "a1b2c3…", "environment": "production", "app_version": "4.2.0", "locale": "en-GB", "enabled": true }Field | Rules |
|---|---|
| Required. iOS: the APNs device token as hex. Android: the FCM registration token. 8 to 4,096 characters of letters, digits and |
| iOS: |
| The running version, for campaigns aimed at a version range. |
| Optional, like |
|
|
Answers 201 { "id": "…", "enabled": true }.
Registering the same token again updates it; there are never duplicates. An
environment,app_versionorlocaleyou leave out keeps its stored value;enabledistrueunless you sendfalse.A token registered for another user moves to the new one, who gets its notifications from then on.
Each user keeps at most 20 devices per app; the least recently seen are dropped.
DELETE /v1/push/devices#
At sign-out, before you forget the user id:
{ "token": "a1b2c3…" }Send it with the same identity headers as your other requests (the user id, its signature, and the device's anonymous id). Removes the token from the key's app only, and only while it's registered to that user or to this device's anonymous visitor: someone else's token isn't touched. Answers 204 either way, whether or not anything was removed. A body without a valid token is a 400; a user id without a valid signature, when the workspace enforces identity verification, a 401. The token travels in the body so it stays out of URLs and logs.
DELETE /v1/push/devices/{token}#
The older form, with the token URL-encoded in the path (FCM tokens contain :). It works the same way, identity headers included; a value that can't be a token (a malformed URL escape included) is a 404. New integrations should send the body form above.