> For AI agents: the complete Sanity documentation index is available at [https://www.sanity.io/docs/llms.txt](https://www.sanity.io/docs/llms.txt).

# Permission filters and API versions

Some GROQ functions in a permission filter require a minimum API version. Requests on older versions fail with HTTP 400 for affected users.

Some GROQ functions used in a permission filter require a minimum API version. If you add one of these functions to a filter on a content resource, requests made with an older API version will fail.

These are the functions with a version floor, and the API version each one requires:

##### Minimum API version by GROQ function

| Function | Minimum API version |
| --- | --- |
| `user::attributes()`, and other `user::` functions | `2024-05-23` |
| `string::` functions, such as `string::startsWith()` | `2021-03-25` |
| `text::query()` | `2021-03-25` |

A filter that uses more than one of these needs the latest version listed. For example, a filter that combines `user::attributes()` with `string::startsWith()` needs `2024-05-23`.

## Who is affected

Only authenticated requests (user sessions and tokens) from users or robots whose [roles](https://www.sanity.io/docs/user-guides/roles) include the filter. Anonymous requests and other users are not affected.

## What happens

If such a request uses an older API version, or no version (which means `v1`), the full request fails with HTTP 400. This applies to all documents, and to reads and writes. It is not limited to the documents that the filter covers.

## What to do

Before you save the filter, make sure that all clients of these users and tokens set an API version at or after the minimum. For example, set `apiVersion: '2024-05-23'` in `@sanity/client`:

**client.ts**

```typescript
import {createClient} from '@sanity/client'

const client = createClient({
  projectId: 'your-project-id',
  dataset: 'production',
  apiVersion: '2024-05-23',
  useCdn: true,
})
```

If you cannot update every client immediately, use a filter that only relies on functions supported by the API versions already in use.

