Laravel 13.35 New Published on

Searching with a request body thanks to the QUERY method

Route::query() declares a route for the HTTP QUERY method: a read, like GET, but with its criteria in the request body.

Topics covered: RoutingHTTP

New in Laravel 13.35. A search with many criteria doesn't fit well in the URL of a GET. So it was sent as a POST, with its criteria in the body, even though it changes nothing. The HTTP QUERY method, standardized by RFC 10008 (June 2026), is made for this case: it is safe and idempotent like GET, and carries a body like POST. Laravel now routes it.

Before

Route::post('/api/books/search', LivreController::class);

Since Laravel 13.35

Route::query('/api/books', LivreController::class);

Tests have their shortcuts: $this->query() and $this->queryJson(), next to get() and getJson(). Be careful: Laravel doesn't yet count QUERY among the methods that only read, so a QUERY route in the web group checks the CSRF token, like a POST.

Your task

The catalogue search goes through POST /api/books/search, with a JSON body: {"authors": […], "before": 1950, "genres": […]}. Declare it as QUERY /api/books instead, in routes/web.php. The controller doesn't change.

Where the feature comes from: the original pull request.