Handling errors
The complete list of response codes
Commerce Layer uses HTTP response codes to show the success or failure of an API request.
Codes in the
2xx
range indicate success.Codes in the
4xx
range indicate an error that failed given the information provided (e.g. bad request, failed validation, or authentication).Codes in the
5xx
range indicate an unhandled error (these are rare and should never happen).
200
OK
The request was successfully processed and everything worked as expected.
201
Created
The request was successfully processed and a new resource was created.
204
No content
The request was successfully processed and an existing resource was deleted.
400
Bad request
401
Unauthorized
The access token was not present in the request, was expired, or didn't have enough permissions.
404
Not found
405
Method not allowed
The request method is known by the server but has been disabled and cannot be used.
406
Not acceptable
The Accept header was not correctly set to application/vnd.api+json
409
Record not unique
The performed operation violates a unique constraint. You can safely ignore this warning.
415
Unsupported media type
The Content-type header was not correctly set to application/vnd.api+json
422
Unprocessable entity
423
Locked
The resource could not be deleted due to integrity constraints.
429
Too many requests
500
Internal server error
Something went wrong on our end and is being investigated by our engineers.
The error object
All the 4xx
responses include an error object in the response body. The object contains the list of errors
with some extra information.
Correct error handling is important. We recommend writing code that gracefully handles all possible API exceptions.
Examples
401 Unauthorized
The following request tries to retrieve (with sales channel API credentials) an SKU that's not sellable in the market the app has in scope (i.e. an SKU that doesn't have a price in one of the market's price list and at least one stock item in one of the market's stock location):
422 Unprocessable Entity
The following request tries to update the quantity of a line item with an out-of-range value:
400 Bad Request
The following request tries to update a price but the ID in the URL does not match the one in the body:
404 Not Found
The following request tries to fetch a non-existing SKU:
Last updated