> For the complete documentation index, see [llms.txt](https://teamleader-sdk.mcore-services.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://teamleader-sdk.mcore-services.dev/api-reference/crm/tags.md).

# Tags

Manage tags in Teamleader Focus.

```php
Teamleader::tags()
```

|                          |                                                                       |
| ------------------------ | --------------------------------------------------------------------- |
| Class                    | `McoreServices\TeamleaderSDK\Resources\CRM\Tags`                      |
| Create / update / delete | — / — / —                                                             |
| Pagination               | `page_size` / `page_number`; no totals — a short page is the last one |

## Endpoints

* `tags.list`

## Filters

`list()` takes no filters.

## Sorting

Pass `sort` (and optionally `sort_order`) in the options. Any other field throws.

| Field | Description                                    |
| ----- | ---------------------------------------------- |
| `tag` | Tag name (the only sort field; ascending only) |

## Methods

### `list()`

```php
list(array $filters = [], array $options = []): array
```

List tags with pagination and sorting

`tags.list` accepts `page` and `sort` but has no filter object at all, so filters are rejected rather than discarded. The API declares exactly one sort field (`tag`) and one order (`asc`); anything else is rejected too, rather than being silently rewritten to the supported value as it was before v2.1.2 — a caller asking for descending order got ascending back with no indication the request had been changed.

* `$filters` — Must be empty — this endpoint accepts no filters
* `$options` — page\_size, page\_number, sort, sort\_order

**Throws** `\InvalidArgumentException` When filters are passed or the sort is unsupported

### `all()`

```php
all(): array
```

Get all tags without pagination

### `search()`

```php
search(string $query, bool $exactMatch = false): array
```

Search tags by name (client-side filtering) Note: The API doesn't support server-side filtering, so we fetch all and filter

* `$query` — Search query
* `$exactMatch` — Whether to match exactly or use partial matching

### `containing()`

```php
containing(string $text): array
```

Get tags containing specific text

* `$text` — Text to search for

### `startingWith()`

```php
startingWith(string $prefix): array
```

Get tags starting with specific text

* `$prefix` — Prefix to search for

### `paginate()`

```php
paginate(int $pageSize = 20, int $pageNumber = 1): array
```

Get paginated results with better metadata

The `pagination` key this adds is computed client-side from the page size and the number of rows returned. The API sends no pagination metadata for tags — `tags.list` declares no meta block — so `has_more_pages` is an inference from a full page, not a fact from the server. A complete final page therefore reports has\_more\_pages = true and costs one extra empty request to disprove.

* `$pageSize` — Items per page
* `$pageNumber` — Page number (1-based)

### `getStatistics()`

```php
getStatistics(): array
```

Get tag statistics

### `info()`

```php
info($id, $includes = null): array
```

Override info method as individual tag info is not supported

**Throws** `\InvalidArgumentException`

### `getResponseStructure()`

```php
getResponseStructure(): array
```

Get response structure documentation

## Examples

Get all tags:

```php
$tags = Teamleader::tags()->list();
```

Get tags with pagination:

```php
$tags = Teamleader::tags()->list([], ['page_size' => 50, 'page_number' => 2]);
```

Get tags sorted alphabetically:

```php
$tags = Teamleader::tags()->list([], ['sort' => 'tag', 'sort_order' => 'asc']);
```

Search for specific tags:

```php
$campaignTags = Teamleader::tags()->search('campaign');
```
