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

Operations 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.

An Operation resource represents a push notification request that targets one or more recipients. When you send a notification, the API validates the input and returns an HTTP 202 Accepted response with an operationId in the response body. Use the operationId to monitor the status and delivery progress of the request.

As the Operation is processed, it generates a PushNotification with an associated pushNotificationId for each recipient. Each PushNotification then creates at least one delivery attempt for each provider (FCM or APNs) that is tried.

(information)

Info

Records are available for 7 days after creation. Requests for data older than 7 days may return incomplete results.


Operation Properties

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

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.

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

statusenum<string>
required

The status of an Operation.

Possible values:
SCHEDULEDPROCESSINGCOMPLETEDCANCELED

statsPushNotificationOperationStats
required

Represents the stats of a sending operation of one or many Push Notifications.

  • total is the total number of Push Notifications in the Operation.

    • To get the status for each Push Notification, fetch the resource with: GET /PushNotifications/{pushNotificationId}.
  • recipients is the total number of recipients targeted in an Operation.

  • unaddressable is the number of recipients to which no sending attempts were made because a valid token could not be found in the recipient's Device Registration set for the Credentials or App provided.

  • scheduled is the number of Push Notifications that are scheduled to be sent by Twilio in the future.

  • queued is the number of Push Notifications that are queued in Twilio for sending.

  • sent is the number of Push Notifications that have been sent by Twilio.

  • failed is the number of Push Notifications that failed during processing by Twilio. Get Errors with GET /PushNotifications/Operations/{operationId}/Errors fore more detail.

  • canceled is the number of Push Notifications that were canceled via API request.

Example: {"total":1,"recipients":1,"queued":0,"sent":0,"scheduled":0,"unaddressable":0,"failed":0,"canceled":0}

createdAtstring<date-time>
required

updatedAtstring<date-time>
required

StatusDescription
SCHEDULEDThe operation is scheduled for future processing.
PROCESSINGThe operation is currently being processed.
COMPLETEDAll notifications in the operation have been processed.
CANCELEDThe operation was canceled.

The stats object in the response provides aggregated delivery metrics:

FieldDescription
totalTotal push notifications in the operation.
recipientsTotal targeted recipients.
unaddressableRecipients with no valid device token found.
scheduledNotifications scheduled for future sending.
queuedNotifications queued for sending.
sentNotifications sent to the provider.
failedNotifications that failed during processing.
canceledNotifications canceled via the API.

GET https://comms.twilio.com/v1/PushNotifications/Operations/{operationId}

Retrieve the status and delivery statistics of a push notification operation by making an HTTP GET request to the Operation resource URI with the Operation ID.

Path parameters

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

OK

Schema
Property nameTypeRequiredDescriptionChild properties
idstring

Optional

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.

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

statusenum<string>

Optional

The status of an Operation.

Possible values:
SCHEDULEDPROCESSINGCOMPLETEDCANCELED

statsPushNotificationOperationStats

Optional

Represents the stats of a sending operation of one or many Push Notifications.

  • total is the total number of Push Notifications in the Operation.

    • To get the status for each Push Notification, fetch the resource with: GET /PushNotifications/{pushNotificationId}.
  • recipients is the total number of recipients targeted in an Operation.

  • unaddressable is the number of recipients to which no sending attempts were made because a valid token could not be found in the recipient's Device Registration set for the Credentials or App provided.

  • scheduled is the number of Push Notifications that are scheduled to be sent by Twilio in the future.

  • queued is the number of Push Notifications that are queued in Twilio for sending.

  • sent is the number of Push Notifications that have been sent by Twilio.

  • failed is the number of Push Notifications that failed during processing by Twilio. Get Errors with GET /PushNotifications/Operations/{operationId}/Errors fore more detail.

  • canceled is the number of Push Notifications that were canceled via API request.

Example: {"total":1,"recipients":1,"queued":0,"sent":0,"scheduled":0,"unaddressable":0,"failed":0,"canceled":0}

createdAtstring<date-time>

Optional


updatedAtstring<date-time>

Optional

Fetch a PushNotification OperationLink to code sample: Fetch a PushNotification Operation
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.fetchOperation("comms_operation_01h9krwprkeee8fzqspvwy6nq8");
9
}
10
main();

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

Returns a list of Operations. You can filter by date range or status.

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

startDatestring<date-time>

Optional

Filter to Operations created after the specified date and time.


endDatestring<date-time>

Optional

Filter to Operations created before the specified date and time.


statusenum<string>

Optional

Filter to Operations with the specified status.

Possible values:
SCHEDULEDPROCESSINGCOMPLETEDCANCELED
200400429500503

OK

Schema
Property nameTypeRequiredDescriptionChild properties
operationsarray[PushNotificationOperation]

Optional

A list of Push Notification Operations.


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.listOperations({
9
pageToken: "pageToken",
10
pageSize: 50,
11
startDate: new Date("2024-01-15T09:30:00Z"),
12
endDate: new Date("2024-01-15T09:30:00Z"),
13
status: "SCHEDULED",
14
});
15
}
16
main();