curl --request POST \
--url https://api.loopreturns.com/api/v1/cart \
--header 'Content-Type: application/json' \
--header 'X-Authorization: <api-key>' \
--data '
{
"cart": [
39076568408247
],
"shopify": "c2FtcGxlLXN0cmluZw=="
}
'import requests
url = "https://api.loopreturns.com/api/v1/cart"
payload = {
"cart": [39076568408247],
"shopify": "c2FtcGxlLXN0cmluZw=="
}
headers = {
"X-Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Authorization': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({cart: [39076568408247], shopify: 'c2FtcGxlLXN0cmluZw=='})
};
fetch('https://api.loopreturns.com/api/v1/cart', 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://api.loopreturns.com/api/v1/cart",
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([
'cart' => [
39076568408247
],
'shopify' => 'c2FtcGxlLXN0cmluZw=='
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Authorization: <api-key>"
],
]);
$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://api.loopreturns.com/api/v1/cart"
payload := strings.NewReader("{\n \"cart\": [\n 39076568408247\n ],\n \"shopify\": \"c2FtcGxlLXN0cmluZw==\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Authorization", "<api-key>")
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://api.loopreturns.com/api/v1/cart")
.header("X-Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"cart\": [\n 39076568408247\n ],\n \"shopify\": \"c2FtcGxlLXN0cmluZw==\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.loopreturns.com/api/v1/cart")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"cart\": [\n 39076568408247\n ],\n \"shopify\": \"c2FtcGxlLXN0cmluZw==\"\n}"
response = http.request(request)
puts response.read_body{
"token": "46923497728c9a7b5o8a433zz5c0bbbb683319824778",
"data": {
"cart": [
39076568408247
],
"shopify": "c2FtcGxlLXN0cmluZw=="
}
}{
"errors": "Unauthorized."
}Create Cart
Create a cart object and populate it with one or more product variants. Quantities are not supported — repeat a variant ID to represent a quantity greater than one.
📘 Optional
shopifysnapshotThe
shopifyfield is optional and only needed when the shop is configured to use Shopify Scripts. Most headless stores can omit it.
Required API key scope
- Carts
curl --request POST \
--url https://api.loopreturns.com/api/v1/cart \
--header 'Content-Type: application/json' \
--header 'X-Authorization: <api-key>' \
--data '
{
"cart": [
39076568408247
],
"shopify": "c2FtcGxlLXN0cmluZw=="
}
'import requests
url = "https://api.loopreturns.com/api/v1/cart"
payload = {
"cart": [39076568408247],
"shopify": "c2FtcGxlLXN0cmluZw=="
}
headers = {
"X-Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Authorization': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({cart: [39076568408247], shopify: 'c2FtcGxlLXN0cmluZw=='})
};
fetch('https://api.loopreturns.com/api/v1/cart', 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://api.loopreturns.com/api/v1/cart",
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([
'cart' => [
39076568408247
],
'shopify' => 'c2FtcGxlLXN0cmluZw=='
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Authorization: <api-key>"
],
]);
$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://api.loopreturns.com/api/v1/cart"
payload := strings.NewReader("{\n \"cart\": [\n 39076568408247\n ],\n \"shopify\": \"c2FtcGxlLXN0cmluZw==\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Authorization", "<api-key>")
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://api.loopreturns.com/api/v1/cart")
.header("X-Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"cart\": [\n 39076568408247\n ],\n \"shopify\": \"c2FtcGxlLXN0cmluZw==\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.loopreturns.com/api/v1/cart")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"cart\": [\n 39076568408247\n ],\n \"shopify\": \"c2FtcGxlLXN0cmluZw==\"\n}"
response = http.request(request)
puts response.read_body{
"token": "46923497728c9a7b5o8a433zz5c0bbbb683319824778",
"data": {
"cart": [
39076568408247
],
"shopify": "c2FtcGxlLXN0cmluZw=="
}
}{
"errors": "Unauthorized."
}Authorizations
Body
An array of product variants.
A product variant, provided either as a plain variant ID or as an object with a variant_id.
39076568408247
A Base64-encoded cart snapshot, used to reflect additional transaction details from the commerce provider (e.g. Shopify) such as automatic discounts. Optional — most integrations can omit it.
Loop only consumes this snapshot server-side when the shop is configured
to use Shopify Scripts. When decoded, it is a JSON object shaped like a
subset of the Shopify Ajax cart (/cart.js), including currency,
total_price, total_discount, cart_level_discount_applications, and
per-line items[]. Headless storefronts that don't use Shopify Scripts
should omit this field.
"c2FtcGxlLXN0cmluZw=="