Design REST API field selection: request only the response properties you need
Field selection lets a client specify which properties an API should include in a response, reducing data the client does not need. OData expresses this with $select, but not every REST API supports this syntax or feature. Field selection changes response shape; it is not an authorization check, so the server must separately restrict which fields may be returned.
Field selection lets a client specify which properties an API should include in a response, reducing data the client does not need. OData expresses this with $select, but not every REST API supports this syntax or feature. Field selection changes response shape; it is not an authorization check, so the server must separately restrict which fields may be returned.
Define the field-selection contract
OData $select names the properties to return for an entity or complex type. For example, this request asks for only a product's name and price:
GET /api/products?$select=name,priceThis is OData syntax. A REST API may use another parameter such as fields or select, or may not support field selection. Document exact selectable field names and nested-path syntax, default response fields, treatment of required identifiers or metadata, and errors for unknown or disallowed fields. Decide whether the default response is already narrow or whether clients may select from a full response.
In OData, $select can be combined with $expand to choose properties of a resource and its related resources. Expanding relationships can increase response size and data-access cost. Allow only necessary expansions at first, limit expansion depth and quantity, and document selection rules for each expanded resource.
Keep field selection separate from authorization
A client requesting a sensitive property such as passwordHash, an internal note, or another user's personal data does not make it permissible to return. Build response schemas from server-controlled allowlists for the user or role and enforce authorization on the server. Excluding sensitive properties from response models or using explicit role-specific response types can make the boundary clearer. The field-selection parameter does not replace this check.
Define consistent behavior for unknown and unauthorized fields. Specify whether the whole request fails or reports only disallowed fields, and avoid responses that reveal sensitive field existence unnecessarily. Silently dropping a field can cause clients to misinterpret the response.
Verify datastore projection and performance
If the server removes properties only just before sending the response, the network payload may shrink while database reads and server-side work remain unchanged. Check whether the data-access layer can turn permitted selections into query projections. ASP.NET Core OData converts query options into LINQ expressions: a provider may translate IQueryable expressions into database queries, while processing an in-memory IEnumerable occurs in memory. Verify what the actual store and provider do.
Because selection can change the response object's shape, clients should assume only requested fields are present, except for identifiers, pagination links, or metadata that the contract promises unconditionally. Apply other query limits such as page size, filter cost, and expansion bounds as well.
An implementation procedure you can verify
List the response properties clients may select and the default properties returned.
Parse field names and nested paths; check them independently against the allowlist and the user's permissions.
Convert the permitted field set into a datastore query projection or an allowed response model.
If relationship expansion is supported, cap allowed paths, depth, and quantity.
Check responses and query behavior for ordinary selections, empty selections, unknown fields, sensitive fields, and expansion requests.
For example, after requesting name,price, confirm that the response contains those properties and only identifiers required by the contract. Inspect a real query plan or data-access trace to see whether the projection also reaches the datastore. This is a verification method, not a claim that a particular implementation was tested.
Sources
[OData: Query options usage — `$select` and `$expand`](https://learn.microsoft.com/en-us/odata/concepts/queryoptions-usage)
[ASP.NET Core OData 8: Fundamentals overview](https://learn.microsoft.com/en-us/odata/webapi-8/fundamentals/overview)
[Microsoft Dataverse: Select columns using OData](https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/query/select-columns)
[Microsoft Azure Architecture Center: RESTful Web API implementation best practices](https://learn.microsoft.com/en-us/azure/architecture/best-practices/api-implementation)