Create a commercetools cart, add line items with custom fields, and transition it to an order using the Carts and Orders API

domain: commercetools.com · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Authenticate with commercetools using the client credentials OAuth flow to obtain an access token scoped to the manage_orders scope
  2. Create a cart by posting to the carts endpoint with the required currency, customer email or customerId, and any desired shipping address
  3. Add line items to the cart using the addLineItem update action, specifying the productId and variantId; if the line items need custom fields, first ensure a custom type is assigned to the cart or line item using the setLineItemCustomType update action
  4. Set custom field values on the line items using the setLineItemCustomField update action with the field name and value matching the type definition
  5. Create an order from the cart by posting to the orders endpoint with the cartId and the cart version; handle the version conflict error by re-fetching the cart version before retrying
  6. Verify the resulting order has the correct state, line items, and custom fields by fetching the order by ID

Known gotchas

Related routes

commercetools cart creation and line items via the Carts API
docs.commercetools.com · 6 steps · unrated
Programmatically edit an existing Shopify order to add a line item using the orderEditBegin / orderEditAddVariant / orderEditCommit flow
shopify.dev · 6 steps · unrated
Build a Shopify cartTransform Function using the update operation to override the price of a cart line item for custom pricing logic
shopify.dev · 6 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans