Code examples

Creating an order

Order creation requires accurate line item details, validated pricing, and current inventory checks. Follow this pattern for reliable order processing.


Use case

Convert a saved cart into a fulfillment order once pricing and inventory are verified.


Example: create a fulfillment order

const baseUrl = 'https://api.hlc.bike/us/v3.0'
const apiKey = process.env.HLC_API_KEY

const order = {
  reference: 'WEB-ORDER-1042',
  items: [
    { sku: '020056-07', quantity: 2 },
    { sku: '861070-L-001', quantity: 1 },
  ],
  documentLanguage: 'en',
}

const res = await fetch(`${baseUrl}/Orders/Create/FulFillment`, {
  method: 'POST',
  headers: {
    ApiKey: apiKey,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(order),
})

const result = await res.json()
Previous
Getting prices