Update Phone Number Webhook
/api/v2/phone-numbers/update Base URL https://api.easify.liveBearer token and Accept header required Authentication →
This endpoint is used to update the incoming webhook URL for a phone number.
The user can update the webhook URL for incoming SMS. If any incoming SMS is received on their number, the SMS data will be posted to the webhook URL.
The response includes the number's webhook_secret, which you use to verify that a webhook came from Easify. It is created the first time a webhook URL is set and stays the same when the URL changes. See Webhooks for the payload and the verification steps.
There is a rate limit of 60 requests per minute per API token. This limit is shared by all API endpoints except those with their own separate limit (/api/v2/sms/send, /api/v3/sms/send, etc.), so requests to other endpoints also count toward it. If you exceed this limit, you will receive a 429 Too Many Requests status, along with a message indicating when you can try again.
Query Parameters
| phone_number_id integer | The phone number's unique ID (will be provided in the phone-numbers API response) | Required |
| webhook_url string | The endpoint used to receive incoming messages for a specific phone number. | Required |
Example Request and Response
Request:
{
"phone_number_id": 1,
"webhook_url": "<> "
}
Success Response:
{
"status": true,
"message": "Webhook URL updated successfully",
"data": {
"id": 228,
"number": "+1864400****",
"approved": "Approved",
"gateway": "Easify SMS Gateway",
"name": "Easify SMS Call Gateway",
"status": "Active",
"webhook_url": "https://***********",
"webhook_secret": "9b1f2c7e4a6d4f0e8c3a7d5b1e2f****",
"created_at": "10-08-2024 07:46:20 AM"
}
}
Responses
| Case | Status Code | Response |
|---|---|---|
| If the user does not provide a token in the header or provides an invalid token | 401 |
{
"status":false,
"message":"Unauthenticated",
"errors":[]
}
|
| If user not provided phone_number_id | 422 |
{
"message": "The phone number id field is required.",
"errors": {
"phone_number_id": ["The phone number field is required."]
}
}
|
| If user provided invalid phone_number_id | 400 |
{
"status":false,"message":"Invalid phone number id","errors": []
}
|
| If user not provided webhook_url | 422 |
{
message":"The webhook url field is required.",
"errors": {
"webhook_url”: ["The webhook url field is required."]
}
}
|
| If the user exceeds the allowed rate limit for requests | 429 |
{
"status":false,
"message":"Too many requests. Try again in 59 seconds",
"errors":[]
}
|
| If the user's subscription has ended | 402 |
{
"status":false,"message":"You need to recharge your account to proceed","errors":[]
}
|
| When the user account is inactive | 403 |
{
"status": false,
"message": "Your account is currently inactive.",
"errors": []
}
|
| If the request comes from an IP address or domain that is not on the account's API whitelist | 400 |
{
"status": false,
"message": "Access denied! Your IP or domain is not whitelisted.[ HostName : ] - [ Ip Address : << YOUR_SERVER_IP >>]",
"errors": []
}
|
Code Examples
php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.easify.live/api/v2/phone-numbers/update?phone_number_id=1&webhook_url=https://example.com/easify-webhook',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer <> ',
'Accept: application/json',
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;