REST API Resource Naming and URL Design

Naming conventions for resources, relationships, nested endpoints, and clean URL design.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all
## Naming conventions
Use consistent casing in paths
/purchase-orders
/api-keys

# Pick one URL style and use it consistently.

Avoid format suffixes in paths
Prefer: GET /reports/123
Avoid:  GET /reports/123.json

# Negotiate format via headers, not path suffixes.

Name relationships clearly
GET /teams/{teamId}/members

# Make related collections obvious.

Keep nesting shallow
Better: /orders/{orderId}/items
Avoid:  /customers/{customerId}/orders/{orderId}/items/{itemId}/notes

# Prefer one or two levels of depth.

Expose canonical resource paths
/orders/{orderId}
/order-items/{itemId}

# Each resource should have an obvious direct URL.

## Path vs query parameters
Put resource identity in the path
GET /users/123

# Use the path for the primary resource being addressed.

Use query parameters for filtering
GET /users?role=admin&status=active

# Filter a collection with query fields.

Use query parameters for field selection
GET /users/123?fields=id,name,email

# Return only needed fields.

Use includes for related resources
GET /orders/ord_123?include=customer,items

# Let clients opt into embedded relationships.

Recommended next

No recommendations yet.