A shorthand is a simple way to write a route handler for common API scenarios. Here’s a reference of the shorthands, and the code they represent.
Shorthands use default status codes, based on the HTTP verb:
- GET is 200
- PUT is 204
- POST is 201
- DEL is 204
PUT and POST change to 200 if there is a response body.
GET shorthands
Single collection
Shorthand |
|
Expanded |
|
Multiple collections
Shorthand |
|
Expanded |
|
Single record
Shorthand |
|
Expanded |
|
Single record with related records
Shorthand |
|
Expanded |
|
Array of specific records
For example, GET /contacts?ids=1,3
Shorthand |
|
Expanded |
|
POST shorthands
Create a resource
Shorthand |
|
Expanded |
|
PUT shorthands
Update a resource
Shorthand |
|
Expanded |
|
DELETE shorthands
Remove a resource
Shorthand |
|
Expanded |
|
Remove a resource and related models
Shorthand |
|
Expanded |
|