q parameter; sorting and pagination are top-level params.
Filtering
Pass filter conditions viaq:
The SDK automatically wraps filter keys in
q[...] and appends [] for array values — pass flat params.Common predicates
Which filters an endpoint accepts
Each list endpoint accepts the attributes, associations and scopes its resource allows, and only the predicates that fit each attribute’s kind of value:
Filters reach associated records at most two levels deep (
line_items_variant_sku_eq). The API reference lists each documented endpoint’s filters and sortable fields in its x-spree-filters entry, and the SDK types that endpoint’s list() call from it, so a misspelled filter or sort field is a compile error rather than an unfiltered response. Filters your own app adds need a one-time declaration before TypeScript accepts them. List methods of endpoints the reference does not document yet accept any filter.
Prefixed IDs in filters
Resource ID filters accept Stripe-style prefixed IDs directly. The server decodes them before querying:_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-levelsort parameter on any list endpoint. Prefix with - for descending. Follows the JSON:API sorting convention.
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 withpage and limit:
Pagination metadata
Responses include ameta object:
Expanding associations
Most admin endpoints return slim payloads by default — associations are returned as IDs. Use theexpand parameter to include related resources inline:
Nested expand
Use dot notation up to 4 levels deep: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 thefields parameter to request only specific fields on a resource. Reduces payload size for bandwidth-sensitive integrations:
idis 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.
