GET / sms/chat-history
Base URL: https://backend.easify.app/api/v2
This endpoint is used to retrieve SMS/Chat History.
The user can fetch the SMS status using the sms_id, which is provided in the Send SMS API response.
There is a rate limit of 60 requests per minute. If you exceed this limit, you will receive a 429 Too Many Requests status, along with a message indicating when you can try again.
Authentication
The Easify API token used for authentication is passed in the header as a Bearer token, which can be obtained from the easify app under Settings > API Settings.
Headers
Authorization string required Bearer << YOUR_EASIFY_API_TOKEN_HERE >>
Query Parameters
sender string | Sender Number(The user's sender number associated with theAPI token and the sender number without the country code) | Required |
receiver string | Receiver Number(To fetch the SMS, use the receiver's number without the country code. For the country code,use the 'country_code' field and enter the appropriate country code.) | Required |
country_code string | Receiver's Country Code (e.g., +1, +972) | Required |
limit integer | Pagination Limit(If the limit is not provided, the default will be 10) | Optional |
Sample Params and Success Response:
Params:
{
"sender": "315293****",
"receiver": "315135****",
"country_code": "+1",
"limit": 1
}
Success Response:
{
"status": true,
"message": "Chat History",
"data": [
{
"id": 516,
"sender": "+1315293****",
"receiver": "+1315135*****",
"message": "hai",
"sms_type": "sms",
"send_by": "sender",
"media_url": "",
"status": "Delivered",
"created_at": "02-05-2024 04:59:21 AM",
"reason": null
}
]
}
Api Response Status
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 sender field | 422 |
{
"message":"The sender field is required.",
"errors": {
"sender": ["The sender field is required."]
}
}
|
If user not provided receiver field | 422 |
{
"message":"The receiver field is required.",
"errors": {
"receiver": ["The receiver field is required."]
}
}
|
If the user provided invalid country code | 422 |
{"message":"Currently, this service is only available in the following countries: Canada, United States, Israel, United Kingdom. Please verify the country code.","errors":{"country_code":["Currently, this service is only available in the following countries: Canada, United States, Israel, United Kingdom. Please verify the country code."]}}
|
If user not provided country_code field | 422 |
{
"message":"The Country code field is
required.",
"errors": {
"country_code": ["The Country code 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":[]
}
|
If the user does not have an enterprise plan | 403 |
{
"status": false,
"message": "Access denied. Your current plan does not allow access to this feature. Please upgrade to the Enterprise plan.",
"errors": []
}
|
For records where the sms_type is voice, the media_url provides a link to the call recording associated with the voice interaction. Conversely, when the sms_type is mms, the media_url contains the multimedia content sent as part of the MMS. The URL serves as a direct link to access the media resource
Outgoing SMS: Messages marked with "send_by": "sender" indicate outgoing messages.These are messages initiated by the sender and directed to the receiver.
Incoming SMS: Conversely, messages with "send_by": "receiver" denote incoming messages. These messages are initiated by the receiver and directed to the sender. By analyzing the send_by field, developers can programmatically determine the direction of the message flow.
PHP-cURL
php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://backend.easify.app/api/v2/sms/chat-history?country_code=+972&sender=31544400**&receiver=555074***',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => [
'Accept: application/json',
'Authorization: Bearer 1955|43da5bb5-5c2b-4059-a4de-d44bf5*****'
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;