Description
A successful POST can create a resource or queue work for later.
Potential impact
Clients may report completion while a job is still pending.
Remediation
Use 201 when the endpoint creates a resource. 202 means it accepted the work, which could still fail. Document how to check the outcome and what data each response returns.
Examples
This OpenAPI 3.0 excerpt adds 201 to createItem.
Before
json
{
"openapi": "3.0.0",
"paths": {
"/item": {
"post": {
"operationId": "createItem",
"summary": "Create item",
"responses": {
"default": {
"description": "Error"
}
}
}
}
}
}
After
json
{
"openapi": "3.0.0",
"paths": {
"/item": {
"post": {
"operationId": "createItem",
"summary": "Create item",
"responses": {
"201": {
"description": "Item created successfully"
},
"default": {
"description": "Error"
}
}
}
}
}
}