Add to Cart
curl --request POST \
--url https://your-store.launchmystore.io/cart/add.js \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"id": {},
"quantity": 123,
"properties": {},
"selling_plan": "<string>"
}
]
}
'import requests
url = "https://your-store.launchmystore.io/cart/add.js"
payload = { "items": [
{
"id": {},
"quantity": 123,
"properties": {},
"selling_plan": "<string>"
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({items: [{id: {}, quantity: 123, properties: {}, selling_plan: '<string>'}]})
};
fetch('https://your-store.launchmystore.io/cart/add.js', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://your-store.launchmystore.io/cart/add.js",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'items' => [
[
'id' => [
],
'quantity' => 123,
'properties' => [
],
'selling_plan' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://your-store.launchmystore.io/cart/add.js"
payload := strings.NewReader("{\n \"items\": [\n {\n \"id\": {},\n \"quantity\": 123,\n \"properties\": {},\n \"selling_plan\": \"<string>\"\n }\n ]\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(string(body))
}HttpResponse<String> response = Unirest.post("https://your-store.launchmystore.io/cart/add.js")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"items\": [\n {\n \"id\": {},\n \"quantity\": 123,\n \"properties\": {},\n \"selling_plan\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://your-store.launchmystore.io/cart/add.js")
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 \"items\": [\n {\n \"id\": {},\n \"quantity\": 123,\n \"properties\": {},\n \"selling_plan\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": 123,
"key": "<string>",
"items_changelog": {}
}Cart
Add to Cart
Add an item to the cart
POST
/
cart
/
add.js
Add to Cart
curl --request POST \
--url https://your-store.launchmystore.io/cart/add.js \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"id": {},
"quantity": 123,
"properties": {},
"selling_plan": "<string>"
}
]
}
'import requests
url = "https://your-store.launchmystore.io/cart/add.js"
payload = { "items": [
{
"id": {},
"quantity": 123,
"properties": {},
"selling_plan": "<string>"
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({items: [{id: {}, quantity: 123, properties: {}, selling_plan: '<string>'}]})
};
fetch('https://your-store.launchmystore.io/cart/add.js', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://your-store.launchmystore.io/cart/add.js",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'items' => [
[
'id' => [
],
'quantity' => 123,
'properties' => [
],
'selling_plan' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://your-store.launchmystore.io/cart/add.js"
payload := strings.NewReader("{\n \"items\": [\n {\n \"id\": {},\n \"quantity\": 123,\n \"properties\": {},\n \"selling_plan\": \"<string>\"\n }\n ]\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(string(body))
}HttpResponse<String> response = Unirest.post("https://your-store.launchmystore.io/cart/add.js")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"items\": [\n {\n \"id\": {},\n \"quantity\": 123,\n \"properties\": {},\n \"selling_plan\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://your-store.launchmystore.io/cart/add.js")
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 \"items\": [\n {\n \"id\": {},\n \"quantity\": 123,\n \"properties\": {},\n \"selling_plan\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": 123,
"key": "<string>",
"items_changelog": {}
}Add to Cart
Adds one or more items to the cart.Add-to-cart is a storefront surface, not part of the OAuth
/api/v1 app
API. It follows the AJAX cart contract: requests are made against the
storefront origin (your store domain), identity is the cart cookie token
(not a Bearer access token), and the response is the flat cart
object — not wrapped in a { status, type, data } envelope. The endpoint
accepts JSON, multipart/form-data, and application/x-www-form-urlencoded
bodies.Request
curl -X POST "https://your-store.launchmystore.io/cart/add.js" \
-H "Content-Type: application/json" \
-H "Cookie: cart=c1-xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx" \
-d '{
"items": [
{
"id": 639664,
"quantity": 2
}
]
}'
const response = await fetch('/cart/add.js', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
items: [
{ id: 639664, quantity: 2 }
]
})
});
const cart = await response.json();
Body Parameters
array
required
Shorthand Format
You can also use the shorthand format for adding a single item (noitems
wrapper):
{
"id": 639664,
"quantity": 2
}
Response
The response is the flat cart object (the same shape returned by Get Cart), reflecting the updated cart after the add. For theme JavaScript, three extra top-level fields are included:integer
Variant ID of the item that was added (used by cart-notification scripts)
string
Line item key of the added/merged line
object
{ added: [{ id, quantity }], removed: [] } describing the changeExample Response
{
"token": "c1-9a3f0c2e-7b1d-4e8a-9f2c-1a2b3c4d5e6f",
"id": 639664,
"key": "639664:default",
"item_count": 2,
"total_price": 5000,
"currency": "USD",
"items": [
{
"key": "639664:default",
"id": 639664,
"product_id": 12001,
"variant_id": 639664,
"title": "Classic T-Shirt",
"variant_title": "Medium / Black",
"quantity": 2,
"price": 2500,
"line_price": 5000,
"sku": "TSHIRT-M-BLK",
"image": {
"src": "https://assets.launchmystore.io/images/tshirt-black.jpg",
"alt": "Black T-Shirt"
},
"properties": {}
}
],
"items_changelog": {
"added": [{ "id": 639664, "quantity": 2 }],
"removed": []
}
}
Adding Items with Properties
Add personalized items with custom properties:{
"items": [
{
"id": 640900,
"quantity": 1,
"properties": {
"Engraving": "Happy Birthday!",
"Gift Wrap": "Yes"
}
}
]
}
Errors
On failure (e.g. variant out of stock) the endpoint returns a standard error body with the real HTTP status:{
"status": 422,
"message": "Variant is out of stock",
"description": "Variant is out of stock"
}
/cart (HTTP 302)
instead of receiving a JSON body.