Skip to contentSkip to navigationSkip to topbar
Page toolsOn this page
Looking for more inspiration?Visit the

Users resource


(new)

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(link takes you to an external page). 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 User stores an end user's device tokens as DeviceRegistrations in the Push Notifications API. The API creates a new User automatically when you register a device and omit the userId.

You can send notifications to a User by providing their userId in the to array when sending a notification. The API delivers the notification to all devices registered to that User.


User Properties

user-properties page anchor
Property nameTypeRequiredPIIDescriptionChild properties
idstring
required
Not PII

A reference to a Push Notification User.

Example: comms_pushnotificationuser_01h9krwprkeee8fzqspvwy6nq8Pattern: ^comms_pushnotificationuser_[0-7][a-hjkmnpqrstv-z0-9]{25,34}

createdAtstring<date-time>
required

The date and time the User was created.


updatedAtstring<date-time>
required

The date and time the User was last updated.


deletedAtstring or null
required

The date and time the User was deleted, if applicable.


GET https://comms.twilio.com/v1/PushNotifications/Users/{userId}

Retrieve a single User resource by making an HTTP GET request to the User resource URI with the User ID.

Path parameters

path-parameters page anchor
Property nameTypeRequiredPIIDescription
userIdstring
required
Example: comms_pushnotificationuser_01h9krwprkeee8fzqspvwy6nq8Pattern: ^comms_pushnotificationuser_[0-7][a-hjkmnpqrstv-z0-9]{25,34}
200400404429500503

OK

SchemaExample
Property nameTypeRequiredDescriptionChild properties
idstring

Optional

A reference to a Push Notification User.

Example: comms_pushnotificationuser_01h9krwprkeee8fzqspvwy6nq8Pattern: ^comms_pushnotificationuser_[0-7][a-hjkmnpqrstv-z0-9]{25,34}

createdAtstring<date-time>

Optional

The date and time the User was created.


updatedAtstring<date-time>

Optional

The date and time the User was last updated.


deletedAtstring or null

Optional

The date and time the User was deleted, if applicable.

Fetch a PushNotification UserLink to code sample: Fetch a PushNotification User
1
import { TwilioClient } from "twilio-comms";
2
3
async function main() {
4
const client = new TwilioClient({
5
accountId: "<username>",
6
authToken: "<password>",
7
});
8
await client.pushNotifications.users.fetch("comms_pushnotificationuser_01h9krwprkeee8fzqspvwy6nq8");
9
}
10
main();

GET https://comms.twilio.com/v1/PushNotifications/Users

Returns a list of all push notification Users associated with your account.

Property nameTypeRequiredPIIDescription
pageTokenstring

Optional

The token to retrieve the next page of results.


pageSizeinteger

Optional

The number of resources to return in a page.

Default: 50Example: 50Minimum: 1Maximum: 1000
200400429500503

OK

SchemaExample
Property nameTypeRequiredDescriptionChild properties
usersarray[PushNotificationUser]

Optional


paginationPaginationMetadata

Optional

Metadata for paginated results. This object contains two tokens to navigate through paginated results.

  • Use next to retrieve the 'next' page in the result list.
  • Use self to retrieve the same page of the result list again.
  • Supply the token in the pageToken query param.
1
import { TwilioClient } from "twilio-comms";
2
3
async function main() {
4
const client = new TwilioClient({
5
accountId: "<username>",
6
authToken: "<password>",
7
});
8
await client.pushNotifications.users.list({
9
pageToken: "pageToken",
10
pageSize: 50,
11
});
12
}
13
main();

DELETE https://comms.twilio.com/v1/PushNotifications/Users/{userId}

Delete a User by making an HTTP DELETE request to the User resource URI with the User ID.

If successful, returns HTTP 202 (Accepted) with a resource ID to check the result.

Property nameTypeRequiredPIIDescription
userIdstring
required
Example: comms_pushnotificationuser_01h9krwprkeee8fzqspvwy6nq8Pattern: ^comms_pushnotificationuser_[0-7][a-hjkmnpqrstv-z0-9]{25,34}
202400404429500503

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.

SchemaExample
Property nameTypeRequiredDescriptionChild properties
resourceIdstring

Optional

The Resource ID is an identifier for the resource that was created or updated in response to the request.


resourceLocationstring<uri>

Optional

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

1
import { TwilioClient } from "twilio-comms";
2
3
async function main() {
4
const client = new TwilioClient({
5
accountId: "<username>",
6
authToken: "<password>",
7
});
8
await client.pushNotifications.users.delete("comms_pushnotificationuser_01h9krwprkeee8fzqspvwy6nq8");
9
}
10
main();