For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
SDKsHelp CenterLog inSign up
    • Overview
  • Getting Started
    • API Mechanics
    • Quickstart
  • Guides
    • Communications API
    • Troubleshooting
    • Events
    • Changelog
  • Comms API Reference
      • Summary
      • POSTSend Push Notifications
      • GETList Push Notifications
      • GETFetch a Push Notification
      • GETFetch a Push Notification Operation
      • GETList Push Notification Operations
        • GETList Device Registrations
        • POSTRegister Device for Push Notifications
        • GETGet a single Device Registration
        • DELDelete a Device Registration
LogoLogo
SDKsHelp CenterLog inSign up
Comms API ReferencePush NotificationsDevice Registrations

Register Device for Push Notifications

POST
https://comms.twilio.com/v1/PushNotifications/DeviceRegistrations
POST
/v1/PushNotifications/DeviceRegistrations
1import { TwilioClient } from "twilio-comms";
2
3async function main() {
4 const client = new TwilioClient({
5 accountId: "YOUR_ACCOUNTID_HERE",
6 authToken: "YOUR_AUTHTOKEN_HERE",
7 });
8 await client.pushNotifications.deviceRegistrations.register({
9 appName: "limonade_app",
10 token: "dqWD7WEC83K41WHyufTS7:APA91bFcrVaOLqKeJfSiEutJXX2Tr9wN_tYOwYd8rFA6mYUMBFqdz9n6k3v5EpFA_ukXD89hGqG3OarzbVfdjGnLOIAQfwbQcqJkjQWMrhwElrtU1y3JLDPfnjc0eTJLxzhyYvDFopEh",
11 provider: "FCM",
12 userId: "comms_pushnotificationuser_01h9krwprkeee8fzqspvwy6nq8",
13 });
14}
15main();
1{
2 "resourceId": "comms_device_registration_01h9krwprkeee8fzqspvwy6nq8",
3 "resourceLocation": "https://comms.twilio.com/v1/PushNotifications/DeviceRegistrations/comms_device_registration_01h9krwprkeee8fzqspvwy6nq8"
4}
This operation registers the push notifications token of the device/browser to the Registration set of a User with the corresponding `appName`. * If a User ID is not provided, a new User is created. * If a User ID is provided and the User exists, the device is registered to the User.
Was this page helpful?
Previous

Get a single Device Registration

Next
Built with

This operation registers the push notifications token of the device/browser to the Registration set of a User with the corresponding appName.

  • If a User ID is not provided, a new User is created.

  • If a User ID is provided and the User exists, the device is registered to the User.

Authentication

AuthorizationBasic

Basic authentication of the form Basic <account_id:auth_token>.

OR
AuthorizationBasic

Basic authentication of the form Basic <api_key:api_key_secret>.

Request

This endpoint expects an object.
appNamestringRequiredformat: "^[a-z0-9_]+$"1-64 characters

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.

tokenstringRequired
The device token to register for push notifications.
providerenumRequired
Push notification service provider.
Allowed values:
userIdstringOptionalformat: "^comms_pushnotificationuser_[0-7][a-hjkmnpqrstv-z0-9]{25,34}"
The ID of the User to register the device to, if available.

Response headers

Locationstring

The location (uri) of the resource identified by Resource-Id.

Response

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.
resourceIdstring
The Resource ID is an identifier for the resource that was created or updated in response to the request.
resourceLocationstringformat: "uri"

The location (uri) of the resource identified by Resource-Id.

Errors

400
Bad Request Error
429
Too Many Requests Error
500
Internal Server Error
503
Service Unavailable Error