curl --request POST \
--url https://api.fabric.inc/v3/collections/batch \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"collections": [
{
"parentCollectionId": "600f1f77bcf86cd799439011",
"name": "Color",
"localizedProperties": {
"en-US": {
"name": "Color"
},
"en-IN": {
"name": "Colour"
}
},
"isLocalizable": true,
"isRoot": true,
"isLeaf": false,
"attributes": [
{
"id": "78184766610c0e32a86d8757",
"value": "blue"
}
],
"categoryIdsIncluded": [
"917329dfd5288b0011332300, 637329dfd5288b0011332387"
],
"categoryIdsExcluded": [
"637329dfd5288b0011332300",
"74184766610c0e32a86d8758"
],
"productAttributeFilters": [
{
"attributeId": "78184766610c0e32a86d8757",
"condition": "EQUALS",
"value": 2
}
]
}
]
}
'import requests
url = "https://api.fabric.inc/v3/collections/batch"
payload = { "collections": [
{
"parentCollectionId": "600f1f77bcf86cd799439011",
"name": "Color",
"localizedProperties": {
"en-US": { "name": "Color" },
"en-IN": { "name": "Colour" }
},
"isLocalizable": True,
"isRoot": True,
"isLeaf": False,
"attributes": [
{
"id": "78184766610c0e32a86d8757",
"value": "blue"
}
],
"categoryIdsIncluded": ["917329dfd5288b0011332300, 637329dfd5288b0011332387"],
"categoryIdsExcluded": ["637329dfd5288b0011332300", "74184766610c0e32a86d8758"],
"productAttributeFilters": [
{
"attributeId": "78184766610c0e32a86d8757",
"condition": "EQUALS",
"value": 2
}
]
}
] }
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({
collections: [
{
parentCollectionId: '600f1f77bcf86cd799439011',
name: 'Color',
localizedProperties: {'en-US': {name: 'Color'}, 'en-IN': {name: 'Colour'}},
isLocalizable: true,
isRoot: true,
isLeaf: false,
attributes: [{id: '78184766610c0e32a86d8757', value: 'blue'}],
categoryIdsIncluded: ['917329dfd5288b0011332300, 637329dfd5288b0011332387'],
categoryIdsExcluded: ['637329dfd5288b0011332300', '74184766610c0e32a86d8758'],
productAttributeFilters: [{attributeId: '78184766610c0e32a86d8757', condition: 'EQUALS', value: 2}]
}
]
})
};
fetch('https://api.fabric.inc/v3/collections/batch', 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/collections/batch",
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([
'collections' => [
[
'parentCollectionId' => '600f1f77bcf86cd799439011',
'name' => 'Color',
'localizedProperties' => [
'en-US' => [
'name' => 'Color'
],
'en-IN' => [
'name' => 'Colour'
]
],
'isLocalizable' => true,
'isRoot' => true,
'isLeaf' => false,
'attributes' => [
[
'id' => '78184766610c0e32a86d8757',
'value' => 'blue'
]
],
'categoryIdsIncluded' => [
'917329dfd5288b0011332300, 637329dfd5288b0011332387'
],
'categoryIdsExcluded' => [
'637329dfd5288b0011332300',
'74184766610c0e32a86d8758'
],
'productAttributeFilters' => [
[
'attributeId' => '78184766610c0e32a86d8757',
'condition' => 'EQUALS',
'value' => 2
]
]
]
]
]),
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://api.fabric.inc/v3/collections/batch"
payload := strings.NewReader("{\n \"collections\": [\n {\n \"parentCollectionId\": \"600f1f77bcf86cd799439011\",\n \"name\": \"Color\",\n \"localizedProperties\": {\n \"en-US\": {\n \"name\": \"Color\"\n },\n \"en-IN\": {\n \"name\": \"Colour\"\n }\n },\n \"isLocalizable\": true,\n \"isRoot\": true,\n \"isLeaf\": false,\n \"attributes\": [\n {\n \"id\": \"78184766610c0e32a86d8757\",\n \"value\": \"blue\"\n }\n ],\n \"categoryIdsIncluded\": [\n \"917329dfd5288b0011332300, 637329dfd5288b0011332387\"\n ],\n \"categoryIdsExcluded\": [\n \"637329dfd5288b0011332300\",\n \"74184766610c0e32a86d8758\"\n ],\n \"productAttributeFilters\": [\n {\n \"attributeId\": \"78184766610c0e32a86d8757\",\n \"condition\": \"EQUALS\",\n \"value\": 2\n }\n ]\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://api.fabric.inc/v3/collections/batch")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"collections\": [\n {\n \"parentCollectionId\": \"600f1f77bcf86cd799439011\",\n \"name\": \"Color\",\n \"localizedProperties\": {\n \"en-US\": {\n \"name\": \"Color\"\n },\n \"en-IN\": {\n \"name\": \"Colour\"\n }\n },\n \"isLocalizable\": true,\n \"isRoot\": true,\n \"isLeaf\": false,\n \"attributes\": [\n {\n \"id\": \"78184766610c0e32a86d8757\",\n \"value\": \"blue\"\n }\n ],\n \"categoryIdsIncluded\": [\n \"917329dfd5288b0011332300, 637329dfd5288b0011332387\"\n ],\n \"categoryIdsExcluded\": [\n \"637329dfd5288b0011332300\",\n \"74184766610c0e32a86d8758\"\n ],\n \"productAttributeFilters\": [\n {\n \"attributeId\": \"78184766610c0e32a86d8757\",\n \"condition\": \"EQUALS\",\n \"value\": 2\n }\n ]\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fabric.inc/v3/collections/batch")
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 \"collections\": [\n {\n \"parentCollectionId\": \"600f1f77bcf86cd799439011\",\n \"name\": \"Color\",\n \"localizedProperties\": {\n \"en-US\": {\n \"name\": \"Color\"\n },\n \"en-IN\": {\n \"name\": \"Colour\"\n }\n },\n \"isLocalizable\": true,\n \"isRoot\": true,\n \"isLeaf\": false,\n \"attributes\": [\n {\n \"id\": \"78184766610c0e32a86d8757\",\n \"value\": \"blue\"\n }\n ],\n \"categoryIdsIncluded\": [\n \"917329dfd5288b0011332300, 637329dfd5288b0011332387\"\n ],\n \"categoryIdsExcluded\": [\n \"637329dfd5288b0011332300\",\n \"74184766610c0e32a86d8758\"\n ],\n \"productAttributeFilters\": [\n {\n \"attributeId\": \"78184766610c0e32a86d8757\",\n \"condition\": \"EQUALS\",\n \"value\": 2\n }\n ]\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": [
{
"success": [
{
"id": "53184766610c0e32a86d875",
"name": "Color"
}
],
"errors": [
{
"name": "Color",
"message": [
"Category must have valid parentId"
]
}
]
}
]
}{
"message": "Request was invalid",
"type": "Bad request",
"errors": [
{
"type": "CLIENT_ERROR",
"message": "Invalid request"
}
]
}{
"message": "The requester is unauthorized",
"type": "UNAUTHORIZED_ERROR"
}{
"type": "REQUEST_DENIED",
"message": "User doesn't have the required permission"
}{
"type": "CONFLICT",
"message": "Unable to update as there is a conflict with a unique attribute.",
"errors": [
{
"type": "CONFLICT",
"message": "<ID> already exists"
}
]
}{
"type": "PAYLOAD_LIMIT_EXCEEDED_ERROR",
"message": "The payload exceeds maximum configured size"
}{
"type": "SERVER_ERROR",
"message": "Internal Server Error"
}Create Multiple Collections
Collection is an alternative way to organize products compared to the original Category system; they’re created based on merchant’s requirements. This endpoint is used to create a new collection Note: You can create up to 25 collections in a single call.
curl --request POST \
--url https://api.fabric.inc/v3/collections/batch \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"collections": [
{
"parentCollectionId": "600f1f77bcf86cd799439011",
"name": "Color",
"localizedProperties": {
"en-US": {
"name": "Color"
},
"en-IN": {
"name": "Colour"
}
},
"isLocalizable": true,
"isRoot": true,
"isLeaf": false,
"attributes": [
{
"id": "78184766610c0e32a86d8757",
"value": "blue"
}
],
"categoryIdsIncluded": [
"917329dfd5288b0011332300, 637329dfd5288b0011332387"
],
"categoryIdsExcluded": [
"637329dfd5288b0011332300",
"74184766610c0e32a86d8758"
],
"productAttributeFilters": [
{
"attributeId": "78184766610c0e32a86d8757",
"condition": "EQUALS",
"value": 2
}
]
}
]
}
'import requests
url = "https://api.fabric.inc/v3/collections/batch"
payload = { "collections": [
{
"parentCollectionId": "600f1f77bcf86cd799439011",
"name": "Color",
"localizedProperties": {
"en-US": { "name": "Color" },
"en-IN": { "name": "Colour" }
},
"isLocalizable": True,
"isRoot": True,
"isLeaf": False,
"attributes": [
{
"id": "78184766610c0e32a86d8757",
"value": "blue"
}
],
"categoryIdsIncluded": ["917329dfd5288b0011332300, 637329dfd5288b0011332387"],
"categoryIdsExcluded": ["637329dfd5288b0011332300", "74184766610c0e32a86d8758"],
"productAttributeFilters": [
{
"attributeId": "78184766610c0e32a86d8757",
"condition": "EQUALS",
"value": 2
}
]
}
] }
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({
collections: [
{
parentCollectionId: '600f1f77bcf86cd799439011',
name: 'Color',
localizedProperties: {'en-US': {name: 'Color'}, 'en-IN': {name: 'Colour'}},
isLocalizable: true,
isRoot: true,
isLeaf: false,
attributes: [{id: '78184766610c0e32a86d8757', value: 'blue'}],
categoryIdsIncluded: ['917329dfd5288b0011332300, 637329dfd5288b0011332387'],
categoryIdsExcluded: ['637329dfd5288b0011332300', '74184766610c0e32a86d8758'],
productAttributeFilters: [{attributeId: '78184766610c0e32a86d8757', condition: 'EQUALS', value: 2}]
}
]
})
};
fetch('https://api.fabric.inc/v3/collections/batch', 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/collections/batch",
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([
'collections' => [
[
'parentCollectionId' => '600f1f77bcf86cd799439011',
'name' => 'Color',
'localizedProperties' => [
'en-US' => [
'name' => 'Color'
],
'en-IN' => [
'name' => 'Colour'
]
],
'isLocalizable' => true,
'isRoot' => true,
'isLeaf' => false,
'attributes' => [
[
'id' => '78184766610c0e32a86d8757',
'value' => 'blue'
]
],
'categoryIdsIncluded' => [
'917329dfd5288b0011332300, 637329dfd5288b0011332387'
],
'categoryIdsExcluded' => [
'637329dfd5288b0011332300',
'74184766610c0e32a86d8758'
],
'productAttributeFilters' => [
[
'attributeId' => '78184766610c0e32a86d8757',
'condition' => 'EQUALS',
'value' => 2
]
]
]
]
]),
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://api.fabric.inc/v3/collections/batch"
payload := strings.NewReader("{\n \"collections\": [\n {\n \"parentCollectionId\": \"600f1f77bcf86cd799439011\",\n \"name\": \"Color\",\n \"localizedProperties\": {\n \"en-US\": {\n \"name\": \"Color\"\n },\n \"en-IN\": {\n \"name\": \"Colour\"\n }\n },\n \"isLocalizable\": true,\n \"isRoot\": true,\n \"isLeaf\": false,\n \"attributes\": [\n {\n \"id\": \"78184766610c0e32a86d8757\",\n \"value\": \"blue\"\n }\n ],\n \"categoryIdsIncluded\": [\n \"917329dfd5288b0011332300, 637329dfd5288b0011332387\"\n ],\n \"categoryIdsExcluded\": [\n \"637329dfd5288b0011332300\",\n \"74184766610c0e32a86d8758\"\n ],\n \"productAttributeFilters\": [\n {\n \"attributeId\": \"78184766610c0e32a86d8757\",\n \"condition\": \"EQUALS\",\n \"value\": 2\n }\n ]\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://api.fabric.inc/v3/collections/batch")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"collections\": [\n {\n \"parentCollectionId\": \"600f1f77bcf86cd799439011\",\n \"name\": \"Color\",\n \"localizedProperties\": {\n \"en-US\": {\n \"name\": \"Color\"\n },\n \"en-IN\": {\n \"name\": \"Colour\"\n }\n },\n \"isLocalizable\": true,\n \"isRoot\": true,\n \"isLeaf\": false,\n \"attributes\": [\n {\n \"id\": \"78184766610c0e32a86d8757\",\n \"value\": \"blue\"\n }\n ],\n \"categoryIdsIncluded\": [\n \"917329dfd5288b0011332300, 637329dfd5288b0011332387\"\n ],\n \"categoryIdsExcluded\": [\n \"637329dfd5288b0011332300\",\n \"74184766610c0e32a86d8758\"\n ],\n \"productAttributeFilters\": [\n {\n \"attributeId\": \"78184766610c0e32a86d8757\",\n \"condition\": \"EQUALS\",\n \"value\": 2\n }\n ]\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fabric.inc/v3/collections/batch")
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 \"collections\": [\n {\n \"parentCollectionId\": \"600f1f77bcf86cd799439011\",\n \"name\": \"Color\",\n \"localizedProperties\": {\n \"en-US\": {\n \"name\": \"Color\"\n },\n \"en-IN\": {\n \"name\": \"Colour\"\n }\n },\n \"isLocalizable\": true,\n \"isRoot\": true,\n \"isLeaf\": false,\n \"attributes\": [\n {\n \"id\": \"78184766610c0e32a86d8757\",\n \"value\": \"blue\"\n }\n ],\n \"categoryIdsIncluded\": [\n \"917329dfd5288b0011332300, 637329dfd5288b0011332387\"\n ],\n \"categoryIdsExcluded\": [\n \"637329dfd5288b0011332300\",\n \"74184766610c0e32a86d8758\"\n ],\n \"productAttributeFilters\": [\n {\n \"attributeId\": \"78184766610c0e32a86d8757\",\n \"condition\": \"EQUALS\",\n \"value\": 2\n }\n ]\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": [
{
"success": [
{
"id": "53184766610c0e32a86d875",
"name": "Color"
}
],
"errors": [
{
"name": "Color",
"message": [
"Category must have valid parentId"
]
}
]
}
]
}{
"message": "Request was invalid",
"type": "Bad request",
"errors": [
{
"type": "CLIENT_ERROR",
"message": "Invalid request"
}
]
}{
"message": "The requester is unauthorized",
"type": "UNAUTHORIZED_ERROR"
}{
"type": "REQUEST_DENIED",
"message": "User doesn't have the required permission"
}{
"type": "CONFLICT",
"message": "Unable to update as there is a conflict with a unique attribute.",
"errors": [
{
"type": "CONFLICT",
"message": "<ID> already exists"
}
]
}{
"type": "PAYLOAD_LIMIT_EXCEEDED_ERROR",
"message": "The payload exceeds maximum configured size"
}{
"type": "SERVER_ERROR",
"message": "Internal Server Error"
}Authorizations
S2S access token (JWT) from fabric Identity service (during Login)
Headers
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. You can retrieve the tenant id , which is also called account id, from Copilot. This header is required.
"517fa9dfd42d8b00g1o3k312"
Unique request ID
"263e731c-45c8-11ed-b878-0242ac120002"
Body
Details to create a collection
Bulk Collection creation
Show child attributes
Show child attributes
Response
OK
Bulk create response
Show child attributes
Show child attributes
Was this page helpful?
