WT Amo CRM library - Documentation
Category: Libraries

getLeadById method

A method for obtaining data of a specific amoCRM lead by its id. The response includes custom lead fields, contacts, companies, funnel id, etc.

REST API method

GET /api/v4/leads/{id}

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.

Parameters

NameTypeDescription
$id int|string AmoCRM lead id.

Differences

The documentation of the amoCRM method informs about a possible optional parameter $with. At the moment, the WT Amocrm library does not support it.

Return values

HTTP 200 Successful response

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

Sample response

stdClass Object
(
    [id] => 20456399
    [name] => Order from site № 00000041
    [price] => 20205
    [responsible_user_id] => 6520033
    [group_id] => 0
    [status_id] => 36335095
    [pipeline_id] => 3753682
    [loss_reason_id] => 
    [created_by] => 0
    [updated_by] => 0
    [created_at] => 1673632365
    [updated_at] => 1673632365
    [closed_at] => 
    [closest_task_at] => 
    [is_deleted] => 
    [custom_fields_values] => Array
        (
            [0] => stdClass Object
                (
                    [field_id] => 870735
                    [field_name] => Comment
                    [field_code] => 
                    [field_type] => text
                    [values] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [value] => 00000041 afasdfasdfasdf Sergey Saratov 1000 1000 +79063049783
                                )

                        )

                    [is_computed] => 
                )

            [1] => stdClass Object
                (
                    [field_id] => 870737
                    [field_name] => teeest
                    [field_code] => 
                    [field_type] => textarea
                    [values] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [value] => 20205.0000 Sergey
                                )

                        )

                    [is_computed] => 
                )

            [2] => stdClass Object
                (
                    [field_id] => 776255
                    [field_name] => _ym_uid
                    [field_code] => _YM_UID
                    [field_type] => tracking_data
                    [values] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [value] => 1652458799256106622
                                )

                        )

                    [is_computed] => 
                )

        )

    [score] => 
    [account_id] => 29145994
    [labor_cost] => 0
    [is_price_computed] => 
    [_links] => stdClass Object
        (
            [self] => stdClass Object
                (
                    [href] => https://yoursubdomain.amocrm.ru/api/v4/leads/20456399?page=1&limit=50
                )

        )

    [_embedded] => stdClass Object
        (
            [tags] => Array
                (
                    [0] => stdClass Object
                        (
                            [id] => 221689
                            [name] => test 2 
                            [color] => 
                        )

                )

            [companies] => Array
                (
                )

        )

)

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] => 401
    [error_message] => getleadById function: Error while trying to get lead details from Amo CRM. Amo CRM API response: error detail from API
)

Code example

use Webtolk\Amocrm\Amocrm;

$amocrm = new Amocrm();
// Lead id
$id = 204563912;
$lead = $amocrm->getLeadById($id);
$lead_name = $lead->name;
$lead_price = $lead->price;

WebTolk Joomla Extensions

90 Extensions
11 Categories
401 Versions released
397249 Downloads
Cart
Cart is empty