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

getLeadsCustomFields method

Method for getting a list of fields for leads in Amo CRM

REST API method

GET /api/v4/leads/custom_fields

Official documentation of the method

Description

  • The method allows you to get a list of entity fields in the account.

Restrictions

  • The method returns up to 50 fields per request.
  • The method is available to all users of the account.
  • Unlike the official documentation, the method of this library does not yet accept additional request parameters.

Response Parameters

ParameterData typeDescription
id int field ID
name string Field name
code string The field code by which the value can be updated in the entity, without passing the field ID
sort int Field sorting
type string Field type. See list of available fields in official docs.
entity_type string Type of entity (leads, contacts, companies, segments, customers, catalogs)
is_computed bool The parameter is responsible for defining the field type as a "computed" field. This key is returned only when the list of transaction fields is received
is_predefined bool Whether the field is preset. This key is returned only when a list of contact and company fields is received
is_deletable bool Whether the field is available for deletion. This key is returned only when a list of contact and company fields is received
is_visible bool Whether the field is displayed in the list interface. This key is returned only when a list of fields of lists (directories) is received
is_deletable bool Is it possible to remove the field from the interface. This key is returned only when a list of fields of lists (directories) is received
is_required bool Обязательно ли поле для заполнения при создании элемента списка. Данный ключ возвращается только при получении списка полей списков (каталогов)
settings array
null
Field settings. This key is returned only when a list of fields of lists (directories) is received
remind string
null
When to remind about a birthday (never – never, day – for a day, week – for a week, month – for a month). The value of this field is only available for a field of the birthday type. This key is returned only when you receive a list of contact fields, transactions and companies
currency string(3)
null
The currency code of the field. Applicable only for the – monetary field type. For other types of fields – null.
enums array
null
Available values for the field. The value of this field is only available for fields with enum support
enums[0] object Available value for the field
enums[0][id] int Value ID
enums[0][value] string Value
enums[0][sort] int Value sorting
enums[0][code] string
null
Character code of the value
nested array
null
Nested values. The key data is returned only when a list of directory fields is received and the value is available only for the category field
nested[0] object The nested value model. The key data is returned only when a list of directory fields is received and the value is available only for the category field
nested[0][id] int ID of the nested value. The key data is returned only when a list of directory fields is received and the value is available only for the category field
nested[0][parent_id] int ID of the parent nested value. The key data is returned only when a list of directory fields is received and the value is available only for the category field
nested[0][value] string The value of the nested value. The key data is returned only when a list of directory fields is received and the value is available only for the category field
nested[0][sort] int Sorting the nested value. The key data is returned only when a list of directory fields is received and the value is available only for the category field
is_api_only bool Whether the field is editable only via the API. This key is returned only when you receive a list of contact fields, transactions and companies
group_id string
null
ID of the field group that this field consists of. This key is returned only when you receive a list of fields of contacts, transactions, buyers and companies
required_statuses array
null
Required fields for changing stages. This key is returned only when you receive a list of contact fields, transactions and companies
required_statuses[0] object The model of the required field for changing stages. This key is returned only when you receive a list of contact fields, transactions and companies
required_statuses[0][status_id] int ID of the status to which this field is required to be filled in. This key is returned only when you receive a list of contact fields, transactions and companies
required_statuses[0][pipeline_id] int ID of the funnel to which this field is required to be filled in. This key is returned only when you receive a list of contact fields, transactions and companies
hidden_statuses array Setting up field hiding. The fields are hidden in the interface depending on the status. This key is returned only when a list of transaction fields is received.
hidden_statuses[0] object A model for setting up field hiding.
hidden_statuses[0][status_id] int ID of the status in which the field is hidden
hidden_statuses[0][pipeline_id] int ID of the pipeline in which the field is hidden
chained_lists array
null
Setting up a chained_list type field. This key is returned only when a list of transaction and buyer fields is received.
chained_lists[0] object A model for setting up a linked list.
chained_lists[0][title] string
null
The name of the linked list that is displayed in the card
chained_lists[0][catalog_id] int catalog ID
chained_lists[0][parent_catalog_id] int ID of the parent catalog
tracking_callback string Callback js is a function that will be executed on the page with the CRM Plugin and the amoCRM form when sending data. This value is returned for fields of the tracking_data type
search_in string
null
List ID or character code (contacts, companies, contacts_and_companies) for a field of the Link to Other element type (linked_entity).

Return values

HTTP 200 Successful response

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

Sample response

Example of amoCRM's response to a request for a list of leads fields:

