WT Amo CRM library - Documentation
Category: Libraries

getTags method

Getting a list of tags for an amoCRM entity

REST API method

GET /api/v4/{entity_type:leads|contacts|companies|customers}/tags

Official documentation of the method

Description

  • The method allows you to get a list of tags for an entity in the account.
  • The tag directory is divided by entities, that is, a tag with the same name will have different IDs in different types of entities
  • Tag color is only available for transaction tags
  • Tag color is only available from the Spring 2022 update
  • Tag functionality is available for the following entities: transactions, contacts, companies and buyers

Restrictions

  • The method is available according to the user's rights.
  • The method returns a maximum of 250 tags at a time. Keep this in mind if your amoCRM has more than 250 tags.

Parameters

NameTypeDescription
$entity_type string

The type of entity for which tags are requested. Available values

  • leads
  • contacts
  • companies
  • customers

Default value - leads.

$data array

GET request parameters according to the official documentation of the method.

  • page int Selection Page
  • limit int The number of entities returned per request (Maximum – 250)
  • filter object Filter
  • filter[name] string Filter by the exact tag name. You can only pass one name
  • filter[id] int|array Filter by tag ID. You can pass either a single ID or an array of multiple IDs
  • query string Allows you to perform a full-text search by tag name

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 tags for a lead entity:

stdClass Object
(
    [_page] => 1
    [_links] => stdClass Object
        (
            [self] => stdClass Object
                (
                    [href] => https://yoursubdomain.amocrm.ru/api/v4/leads/tags/?limit=50&page=1
                )

        )

    [_embedded] => stdClass Object
        (
            [tags] => Array
                (
                    [0] => stdClass Object
                        (
                            [id] => 221687
                            [name] => тест
                            [color] => 
                        )

                    [1] => stdClass Object
                        (
                            [id] => 221689
                            [name] => тест 2 
                            [color] => 
                        )

                    [2] => stdClass Object
                        (
                            [id] => 221691
                            [name] => тест 43
                            [color] => 
                        )

                )

        )

)

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] => getTags function: Error while trying to get tag(s) from Amo CRM. Amo CRM API response: <b>title</b>: Not Found
<b>type</b>: https://httpstatus.es/404
<b>status</b>: 404
<b>detail</b>: Cannot GET https://infowebtolkru.amocrm.ru/leadss/tags?limit%5B0%5D=250!

)

Code example

use Webtolk\Amocrm\Amocrm;	

$limit = 78;
$requset_options = [
	'limit' = (((int) $limit > 250) ? 250 : $limit)
];

$amocrm = new Amocrm();
$result_amo_crm = $amocrm->getTags('leads',$requset_options);

WebTolk Joomla Extensions

89 Extensions
11 Categories
392 Versions released
379452 Downloads
Cart
Cart is empty