---
title: "Wire contract — Query Builder for Laravel | Roundly"
description: "The frozen query-string syntax for filters, operators, sorts and pagination, and the status code each mistake returns."
url: https://roundly-consulting.com/open-source/docs/query-builder-for-laravel/wire-contract
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Query Builder for Laravel](https://roundly-consulting.com/open-source/docs/query-builder-for-laravel.md)

# Wire contract

The query-string format is a frozen contract — front ends and bookmarks keep working as the package evolves. With the default parameter names:

| Concern | Syntax | Semantics |
| --- | --- | --- |
| Filter | `filter[<name>]=<value>` | One param per filter; <name> is the allow-list key. |
| Multi-value filter | `filter[<name>]=a,b,c` | Comma-split → array; exact → whereIn. |
| Array filter value | `filter[<name>][]=a` | One level of nesting is flattened into the list. |
| Boolean filter value | `filter[<name>]=true / false` | A real bool (also 1/0, any case) only for a filter that opts in — boolean(), FilterValueShape::Boolean, booleans: true. Every other filter receives the text. |
| Search phrase | `filter[<name>]=Smith, John` | search() only: one phrase — a comma is part of it, no operator is read, and a blank phrase is no filter. |
| Operator | `filter[<name>]=<token>:<value>` | operators(), nullable(), relation() and jsonContains() only; an undeclared token stays part of the value. |
| Unset | `filter[<name>]=none / not:none` | The sentinel of nullable(), and of relation() when given one. |
| Sort asc / desc | `sort=field / sort=-field` | Leading - = descending. |
| Multi-sort | `sort=-created_at,name` | Applied left → right; duplicate columns collapse to the first, capped by limits.max\_sorts (allow-listed sorts only). |
| Pagination | `page=<n>&per_page=<n>` | Laravel paginator names; per\_page validated by HasPageSize. |
| Unknown filter/sort key | Any key not allow-listed | HTTP 400 (or dropped in ignore mode; with every sort dropped, the default sort applies). |
| Invalid per\_page | \> max, < 1, non-integer | HTTP 422. |

## A full request

A request using every part of the contract (the endpoint must declare each filter and sort):

```
GET /posts?filter[status]=not:draft,archived&filter[title]=laravel&filter[project]=none&sort=-created_at,title&page=2&per_page=25
```

Parameter names come from parameters.\* and pagination.\* in the config; change them only together with your front end.

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/query-builder-for-laravel.md)