stdClass Object
(
    [_total_items] => 25
    [_page] => 1
    [_page_count] => 1
    [_links] => stdClass Object
        (
            [self] => stdClass Object
                (
                    [href] => https://yourdomain.amocrm.ru/api/v4/leads/custom_fields?page=1&limit=250
                )

        )

    [_embedded] => stdClass Object
        (
            [custom_fields] => Array
                (
                    [0] => stdClass Object
                        (
                            [id] => 776243
                            [name] => utm_source
                            [type] => tracking_data
                            [account_id] => 29145994
                            [code] => UTM_SOURCE
                            [sort] => 509
                            [is_api_only] => 1
                            [enums] => 
                            [group_id] => statistic
                            [required_statuses] => Array
                                (
                                )

                            [is_deletable] => 
                            [is_predefined] => 1
                            [entity_type] => leads
                            [tracking_callback] => 
                            [remind] => 
                            [triggers] => Array
                                (
                                )

                            [currency] => 
                            [hidden_statuses] => Array
                                (
                                )

                            [chained_lists] => 
                            [_links] => stdClass Object
                                (
                                    [self] => stdClass Object
                                        (
                                            [href] => https://yourdomain.amocrm.ru/api/v4/leads/custom_fields/776243?page=1&limit=250
                                        )

                                )

                        )

                    [1] => stdClass Object
                        (
                            [id] => 776245
                            [name] => utm_medium
                            [type] => tracking_data
                            [account_id] => 29145994
                            [code] => UTM_MEDIUM
                            [sort] => 510
                            [is_api_only] => 1
                            [enums] => 
                            [group_id] => statistic
                            [required_statuses] => Array
                                (
                                )

                            [is_deletable] => 
                            [is_predefined] => 1
                            [entity_type] => leads
                            [tracking_callback] => 
                            [remind] => 
                            [triggers] => Array
                                (
                                )

                            [currency] => 
                            [hidden_statuses] => Array
                                (
                                )

                            [chained_lists] => 
                            [_links] => stdClass Object
                                (
                                    [self] => stdClass Object
                                        (
                                            [href] => https://yourdomain.amocrm.ru/api/v4/leads/custom_fields/776245?page=1&limit=250
                                        )

                                )

                        )

                    [2] => stdClass Object
                        (
                            [id] => 776247
                            [name] => utm_campaign
                            [type] => tracking_data
                            [account_id] => 29145994
                            [code] => UTM_CAMPAIGN
                            [sort] => 511
                            [is_api_only] => 1
                            [enums] => 
                            [group_id] => statistic
                            [required_statuses] => Array
                                (
                                )

                            [is_deletable] => 
                            [is_predefined] => 1
                            [entity_type] => leads
                            [tracking_callback] => 
                            [remind] => 
                            [triggers] => Array
                                (
                                )

                            [currency] => 
                            [hidden_statuses] => Array
                                (
                                )

                            [chained_lists] => 
                            [_links] => stdClass Object
                                (
                                    [self] => stdClass Object
                                        (
                                            [href] => https://yourdomain.amocrm.ru/api/v4/leads/custom_fields/776247?page=1&limit=250
                                        )

                                )

                        )

                    [3] => stdClass Object
                        (
                            [id] => 776249
                            [name] => utm_term
                            [type] => tracking_data
                            [account_id] => 29145994
                            [code] => UTM_TERM
                            [sort] => 512
                            [is_api_only] => 1
                            [enums] => 
                            [group_id] => statistic
                            [required_statuses] => Array
                                (
                                )

                            [is_deletable] => 
                            [is_predefined] => 1
                            [entity_type] => leads
                            [tracking_callback] => 
                            [remind] => 
                            [triggers] => Array
                                (
                                )

                            [currency] => 
                            [hidden_statuses] => Array
                                (
                                )

                            [chained_lists] => 
                            [_links] => stdClass Object
                                (
                                    [self] => stdClass Object
                                        (
                                            [href] => https://yourdomain.amocrm.ru/api/v4/leads/custom_fields/776249?page=1&limit=250
                                        )

                                )

                        )
                )

        )

)

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] => 404
    [error_message] => getLeadsCustomFields function: Error while trying to get leads custom fields list from Amo CRM. Amo CRM API response: title: Not Found
type: https://httpstatus.es/404
status: 404
detail: Cannot GET https://yourdomain.amocrm.ru/leads/custom_fields1!

)

In this example, there is a typo in the name of the amoCRM API method specifically to demonstrate an error response.

Code example

<?php
use Webtolk\Amocrm\Amocrm;
defined('_JEXEC') or die;

$amocrm         = new Amocrm();
$result_amo_crm = $amocrm->getLeadsCustomFields();

WebTolk Joomla Extensions

78 Extensions
11 Categories
332 Versions released
312031 Downloads
Cart
Cart is empty