DeviceRegistrations resource
Beta
The Push Notifications API is currently available as a Private Beta product. The information contained in this document is subject to change. You acknowledge and agree that your use of the Twilio Push Notifications API is subject to the terms of the Services in Private Beta. This means that some features are not yet implemented and others may be changed before the product is declared as Generally Available. Private Beta products are not covered by the Twilio Support Terms or Twilio Service Level Agreement.
A Device Registration resource associates a device token with a User for push notification delivery. Instead of managing device tokens yourself, you can store them as Device Registrations and send notifications to Users by their userId.
Each Device Registration links a userId to a device token and provider (APN or FCM), scoped to a specific App.
A reference to a Device Registration.
comms_device_registration_01h9krwprkeee8fzqspvwy6nq8Pattern: ^comms_device_registration_[a-hjkmnpqrstv-z0-9]{26,34}$A reference to a Push Notification User.
comms_pushnotificationuser_01h9krwprkeee8fzqspvwy6nq8Pattern: ^comms_pushnotificationuser_[0-7][a-hjkmnpqrstv-z0-9]{25,34}List of devices registered in this set.
1Max items: 50A list of resources that are associated with this Device Registration.
POST https://comms.twilio.com/v1/PushNotifications/DeviceRegistrations
Register a device for push notifications by making an HTTP POST request to the Device Registrations resource URI.
You must specify an appName that matches an existing App. If the appName does not match any existing App, the operation fails.
If you omit the userId, the API creates a new User automatically.
application/jsonThe ID of the User to register the device to, if available.
comms_pushnotificationuser_01h9krwprkeee8fzqspvwy6nq8Pattern: ^comms_pushnotificationuser_[0-7][a-hjkmnpqrstv-z0-9]{25,34}The name of the App to register the device for.
If the appName does not match the name
of any existing Push Notification App, the operation will fail.
^[a-z0-9_]+$Min length: 1Max length: 64Push notification service provider.
APNFCMThe request was accepted and a resource ID is available to check the result. The response body contains the resource ID and link to the resource.
Optional
The Resource ID is an identifier for the resource that was created or updated in response to the request.
Optional
The location (uri) of the resource identified by Resource-Id.
1import { TwilioClient } from "twilio-comms";23async function main() {4const client = new TwilioClient({5accountId: "<username>",6authToken: "<password>",7});8await client.pushNotifications.deviceRegistrations.register({9userId: "comms_pushnotificationuser_01h9krwprkeee8fzqspvwy6nq8",10appName: "limonade_app",11token: "dqWD7WEC83K41WHyufTS7:APA91bFcrVaOLqKeJfSiEutJXX2Tr9wN_tYOwYd8rFA6mYUMBFqdz9n6k3v5EpFA_ukXD89hGqG3OarzbVfdjGnLOIAQfwbQcqJkjQWMrhwElrtU1y3JLDPfnjc0eTJLxzhyYvDFopEh",12provider: "FCM",13});14}15main();
GET https://comms.twilio.com/v1/PushNotifications/DeviceRegistrations/{deviceRegistrationId}
Retrieve a single Device Registration resource by making an HTTP GET request to the Device Registration resource URI with the Device Registration ID.
comms_device_registration_01h9krwprkeee8fzqspvwy6nq8Pattern: ^comms_device_registration_[a-hjkmnpqrstv-z0-9]{26,34}$OK
Optional
A reference to a Device Registration.
comms_device_registration_01h9krwprkeee8fzqspvwy6nq8Pattern: ^comms_device_registration_[a-hjkmnpqrstv-z0-9]{26,34}$Optional
The name of the App that the device registrations are for.
Optional
A reference to a Push Notification User.
comms_pushnotificationuser_01h9krwprkeee8fzqspvwy6nq8Pattern: ^comms_pushnotificationuser_[0-7][a-hjkmnpqrstv-z0-9]{25,34}Optional
List of devices registered in this set.
1Max items: 50Optional
A list of resources that are associated with this Device Registration.
1import { TwilioClient } from "twilio-comms";23async function main() {4const client = new TwilioClient({5accountId: "<username>",6authToken: "<password>",7});8await client.pushNotifications.deviceRegistrations.fetch("comms_device_registration_01h9krwprkeee8fzqspvwy6nq8");9}10main();
GET https://comms.twilio.com/v1/PushNotifications/DeviceRegistrations
Returns a list of Device Registrations. The userId query parameter is required. You can optionally filter by appName.
Filter Device Registrations by User.id to retrieve only registrations for that User.
comms_pushnotificationuser_01h9krwprkeee8fzqspvwy6nq8Pattern: ^comms_pushnotificationuser_[0-7][a-hjkmnpqrstv-z0-9]{25,34}Filter Device Registrations by their appName. Must be accompanied by the userId query parameter.
^[a-z0-9_]+$Min length: 1Max length: 64The number of resources to return in a page.
50Example: 50Minimum: 1Maximum: 1000OK
Optional
List of Device Registrations.
Optional
Metadata for paginated results. This object contains two tokens to navigate through paginated results.
- Use
nextto retrieve the 'next' page in the result list. - Use
selfto retrieve the same page of the result list again. - Supply the token in the
pageTokenquery param.
1import { TwilioClient } from "twilio-comms";23async function main() {4const client = new TwilioClient({5accountId: "<username>",6authToken: "<password>",7});8await client.pushNotifications.deviceRegistrations.list({9userId: "comms_pushnotificationuser_01h9krwprkeee8fzqspvwy6nq8",10appName: "appName",11pageToken: "pageToken",12pageSize: 50,13});14}15main();
DELETE https://comms.twilio.com/v1/PushNotifications/DeviceRegistrations/{deviceRegistrationId}
Delete a Device Registration by making an HTTP DELETE request to the Device Registration resource URI with the Device Registration ID.
If successful, returns HTTP 202 (Accepted) with a resource ID to check the result.
Once deleted, the User no longer receives push notifications for the specified App until new devices are registered.
comms_device_registration_01h9krwprkeee8fzqspvwy6nq8Pattern: ^comms_device_registration_[a-hjkmnpqrstv-z0-9]{26,34}$The request was accepted and a resource ID is available to check the result. The response body contains the resource ID and link to the resource.
Optional
The Resource ID is an identifier for the resource that was created or updated in response to the request.
Optional
The location (uri) of the resource identified by Resource-Id.
1import { TwilioClient } from "twilio-comms";23async function main() {4const client = new TwilioClient({5accountId: "<username>",6authToken: "<password>",7});8await client.pushNotifications.deviceRegistrations.delete("comms_device_registration_01h9krwprkeee8fzqspvwy6nq8");9}10main();