Sorting, Projection and Expansion
Sorting can be expressed with parameters such as sort=-createdAt,name, where a convention defines descending and ascending order.
Field selection can reduce response size: GET /users?fields=id,name,email.
Relationship expansion can be expressed through parameters such as ?include=orders, but uncontrolled expansion can create expensive queries and accidental data exposure.
Every dynamic field, sort key, and expansion option should be validated against an allowlist.
Security Boundary
Never pass arbitrary client-supplied field names, sort expressions, or database operators directly into database queries.