Skip to main content

Getting started

Documentation for all public and administrative Storefront APIs.

Authentication

We use the OAuth 2.0 Authorization Framework to authenticate requests. When your Storefront account is provisioned, you will receive a pair of YOUR_CLIENT_ID and YOUR_CLIENT_SECRET that you need to keep for yourself. You use the YOUR_CLIENT_ID and YOUR_CLIENT_SECRET to authenticate yourself to Storefront, and receive an access token in exchange. That access token must be used in every API call you send.

caution

Never share your YOUR_CLIENT_SECRET!

note

Access tokens are short-lived, meaning: they expire within minutes. Once an access token expires, simply request a new access token by method described below.

User-Scoped and Tenant-Scoped Clients

There are two types of clients. User-scoped clients are always assigned to an individual user. Tenant-scoped clients can be used to execute an API request on behalf of another user.

A user-scoped client is required for APIs that require elevated permissions such as creating new catalogs or modifying vendors. For example, the Admin API requires a user-scoped client.

A tenant-scoped client can be used for APIs that are typically executed by a machine on behalf of a user. An example is to search for a product on behalf of some shopper. It would simply not be suitable to issue a client for each user, especially for organizations with thousands of users.

Tenant-scoped clients typically allow to pass the email address for which the request should be executed. Please refer to the actual documentation if and how a user-scoped or a tenant-scoped client are permitted.

Issuing an Access Token

Here are the steps towards getting yourself an access token.

Prepare a HTTP request like so:

  1. Set the URL to https://YOUR_DOMAIN/oauth/authorize.
  2. Set the Content-Type header to application/x-www-form-urlencoded.
  3. Set the grant_type=client_credentials as a parameter.
  4. Set the client_id=YOUR_CLIENT_ID as a parameter.
  5. Set the client_secret=YOUR_CLIENT_SECRET as a parameter.
  6. (optional) For tenant-scoped clients, set the email=YOUR_EMAIL_ADDRESS as a parameter.
  7. Send the HTTP request via HTTP POST.

Examples

curl --request POST \
--url 'https://YOUR_DOMAIN/oauth/authorize' \
--header 'content-type: application/x-www-form-urlencoded' \
--data grant_type=client_credentials \
--data client_id=YOUR_CLIENT_ID \
--data client_secret=YOUR_CLIENT_SECRET

Parameters

ParameterDescription
grant_typeSet this to client_credentials to ask for the OAuth 2.0 Client Credentials flow.
client_idYour Storefront Client ID. You can find this in the settings tab of your account.
client_secretYour Storefront Client Secret. You can find this in the settings tab of your account.
emailOnly required if the Client is tenant-scoped.

Response

If everything goes well, you will receive a successful HTTP response with status 200 OK with a payload containing the access_token, token_type, and expires_in values:

{
"access_token": "HH3wr4...Neuz2PI",
"token_type": "bearer",
"expires_in": 300
}

Notice that the expires_in specifies the number of seconds until this access token expires.

note

If your access token is expired, you'll get a HTTP response with status 401 Unauthorized.

Errors

In case of an error, you can use the HTTP status code and the response body to find out what went wrong.

HTTP Status CodeDescription
400 Bad RequestThe server understood your request but is unable to complete it, e.g. because a required parameter is missing.
401 UnauthorizedYou sent invalid credentials.
500 Internal Server ErrorSomething went wrong on our side.

The HTTP response body if formatted according to the OAuth 2.0 Specification Section 5.2.

Example:

{
"error": "invalid_request",
"error_description": "Invalid request"
}