WT Amo CRM library - Documentation
Category: Libraries
WT Amo CRM library
  • Download type: Free
  • Version: 1.2.1
  • Downloads: 2539

createLeads method

The method allows you to add leads from Joomla to an amoCRM account in batches.

REST API method

POST /api/v4/leads

Official documentation of the method

Description

The method allows you to get the data of a specific transaction by ID.

Restrictions

The method is available according to the user's rights.

Batch methods of the amoCRM REST API allow you to add no more than 50 elements at a time. In the context of this method - no more than 50 leads.

Parameters

NameTypeDescription
$data array amoCRM transaction data array according to official documentation of the method.

Return values

HTTP 200 Successful response

The return value corresponds to the amoCRM documentation for this method.

Sample response

stdClass Object
(
    [_links] => stdClass Object
        (
            [self] => stdClass Object
                (
                    [href] => https://yoursubdomain.amocrm.ru/api/v4/leads
                )

        )

    [_embedded] => stdClass Object
        (
            [leads] => Array
                (
                    [0] => stdClass Object
                        (
                            [id] => 20534409
                            [request_id] => 0
                            [_links] => stdClass Object
                                (
                                    [self] => stdClass Object
                                        (
                                            [href] => https://yoursubdomain.amocrm.ru/api/v4/leads/20534409
                                        )

                                )

                        )

                )

        )

)

HTTP 40x Failed response

The official documentation says about a possible response code 401 The user is not authorized. The WT Amocrm library returns an error object of the following structure:

stdClass Object
(
    [error_code] => 400
    [error_message] => createLeads function: Error while trying to create lead in Amo CRM. Amo CRM API response: request_id: 0
code: NotSupportedChoice
path: pipeline_id
detail: The value you selected is not a valid choice.
title: Bad Request
type: https://httpstatus.es/400
status: 400
detail: Request validation failed

)

Code example

use Webtolk\Amocrm\Amocrm;

$amocrm = new Amocrm();
$leads = [];
$order_summ = 15453.44; // The amount, the budget of the transaction.
$lead_data = [
	'created_by'  => 0, // The ID of the user creating the lead. When the value 0 is passed, the lead will be considered created by the robot. The field is optional
	'name'        => 'Order #2987427', // displayed lead name
	'pipeline_id' => 3753682, // pipline id. The list of pipelines is obtained by the method getLeadsPiplines()
	'price'       => (int) $order_summ, // amoCRM accepts only integer values here. If you need amounts up to a penny, we pass them additionally to the fields or a note.
];

$lead_data['_embedded']['contacts'] = array();

/**
 * The contact data array is added as a nested entity.
 */
$contact_id = 32942695; // Contact id. We search and get it via the method getContacts.
$contact = [
	'id' => $contact_id,
	'is_main' => true,
];
$lead_data['_embedded']['contacts'][] = $contact;
$leads[] = $lead_data;
	
$result_amo_crm = $amocrm->createLeads($leads);

WebTolk Joomla Extensions

77 Extensions
11 Categories
323 Versions released
302377 Downloads
Cart
Cart is empty