Verify Push Webhooks
Verify Push is in Public Beta.
概要
Webhooks are a general pattern for how one system can be notified of events generated by another system in real-time. In the case of Verify Push, your app backend can be notified when a Factor
has been verified or when a Challenge
has been approved by the Verify Push service, so that it knows to advance the user to the next step in your flow. This is more real-time and efficient than constantly polling the Verify Push API for the status
of a Factor
or Challenge
.
To configure webhooks, follow these steps:
- Configure a webhook in your Verify Service via the Console UI
- Receive, parse, and verify a webhook
- Manage webhooks via Verify API (optional)
1. Configure a webhook in your Verify Service
前提条件
- Create a Verify Service.
- Create a REST API endpoint in your app backend that can receive HTTP POST requests.
Configure a webhook via Console UI
You can configure a webhook either via UI or API. We'll show the UI option first and then the API option later.
Go to Twilio Console > Verify > Service > Webhooks:
Click "Create Webhook Now" and complete the form:
- Enter a friendly name that will help you identify the webhook in the future.
- Select the events that you want to receive. See definitions in the Webhook Events table below.
- Enter the URL of your app backend's API endpoint.
- Click Create to finish creating your webhook.
Webhookイベント
イベント | 概要 |
* |
Fires when any of the following events occur. |
factor.created |
Fires when a factor is created for the entity but is not ready to receive challenges. |
factor.verified |
Fires when a factor is verified and now is able to receive challenges. |
factor.deleted |
Fires when a factor was deleted from an entity. |
challenge.approved |
Fires when a challenge is approved by the user. |
challenge.denied |
Fires when a challenge is denied by the user. |
2. Receive, parse, and verify a webhook
When Twilio makes an HTTP request to your app backend, it will include parameters related to the event that triggered it:
パラメーター | Type | 概要 |
uuid |
文字列 | Unique identifier for the webhook |
type |
文字列 | EventType |
account_sid |
String, SID | The Twilio Account SID that the Service instance belongs to |
service_sid |
String, SID | The Verify Service instance SID that the action relates to |
entity_identity |
文字列 | Unique identifier for the user |
factor_sid |
String, SID | The Verify Push Factor instance that the action relates to |
challenge_sid |
String, SID | The Verify Push Challenge instance that the action relates to |
Verify the webhook's signature to confirm that it came from Twilio
- Each HTTP request is issued with the
Content-Type
headerapplication/x-www-urlencoded
and signed with anX-Twilio-Signature
HTTP header. - Twilio uses the parameters sent in the webhook and the exact URL your application supplied to Twilio to create this signature. The signature uses the
HMAC-SHA1
hashing algorithm with your Twilio account's auth token as the secret key. - Your application can verify that this signature is correct using the server side Twilio SDKs. You will need your account's auth token, the value of the
X-Twilio-Signature
HTTP header that Twilio passed to you, the URL that Twilio sent the webhook to, and all of the parameters sent by Twilio. - For more information, check out our guide to Getting Started with Twilio Webhooks and Validating Requests are coming from Twilio. Find other webhook pages, such as a security guide and an FAQ in the Webhooks section of the docs.
3. Manage webhooks via Verify API (optional)
In addition to the Console UI, you can programmatically manage the Webhooks
resource according to this API reference:
Webhook properties
Resource Properties in REST API format | |
---|---|
sid
|
The unique string that we created to identify the Webhook resource. |
service_sid
|
The unique SID identifier of the Service. |
account_sid
|
The SID of the Account that created the Service resource. |
friendly_name
|
The string that you assigned to describe the webhook. This value should not contain PII. |
event_types
|
The array of events that this Webhook is subscribed to. Possible event types: |
status
|
The webhook status. Default value is |
webhook_url
|
The URL associated with this Webhook. |
webhook_method
|
The method to be used when calling the webhook's URL. |
date_created
|
The date and time in GMT when the resource was created specified in RFC 2822 format. |
date_updated
|
The date and time in GMT when the resource was last updated specified in RFC 2822 format. |
url
|
The absolute URL of the Webhook resource. |
Create a Webhook
https://verify.twilio.com/v2/Services/{ServiceSid}/Webhooks
パラメーター
Parameters in REST API format | |
---|---|
service_sid
Path
|
The unique SID identifier of the Service. |
friendly_name
必須
|
The string that you assigned to describe the webhook. This value should not contain PII. |
event_types
必須
|
The array of events that this Webhook is subscribed to. Possible event types: |
webhook_url
必須
|
The URL associated with this Webhook. |
status
オプション
|
The webhook status. Default value is |
例 1
Fetch a Webhook resource
https://verify.twilio.com/v2/Services/{ServiceSid}/Webhooks/{Sid}
パラメーター
Parameters in REST API format | |
---|---|
service_sid
Path
|
The unique SID identifier of the Service. |
sid
Path
|
The Twilio-provided string that uniquely identifies the Webhook resource to fetch. |
例 1
Read multiple Webhook resources
https://verify.twilio.com/v2/Services/{ServiceSid}/Webhooks
パラメーター
Parameters in REST API format | |
---|---|
service_sid
Path
|
The unique SID identifier of the Service. |
例 1
Update a Webhook resource
https://verify.twilio.com/v2/Services/{ServiceSid}/Webhooks/{Sid}
パラメーター
Parameters in REST API format | |
---|---|
service_sid
Path
|
The unique SID identifier of the Service. |
sid
Path
|
The Twilio-provided string that uniquely identifies the Webhook resource to update. |
friendly_name
オプション
|
The string that you assigned to describe the webhook. This value should not contain PII. |
event_types
オプション
|
The array of events that this Webhook is subscribed to. Possible event types: |
webhook_url
オプション
|
The URL associated with this Webhook. |
status
オプション
|
The webhook status. Default value is |
例 1
Delete a Webhook resource
https://verify.twilio.com/v2/Services/{ServiceSid}/Webhooks/{Sid}
パラメーター
Parameters in REST API format | |
---|---|
service_sid
Path
|
The unique SID identifier of the Service. |
sid
Path
|
The Twilio-provided string that uniquely identifies the Webhook resource to delete. |
例 1
ヘルプが必要ですか?
誰しもが一度は考える「コーディングって難しい」。そんな時は、お問い合わせフォームから質問してください。 または、Stack Overflow でTwilioタグのついた情報から欲しいものを探してみましょう。