Skip to main content

Create a Cart Shipping Group

POST Create a Cart Shipping Group

https://useast.api.elasticpath.com/v2/carts/:id/shipping-groups

Use this endpoint to create a cart shipping group. Once you have created a cart shipping group, assign the shipping group to the cart item by associating the cart item with the shipping group ID. This is important because it is necessary to associate items with shipping groups in order to include shipping groups in the corresponding cart, order, and totals.

Use any one of the following endpoints to associate the cart shipping group to the cart item:

note
  • Ensure that the currency of the cart matches with the currency of the cart shipping group. For example, when creating the cart shipping group, the currency must be in USD if the cart currency is in USD.
  • If multiple cart items have the same shipping group ID, the shipping price is only calculated once.

Parameters

Path parameters

NameRequiredTypeDescription
idRequiredstringThe unique identifier of the cart to create a shipping group.

Headers

NameRequiredTypeDescription
AuthorizationRequiredstringThe Bearer token required to get access to the API.
X-MOLTIN-CURRENCYOptionalstringSpecifies the currency to be used other than the store's default currency when creating a cart shipping group and linking it to the desired cart items.

Body

NameRequiredTypeDescription
typeRequiredstringRepresents the type of object being returned. Must be set to shipping_group.
shipping_typeOptionalstringRepresents the type of shipment. The maximum character allowed is 50. For example, UPS Ground, Canada Post Expedited.
tracking_referenceOptionalstringSpecifies the tracking reference of the shipment. The maximum character allowed is 50. For example, ground_1234.
shipping_priceOptionalobjectIncludes shipping_price.base,shipping_price.tax, and shipping_price.fees.
shipping_price.baseOptionalnumberSpecifies the base price of the shipment. If not provided, it is zero.
shipping_price.taxOptionalnumberSpecifies the tax price applied to the shipment. If not provided, it is zero.
shipping_price.feesOptionalnumberSpecifies the shipping fees applied to the shipment. If not provided, it is zero.
delivery_estimateOptionalobjectSpecifies the delivery estimate object.
delivery_estimate.startOptionalstringRepresents the start date of the delivery.
delivery_estimate.endOptionalstringRepresents the end date of the delivery.
addressOptionalobjectSpecifies the details of the shipping address.
address.first_nameOptionalstringSpecifies first name of the shipping recipient.
address.last_nameOptionalstringSpecifies last name of the shipping recipient.
address.company_nameOptionalstringSpecifies company name of the shipping recipient.
address.line_1OptionalstringIndicates first line of the shipping address.
address.line_2OptionalstringIndicates second line of the shipping address.
address.postcodeOptionalstringRepresents postal code of the shipping address.
address.countyOptionalstringSpecifies the county of the shipping address.
address.countryOptionalstringSpecifies the country of the shipping address.
address.regionOptionalstringSpecifies the state, province, or region of the shipping address.
address.instructionsOptionalstringSpecifies shipping instructions.

Request Example

curl -X POST https://useast.api.elasticpath.com/v2/carts/:id/shipping-groups
-H "Authorization: Bearer XXXX" \
-H "Content-Type: application/json" \
-d $ {
"data": {
"type": "shipping_group",
"shipping_type": "UPS Ground",
"tracking_reference": "ground_1234",
"shipping_price": {
"base":500,
"tax":100,
"fees":100
},
"delivery_estimate": {
"start": "2023-04-25T00:00:00.000+00:00",
"end": "2023-04-29T00:00:00.000+00:00"
},
"address": {
"first_name": "Ron",
"last_name": "Swanson",
"phone_number": "",
"company_name": "Ron Swanson Enterprises",
"line_1": "1 Sunny Street",
"line_2": "",
"postcode": "92802",
"county": "Orange",
"country": "US",
"region": "CA",
"instructions": ""
}
}
}

Response Example

201 Created

{
"data": {
"type": "shipping_group",
"id": "eb063818-939a-458f-97a4-2601c0c2b445",
"relation": "cart",
"order_id": "",
"cart_id": "2b5cb684-7fdf-4a50-9e6a-9e880f7150ba",
"shipping_type": "UPS Ground",
"tracking_reference": "ground_1234",
"address": {
"first_name": "Ron",
"last_name": "Swanson",
"company_name": "Ron Swanson Enterprises",
"phone_number": "",
"line_1": "1 Sunny Street",
"line_2": "",
"postcode": "92802",
"county": "Orange",
"country": "US",
"region": "CA",
"instructions": ""
},
"delivery_estimate": {
"start": "2023-04-25T00:00:00Z",
"end": "2023-04-29T00:00:00Z"
},
"created_at": "2023-06-23T16:36:10.71799334Z",
"updated_at": "2023-06-23T16:36:10.717994647Z",
"relationships": {
"cart": {
"data": {
"type": "cart",
"id": "2b5cb684-7fdf-4a50-9e6a-9e880f7150ba"
}
}
},
"meta": {
"shipping_display_price": {
"total": {
"amount": 700,
"currency": "USD",
"formatted": "$7.00"
},
"base": {
"amount": 500,
"currency": "USD",
"formatted": "$5.00"
},
"tax": {
"amount": 100,
"currency": "USD",
"formatted": "$1.00"
},
"fees": {
"amount": 100,
"currency": "USD",
"formatted": "$1.00"
}
}
}
}
}

Errors

When the currency of the cart shipping group does not match the currency of the cart, the following error response is returned:

{
"errors": [
{
"status": 400,
"source": "request",
"title": "Cart Currency Mismatch",
"detail": "This cart uses USD, cannot add shipping group with currency GBP"
}
]
}