Authorization - Session VS No Session
Last updatedGet the data you need.#
The API is designed to allow you to keep as little state as possible on the frontend.
-
All the mutations affecting the selection will always return the selection and session, allowing you to always be able update your frontend components to reflect the last saved state in Centra. So there's no need for an extra query to refresh your mini cart and session state.
-
All lists return pagination information.
-
DisplayItem.filters reflect which filters are available and which have been applied.
Separation of concerns with session and no session mode#
The DTC API can be configured in two different modes, depending on the use case. Both modes require you to send an Authorization with the Bearer token from the plugin. One plugin can only be configured to operate in one specific mode.
NOTE: When you are querying data using a session scoped token, the data will always be returned based on the current market and price list. Translations of translatable fields will automatically be promoted to the corresponding root field, given that the translation is not empty based on the session language. If you have entered a translation for any value, the translation will always be used for the corresponding language, even if the surrounding entities are not translated (e.g. parent category name is not translated, but child category is - then the translated name for the child category will be used, but the non-translated for the parent category).
When using a no session scoped token this also applies if you apply just one languageCode, market or price list property. This allows you to effectively build a cache using the key or key(s) most suitable for you.
Session mode#
Session mode allows shoppers to perform cart, checkout and post-checkout operations and browse the catalog based on the market, price list and language of the shopper’s session. This mode also allows customers to login. Upon the first request using the bearer token you will receive a new token back for further use for the current shopper. Currently this is the only mode you can use in order to make a purchase. This mode is allowed to be used client-side(*).
(*) Certain fields and operations require you to send an additional shared secret. If a shared secret is provided only server-side, consumption of the API is allowed. The plugin can also be configured to only be allowed to be consumed server-side.
No session mode#
This mode is completely stateless and only exposes data in order for consumers to build their own cache. This mode is only accessible server side, and consuming the API in this mode should only be done in order to populate your cache, not as a means to access all data from a middleware or such.