Create an optimization workflow - Fabric
Create an optimization workflow
cURL
curl --request POST \
--url https://commerceos.aiagents.fabric.inc/api/v2/optimize/workflows \
--header 'Content-Type: application/json' \
--header 'domain: <domain>' \
--data '
{
"input": {
"artifact": {
"artifact_id": "art_95c650ded4824dc79bb6df16427e4a10"
}
},
"name": "Spring 2026 catalog enrichment",
"origin": "API",
"tags": []
}
'
Python
import requests
url = "https://commerceos.aiagents.fabric.inc/api/v2/optimize/workflows"
payload = {
"input": { "artifact": { "artifact_id": "art_95c650ded4824dc79bb6df16427e4a10" } },
"name": "Spring 2026 catalog enrichment",
"origin": "API",
"tags": []
}
headers = {
"domain": "<domain>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
JavaScript (Fetch)
const options = {
method: 'POST',
headers: {domain: '<domain>', 'Content-Type': 'application/json'},
body: JSON.stringify({
input: {artifact: {artifact_id: 'art_95c650ded4824dc79bb6df16427e4a10'}},
name: 'Spring 2026 catalog enrichment',
origin: 'API',
tags: []
})
};
fetch('https://commerceos.aiagents.fabric.inc/api/v2/optimize/workflows', 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://commerceos.aiagents.fabric.inc/api/v2/optimize/workflows",
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([
'input' => [
'artifact' => [
'artifact_id' => 'art_95c650ded4824dc79bb6df16427e4a10'
]
],
'name' => 'Spring 2026 catalog enrichment',
'origin' => 'API',
'tags' => []
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"domain: <domain>"
],
]);
$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://commerceos.aiagents.fabric.inc/api/v2/optimize/workflows"
payload := strings.NewReader("{\n \"input\": {\n \"artifact\": {\n \"artifact_id\": \"art_95c650ded4824dc79bb6df16427e4a10\"\n }\n },\n \"name\": \"Spring 2026 catalog enrichment\",\n \"origin\": \"API\",\n \"tags\": []\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("domain", "<domain>")
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))
}
Response Status Codes
- 201 - Workflow created
- 400 - Bad request
- 401 - Unauthorized
- 403 - Forbidden
- 404 - Not found
- 422 - Unprocessable entity
- 500 - Internal server error
Example Workflow Response
{
"id": "9349773c-27fe-4d4f-a093-a5793dff8702",
"brand_id": "691df5949676c8e0b1d7b6b3",
"type": "OPTIMIZE",
"origin": "API",
"mode": "prod",
"workflow_type": null,
"status": "PENDING",
"current_step": null,
"current_hitl_gate": null,
"name": "Spring 2026 catalog enrichment",
"tags": [],
"started_at": null,
"completed_at": null,
"last_error": null,
"retry_count": 0,
"workflow_metadata": null,
"progress": null,
"review_summary": {
"total_categories": 0,
"decided_categories": 0,
"pending_categories": 0,
"rerunning_categories": 0,
"rejected_categories": 0,
"ready_for_publish_categories": 0,
"published_categories": 0
},
"reviewer_summary": [],
"created_by": {
"id": "user_xyz",
"type": "user",
"name": "Integration Bot",
"email": "integration@acme.com"
},
"updated_by": {
"id": "user_xyz",
"type": "user",
"name": "Integration Bot",
"email": "integration@acme.com"
},
"created_at": "2026-05-15T10:35:00Z",
"updated_at": "2026-05-15T10:35:00Z"
}
Error Response Example
{
"errors": "<array>",
"message": "Bad request",
"type": "CLIENT_ERROR"
}