Test the create family endpoint with your own data
Create a new product family
This endpoint allows you to create a new product family to group products with similar characteristics.
Families enable you to define family-specific attributes that apply only to products within that family.
POST https://api.commerceclarity.com/api/v1/families/create
| Parameter | Type | Required | Description |
|---|---|---|---|
name |
string | Required | Display name for the family |
family_id |
string | Required | Unique identifier (slug) for the family |
description |
string | Optional | Optional description for the family |
is_enabled |
boolean | Optional | Whether the family is active (default: true) |
curl -X POST "https://api.commerceclarity.com/api/v1/families/create" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Electronics",
"family_id": "electronics",
"description": "Electronic devices and accessories",
"is_enabled": true
}'
$client = new \GuzzleHttp\Client();
$response = $client->post('https://api.commerceclarity.com/api/v1/families/create', [
'headers' => [
'Authorization' => 'Bearer ' . $apiToken,
'Content-Type' => 'application/json',
],
'json' => [
'name' => 'Electronics',
'family_id' => 'electronics',
'description' => 'Electronic devices and accessories',
'is_enabled' => true
]
]);
$data = json_decode($response->getBody(), true);
const response = await fetch('https://api.commerceclarity.com/api/v1/families/create', {
method: 'POST',
headers: {
'Authorization': `Bearer ${apiToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Electronics',
family_id: 'electronics',
description: 'Electronic devices and accessories',
is_enabled: true
})
});
const data = await response.json();
{
"status": "success",
"message": "Family created successfully",
"data": {
"_id": "507f1f77bcf86cd799439011",
"name": "Electronics",
"family_id": "electronics",
"description": "Electronic devices and accessories",
"is_enabled": true,
"user_id": "507f1f77bcf86cd799439010",
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
}
{
"status": "error",
"message": "Validation failed",
"errors": {
"family_id": ["The family_id has already been taken."]
}
}