Reassign Products to a Different Category Synchronously
curl --request POST \
--url https://api.fabric.inc/v3/products/actions/change-category \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"products": [
{
"id": "AASSBCC12334FCD12334V"
}
],
"targetCategoryId": "AACCVVV1234567"
}
'import requests
url = "https://api.fabric.inc/v3/products/actions/change-category"
payload = {
"products": [{ "id": "AASSBCC12334FCD12334V" }],
"targetCategoryId": "AACCVVV1234567"
}
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({products: [{id: 'AASSBCC12334FCD12334V'}], targetCategoryId: 'AACCVVV1234567'})
};
fetch('https://api.fabric.inc/v3/products/actions/change-category', 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/products/actions/change-category",
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([
'products' => [
[
'id' => 'AASSBCC12334FCD12334V'
]
],
'targetCategoryId' => 'AACCVVV1234567'
]),
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/products/actions/change-category"
payload := strings.NewReader("{\n \"products\": [\n {\n \"id\": \"AASSBCC12334FCD12334V\"\n }\n ],\n \"targetCategoryId\": \"AACCVVV1234567\"\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/products/actions/change-category")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"products\": [\n {\n \"id\": \"AASSBCC12334FCD12334V\"\n }\n ],\n \"targetCategoryId\": \"AACCVVV1234567\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fabric.inc/v3/products/actions/change-category")
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 \"products\": [\n {\n \"id\": \"AASSBCC12334FCD12334V\"\n }\n ],\n \"targetCategoryId\": \"AACCVVV1234567\"\n}"
response = http.request(request)
puts response.read_body{
"data": [
{
"success": [
{
"id": "AASSBCC12334FCD12334V",
"sku": "XP-123345"
}
],
"errors": [
{
"id": "AASSBCC12334FCD23456A",
"sku": "XP-23456",
"message": [
"Product AASSBCC12334FCD12334V is already published"
]
}
]
}
]
}{
"message": "Request is invalid",
"type": "Bad request",
"errors": [
{
"type": "CLIENT_ERROR",
"message": "Invalid request. Unable to find or create product"
}
]
}{
"type": "UNAUTHORIZED_ERROR",
"message": "The requester is unauthorized"
}{
"type": "REQUEST_DENIED",
"message": "User doesn't have the required permission"
}{
"type": "PAYLOAD_LIMIT_EXCEEDED_ERROR",
"message": "Payload exceeds maximum configured size"
}{
"message": "Internal Server Error",
"type": "SERVER_ERROR"
}Change Category Assignment
Reassign Products to a Different Category Synchronously
To enhance product visibility or improve product organization, you may want to reassign products to a different category. With this endpoint, you can synchronously reassign up to 25 products to a different category. The response will show a list of successful and unsuccessful reassignments
POST
/
products
/
actions
/
change-category
Reassign Products to a Different Category Synchronously
curl --request POST \
--url https://api.fabric.inc/v3/products/actions/change-category \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"products": [
{
"id": "AASSBCC12334FCD12334V"
}
],
"targetCategoryId": "AACCVVV1234567"
}
'import requests
url = "https://api.fabric.inc/v3/products/actions/change-category"
payload = {
"products": [{ "id": "AASSBCC12334FCD12334V" }],
"targetCategoryId": "AACCVVV1234567"
}
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({products: [{id: 'AASSBCC12334FCD12334V'}], targetCategoryId: 'AACCVVV1234567'})
};
fetch('https://api.fabric.inc/v3/products/actions/change-category', 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/products/actions/change-category",
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([
'products' => [
[
'id' => 'AASSBCC12334FCD12334V'
]
],
'targetCategoryId' => 'AACCVVV1234567'
]),
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/products/actions/change-category"
payload := strings.NewReader("{\n \"products\": [\n {\n \"id\": \"AASSBCC12334FCD12334V\"\n }\n ],\n \"targetCategoryId\": \"AACCVVV1234567\"\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/products/actions/change-category")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"products\": [\n {\n \"id\": \"AASSBCC12334FCD12334V\"\n }\n ],\n \"targetCategoryId\": \"AACCVVV1234567\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fabric.inc/v3/products/actions/change-category")
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 \"products\": [\n {\n \"id\": \"AASSBCC12334FCD12334V\"\n }\n ],\n \"targetCategoryId\": \"AACCVVV1234567\"\n}"
response = http.request(request)
puts response.read_body{
"data": [
{
"success": [
{
"id": "AASSBCC12334FCD12334V",
"sku": "XP-123345"
}
],
"errors": [
{
"id": "AASSBCC12334FCD23456A",
"sku": "XP-23456",
"message": [
"Product AASSBCC12334FCD12334V is already published"
]
}
]
}
]
}{
"message": "Request is invalid",
"type": "Bad request",
"errors": [
{
"type": "CLIENT_ERROR",
"message": "Invalid request. Unable to find or create product"
}
]
}{
"type": "UNAUTHORIZED_ERROR",
"message": "The requester is unauthorized"
}{
"type": "REQUEST_DENIED",
"message": "User doesn't have the required permission"
}{
"type": "PAYLOAD_LIMIT_EXCEEDED_ERROR",
"message": "Payload exceeds maximum configured size"
}{
"message": "Internal Server Error",
"type": "SERVER_ERROR"
}Authorizations
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.
Example:
"517fa9dfd42d8b00g1o3k312"
Query Parameters
Body
application/json
Was this page helpful?
