Search for multiple carts - Fabric
Search for multiple carts
cURL
curl --request POST \
--url https://api.fabric.inc/v3/carts/search \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-fabric-tenant-id: <x-fabric-tenant-id>' \
--data '
{
"limit": 100,
"offset": 0,
"filter": {
"status": [
"ACTIVE"
],
"orderNumber": "10001",
"customer": {
"id": "109840938",
"sessionId": "3a5fd2d3-5c96-4e57-b069-7ff2a88c1119"
},
"promotionTitles": [
"PROMO_TEST"
],
"updatedAt": {
"start": "2023-06-13T16:50:00.682Z",
"end": "2024-06-13T16:50:00.682Z"
},
"createdAt": {
"start": "2023-06-13T16:50:00.682Z",
"end": "2024-06-13T16:50:00.682Z"
},
"channels": [
"12"
]
}
}
'
Python
import requests
url = "https://api.fabric.inc/v3/carts/search"
payload = {
"limit": 100,
"offset": 0,
"filter": {
"status": ["ACTIVE"],
"orderNumber": "10001",
"customer": {
"id": "109840938",
"sessionId": "3a5fd2d3-5c96-4e57-b069-7ff2a88c1119"
},
"promotionTitles": ["PROMO_TEST"],
"updatedAt": {
"start": "2023-06-13T16:50:00.682Z",
"end": "2024-06-13T16:50:00.682Z"
},
"createdAt": {
"start": "2023-06-13T16:50:00.682Z",
"end": "2024-06-13T16:50:00.682Z"
},
"channels": ["12"]
}
}
headers = {
"x-fabric-tenant-id": "<x-fabric-tenant-id>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
JavaScript - Fetch
const options = {
method: 'POST',
headers: {
'x-fabric-tenant-id': '<x-fabric-tenant-id>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
limit: 100,
offset: 0,
filter: {
status: ['ACTIVE'],
orderNumber: '10001',
customer: {id: '109840938', sessionId: '3a5fd2d3-5c96-4e57-b069-7ff2a88c1119'},
promotionTitles: ['PROMO_TEST'],
updatedAt: {start: '2023-06-13T16:50:00.682Z', end: '2024-06-13T16:50:00.682Z'},
createdAt: {start: '2023-06-13T16:50:00.682Z', end: '2024-06-13T16:50:00.682Z'},
channels: ['12']
}
})
};
fetch('https://api.fabric.inc/v3/carts/search', 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.fabric.inc/v3/carts/search",
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([
'limit' => 100,
'offset' => 0,
'filter' => [
'status' => ['ACTIVE'],
'orderNumber' => '10001',
'customer' => [
'id' => '109840938',
'sessionId' => '3a5fd2d3-5c96-4e57-b069-7ff2a88c1119'
],
'promotionTitles' => ['PROMO_TEST'],
'updatedAt' => [
'start' => '2023-06-13T16:50:00.682Z',
'end' => '2024-06-13T16:50:00.682Z'
],
'createdAt' => [
'start' => '2023-06-13T16:50:00.682Z',
'end' => '2024-06-13T16:50:00.682Z'
],
'channels' => ['12']
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"x-fabric-tenant-id: <x-fabric-tenant-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Go
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.fabric.inc/v3/carts/search"
payload := strings.NewReader("{\n \"limit\": 100,\n \"offset\": 0,\n \"filter\": {\n \"status\": [\n \"ACTIVE\"\n ],\n \"orderNumber\": \"10001\",\n \"customer\": {\n \"id\": \"109840938\",\n \"sessionId\": \"3a5fd2d3-5c96-4e57-b069-7ff2a88c1119\"\n },\n \"promotionTitles\": [\n \"PROMO_TEST\"\n ],\n \"updatedAt\": {\n \"start\": \"2023-06-13T16:50:00.682Z\",\n \"end\": \"2024-06-13T16:50:00.682Z\"\n },\n \"createdAt\": {\n \"start\": \"2023-06-13T16:50:00.682Z\",\n \"end\": \"2024-06-13T16:50:00.682Z\"\n },\n \"channels\": [\n \"12\"\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-fabric-tenant-id", "<x-fabric-tenant-id>")
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))
}
Error Response
{
"type": "BAD_REQUEST",
"message": "x-fabric-tenant-id is required"
}
Authorization
x-fabric-tenant-id string
required
A header used by fabric to identify the tenant making the request. You must include tenant id in the authentication header for an API request to access any of fabric’s endpoints.