Create Cart
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."
}Cart
Create Cart
Create a cart object and populate it with one or more product variants.
🚧 Create Cart Object
When setting up Shop Now: On-Store for a headless store, be sure to create a base 64-encoded liquid cart object and send it to Loop.
Required API key scope
- Carts
POST
/
cart
Create Cart
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
application/json
An array of product variants.
A product variant, provided either as a plain variant ID or as an object with a variant_id.
Example:
39076568408247
A Base64-encoded liquid cart object, used to reflect any additional transaction details in the commerce provider (e.g. Shopify) such as discounts.
Example:
"c2FtcGxlLXN0cmluZw=="
⌘I