> For the complete documentation index, see [llms.txt](https://docs.comfortable.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.comfortable.io/sdk/php/query-by-tags.md).

# Query by Tags

### Query by IncludeTags

```php
<?php
// $results will be include all documents with the tag "include" or "me"
$results = $api->getDocuments()
  ->includeTags(["include", "me"])
  ->execute();
```

### Query by ExcludeTags

```php
<?php
// $results will exclude all documents with the "exclude me" tag
$results = $api->getDocuments()
  ->excludeTags(["exclude"])
  ->execute();
```

### Combine IncludeTags & ExcludeTags

```php
<?php
// $results will hold all documents with the tag "sports",
// except the documents with the "soccer" tag.
$results = $api->getDocuments()
  ->includeTags(["sports"])
  ->excludeTags(["soccer"])
  ->execute();
```
