Last modified: August 22, 2025
Use the carts API to create and manage data related to ecommerce purchases in HubSpot. This can be especially useful for keeping HubSpot data synced with external ecommerce platforms, such as Shopify and NetSuite.
For example, use the API to sync cart data with Shopify, including associating the cart with an order and contact record.
Create carts
To create a cart, make aPOST
request to crm/v3/objects/cart
.
In the request body, you can include the properties
and associations
objects to set property values and associate the cart with other CRM objects (e.g., contacts and line items). Learn more about order properties and associations below.
Properties
Cart details are stored in cart properties. HubSpot provides a set of default cart properties, but you can also create your own custom properties using the properties API. To include properties when creating a cart, add them as fields in aproperties
object in the request body.For example, the request body below would create a cart with some basic product details based on the information provided by the buyer at checkout.
Associations
You can associate carts with other HubSpot CRM objects at creation by including anassociations
object. You can also use the associations API to update existing carts after creation.
In the associations
array, include the following fields:
Fields | Type | Description |
---|---|---|
toObjectId | String | The ID of the record that you want to associate the cart with. |
associationTypeId | String | A unique identifier to indicate the association type between the cart and the other object. Below are the CRM objects that you can associate orders with, along with their associationTypeId :To see a list of all association types, check out the associations API documentation. Or, you can retrieve each value by making a GET request to /crm/v4/associations/{fromObjectType}/{toObjectType}/labels . |
POST
request body below would create a cart that’s associated with a specific contact and two line items.
Retrieve carts
Depending on the information you need, there are a few ways to retrieve carts:- To retrieve all carts, make a
GET
request to/crm/v3/objects/cart
. - To retrieve a specific cart, make a
GET
request to the above URL and specify a cart ID. For example:/crm/v3/objects/cart/44446244097
. - To retrieve carts that meet a specific set of criteria, you can make a
POST
request to the search endpoint and include filters in the request body. Learn more about searching the CRM.
properties
query parameter in the request URL along with comma-separated property names. For example, making a GET
request to the following URL would result in the response below:
/crm/v3/objects/cart?properties=hs_external_cart_id&hs_external_status
GET
request to crm/v3/properties/cart
.
Learn more about cart properties.
Search for carts by properties
You can use the search endpoint to retrieve carts that meet a specific set of filter criteria. This will be aPOST
request that includes your filter criteria in the request body.
For example, to search for all carts placed at a specific store, you would make a POST
request to crm/v3/objects/cart/search
with the following request body:
Retrieve a cart with associations
To retrieve a cart and the contact associated with it, make aGET
request to:
crm/v3/objects/cart/{cartId}/associations/contact
This will return the IDs of the currently associated contact, along with meta information about the association type.
GET
request to crm/v3/objects/contacts/301
.
filters
array specifies the search criteria, while the properties
array specifies which properties to return.
Update carts
To update a cart, make aPATCH
request to /crm/v3/objects/cart/{cartId}
. In the request body, include a properties
object containing the properties that you want to update.
For example, if you wanted to update a cart after it’s been fulfilled, you could send the following request body:
PUT
request to /crm/v3/objects/cart/{cartId}/associations/{toObjectType}/{toObjectId}/{associationTypeId}
. You can also use the associations API.
See the associations section for
associationTypeId
values for cart-to-object associations. You can also make a GET
request to /crm/v4/associations/{fromObjectType}/{toObjectType}/labels
.To see all a list of all values, check out the associations API documentation.PUT
request to the following URL:
/crm/v3/objects/cart/{cartId}/associations/order/{orderId}/592
The response will return a set of default properties along with an associations
object containing information about the association that you set.
DELETE
request to the following URL:
/crm/v3/objects/cart/{cartId}/associations/{toObjectType}/{toObjectId}/{associationTypeId}
For example, if you wanted to remove an associated line item from a cart, your request URL would be the following:
/crm/v3/objects/cart/{cartId}/associations/line_items/{lineItemId}/590
Cart properties
When managing your cart data, you may want to use some of the common properties in the table below. To get all cart properties, make aGET
request to /crm/v3/properties/cart
. Learn more about using the properties API.
Property name | Label in UI | Description |
---|---|---|
hs_cart_name | Name | The name in an external system. |
hs_external_cart_id | Cart ID | Unique identifier from an external system. |
hs_source_store | Source Store | Data used to identify which store the cart came from. |
hs_external_status | Status | The current status of the cart. |
hs_cart_url | Cart Url | The recovery URL that’s sent to a customer so they can revive an abandoned cart. |
hs_total_price | Total Price | The sum total amount associated with the cart. |
hs_currency_code | Currency Code | The currency code used in the cart. |
hs_cart_discount | Cart Discount | Amount of discount in the cart. |
hs_tags | Tags | A collection of tag strings for the cart. |