メニュー

Expand
ページを評価:

Notify delivery callbacks

What is a Notify delivery callback?

A Notify delivery callback is a URL that sends webhooks which provides you with information about how many messages were sent and if those messages were sent correctly by the Notify API. Let’s keep in mind that Notify is a bulk-first messaging API, where one API call can trigger from zero to multiple thousands messages.

Note: Each Callback will contain the status for up to 1000 SMS and/or pushes.

What information is reported in delivery callbacks?

Every callback contains a list of the deliveries-messages which were sent as part of the notification.

The status of one notification can be delivered in one or multiple delivery callbacks, depending on the size of the notification. The final callback from the Notify API will always have a flag IsFinal set to True to indicate that notification is handled completely.

Every delivery in the list has one of the following status:

  • SENT: Notify successfully passed the message to the channel (i.e. Twilio SMS, FCM, APN)
  • FAILED: The channel (Twilio SMS, FCM, APM) returned an error.

Notify callbacks do not update the state of the message once it has been passed to the channel. It means there will be no further updates when a recipient has received a message.

Data format

Notify delivery callback provides the following payload information.

パラメーター Type 概要

NotificationSid

文字列

A 34 character string that uniquely identifies the Notification that triggered the Delivery attempt

AccountSid

文字列

The unique ID of the Account that sent this notification

Service SID

文字列

The unique ID of the Service that sent this notification

Count

integer

Number of Deliveries in this report

SequenceId

integer

Sequence number of the batch starting from 0

IsFinal

boolean

Flag to indicate it is the final batch for the bulk notification

DeliveryState

JSON

The status of this Delivery attempt

Data format for DeliveryState

The DeliveryState indicates the status of a delivery attempt. The number of performed delivery attempts should be equal to the number of DeliveryState parameters shown in the payload.

パラメーター

Type

概要

sid

文字列

Provider unique message id (for APN/FCM) or message sid (SMxxx for SMS, MMxxx for MMS, RUxxx for rest of adapters)

タイプ

文字列

Channel type (e.g., APN, FCM, SMS, etc...)

status

文字列

SENT or FAILED

identity

文字列

Identity

error_code

整数(オプション)

Twilio error code, if error happened. For more information, go to Twilio error codes

Payload example

Content-Type: application/x-www-form-urlencoded

&SequenceId=0
&NotificationSid={NotificationSid}
&IsFinal=False
&Count=2
&DeliveryState[0]="{ \"sid\": \"message sid\", \"channel\": \"APN\", \"status\": \"SENT\" }"
&DeliveryState[1]="{ \"sid\": \"message sid\", 
     \"channel\": \"APN\", 
     \"status\": \"FAILED\",
     \"error_code\": 52131,
     \"error_message\": \"The provided APNs device token has been unregistered\" }"

How to subscribe to the status callback?

The Notification's resource accepts an optional "DeliveryCallbackUrl" field that should contain a URL which will be called to provide the Notification status, as shown in the following example:

curl -X POST 'https://notify.twilio.com/v1/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Notifications' \
   --data-urlencode 'Identity=00000001' \
   --data-urlencode 'Body=Hello Bob' \
   --data-urlencode 'DeliveryCallbackUrl=https://myhost/notifyCallbacks'
   -u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN

ページを評価:

ヘルプが必要ですか?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Community Forums or browsing the Twilio tag on Stack Overflow.

        
        
        

        フィードバックくださりありがとうございます!

        We are always striving to improve our documentation quality, and your feedback is valuable to us. Please select the reason(s) for your feedback or provide additional information about how we can improve:

        Sending your feedback...
        🎉 Thank you for your feedback!
        Something went wrong. Please try again.

        Thanks for your feedback!

        Refer us and get $10 in 3 simple steps!

        ステップ1

        Get link

        Get a free personal referral link here

        ステップ2:

        Give $10

        Your user signs up and upgrade using link

        ステップ3

        Get $10

        1,250 free SMSes
        OR 1,000 free voice mins
        OR 12,000 chats
        OR more