Notifications

For more information, see the Notifications REST Resource documentation.

Listing Your Notifications

The following code will print out additional information about each of your current TwilioNotification resources.

String ACCOUNT_SID = 'AXXXXXXXXXXXXXXXXX';
String AUTH_TOKEN = 'YYYYYYYYYYYYYYYYYY';
TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

for (TwilioNotification n : client.getAccount().getNotifications().getPageData()) {
    System.debug(n.getMoreInfo());
}

You can filter transcriptions by Log and MessageDate. The Log value is 0 for ERROR and 1 for WARNING.

String ACCOUNT_SID = 'AXXXXXXXXXXXXXXXXX';
String AUTH_TOKEN = 'YYYYYYYYYYYYYYYYYY';
TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

String ERROR = '0';

Map<String,String> filters = new Map<String,String> {
            'Log' => ERROR;
}

for (TwilioNotification n : client.getAcount().getNotifications().getPageData()) {
    System.debug(n.getErrorCode());
}

Note

Due to the potentially voluminous amount of data in a notification, the full HTTP request and response data is only returned in the Notification instance resource representation.

Deleting Notifications

Your account can sometimes generate an inordinate amount of Notification resources. The TwilioNotificationList resource allows you to delete unnecessary notifications.

String ACCOUNT_SID = 'AXXXXXXXXXXXXXXXXX';
String AUTH_TOKEN = 'YYYYYYYYYYYYYYYYYY';
TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

client.getAccount().getNotifications().deleteResource("NO123")