Add Product
Creates a new product. Required: product name, category, brand, and price. Category/brand can be sent as ID or name (missing names are created automatically).
Request Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Yes* | Product name (or use translations) |
category / category_id | string / int | Yes | Category name or ID |
brand / brand_id | string / int | Yes | Brand name or ID |
price | float | Yes* | Sale price (or doviz_price) |
cost | float | No | Cost price |
old_price | float | No | List / crossed-out price |
stock | integer | No | Stock quantity |
active | integer | No | 1 or 0 |
barcode | string | No | Barcode |
stock_code | string | No | SKU / stock code |
description_html | string | No | HTML description |
short_description | string | No | Short text |
vat | float | No | VAT rate |
doviz | string | No | try, usd, eur, xau |
doviz_price | float | No | Price in currency |
cargo_day | integer | No | Shipping days |
label | string | No | Product label |
desi | float | No | Desi / volumetric weight |
translations | object | No | Multi-language fields keyed by lang code |
variations | array | No | Variant rows (sku, options, price, stock) |
Note: After create, upload images via
POST /products/{id}/image. HTTP status on success is 201.
PHP
<?php
$baseUrl = 'https://example.com/api/v1';
$apiKey = 'YOUR_API_KEY';
function apiRequest(string $method, string $url, string $apiKey, ?array $data = null): array
{
$ch = curl_init();
$headers = [
'X-API-Key: ' . trim($apiKey),
'Accept: application/json',
];
if ($data !== null) {
$headers[] = 'Content-Type: application/json';
}
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_SSL_VERIFYPEER => true,
]);
if ($data !== null) {
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data, JSON_UNESCAPED_UNICODE));
}
$response = curl_exec($ch);
$httpCode = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
curl_close($ch);
$decoded = json_decode((string) $response, true);
return [
'http_code' => $httpCode,
'curl_error' => $error,
'response' => is_array($decoded) ? $decoded : $response,
];
}
// Multi-language product with variations
$payload = [
'translations' => [
'tr' => [
'name' => 'Pamuklu Tişört',
'slug' => 'pamuklu-tisort',
'description_html' => '<p>Yumuşak kumaş</p>',
],
'en' => [
'name' => 'Cotton T-Shirt',
'slug' => 'cotton-t-shirt',
'description_html' => '<p>Soft fabric</p>',
],
],
'category' => 'Test Category',
'brand' => 'Test Brand',
'cost' => 50,
'price' => 199.99,
'stock' => 15,
'active' => 1,
'barcode' => '86991233322',
'stock_code' => 'fs123',
'variations' => [
[
'sku' => 'TSH-RED-M',
'barcode' => '8690000001001',
'options' => [
'Color' => 'Red',
'Size' => 'M',
],
'price' => 249.90,
'stock' => 12,
'active' => true,
],
],
];
$result = apiRequest('POST', $baseUrl . '/products', $apiKey, $payload);
$productId = (int) ($result['response']['data']['id'] ?? 0);
print_r($result);
cURL
# Simple create (category / brand by name)
curl -s -X POST \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"name": "Omega 3 Balık Yağı 90 Kapsül",
"category": "Vitamin & Takviye",
"brand": "Nutrof",
"price": 249.90,
"old_price": 299.90,
"stock": 50,
"active": 1,
"barcode": "8690000000888",
"stock_code": "OMEGA3-90",
"description_html": "<p>90 kapsül, soğuk sıkım.</p>"
}' \
"https://example.com/api/v1/products"
# Multi-language + variations
curl -s -X POST \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"translations": {
"tr": { "name": "Pamuklu Tişört", "slug": "pamuklu-tisort", "description_html": "<p>Yumuşak kumaş</p>" },
"en": { "name": "Cotton T-Shirt", "slug": "cotton-t-shirt", "description_html": "<p>Soft fabric</p>" }
},
"category": "Test Category",
"brand": "Test Brand",
"cost": 50,
"price": 199.99,
"stock": 15,
"active": 1,
"barcode": "86991233322",
"stock_code": "fs123",
"variations": [
{
"sku": "TSH-RED-M",
"barcode": "8690000001001",
"options": { "Color": "Red", "Size": "M" },
"price": 249.90,
"stock": 12,
"active": true
}
]
}' \
"https://example.com/api/v1/products"
Sample Response (JSON)
{
"success": true,
"message": "Ürün eklendi",
"lang": "tr",
"data": {
"id": 6,
"name": "Pamuklu Tişört",
"slug": "pamuklu-tisort",
"price": 199.99,
"stock": 15,
"active": 1,
"barcode": "86991233322",
"stock_code": "fs123",
"category_name": "Test Category",
"brand_name": "Test Brand",
"has_variations": true
}
}