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
LogoLogo
SDKsHelp CenterLog inSign up
Comms API ReferencePush Notifications

Send Push Notifications

POST
https://comms.twilio.com/v1/PushNotifications
POST
/v1/PushNotifications
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.send({
9 to: [
10 {
11 token: "dqWD7WEC83K41WHyufTS7:APA91bFcrVaOLqKeJfSiEutJXX2Tr9wN_tYOwYd8rFA6mYUMBFqdz9n6k3v5EpFA_ukXD89hGqG3OarzbVfdjGnLOIAQfwbQcqJkjQWMrhwElrtU1y3JLDPfnjc0eTJLxzhyYvDFopEh",
12 provider: "FCM",
13 },
14 {
15 token: "utJXX2Tr9wN_tYOwYd8rFA6mYUMBFqdz9n6k3v5EpFAukXD89hGq",
16 provider: "APN",
17 },
18 ],
19 content: {
20 title: "Boarding time @ TLL",
21 body: "Dear customer, you have 1 hour until boarding time at the Tallinn airport",
22 },
23 from: {
24 fcm: "comms_credential_01h9krwprkeee8fzqspvwy6nq8",
25 apn: "comms_credential_8qn6ywvpsqzf8eeekrpwrk9h10",
26 },
27 priority: "HIGH",
28 sound: "ring",
29 });
30}
31main();
1{
2 "operationId": "comms_operation_01h9krwprkeee8fzqspvwy6nq8",
3 "operationLocation": "https://comms.twilio.com/v1/PushNotifications/Operations/comms_operation_01h9krwprkeee8fzqspvwy6nq8"
4}
This operation creates and sends out Push Notifications to the specified recipients.
Was this page helpful?
Previous

List Push Notifications

Next
Built with

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.
tolist of objectsRequired

A list of recipients to send the Push Notifications(s) to.

contentobjectRequired
The content of the Push Notification. *** * Use the [Liquid](https://shopify.github.io/liquid/) templating language for personalization in any text-based field. * When using a templated content, use the `variables` field on each recipient to specify the values to substitute. * For each variable you specify in your template, you should have a matching key in each recipient's `variables` object.
fromobjectOptional

The sender of the Push Notification(s). Leave unspecified to automatically use the default App.

priorityenumOptionalDefaults to HIGH
The priority of the Push Notification. A value of "low" reduces the client app battery consumption. A value of "high" sends the notification immediately and can wake up a sleeping device.
Allowed values:
soundstring or nullOptional
The name of the sound to be played for the Push Notification.
scheduleobjectOptional

A schedule defines when a communication will be sent to a recipient.

tagsmap from strings to stringsOptional
Custom metadata in the form of key-value pairs. Maximum size of a tag key is 128 characters. Maximum size of a tag value is 256 characters. There can be a maximum of 10 key-value pairs. This field can be templated with [Liquid](https://shopify.github.io/liquid/). Specify `variables` with each recipient for personalization.

Response headers

Locationstring

The location (uri) of the Operation resource. Issue a GET request to this URI to retrieve the status of the Operation.

Response

The request was accepted and an Operation was created to track its progress. The response body contains the ID and link to the Operation resource.
operationIdstringformat: "^comms_operation_[0-7][a-hjkmnpqrstv-z0-9]{25,34}"
The Operation ID is an identifier that can be used to correlate all of the resources created in a request. Issue a GET request to the resource list location, using the Operation ID as a query parameter to retrieve the resources that correlate with the Operation.
operationLocationstringformat: "uri"

The location (uri) of the Operation resource identified by operationId.

Errors

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

The content of the Push Notification.


  • Use the Liquid templating language for personalization in any text-based field.

  • When using a templated content, use the variables field on each recipient to specify the values to substitute.

  • For each variable you specify in your template, you should have a matching key in each recipient’s variables object.

Custom metadata in the form of key-value pairs. Maximum size of a tag key is 128 characters. Maximum size of a tag value is 256 characters. There can be a maximum of 10 key-value pairs.

This field can be templated with Liquid. Specify variables with each recipient for personalization.