Porting webhooks
Public Beta
The Porting API and webhooks are in Public Beta. The information in this document could change. We might add or update features before the product becomes Generally Available. Beta products don't have a Service Level Agreement (SLA). Learn more about beta product support.
Porting webhooks send notifications about events associated with port-in requests and port-in phone numbers. The parent account receives all webhooks for any port-in requests created on the parent account or any subaccounts.
The complete webhook url that will be called when a notification event for port in request or port in phone number happens
The complete webhook url that will be called when a notification event for a port out phone number happens.
A list to filter what notification events to receive for this account and its sub accounts. If it is an empty list, then it means that there are no filters for the notifications events to send in each webhook and all events will get sent.
Creation date for the port in webhook configuration
Creation date for the port out webhook configuration
Use the following webhooks associated with port-in request or port-in phone number events.
Resource | Event | Description |
---|---|---|
PortIn request | PortInWaitingForSignature | A Letter of Authorization (LOA) has been generated for the port-in request and is waiting to be signed. |
PortInInProgress | The port-in request has been submitted to the losing carrier and is progressing normally. | |
PortInCompleted | All phone numbers in the port-in request have been canceled or successfully ported to Twilio. | |
PortInActionRequired | Something happened with the port-in request that requires an action. For example: a phone number has been rejected by the losing carrier. | |
PortInCanceled | All phone numbers in the port-in request have been canceled or the port-in request itself. | |
PortIn PhoneNumber | PortInPhoneNumberWaitingForSignature | A Letter of Authorization (LOA) has been generated for the port-in request and this number is part of it and is waiting to be signed. |
PortInPhoneNumberSubmitted | The phone number has been submitted to the losing carrier for port approval. | |
PortInPhoneNumberPending | The phone number port has been accepted by the losing carrier. | |
PortInPhoneNumberCompleted | The phone number in the port-in request has been successfully ported to Twilio. | |
PortInPhoneNumberRejected | The phone number has been rejected by the losing carrier. | |
PortInPhoneNumberCanceled | The phone number was canceled during the port-in process. |
Configure a webhook to receive the notifications of a port-in request or updates to an existing request. Requests overwrite any existing configurations.
Info
The Webhook configuration is tied to the account used to create the port-in request or its parent account.
1$ curl -X POST 'https://numbers.twilio.com/v1/Porting/Configuration/Webhook' \2--header 'Content-Type: application/json' \3--data '{4"port_in_target_url": "https://www.example.com/port-in",5"port_out_target_url": "https://www.example.com/port-out",6"notifications_of": [7"PortInWaitingForSignature",8"PortInInProgress",9"PortInCompleted",10"PortInActionRequired",11"PortInCanceled",12"PortInPhoneNumberWaitingForSignature",13"PortInPhoneNumberSubmitted",14"PortInPhoneNumberPending",15"PortInPhoneNumberCompleted",16"PortInPhoneNumberRejected",17"PortInPhoneNumberCanceled",18"PortOutPhoneNumberCompleted"19]20}' \21-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
Output
1{2"port_in_target_url": "https://www.webhook1.com/",3"port_out_target_url": "https://www.webhook2.com/",4"notifications_of": [5"PortInWaitingForSignature",6"PortInInProgress",7"PortInCompleted",8"PortInActionRequired",9"PortInCanceled",10"PortInPhoneNumberWaitingForSignature",11"PortInPhoneNumberSubmitted",12"PortInPhoneNumberPending",13"PortInPhoneNumberCompleted",14"PortInPhoneNumberRejected",15"PortInPhoneNumberCanceled",16"PortOutPhoneNumberCompleted"17],18"url": "https://numbers.twilio.com/v1/Porting/Configuration/Webhook"19}
GET https://numbers.twilio.com/v1/Porting/Configuration/Webhook
Retrieve the current webhook configuration.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function fetchPortingWebhookConfigurationFetch() {11const portingWebhookConfigurationFetch =12await client.numbers.v1.portingWebhookConfigurationFetch.fetch();1314console.log(portingWebhookConfigurationFetch.url);15}1617fetchPortingWebhookConfigurationFetch();
Response
1{2"port_in_target_url": "https://www.example.com/port-in",3"port_out_target_url": "https://www.example.com/port-out",4"notifications_of": [5"PortInWaitingForSignature",6"PortInInProgress",7"PortInCompleted",8"PortInActionRequired",9"PortInCanceled",10"PortInExpired",11"PortInPhoneNumberWaitingForSignature",12"PortInPhoneNumberSubmitted",13"PortInPhoneNumberPending",14"PortInPhoneNumberCompleted",15"PortInPhoneNumberRejected",16"PortOutPhoneNumberCompleted"17],18"port_in_target_date_created": "2024-05-14T13:49:04Z",19"port_out_target_date_created": "2024-05-14T13:49:07Z",20"url": "https://numbers.twilio.com/v1/Porting/Configuration/Webhook"21}
Delete a specific webhook configuration. It could take a few minutes for this action to take effect since the configuration may be cached.
HTTP Method: DELETE
Path: https://numbers.twilio.com/v1/Porting/Configuration/Webhook/{webhook_type}
Parameter | Description |
---|---|
webhook_type | Can be PORT_IN |
1curl -X DELETE 'https://numbers.twilio.com/v1/Porting/Configuration/Webhook/{webhook_type}' \2-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
HTTP status code: 204 No content
Use the following webhooks associated with port-in request or port-in phone number events.
Warning
When you create a webhook you must use a public URL that can be reached by Twilio.
The port in webhook sends the following request body in a POST
HTTP request and expects to receive an HTTP 200
OK response.
1{2"port_in_request_sid": "port_in_request_sid",3"port_in_phone_number_sid": "port_in_phone_number_sid",4"last_date_updated": "2024‑01‑25 00:00:00.000",5"phone_number": "+1800XXXXXXX",6"status": "waiting_for_signature",7"portable": "true",8"not_portable_reason_code": null,9"not_portable_reason": null,10"rejection_reason": null,11"rejection_reason_code": null12}
Field | Description |
---|---|
port_in_request_sid | The SID of the port-in request |
port_in_phone_number_sid | The SID of the port-in phone number if the event is for a phone number otherwise it should be null. |
last_date_updated | The date for the last time that the status of the port-in request or port-in phone number was updated. |
phone_number | The phone number in e164 format if this is an event for a phone number. Otherwise, this is null. |
status | The current status of the port-in request or port-in phone number. |
portable | If the event is for a phone number, this field is a Boolean describing whether the number is portable or not. |
not_portable_reason_code | If the number is not portable, it shows the not portable reason code. |
not_portable_reason | If the number is not portable, it shows the not portable reason. |
rejection_reason | If the number was rejected by the vendor, it shows the rejection reason. |
rejection_reason_code | If the number was rejected by the vendor, it shows the rejection reason code. |
Twilio retries each webhook request up to 10 times. The backoff interval doubles after each retry. Retries begin 5 minutes after the first attempt and stop after 21 hours.
Twilio uses webhooks to notify your application about events occurring in your Twilio products, sending these updates to the URL you configured. To safeguard the communication between Twilio and your web application, Twilio supports encryption and cryptographically signs its requests. These signatures ensure the authenticity of requests from Twilio. You can verify a request's legitimacy by following the guidelines in the Twilio Security documentation.