# Constraints

## Introduction

Similar to [Value Filters](https://docs.api.intratool.de/introduction/query-manipulation/value-filters), constraints are used to alter the query of a GET Request to fetch the required data for a specific use-case.

They are slightly different from [Value Filters](https://docs.api.intratool.de/introduction/query-manipulation/value-filters), as they enable the user to set constraints which are not aimed on a single field value but on relations or many fields.

{% hint style="info" %}
Every constraint can be combined with [Value Filters](https://docs.api.intratool.de/introduction/query-manipulation/value-filters) as seen below.
{% endhint %}

### Definition

* `{route}` - The endpoint you want to retrieve data of
* `?filter` - To identify the incoming URL parameter
* `[{constraint}]` - One of the constraints from the listing below
* `[{field}]` - The field (or relation field) on which the constraint should be applied
* `[{valueFilter}]` - (Optional) Field value filters for related entries
* `{value}` - Value depending on applied filters and constraints

<mark style="color:green;">`GET`</mark> `/api/{route}?filter[{constraint}][{field}][{valueFilter}]={value}`

## Doesn't Have

Constraint that manipulates the Query so that only the entries which doesn't have a relation to the given relation will get returned.

If you want to add a simple doesnt\_have constraint without further conditions on specific field values you can just pass the value `1`.

<mark style="color:green;">`GET`</mark> `/api/{route}?filter[doesnt_have][{field}]={value}`

## Has

Constraint that manipulates the Query so that only the entries which have a relation to the given field will get returned.

If you want to add a simple has constraint without further conditions on specific field values you can just pass the value `1`.

<mark style="color:green;">`GET`</mark> `/api/{route}?filter[has][{field}]={value}`

## Where One Of

Constraint that manipulates the Query, so that only the entries which have a relation to one of the given fields, will get returned.

This can be combined with [Value Filters](https://docs.api.intratool.de/introduction/query-manipulation/value-filters) to add conditions on field values of the given relation keys.

Accepts a comma-separated list of relations.

<mark style="color:green;">`GET`</mark> `/api/{route}?filter[where_one_of][{fields}]={value}`
