> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://mailchimp.com/developer/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://mailchimp.com/developer/_mcp/server.

# Add cart

POST https://api.mailchimp.com/3.0/ecommerce/stores/{store_id}/carts
Content-Type: application/json

Add a new cart to a store.

Reference: https://mailchimp.com/developer/marketing/api/ecommerce/create-store-cart

## Authentication

- `Authorization` header (bearer token, required) — Authorization using a Mailchimp API key (a.k.a. Bearer token)
- `Authorization` header (bearer token, required) — Authorization using OAuth

## Request

### Path parameters

- `store_id` (string, required) — The store id.

### Body (application/json)

This endpoint expects an object.

- `currency_code` (string, required) — The three-letter ISO 4217 code for the currency that the cart uses.
- `customer` (EcommerceStoresCartsPost, required) — Information about a specific customer. For existing customers include only the `id` parameter in the `customer` object body.
- `id` (30EcommerceStoresStoreIdCartsPostRequestBodyContentApplicationJsonSchemaId, required) — A unique identifier for the cart.
- `lines` (list of 30EcommerceStoresStoreIdCartsPostRequestBodyContentApplicationJsonSchemaLinesItems, required) — An array of the cart's line items.
- `order_total` (30EcommerceStoresStoreIdCartsPostRequestBodyContentApplicationJsonSchemaOrderTotal, required)
- `campaign_id` (string, optional) — A string that uniquely identifies the campaign for a cart.
- `checkout_url` (string, optional) — The URL for the cart. This parameter is required for [Abandoned Cart](https://mailchimp.com/help/create-a-classic-abandoned-cart-email/) automations.
- `tax_total` (30EcommerceStoresStoreIdCartsPostRequestBodyContentApplicationJsonSchemaTaxTotal, optional)

## Response

### 200

- `_links` (list of ECommerceCartLinksItems, optional) — A list of link types and descriptions for the API schema documents.
- `campaign_id` (string, optional) — A string that uniquely identifies the campaign associated with a cart.
- `checkout_url` (string, optional) — The URL for the cart. This parameter is required for [Abandoned Cart](https://mailchimp.com/help/create-a-classic-abandoned-cart-email/) automations.
- `created_at` (datetime, optional) — The date and time the cart was created in ISO 8601 format.
- `currency_code` (string, optional) — The three-letter ISO 4217 code for the currency that the cart uses.
- `customer` (ECommerceCustomer, optional) — Information about a specific customer.
- `id` (string, optional) — A unique identifier for the cart.
- `lines` (list of ECommerceCartLineItem, optional) — An array of the cart's line items.
- `order_total` (double, optional) — The order total for the cart.
- `tax_total` (double, optional) — The total tax for the cart.
- `updated_at` (datetime, optional) — The date and time the cart was last updated in ISO 8601 format.

## Types

### EcommerceStoresCartsPost

Information about a specific customer. For existing customers include only the `id` parameter in the `customer` object body.

- `id` (string, required) — A unique identifier for the customer. Limited to 50 characters.
- `address` (EcommerceStoresCartsPostAddress, optional) — The customer's address.
- `company` (string, optional) — The customer's company.
- `email_address` (string, optional) — The customer's email address.
- `first_name` (string, optional) — The customer's first name.
- `last_name` (string, optional) — The customer's last name.
- `opt_in_status` (boolean, optional) — The customer's opt-in status. This value will never overwrite the opt-in status of a pre-existing Mailchimp list member, but will apply to list members that are added through the e-commerce API endpoints. Customers who don't opt in to your Mailchimp list [will be added as `Transactional` members](https://mailchimp.com/developer/marketing/docs/e-commerce/#customers).

### 30EcommerceStoresStoreIdCartsPostRequestBodyContentApplicationJsonSchemaId

A unique identifier for the cart.

### 30EcommerceStoresStoreIdCartsPostRequestBodyContentApplicationJsonSchemaLinesItems

Information about a specific cart line item.

- `id` (string, required) — A unique identifier for the cart line item.
- `price` (30EcommerceStoresStoreIdCartsPostRequestBodyContentApplicationJsonSchemaLinesItemsPrice, required)
- `product_id` (string, required) — A unique identifier for the product associated with the cart line item.
- `product_variant_id` (string, required) — A unique identifier for the product variant associated with the cart line item.
- `quantity` (integer, required) — The quantity of a cart line item.

### 30EcommerceStoresStoreIdCartsPostRequestBodyContentApplicationJsonSchemaOrderTotal

### 30EcommerceStoresStoreIdCartsPostRequestBodyContentApplicationJsonSchemaTaxTotal

### ECommerceCartLinksItems

This object represents a link from the resource where it is found to another resource or action that may be performed.

- `href` (string, optional) — This property contains a fully-qualified URL that can be called to retrieve the linked resource or perform the linked action.
- `method` (enum, optional) — The HTTP method that should be used when accessing the URL defined in 'href'.
  - Allowed values: `GET`, `POST`, `PUT`, `PATCH`, `DELETE`, `OPTIONS`, `HEAD`
- `rel` (string, optional) — As with an HTML 'rel' attribute, this describes the type of link.
- `schema` (string, optional) — For HTTP methods that can receive bodies (POST and PUT), this is a URL representing the schema that the body should conform to.
- `targetSchema` (string, optional) — For GETs, this is a URL representing the schema that the response should conform to.

### ECommerceCustomer

Information about a specific customer.

- `_links` (list of ECommerceCustomerLinksItems, optional) — A list of link types and descriptions for the API schema documents.
- `address` (ECommerceCustomerAddress, optional) — The customer's address.
- `company` (string, optional) — The customer's company.
- `created_at` (datetime, optional) — The date and time the customer was created in ISO 8601 format.
- `email_address` (string, optional) — The customer's email address.
- `first_name` (string, optional) — The customer's first name.
- `id` (string, optional) — A unique identifier for the customer.
- `last_name` (string, optional) — The customer's last name.
- `opt_in_status` (boolean, optional) — The customer's opt-in status. This value will never overwrite the opt-in status of a pre-existing Mailchimp list member, but will apply to list members that are added through the e-commerce API endpoints. Customers who don't opt in to your Mailchimp list [will be added as `Transactional` members](https://mailchimp.com/developer/marketing/docs/e-commerce/#customers).
- `orders_count` (integer, optional) — The customer's total order count.
- `sms_phone_number` (string, optional) — A US phone number for SMS contact.
- `total_spent` (ECommerceCustomerTotalSpent, optional)
- `updated_at` (datetime, optional) — The date and time the customer was last updated in ISO 8601 format.

### ECommerceCartLineItem

Information about a specific cart line item.

- `_links` (list of ECommerceCartLineItemLinksItems, optional) — A list of link types and descriptions for the API schema documents.
- `id` (string, optional) — A unique identifier for the cart line item.
- `price` (double, optional) — The price of a cart line item.
- `product_id` (string, optional) — A unique identifier for the product associated with the cart line item.
- `product_title` (string, optional) — The name of the product for the cart line item.
- `product_variant_id` (string, optional) — A unique identifier for the product variant associated with the cart line item.
- `product_variant_title` (string, optional) — The name of the product variant for the cart line item.
- `quantity` (integer, optional) — The quantity of a cart line item.

### EcommerceStoresCartsPostAddress

The customer's address.

- `address1` (string, optional) — The mailing address of the customer.
- `address2` (string, optional) — An additional field for the customer's mailing address.
- `city` (string, optional) — The city the customer is located in.
- `country` (string, optional) — The customer's country.
- `country_code` (string, optional) — The two-letter code for the customer's country.
- `postal_code` (string, optional) — The customer's postal or zip code.
- `province` (string, optional) — The customer's state name or normalized province.
- `province_code` (string, optional) — The two-letter code for the customer's province or state.

### 30EcommerceStoresStoreIdCartsPostRequestBodyContentApplicationJsonSchemaLinesItemsPrice

### ECommerceCustomerLinksItems

This object represents a link from the resource where it is found to another resource or action that may be performed.

- `href` (string, optional) — This property contains a fully-qualified URL that can be called to retrieve the linked resource or perform the linked action.
- `method` (enum, optional) — The HTTP method that should be used when accessing the URL defined in 'href'.
  - Allowed values: `GET`, `POST`, `PUT`, `PATCH`, `DELETE`, `OPTIONS`, `HEAD`
- `rel` (string, optional) — As with an HTML 'rel' attribute, this describes the type of link.
- `schema` (string, optional) — For HTTP methods that can receive bodies (POST and PUT), this is a URL representing the schema that the body should conform to.
- `targetSchema` (string, optional) — For GETs, this is a URL representing the schema that the response should conform to.

### ECommerceCustomerAddress

The customer's address.

- `address1` (string, optional) — The mailing address of the customer.
- `address2` (string, optional) — An additional field for the customer's mailing address.
- `city` (string, optional) — The city the customer is located in.
- `country` (string, optional) — The customer's country.
- `country_code` (string, optional) — The two-letter code for the customer's country.
- `postal_code` (string, optional) — The customer's postal or zip code.
- `province` (string, optional) — The customer's state name or normalized province.
- `province_code` (string, optional) — The two-letter code for the customer's province or state.

### ECommerceCustomerTotalSpent

### ECommerceCartLineItemLinksItems

This object represents a link from the resource where it is found to another resource or action that may be performed.

- `href` (string, optional) — This property contains a fully-qualified URL that can be called to retrieve the linked resource or perform the linked action.
- `method` (enum, optional) — The HTTP method that should be used when accessing the URL defined in 'href'.
  - Allowed values: `GET`, `POST`, `PUT`, `PATCH`, `DELETE`, `OPTIONS`, `HEAD`
- `rel` (string, optional) — As with an HTML 'rel' attribute, this describes the type of link.
- `schema` (string, optional) — For HTTP methods that can receive bodies (POST and PUT), this is a URL representing the schema that the body should conform to.
- `targetSchema` (string, optional) — For GETs, this is a URL representing the schema that the response should conform to.

## Examples

**Request**

```json
{
  "currency_code": "string",
  "customer": {
    "id": "string"
  },
  "id": "string",
  "lines": [
    {
      "id": "string",
      "price": 1.1,
      "product_id": "string",
      "product_variant_id": "string",
      "quantity": 1
    }
  ],
  "order_total": 1.1
}
```

**Response**

```json
{
  "_links": [
    {
      "href": "string",
      "method": "GET",
      "rel": "string",
      "schema": "string",
      "targetSchema": "string"
    }
  ],
  "campaign_id": "839488a60b",
  "checkout_url": "string",
  "created_at": "2015-07-15T19:28:00+00:00",
  "currency_code": "string",
  "customer": {
    "_links": [
      {
        "href": "string",
        "method": "GET",
        "rel": "string",
        "schema": "string",
        "targetSchema": "string"
      }
    ],
    "address": {
      "address1": "675 Ponce de Leon Ave NE",
      "address2": "Suite 5000",
      "city": "Atlanta",
      "country": "United States",
      "country_code": "US",
      "postal_code": "30308",
      "province": "Georgia",
      "province_code": "GA"
    },
    "company": "string",
    "created_at": "2015-07-15T19:28:00+00:00",
    "email_address": "string",
    "first_name": "string",
    "id": "string",
    "last_name": "string",
    "opt_in_status": true,
    "orders_count": 4,
    "sms_phone_number": "string",
    "total_spent": 1.1,
    "updated_at": "2015-07-15T19:28:00+00:00"
  },
  "id": "string",
  "lines": [
    {
      "_links": [
        {
          "href": "string",
          "method": "GET",
          "rel": "string",
          "schema": "string",
          "targetSchema": "string"
        }
      ],
      "id": "string",
      "price": 1.1,
      "product_id": "string",
      "product_title": "string",
      "product_variant_id": "string",
      "product_variant_title": "string",
      "quantity": 1
    }
  ],
  "order_total": 1.1,
  "tax_total": 1.1,
  "updated_at": "2015-07-15T19:28:00+00:00"
}
```

**SDK Code**

```python
import requests

url = "https://api.mailchimp.com/3.0/ecommerce/stores/store_id/carts"

payload = {
    "currency_code": "string",
    "customer": { "id": "string" },
    "id": "string",
    "lines": [
        {
            "id": "string",
            "price": 1.1,
            "product_id": "string",
            "product_variant_id": "string",
            "quantity": 1
        }
    ],
    "order_total": 1.1
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.mailchimp.com/3.0/ecommerce/stores/store_id/carts';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"currency_code":"string","customer":{"id":"string"},"id":"string","lines":[{"id":"string","price":1.1,"product_id":"string","product_variant_id":"string","quantity":1}],"order_total":1.1}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.mailchimp.com/3.0/ecommerce/stores/store_id/carts"

	payload := strings.NewReader("{\n  \"currency_code\": \"string\",\n  \"customer\": {\n    \"id\": \"string\"\n  },\n  \"id\": \"string\",\n  \"lines\": [\n    {\n      \"id\": \"string\",\n      \"price\": 1.1,\n      \"product_id\": \"string\",\n      \"product_variant_id\": \"string\",\n      \"quantity\": 1\n    }\n  ],\n  \"order_total\": 1.1\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.mailchimp.com/3.0/ecommerce/stores/store_id/carts")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"currency_code\": \"string\",\n  \"customer\": {\n    \"id\": \"string\"\n  },\n  \"id\": \"string\",\n  \"lines\": [\n    {\n      \"id\": \"string\",\n      \"price\": 1.1,\n      \"product_id\": \"string\",\n      \"product_variant_id\": \"string\",\n      \"quantity\": 1\n    }\n  ],\n  \"order_total\": 1.1\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.mailchimp.com/3.0/ecommerce/stores/store_id/carts")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"currency_code\": \"string\",\n  \"customer\": {\n    \"id\": \"string\"\n  },\n  \"id\": \"string\",\n  \"lines\": [\n    {\n      \"id\": \"string\",\n      \"price\": 1.1,\n      \"product_id\": \"string\",\n      \"product_variant_id\": \"string\",\n      \"quantity\": 1\n    }\n  ],\n  \"order_total\": 1.1\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.mailchimp.com/3.0/ecommerce/stores/store_id/carts', [
  'body' => '{
  "currency_code": "string",
  "customer": {
    "id": "string"
  },
  "id": "string",
  "lines": [
    {
      "id": "string",
      "price": 1.1,
      "product_id": "string",
      "product_variant_id": "string",
      "quantity": 1
    }
  ],
  "order_total": 1.1
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.mailchimp.com/3.0/ecommerce/stores/store_id/carts");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"currency_code\": \"string\",\n  \"customer\": {\n    \"id\": \"string\"\n  },\n  \"id\": \"string\",\n  \"lines\": [\n    {\n      \"id\": \"string\",\n      \"price\": 1.1,\n      \"product_id\": \"string\",\n      \"product_variant_id\": \"string\",\n      \"quantity\": 1\n    }\n  ],\n  \"order_total\": 1.1\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "currency_code": "string",
  "customer": ["id": "string"],
  "id": "string",
  "lines": [
    [
      "id": "string",
      "price": 1.1,
      "product_id": "string",
      "product_variant_id": "string",
      "quantity": 1
    ]
  ],
  "order_total": 1.1
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.mailchimp.com/3.0/ecommerce/stores/store_id/carts")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```