Errors
The HTTP status codes the Storefront API returns and the format of error responses.
The Storefront API uses standard HTTP status codes. Error responses use the problem details format defined by RFC 7807.
Status codes
| Status | Meaning | What to do |
|---|---|---|
200 OK | The request succeeded. | |
201 Created | The resource was created. | |
202 Accepted | The request was accepted and is being processed. The body contains a notificationId. | Poll the notification. |
204 No Content | The request succeeded and there is no body. | |
400 Bad Request | The request is invalid. The errors field lists the invalid fields. | Correct the request. Do not retry it unchanged. |
401 Unauthorized | The API key or the bearer token is missing or invalid. | See Authentication. |
404 Not Found | The resource does not exist in this store. | Check the id and the API key. |
500 Internal Server Error | OneBasket failed to process the request. | Retry with a delay. Contact Stadion support if it continues. |
Error response format
{
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
"title": "Bad request",
"status": 400,
"detail": "One or more validation errors occurred.",
"instance": "/kiosks",
"errors": {
"pageSize": ["The value must be greater than 0."]
}
}| Field | Type | Description |
|---|---|---|
type | string | A URI that identifies the problem type. |
title | string | A short summary of the problem type. |
status | number | The HTTP status code. |
detail | string | An explanation of this occurrence of the problem. |
instance | string | A URI that identifies this occurrence of the problem. |
errors | object | On 400 responses only. Keyed by field name. |
The values in the example above are illustrative. Build your error handling on status and on the keys of errors, not on the text of title or detail.
Failures of asynchronous requests
An asynchronous request can be accepted and still fail later, for example when a provider rejects a product because it is out of stock. That failure is not reported as an HTTP error. It is reported as a notification with status: "failed". See Asynchronous operations.
Retries
- Retry
500responses and network failures with an increasing delay between attempts. - Do not retry
400,401or404responses without changing the request. - Before you retry a request that changes a basket, read the basket first. The first attempt may have succeeded.