API specification
Basic info about endpoints, resources, credentials, and environments
Commerce Layer exposes a fast REST API that lets you add ecommerce to your favorite tech stack.
Commerce Layer API is 100% compliant with the JSON API specification (v1.0). It supports compound documents, sparse fieldsets, resource linking, filtering, sorting, pagination, and more. The JSON API community has shared some client libraries that can help you get started.
The guide that follows is your reference for all the operations that you can perform on the API resources and contains all the information you need to get a comprehensive overview of how it works.
Authentication
All API requests must be authenticated. To get a valid access token you need to send a POST request to the following endpoint:
https://auth.commercelayer.io/oauth/tokenBase endpoint
Once you have a valid token, all API requests must be made over HTTPS to the following base endpoint:
https://yourdomain.commercelayer.ioWhere yourdomain is the unique subdomain of your organization.
Versioning
The Commerce Layer Core API is versioned to support the gradual rollout of new capabilities while maintaining backward compatibility for existing integrations:
Resources introduced by a new version are only available starting from that version.
Resources removed by a new version remain temporarily available but are explicitly deprecated in the API response, and will eventually become unavailable in future versions.
2017-08 is the default version, used whenever the request URL doesn't specify one, so existing integrations keep working unchanged. Newer versions are opt-in: you only get them by requesting them explicitly.
Meta information
Some meta information is automatically provided in the API response. This information is split into two distinct levels:
Document-level meta
The meta object at the document level is present on every successful response, whether it returns a single resource or a collection. Error responses may also include it:
It contains context about the current request:
api_version
The API version used for this request.
api_versions
The list of API versions supported by the requested resource.
mode
Whether the request is in test or live mode.
organization_id
The organization the request belongs to.
trace_id
A unique identifier assigned to the request, carried across all layers and included in every log entry. Use it to correlate all logs belonging to the same request, reconstruct its path across services, and troubleshoot issues without guesswork.
deprecations
The list of deprecation warnings (omitted when none).
If the response refers to a paginated list of records, the document-level meta is enriched with additional pagination info:
record_count
The total number of records matching the request.
page_count
The total number of pages available.
page_number
The current page number.
page_size
The number of records per page.
record_count_estimated
Set to true when record_count and page_count are estimates rather than exact counts (omitted otherwise — see pagination).
Deprecation warnings
When a response includes deprecation warnings, they appear as a list under meta.deprecations at the document level. Each entry describes what is deprecated:
type
What is deprecated: resource, field, or relationship.
name
The name of the deprecated item.
removed_in
The version when it will be hard-removed.
more_info
Additional context or a link to the documentation.
Resource-level meta
The meta object at the resource level is present on every resource object appearing in the response, whether it returns a single resource or a collection:
At the moment it contains one field only:
created_with_version
The API version that was active when this resource was created. Resources created before API versioning was introduced report the version of the current request instead.
Core resources
Commerce Layer commerce API features 400+ endpoints. Check our API reference for the complete and updated list of all the core resources, in detail. For each single resource you will find:
The resource object and its fields, attributes, and relationships.
The allowed CRUD operations you can perform on the related endpoint with basic examples of the request/response format.
Credentials
Commerce Layer implements the industry-standard OAuth 2.0 protocol to manage clients' authorization. It defines three types of API credentials: sales channel, integration, webapp. Which one to use depends on your specific need. You can leverage our how-tos to get started with the most popular use cases.
Environments
For each organization, you can work either in test mode (default) or live mode.
Test mode also provides you with a development environment after the go-live. All API calls are identical between the two environments. Use test or live API credentials to make the switch.
Open-source projects and developer tools
JS SDK, CLI, and React components are available as open-source projects. More libraries and SDKs for the most popular languages are coming soon. We also provide a tested and constantly updated OpenAPI schema you can leverage to build mock servers, auto-generate code, and implement contract testing.
Changelog
To stay up-to-date with any changes we make on Commerce Layer APIs, apps, and open-source projects (including versioning, product releases, new features, and general improvements), make sure to check our changelog.
Last updated