# Sort & filter

List endpoints accept a consistent set of query parameters so you can slice and order results server-side rather than downloading everything and filtering in your client.

## Sort

Pass a `sort` query parameter with one or more comma-separated field names. Prefix a field with `-` to sort descending.

```bash
# Newest integrations first
curl "$BASE/v1/integrations?sort=-createdAt" -H "Authorization: Bearer $TOKEN"

# Name ascending, then lastModified descending
curl "$BASE/v1/flows?sort=name,-lastModified" -H "Authorization: Bearer $TOKEN"
```

**Sortable fields** are documented per endpoint. The safest general-purpose fields are `_id`, `createdAt`, `lastModified`, and `name`.

## Filter

### Exact match

Most top-level string fields can be filtered by supplying the field name as a query param:

```bash
# Only my NetSuite connections
curl "$BASE/v1/connections?type=netsuite"

# All flows in a specific integration
curl "$BASE/v1/flows?_integrationId=5f83a9b2c7d3e8f1a2b3c4d5"
```

### Free-text search

Many endpoints accept `search` or `q` for partial-match against `name` and related fields:

```bash
curl "$BASE/v1/integrations?search=shopify"
```

The server decides which fields participate in the search. Names, descriptions, and tags are typical candidates.

### Boolean flags

Booleans are passed as `true` / `false` strings:

```bash
curl "$BASE/v1/flows?disabled=false&sandbox=true"
```

### Time windows

Use ISO-8601 strings with `createdAfter`, `createdBefore`, `modifiedAfter`, and `modifiedBefore`:

```bash
curl "$BASE/v1/audit?source=ui&createdAfter=2026-04-01T00:00:00Z&createdBefore=2026-04-30T23:59:59Z"
```

## Field selection

A handful of endpoints support `fields=` to reduce the payload:

```bash
curl "$BASE/v1/integrations?fields=_id,name,mode"
```

When supported, this is the single biggest performance win for large listings.

## Combining with pagination

Filters run **before** pagination. When you paginate a filtered listing, the `Link: rel="next"` URL carries your filters forward automatically — don't re-append them to the next URL. Follow the header exactly as-is. See [Pagination](/api/using-the-api/pagination.md) for the iteration pattern.

## When the CLI is faster

For ad-hoc exploration, a few CLI list commands accept server-side filters (notably `jobs list` and `audit list`); most resource listings don't, so filter with `--jq` on the client side:

```bash
# audit: server-side filters
celigo audit list --source ui --start-date 2026-04-01T00:00:00Z --end-date 2026-04-30T23:59:59Z

# jobs: server-side filters
celigo jobs list --flow 5f83a9b2c7d3e8f1a2b3c4d5 --status failed

# other resources: filter client-side with --jq
celigo flows list       --jq --arg int 5f83a9b2c7d3e8f1a2b3c4d5 \
  '[.[] | select(._integrationId == $int and .disabled == false)]'
celigo connections list --jq '[.[] | select(.type == "netsuite")]'
```

See the [CLI Reference](https://developer.celigo.com/cli).


---

# Agent Instructions: 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:

```
GET https://developer.celigo.com/api/using-the-api/sorting-filtering.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
