0042 - API standards for creating resources
| ID: | ADR-0042 |
|---|---|
| Status: | PROPOSED |
| Published: | 2026-10-05 |
Notation
This ADR uses RFC 2119 keywords (MUST, MUST NOT,
SHOULD, SHOULD NOT, MAY) deliberately.
Context and problem statement
ADR-0036 requires service-to-service APIs to conform to a documented set of standards, and ADR-0039 builds those standards on IETF RFCs. This ADR sets how a resource is created: the method, the path, the request, and what a successful response returns. Payload shape and errors are set by ADR-0040.
Considered options
POSTto the collection, returning the new resource.PUTto a client-chosen ID as the primary way to create.POSTreturning only aLocationheader and no body.
Decision outcome
Chosen option: POST to the collection, returning the new resource, because the caller usually
needs the server-generated ID and the stored representation, and getting both in one response saves
a second call.
- The method
MUSTbePOST, and the pathSHOULDbe the collection,/api/v1/{resource plural}. - When the service generates the ID, the request
MUSTomitid. - APIs that support create-or-update
MUSTdo so throughPUT(see ADR-0044). - On success, APIs
SHOULDreturn201butMAYreturn202or204.
| Status | Meaning | Body |
|---|---|---|
201 Created | The resource was created. | The latest representation of the resource. |
202 Accepted | The resource is scheduled to be created. | The job scheduled to create it (ADR-0045). |
204 No Content | The resource was created. | Nothing. |
POST /api/v1/users
Content-Type: application/json
{
"data": {
"attributes": {
"firstName": "Bob",
"lastName": "Smith"
},
"type": "user"
}
}
Creating many resources at once is a bulk create (see ADR-0046).
Positive consequences
- One round trip returns everything a caller needs about the new resource.
- Creation looks the same on every API.
Negative consequences
201responses carry the full representation, which is wasted when the caller does not need it.204remains available for that case.