Project

General

Profile

CRM Leads / Save

API CRM Leads / Save se foloseste pentru a salva in CRM-ul While1 Voice leads din surse externe.

API URL

https://[YOUR-PBX-URL]/api/crm-leads

Datele se trasmit prin POST sau GET si trebuie sa fie de forma:

Array
(
    [action] => save
    [data] => Array
        (
            [ASDF1234] => Array
                (
                    [properties] => Array
                        (
                            [id] => null
                            [crm_type_id] => 1
                            [remote_id] => null
                            [subject] => New API Lead
                            [contact_name] => John Doe
                            [contact_email] => test@example.com
                            [contact_telephone] => 0700000001
                            [referrer_source] => contact form
                        )
                    [custom_fields] => Array
                        (
                            [11] => array(1, 3, 4)
                            [13] => array(1)
                            [16] => Test company
                        )
                )
        )
    [api_hash] => 20b093246dac88454f390553e813aa0d
)

Parametrul action trebuie sa aiba valoarea save

Parametri:

  • data: Array cu leadurile
  • data - properties: Array cu proprietatile standard ale fiecarui lead
  • data - custom_fields: Array cu custom-fields setate in CRM Config :: Custom fields ale fiecarui lead

Headere HTTP:

Content-Type: text/xml
Authorization: Bearer <token>

Exemplu generare parametri:

$params = array(
    'action' => 'save',
    'data' => array(
        'ASDF1234' => array(
            // Lead properties
            'properties' => array(
                'id' => '', // will be matched by remote_id if left blank
                'crm_type_id' => 1, // ID from CRM Config :: Element types
                'remote_id' => null,
                'subject' => 'New API Lead',
                'contact_name' => 'John Doe',
                'contact_email' => 'test@example.com',
                'contact_telephone' => '0700000001',
                'referrer_source' => 'contact form',
            ),
            // Custom fields (Keys are IDs from CRM Config :: Custom fields). If specified, will be deleted, if not, will be ignored
            'custom_fields' => array(
                11 => 'source: test',
                13 => 'product: test',
                16 => 'Test company', 
            )
        )
    )
);

Exemplu generare hash:

$params['api_hash'] = md5(http_build_query($params) . 'your_api_key'); // make hash

Exemplu trimitere date:

$url = 'https://[YOUR-PBX-URL]/api/crm-leads';
$token = 'your_api_token';
echo curlPost($url, http_build_query($params), array("Authorization: Bearer {$token}"));

Raspuns

In caz de succes:

{
    "has_error": false,
    "messages": [],
    "results": {
    "ASDF1234": {
            "id": 3,
            "contact_id": 23,
            "remote_id": null
        }
    }
}

Sau in caz de eroare:

{

    "has_error": true,
    "messages": [
        "Error on Lead update (ASDF1234): Contact ID is required" 
    ],
    "pagination": [ ],
    "results": [ ]

}

Disponibil si in alte limbi: EN