Errors
The Admin API uses HTTP status codes to indicate the success or failure of an API request. In general:
2xx
range indicates success3xx
range indicates a redirect4xx
range indicates a failure caused by the provided information-
5xx
range indicates a problem with our servers
If an error occurs, the API responds with an error response containing a list of errors. In most cases, the list will contain a single error. However, some endpoints might return multiple errors.
The status codes, error responses, and error entities are provided in the tables below.
HTTP Status Codes
200s status codes
HTTP Status Code | Description |
---|---|
200 OK | Request has been fulfilled. |
201 Created | Request has been fulfilled and new resource created. |
204 No Content | There is no content for a successful request. |
206 Partial Content | Request has been fulfilled for the partial content requested. |
400s status codes
HTTP Status Code | Description |
---|---|
400 Bad Request | Missing or invalid parameter. |
401 Unauthorized | No or invalid access token. |
403 Forbidden | You have not been unauthorized to access the resource. |
404 Not Found | Requested resource doesn't exist. |
408 Request Timeout | The client failed to complete the request within a certain timeframe. |
409 Conflict | Requested resource could not be processed because of a conflict. |
412 Precondition Failed | Preconditions were not met. |
413 Payload Too Large | The request entity is larger than limits defined by server. |
424 Failed Dependency | Request failed due to a failure of dependency. |
500s status codes
HTTP status code | Description |
---|---|
500 Internal Server Error | Unexpected error on Storefront API server. |
502 Bad Gateway | Server got an invalid response. |
503 Service Unavailable | Service unavailable due to internal errors. |
504 Gateway Timeout | The server took too long to respond. |
Complete list of HTTP status codes.
Error Response
Parameter | Details |
---|---|
errorKey | String A key that describes the occurred error. |
message | String Description of the error. |
context | Array Additional context to interpret the error message. |
Error Entity
Parameter | Details |
---|---|
field | String Describe field where the error occurred. |
description | String Some human-readable description of the error. |
Error Handling
When using a SDK to consume the Admin API endpoints, it is good practice to catch possible errors.
try {
$productCollection = $adminApi->products->all();
} catch (ApiErrorException $apiException) {
// Get the first error
echo $apiException->getFirstError()->getMessage();
// Get all errors
foreach ($apiException->getErrors() as $error) {
echo $error->getMessage();
}
} catch (Exception $exception) {
// e.g. Connection problems
}