Base URL
All Storefront API endpoints are called under the following URL:your-shop.de, the domain of the WEBSALE server must be used. This is different from the main domain of the shop. Please clarify the domain with your WEBSALE contact and also note Section 5.
Authentication
Unlike the Admin Interface API, the Storefront API does not require a separate API authentication. Requests to the Storefront API always run in the context of the public shop. Individual endpoints may nevertheless require an active session, e.g. for functions related to the customer account. In these cases, access is not controlled via a separate API login, but via the existing session or the normal login in the frontend.Session handling
For coherent actions in the shop (e.g. building a shopping cart, using a wish list, reading customer-dependent data), a session must be used. The session is the unique ID with which the shop assigns multiple requests to a common context and can thus recognize user-specific data (e.g. shopping cart content and customer assignment). Not all endpoints require an active session. However, sending a session along is allowed at any time and expressly recommended when multiple requests belong to a coherent usage context.Create session
A new session is created via the following endpoint:sessionId or similar) that is reused for further requests.
Passing the session in requests
So that the shop recognizes an existing session, the session ID is then sent along with all further requests in the HTTP headerX-Session.
Example request (raw format)
Example with curl
X-Sessionis the name of the custom header.- The header value is the previously generated session ID.
?session=…), but is exclusively transmitted via the header. This way, the session ID stays out of URLs and browser histories and can be cleanly controlled via the request context.
Effects of the session
Whether a session is required or evaluated depends on the respective endpoint:- For purely public data (e.g. general product information), a request without a session may be possible.
- If a valid session is sent along, endpoints can return user-specific information, e.g.:
- customer-dependent prices,
- already filled shopping carts,
- customer account-dependent settings.
401 Unauthorized or 403 Forbidden).
The exact error handling is described in the section “Error handling”.
Error handling
In the Storefront API, errors are returned uniformly via HTTP status codes and a structured error response in JSON format.- The HTTP status code indicates whether a request was generally successful (2xx) or failed (4xx/5xx).
- The error response in JSON format provides additional details that can be used to specifically evaluate and display errors in the frontend (e.g. incorrect parameters or functional errors during execution).
HTTP status codes
The Storefront API uses the usual HTTP status codes. Typical examples:- 2xx – Success
200 OK– Request successful, response contains data.201 Created– Resource was successfully created.204 No Content– Request successful, but no data is returned.
- 4xx – Client-side errors
400 Bad Request– Request is invalid, e.g. due to incorrect or missing parameters or functional errors.401 Unauthorized– Authentication is missing or invalid.403 Forbidden– Request is authenticated, but not authorized.404 Not Found– Resource or endpoint was not found.
- 5xx – Server-side errors
500 Internal Server Error– Unexpected error in the backend.
Error response
All error messages are returned in JSON format. The response follows a uniform structure that makes it possible to systematically evaluate errors and prepare them for the frontend:Parameter overview error response
| Parameter | Type | Description |
|---|---|---|
error | Short, technical error code at the top level describing the type of error (e.g. invalidParameters, actionFailed). | |
detail | Optional short description of the error, e.g. for logging or technical evaluations. | |
paramErrors | Object with detail information about incorrect parameters. The keys correspond to the parameter names, the values are objects with further information on the respective error. The paramErrors field can be empty depending on the error type. See section Parameter error codes | |
actionErrors | List of functional errors that occurred during the execution of the actual action (e.g. “Review not allowed for this order”). Each entry contains, among other things: - code – technical error code that names the cause, - field – optionally the affected field, - text – meaningful error message for display in the frontend, - details / subCode – optional additional information. The actionErrors field can be empty depending on the error type. See section Action errors |
Parameter error codes (paramErrors)
Parameter errors occur when a request is formally invalid, e.g. because a required field is missing or a value has the wrong format.
In these cases, the API usually returns:
- the HTTP status
400 Bad Request - the error object with
error = "invalidParameters"- one or more entries in
paramErrors
paramErrors.<parameter_name>.type have the following meaning:
| Error code | Type | Description |
|---|---|---|
unknownDataField | An unknown field was sent. | |
invalidFormat | The parameter has an invalid format, e.g. string instead of integer or a non-parsable JSON fragment. | |
invalidValue | The value of the parameter is invalid - e.g. outside the valid range. | |
invalidCombination | Two or more parameters are mutually exclusive. | |
syntaxError | There is a syntax error in the parameter. | |
missing | A required field is missing. | |
readonlyField | An attempt was made to write to a read-only field. | |
duplicateEntry | A value that may occur only once was used multiple times. |
Action errors (actionErrors)
“Action” refers to all API calls that change the “shop state” — that is, usually POST, PUT, or DELETE calls (e.g. add product to cart, create address, subscribe to newsletter, etc.).
Pure read calls (e.g. loading products) are not “actions” and generally do not return these errors.
Action errors occur when the request is formally correct (all parameters are valid), but the requested action still cannot be successfully carried out, e.g.
- No further review may be created for an order
- The specified product cannot be rated in this context
- An action is not allowed for the current state (e.g. item no longer available, minimum quantity not met)
400 Bad Request) is returned.
The error object additionally contains:
- a suitable value in the
errorfield that describes the general error category, e.g.actionFailed, - one or more entries in
actionErrorsthat describe the specific action errorcode– technical error code (e.g.ratingNotAllowed,orderNotFound,cartProductNotAvailable),field– optionally the affected field or entity (e.g.productId,cart),text– meaningful error text that can be displayed directly in the frontend or localized,details– optional object with additional information (e.g. affected IDs, available quantity),subCode– optional sub-code for finer differentiation.
Example
A customer tries to add a product to the cart. The request is formally correct (all parameters present and in the correct format), but the product is no longer available. HTTP response → Status:400 Bad Request
Response body:
- The request is formally correct (
paramErrorsis empty). - The action (add product to cart) could not be carried out (
error = "actionFailed"). - The functional reason is the action error with
code = "cartProductNotAvailable",- an affected field
field = "productId"and - a meaningful error text in
textthat can be displayed directly in the frontend.
actionErrors[].code) can occur at an endpoint is documented at the respective endpoint.
Setting up the Storefront API-based storefront
When a WEBSALE shop is called via its domain (e.g.www.your-shop.de), the storefront is delivered and displayed by default via the WEBSALE template theme.
If the storefront is to be operated instead based on the Storefront API (e.g. with your own frontend framework), corresponding settings are required so that this new storefront is delivered and used.
Please speak with your WEBSALE contact to discuss the necessary settings in detail.