Skip to main content
The Admin API uses Ransack for filtering and sorting on collection endpoints. All filter conditions go through the q parameter; sorting and pagination are top-level params.

Filtering

Pass filter conditions via q:
The SDK automatically wraps filter keys in q[...] and appends [] for array values — pass flat params.

Common predicates

Prefixed IDs in filters

Resource ID filters accept Stripe-style prefixed IDs directly. The server decodes them before querying:
The same applies to _id_in, _id_not_eq, and other ID predicates.

Combining filters

Multiple filters combine with AND:

Filtering by association

Use underscore notation to filter on associated model attributes:

Custom search scopes

Some resources expose convenience search scopes:

Sorting

Use the top-level sort parameter on any list endpoint. Prefix with - for descending. Follows the JSON:API sorting convention.
Sortable columns are limited to those whitelisted on the model (Ransack’s whitelisted_ransackable_attributes). Sorting on a virtual column (e.g., a serializer-computed field like display_total_spent) is not supported.

Pagination

All collection endpoints return paginated results. Control with page and limit:

Pagination metadata

Responses include a meta object:

Expanding associations

Most admin endpoints return slim payloads by default — associations are returned as IDs. Use the expand parameter to include related resources inline:

Nested expand

Use dot notation up to 4 levels deep:
A nested expand implicitly includes its parent — expand: ['items.variant'] returns both items and their variant data.

What can I expand?

Each endpoint documents its supported expand keys in the OpenAPI reference. Common admin expansions:

Field selection

Use the fields parameter to request only specific fields on a resource. Reduces payload size for bandwidth-sensitive integrations:
Rules:
  • id is always included
  • Expanded associations return their full payload regardless of fields
  • Field selection applies to the top-level resource only
TypeScript types in @spree/admin-sdk remain fully typed regardless of fields. At runtime, only the requested fields are present — the rest are undefined.