API credentials
An overview of Commerce Layer's API credentials types and how generate them
Last updated
An overview of Commerce Layer's API credentials types and how generate them
Last updated
To use Commerce Layer API you need to be in the first place. This means you need to get a valid access token. The permissions you're granted authenticating with that token are determined by the type of API client you used to get it. Three different types are currently available in order to get your credentials: sales channel, integration, and webapp. Which one to use depends on your specific use case.
Sales channels are used to build any customer touchpoint (e.g. your storefront with a fully-functional shopping cart and checkout flow).
Sales channels grant non-confidential (public) API credentials. They can authenticate by providing just a client ID and their are restricted so that they can be safely used client-side and their tokens exposed to the public without any risks. For example, they can access only one order at a time (the one associated with the shopping cart you're about to checkout, identified by a not guessable, unique hashID) and respond with a 401 Unauthorized
error if you try to request a list of orders.
Sales channels require a when requesting their access tokens. This way all the API call results are automatically filtered based on the specified scope. In particular:
Only the SKUs that are sellable in that market are returned (to be sellable in a market an SKU must have a price in the market's price list and at least one stock item in one of the market's stock locations, regardless of its quantity).
Only the prices associated with that market's price list are returned.
The stock availability is calculated by checking only the stock locations associated with that market (e.g. only the stock items associated with that market's stock locations are returned).
Integrations are used to develop backend integrations with any 3rd-party system.
Integrations provide confidential API credentials. They need a client ID and a client secret to authenticate and can have one of two :
Read-only — to perform GET
requests on any single resource or list of resources.
Admin — to perform any CRUD (create, retrieve, update, or delete) action on any resource.
Webapps are used to develop custom web apps or services for your users, extending Commerce Layer backend with any functionality that is not provided out of the box.
Head over to the API credentials section by clicking on the related item under the Developers dropdown in the nav menu sidebar on the left of your dashboard. The list of your current available API credentials will be displayed. You can access each one individually to update or delete them. To create a new one, click on + New on the top right of the list:
The following page is where you can select the kind of API credentials you want to create.
To create a sales channel, select the Sales channel card, give your new API credentials a meaningful name, and click on the Create button:
On successful creation, you will enter the details page, where you can find and copy to clipboard your API credentials (client ID, base endpoint, and allowed scopes):
To create an integration, select the Integration card, give your new API credentials a meaningful name, choose its role from the related dropdown, and click on the Create button:
On successful creation, you will enter the details page, where you can find and copy to clipboard your API credentials (client ID, client secret, and base endpoint):
On successful creation, you will enter the details page, where you can find and copy to clipboard your API credentials (client ID, client secret, and base endpoint):
Webapps let you execute the OAuth 2.0 grant flow to get an access token after a user authorizes an app. They don't come with their own , since they get the set of permissions of the authenticated user.
The Core API endpoint is read-only, meaning that by using the API you can only the information about the API credentials within the current scope. The full set of CRUD operations (create, update, and delete) on all your API credentials are available via the or via the admin Dashboard, as shown in the screenshots below.
To create a webapp, select the Webapp card, give your new API credentials a meaningful name, insert the redirect URI (necessary for the flow), and click on the Create button: