NAV
PHP cURL

Introduction

This is KWIGA API documentation page. You have the ability to perform certain actions on your behalf in certain cabinets using your API.

In order to enable the API you should click on the corresponding checkbox in the settings section of your account. After that a token will be generated and account hash will be created, that will be used for subsequent API calls.

If a token is compromised, it can be re-issued, that will make the old token inactive and generate a new one.

API is only available for those users who have API enabled in their account.

API has a limit on hits per second. Currently 1 hit per second is available.

Basic work with API

<?php

$headers = [
    'Accept: application/json',
    'Token: <Token>',
    'Cabinet-Hash: <Cabinet-Hash>',
];

$id = 1;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.kwiga.com/contacts/' . $id);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response);
?>
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -H 'Token: <Token>' -H 'Cabinet-Hash: <Cabinet-Hash>' -X GET https://api.kwiga.com/contacts/1

All requests must be directed to the domain:

https://api.kwiga.com

For authorization the API token should be send in the headers as a token:

Token: {token}

To identify the account in which the actions take place, the hash of the account must be sent along in the headers:

Cabinet-Hash: {cabinet_hash}

Errors

Error Code Meaning
400 Bad Request - Your request is invalid.
401 Unauthorized - Your API key is wrong.
403 Forbidden - The requested resource is hidden for administrators only.
404 Not Found - Server cannot find the requested resource.
405 Method Not Allowed -- Server knows the request method, but the target resource doesn't support this method.
406 Not Acceptable - You requested a format that isn't json.
410 Gone - The requested resource has been removed from our servers.
422 Unprocessable entity.
429 Too Many Requests - You're sending too many requests! Slow down!
500 Internal Server Error - We had a problem with our server. Try again later.
503 Service Unavailable - We're temporarily offline for maintenance. Please try again later.

CRM. Contacts

List of contacts

Request example:

<?php
// Request without parameters

