Create Contact Group
POST
/api/v2/contact-groups/create Base URL https://api.easify.liveBearer token and Accept header required Authentication →
This endpoint is used to create a new contact group.
The user can create a new contact group with a name of their choice.
There is a rate limit of 15 requests per minute per API token. This count is shared by all API endpoints, including GET requests, except those with their own separate limit (/api/v2/sms/send, /api/v3/sms/send, etc.), so this endpoint is refused once your token has made 15 requests to the shared endpoints within a 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.
Request Body
| name string | Specify the name for the contact group | required |
Example Request and Response
Request
{
"name": "My Contact Group"
}
Success Response:
{
"status": true,
"message": "Contact Group created successfully",
"data": {
"id": 1,
"name": "My Contact Group",
"contacts_count": 0,
"shared_group": false,
"default_group": false,
"created_at": "12-02-2024 03:13:35 AM"
}
}
- The contacts_count in the response refers to the total number of contacts in the specific contact group.
- The shared_group is a Boolean field that specifies whether the contact group is the main user's shared contact group or not.
- The default_group is a Boolean field that indicates whether the contact group is the user's default contact group in the Easify app
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 the user provides the name of an existing contact group | 422 |
{
"message": "The name has already been taken.",
"errors": {
"name": ["The name has already been taken."]
}
}
|
| 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": []
}
|
Code Examples
Create a contact group
php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.easify.live/api/v2/contact-groups/create',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode([
'name' => 'My Contact Group',
]),
CURLOPT_HTTPHEADER => [
'Authorization: Bearer <> ',
'Content-Type: application/json',
'Accept: application/json',
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;