API Playground

Test the create family endpoint with your own data

Authentication Required

You need to Login to test the API playground

Create Product Family

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.

Note: This operation does not consume credits
Endpoint URL
POST https://api.commerceclarity.com/api/v1/families/create

Request Parameters

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)

Request Examples

Basic Request
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
  }'
PHP Example (Guzzle HTTP Client)
$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);
JavaScript Example (Fetch API)
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();

Response Example

Success Response
{
  "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"
  }
}
Error Response - Validation
{
  "status": "error",
  "message": "Validation failed",
  "errors": {
    "family_id": ["The family_id has already been taken."]
  }
}