$headers = [
    'Accept: application/json',
    'Token: <Token>',
    'Cabinet-Hash: <Cabinet-Hash>',
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.kwiga.com/contacts');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response);
?>
<?php
// Request with pagination

$headers = [
    'Accept: application/json',
    'Token: <Token>',
    'Cabinet-Hash: <Cabinet-Hash>',
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.kwiga.com/contacts?page=1&per_page=500');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response);
?>
<?php
// Request with pagination and filtering

$headers = [
    'Accept: application/json',
    'Token: <Token>',
    'Cabinet-Hash: <Cabinet-Hash>',
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.kwiga.com/contacts?page=1&per_page=500&filters[date_from]=2022-04-27&filters[search]=Ivanov');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response);
?>
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -H 'Token: <Token>' -H 'Cabinet-Hash: <Cabinet-Hash>' -X GET https://api.kwiga.com/contacts
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -H 'Token: <Token>' -H 'Cabinet-Hash: <Cabinet-Hash>' -X GET https://api.kwiga.com/contacts?page=1&per_page=500
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -H 'Token: <Token>' -H 'Cabinet-Hash: <Cabinet-Hash>' -X GET https://api.kwiga.com/contacts?page=1&per_page=500&filters[date_from]=2022-04-27&filters[search]=Ivanov

Example of response:

{
  "data": [
    {
      "id": 1,
      "created_at": "2022-02-04T12:17:32.000000Z",
      "email": "test@example.com",
      "first_name": "James",
      "last_name": "Bond",
      "phone": "+380931234567"
    },
    {
      "id": 2,
      "created_at": "2022-02-04T12:17:32.000000Z",
      "email": "test2@example.com",
      "first_name": "Petr",
      "last_name": "Ivanov",
      "phone": "+380983234512"
    }
  ],
  "links": {
        "first": "https://api.kwiga.com/contacts?page=1",
        "last": "https://api.kwiga.com/contacts?page=2",
        "prev": null,
        "next": "https://api.kwiga.com/contacts?page=2"
   },
   "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 2,
        "links": [
            {
                "url": null,
                "label": "&laquo; Prev",
                "active": false
            },
            {
                "url": "https://api.kwiga.com/contacts?page=1",
                "label": "1",
                "active": true
            },
            {
                "url": "https://api.kwiga.com/contacts?page=2",
                "label": "2",
                "active": false
            },
            {
                "url": "https://api.kwiga.com/contacts?page=2",
                "label": "Next &raquo;",
                "active": false
            }
        ],
        "path": "https://api.kwiga.com/contacts",
        "per_page": 2,
        "to": 2,
        "total": 3
    }
}

HTTP Request

GET https://api.kwiga.com/contacts

URL Parameters

Parameter Description
page
(integer)
Page Number
per_page
(integer)
Number of fetch items
filters[is_active]
(integer)
Filter by Active Contacts
filters[date_from]
(2022-04-27)
Filter by creation date. Parameter 'from'
filters[date_to]
(2022-04-29)
Filter by creation date. 'To' parameter
filters[search]
(string)
Filter by email, phone, name

Get contact

Request example:

<?php

$headers = [
    'Accept: application/json',
    'Token: <Token>',
    'Cabinet-Hash: <Cabinet-Hash>',
];

$id = 1;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.kwiga.com/contacts/' . $id);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response);
?>
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -H 'Token: <Token>' -H 'Cabinet-Hash: <Cabinet-Hash>' -X GET https://api.kwiga.com/contacts/1

Example of response:

{
  "data": [
    {
      "id": 1,
      "created_at": "2022-02-04T12:17:32.000000Z",
      "email": "test@example.com",
      "first_name": "James",
      "last_name": "Bond",
      "phone": "+380931234567",
      "tags": [
        {
         "id": 2,
         "name": "tag1",
         "created_at": "2022-02-14T08:58:38.000000Z"
        }
      ]
    }
  ]
}

HTTP Request

GET https://api.kwiga.com/contacts/{id}

Create contact

Request example:


$headers = [
    'Accept: application/json',
    'Content-Type: application/x-www-form-urlencoded',
    'Token: <Token>',
    'Cabinet-Hash: <Cabinet-Hash>',
];

$data = [
    'first_name' => 'James',
    'last_name' => 'Bond',
    'email' => 'test@example.com',
    'phone' => '+380931234567',
    'tags' => ['tag1'],
    'send_activation_email' => true,
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.kwiga.com/contacts/');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$result = json_decode($response);
curl -X POST -H 'Accept: application/json' -H 'Token: <Token>' -H 'Cabinet-Hash: <Cabinet-Hash>' -H 'Content-Type: application/json' -d '{"first_name" : "James", "last_name" : "Bond", "email" : "test@example.com", "send_activation_email" : true, "phone":"+380931234567"}' https://api.kwiga.com/contacts

Example of response:

{
  "data": [
    {
      "id": 4,
      "created_at": "2022-02-04T12:17:32.000000Z",
      "email": "test@example.com",
      "first_name": "James",
      "last_name": "Bond",
      "phone": "+380931234567",
      "tags": [
        {
         "id": 2,
         "name": "tag1",
         "created_at": "2022-02-14T08:58:38.000000Z"
        }
      ]
    }
  ]
}

HTTP Request

POST https://api.kwiga.com/contacts

Request (application/x-www-form-urlencoded)

Parameter Description
email
(string)
(required)
Email - should be unique value within an account
phone
(string)
Phone number - format: +{country code}{phone}
Example: +380930123456
first_name
(string)
Name
last_name
(string)
Last name
tags
(string[])
Tags
send_activation_email
(boolean)
Send a welcome email
locale
(string)
Contact’s language in iso_2 format
Options include: ru (by default), uk, en

Добавить покупку

This method creates or finds contact, as well as adds purchase of the specified offer

Request example:


$headers = [
    'Accept: application/json',
    'Content-Type: application/x-www-form-urlencoded',
    'Token: <Token>',
    'Cabinet-Hash: <Cabinet-Hash>',
];

$data = [
    'first_name' => 'James',
    'last_name' => 'Bond',
    'email' => 'test@example.com',
    'phone' => '+380931234567',
    'send_activation_email' => true,
    'locale' => 'uk',
    'offer' => 'er1DXGGlkwFo',
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.kwiga.com/contacts/purchases');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$result = json_decode($response);
curl -X POST -H 'Accept: application/json' -H 'Token: <Token>' -H 'Cabinet-Hash: <Cabinet-Hash>' -H 'Content-Type: application/json' -d '{"first_name" : "James", "last_name" : "Bond", "email" : "test@example.com", "send_activation_email" : true, "phone":"+380931234567", "locale": "uk", "offer":"er1DXGGlkwFo"}' https://api.kwiga.com/contacts/purchases

Example of response:

{
  "data": [
    {
      "id": 4,
      "created_at": "2022-02-04T12:17:32.000000Z",
      "email": "test@example.com",
      "first_name": "James",
      "last_name": "Bond",
      "phone": "+380931234567",
    }
  ]
}

HTTP Request

POST https://api.kwiga.com/contacts/purchases

Request (application/x-www-form-urlencoded)

Parameter Description
email
(string)
(required)
Email - should be unique value within an account
phone
(string)
Phone number - format: +{country code}{phone}
Example: +380930123456
first_name
(string)
Name
last_name
(string)
Last name
tags
(string[])
Tags
send_activation_email
(boolean)
Send a welcome email
locale
(string)
Contact’s language in iso_2 format
Options include: ru (by default), uk, en
offer
(string)
Identifier of the offer (can be obtained in the end of the offer link).
Example: er1DXGGlkwFo

Marketing. Mailing

Contact Group List

Request example:

<?php
// Request without parameters

$ch = curl_init();
$headers = [
    'Accept: application/json',
    'Token: <Token>',
    'Cabinet-Hash: <Cabinet-Hash>',
];

curl_setopt($ch, CURLOPT_URL, 'https://api.kwiga.com/mailing/contact-lists');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response);
?>
<?php
// Request with pagination

$headers = [
    'Accept: application/json',
    'Token: <Token>',
    'Cabinet-Hash: <Cabinet-Hash>',
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.kwiga.com/mailing/contact-lists?page=1&limit=50');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response);
?>
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -H 'Token: <Token>' -H 'Cabinet-Hash: <Cabinet-Hash>' -X GET https://api.kwiga.com/mailing/contact-lists
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -H 'Token: <Token>' -H 'Cabinet-Hash: <Cabinet-Hash>' -X GET https://api.kwiga.com/mailing/contact-lists?page=1&limit=50

Example of response:

{
  "data": [
    {
        "id": 2,
        "title": "Пример 2",
        "description": "Описание",
        "is_default": false,
        "created_at": "2022-04-28T13:22:44.000000Z",
        "updated_at": "2022-04-28T13:22:44.000000Z"
    },
    {
        "id": 1,
        "title": "Мой первый список",
        "description": "Данный список создаётся автоматически с вашим контактом внутри. Вы можете его отредактировать под свои потребности.",
        "is_default": true,
        "created_at": "2022-04-28T12:47:08.000000Z",
        "updated_at": "2022-04-28T12:47:08.000000Z"
    }
  ],
  "links": {
        "first": "https://api.kwiga.com/mailing/contact-lists?page=1",
        "last": "https://api.kwiga.com/mailing/contact-lists?page=2",
        "prev": null,
        "next": "https://api.kwiga.com/mailing/contact-lists?page=2"
   },
   "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 2,
        "links": [
            {
                "url": null,
                "label": "&laquo; Prev",
                "active": false
            },
            {
                "url": "https://api.kwiga.com/mailing/contact-lists?page=1",
                "label": "1",
                "active": true
            },
            {
                "url": "https://api.kwiga.com/mailing/contact-lists?page=2",
                "label": "2",
                "active": false
            },
            {
                "url": "https://api.kwiga.com/mailing/contact-lists?page=2",
                "label": "Next &raquo;",
                "active": false
            }
        ],
        "path": "https://api.kwiga.com/mailing/contact-lists",
        "per_page": 2,
        "to": 2,
        "total": 3
    }
}

HTTP Request

GET https://api.kwiga.com/mailing/contact-lists

URL Parameters

Parameter Description
page
(integer)
Page Number
limit
(integer)
Number of fetch items

Getting a group of contacts

Request example:

<?php

$headers = [
    'Accept: application/json',
    'Token: <Token>',
    'Cabinet-Hash: <Cabinet-Hash>',
];

$id = 1;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.kwiga.com/mailing/contact-lists/' . $id);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response);
?>
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -H 'Token: <Token>' -H 'Cabinet-Hash: <Cabinet-Hash>' -X GET https://api.kwiga.com/mailing/contact-lists/1

Example of response:

{
  "data": {
    "id": 1,
    "title": "Мой первый список",
    "description": "Данный список создаётся автоматически с вашим контактом внутри. Вы можете его отредактировать под свои потребности.",
    "is_default": true,
    "created_at": "2022-04-28T12:47:08.000000Z",
    "updated_at": "2022-04-28T12:47:08.000000Z",
    "contacts": [
        {
            "id": 1,
            "first_name": "Alex",
            "middle_name": null,
            "last_name": "Иванович Burt",
            "name": "Иванович Burt Alex",
            "sex": null,
            "age": null,
            "email": "admin@grandstep.com.ua",
            "phone_country": "UA",
            "phone_number": "983721222",
            "city": null,
            "phone": "+380983721222",
            "created_at": "2022-04-28T12:47:07.000000Z",
            "updated_at": "2022-04-28T12:47:08.000000Z"
        }
    ],
    "statistic": {
        "contact_list_id": 1,
        "count_contacts": 1
    }
}
}

HTTP Request

GET https://api.kwiga.com/mailing/contact-lists/{id}

Creating a contact group

Request example:


$headers = [
    'Accept: application/json',
    'Content-Type: application/x-www-form-urlencoded',
    'Token: <Token>',
    'Cabinet-Hash: <Cabinet-Hash>',
];

$data = [
    'title' => 'Название группы',
    'description' => 'описание'
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.kwiga.com/mailing/contact-lists/');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$result = json_decode($response);
curl -X POST -H 'Accept: application/json' -H 'Token: <Token>' -H 'Cabinet-Hash: <Cabinet-Hash>' -H 'Content-Type: application/json' -d '{"title" : "Название группы", "description" : "описание"}' https://api.kwiga.com/mailing/contact-lists

Example of response:

{
    "data": {
        "id": 3,
        "title": "fsdaf asfsf dsafsda fsda",
        "description": "1dsad sadsa ds dsa",
        "is_default": false,
        "created_at": "2022-05-04T09:57:37.000000Z",
        "updated_at": "2022-05-04T09:57:37.000000Z"
    }
}

HTTP Request

POST https://api.kwiga.com/mailing/contact-lists

Request (application/x-www-form-urlencoded)

Parameter Description
title
(string)
(required)
Title
description
(string)
Description

Adding Contacts to a Bulk

Request example:


$headers = [
    'Accept: application/json',
    'Content-Type: application/x-www-form-urlencoded',
    'Token: <Token>',
    'Cabinet-Hash: <Cabinet-Hash>',
];

$data = [
    'contacts' => [
        1,
        2
    ],
    'contact_lists' => [
        1
    ]
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.kwiga.com/mailing/contact-lists/bulk-contacts/');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$result = json_decode($response);
curl -X POST -H 'Accept: application/json' -H 'Token: <Token>' -H 'Cabinet-Hash: <Cabinet-Hash>' -H 'Content-Type: application/json' -d '{"contacts" : [1, 2], "contact_lists" : [2]}' https://api.kwiga.com/mailing/contact-lists/bulk-contacts

Example of response:

{
    "success": true
}

HTTP Request

POST https://api.kwiga.com/mailing/contact-lists/bulk-contacts

URL Parameters

Parameter Description
contacts
(array)
(required)
Contacts (ID)
contact_lists
(array)
(required)
Contact Groups (ID)

Payments. Coupons

Coupon list

Request example:

<?php
// Request without parameters

$headers = [
    'Accept: application/json',
    'Token: <Token>',
    'Cabinet-Hash: <Cabinet-Hash>',
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.kwiga.com/coupons');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response);
?>
<?php
// Query with filtering

$headers = [
    'Accept: application/json',
    'Token: <Token>',
    'Cabinet-Hash: <Cabinet-Hash>',
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.kwiga.com/coupons?filters[date_from]=2022-04-15&filters[date_to]=2022-04-27');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response);
?>
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -H 'Token: <Token>' -H 'Cabinet-Hash: <Cabinet-Hash>' -X GET https://api.kwiga.com/coupons
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -H 'Token: <Token>' -H 'Cabinet-Hash: <Cabinet-Hash>' -X GET https://api.kwiga.com/coupons?filters[date_from]=2022-04-15&filters[date_to]=2022-04-27

Example of response:

{
    "data": [
        {
            "id": 3,
            "code": "KwigaSMVT-MD",
            "reward": 30,
            "is_fixed": true,
            "is_disposable": false,
            "used_amount": 0,
            "total_uses": 10,
            "total_uses_per_user": 1,
            "user": {
                "id": 3,
                "avatar_url": "https://someurl.com",
                "hash": "EL9p2ycy4Ypga715",
                "name": "Test User",
                "email": "test@example.com",
                "tag_name": "TestUser"
            },
            "created_at": "2022-04-28T09:46:11.000000Z",
            "updated_at": "2022-04-28T09:46:11.000000Z",
            "deleted_at": null
        }
    ]
}

GET https://api.kwiga.com/coupons

URL Parameters

Parameter Description
filters[date_from]
(2022-04-15)
Filter by creation date. Parameter 'from'
filters[date_to]
(2022-04-27)
Filter by creation date. 'To' parameter

Getting a coupon

Request example:

<?php

$headers = [
    'Accept: application/json',
    'Token: <Token>',
    'Cabinet-Hash: <Cabinet-Hash>',
];

$id = 1;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.kwiga.com/coupons/' . $id);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response);
?>
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -H 'Token: <Token>' -H 'Cabinet-Hash: <Cabinet-Hash>' -X GET https://api.kwiga.com/coupons/1

Example of response:

{
    "data": {
        "id": 1,
        "code": "KwigaSMVT-MD",
        "reward": 30,
        "is_fixed": true,
        "is_disposable": false,
        "used_amount": 0,
        "total_uses": 10,
        "total_uses_per_user": 1,
        "created_at": "2022-04-28T09:46:11.000000Z",
        "updated_at": "2022-04-28T09:46:11.000000Z",
        "deleted_at": null
    }
}

HTTP Request

GET https://api.kwiga.com/coupons/{id}