Other HTTP API updates
Learn about the other recent changes to Composable Commerce APIs, and how they can improve the development of your Projects.
After completing this page, you should be able to:
- Identify how the recent changes affect the use of the Composable Commerce API in your Projects.
Check if a resource exists
Many business flows require you to check whether a resource exists. For example, let's say you want to render a page from your Content Management System (CMS) and part of the data includes a Product. The CMS might give you the basic information required to render the Product, but it cannot tell if the Product is still available in your Project.
Previously, you would have had to send a request to GET the Products to check if they are still available. This would however mean that you would receive the Product data, which is unnecessary in this case.
Developers can now check if a particular resource exists in the project by using a new HEAD method that's available for all our resources. HEAD requests can be faster because the server does not need to send a large body in the response. Developers can use this function either by ID, key, or query predicate for an endpoint. If a resource exists, a 200
OK status is returned; otherwise a 404
Not Found.
Added support for keys for more resources
We added support for the key
field on more resources, for consistency. A key is a semantic identifier that you can control, while an ID is a technical identifier without much meaning outside the internal-facing Composable Commerce code.
We added the key
field to various Cart and Order data types, including:
- Parcel
- Delivery
- LineItem
- CustomLineItem
- LineItemReturnItems
- CustomLineItemReturnItem
- ShoppingListLineItem
- TextLineItem
- TaxRate
To make your development easier and the resulting code more robust, many update actions can now be used with a key instead of the ID identifier only. This affects numerous update actions on Carts, Orders, and Order Edits. Line Item and Custom Line Item-relate update actions have the lineItemKey
and customLineItemKey
fields respectively.
Enhancements to Carts and Orders
Carts and Orders are the heart of digital commerce and Composable Commerce. We're constantly striving to assist you in offering a great shopping experience to your customers. In 2023, we added a number of fields to those endpoints, some of which are as follows:
- You can now use
shippingCustomFields
and set ashippingKey
to reference a Shipping Method for Carts and Orders with a single Shipping Method. - You can now update the inventory mode of a Line Item.
- You can now have taxes on Custom Line Item, with the addition of
taxedPricePortions
on CustomLineItem. - You can now construct predicates that match against
ShippingInfo
on Carts with multiple Shipping Methods, with the introduction ofshippingInfoExists
andforAllShippingInfos
Cart Predicates functions. - You can now set individual external Tax Rates for multiple Shipping Methods within a Line Item, with the introduction of
perMethodExternalTaxRate
on LineItemDraft. - Added support for external tax rates and tax amounts on multiple Shipping Methods using update actions for Carts and Order Edits.
- B2B carts can now be replicated using Replicate Cart in BusinessUnit endpoint in Associate Carts.
Test your knowledge
Reminder about renewal
You have been learning about the changes made to Composable Commerce in 2023. If you own a valid certification from 2023 and have not yet renewed, please contact training@commercetools.com. Self-service renewal is now closed.