> For the complete documentation index, see [llms.txt](https://docs.opensoutheners.com/home/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.opensoutheners.com/home/laravel-scim/filtering.md).

# Filtering

SCIM clients can filter list results using the `filter` query parameter. The package parses SCIM filter syntax and translates it into Eloquent query conditions.

## Basic usage

```
GET /scim/v2/Users?filter=userName eq "john@example.com"
```

No code changes needed. Filtering works automatically for any registered schema.

## Supported operators

| Operator | Description           | Example                          |
| -------- | --------------------- | -------------------------------- |
| `eq`     | Equal                 | `userName eq "john@example.com"` |
| `ne`     | Not equal             | `active ne "false"`              |
| `co`     | Contains              | `name co "john"`                 |
| `sw`     | Starts with           | `userName sw "john"`             |
| `pr`     | Present (not null)    | `externalId pr`                  |
| `gt`     | Greater than          | `meta.created gt "2024-01-01"`   |
| `ge`     | Greater than or equal | `meta.created ge "2024-01-01"`   |
| `lt`     | Less than             | `meta.created lt "2024-12-31"`   |
| `le`     | Less than or equal    | `meta.created le "2024-12-31"`   |

## Logical operators

Combine conditions with `and`, `or`, and `not`:

```
GET /scim/v2/Users?filter=userName eq "john@example.com" and active eq "true"
```

```
GET /scim/v2/Users?filter=name co "john" or name co "jane"
```

## Attribute mapping

Filter attribute names are automatically mapped to database columns using the `modelAttribute` defined in your `ScimSchemaAttribute`. For example:

```php
#[ScimSchemaAttribute(modelAttribute: 'email')]
string $userName,
```

A filter on `userName` will query the `email` column in the database.

## Pagination

SCIM uses 1-based pagination with `startIndex` and `count` parameters:

```
GET /scim/v2/Users?startIndex=1&count=25
```

| Parameter    | Default | Description                       |
| ------------ | ------- | --------------------------------- |
| `startIndex` | `1`     | 1-based index of the first result |
| `count`      | `10`    | Number of results per page        |

The response includes pagination metadata:

```json
{
    "schemas": ["urn:ietf:params:scim:api:messages:2.0:ListResponse"],
    "totalResults": 42,
    "itemsPerPage": 25,
    "startIndex": 1,
    "Resources": [...]
}
```

## Max results

The `filter.maxResults` config limits how many results can be returned per page:

```php
// config/scim.php
'filter' => [
    'maxResults' => 100,
],
```

If a client requests more than this via `count`, the limit is capped.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.opensoutheners.com/home/laravel-scim/filtering.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
