Ürün/Hizmet Oluşturma
Yeni ürün/hizmet kaydı oluşturma.
Endpoint
POST /kolaybi/v1/products
Parametreler
Parametre | Tip | Zorunlu | Açıklama |
---|---|---|---|
name | string | Evet | Ürün adı |
code | string | Hayır | Ürün kodu |
barcode | string | Hayır | Barkod numarası |
description | string | Hayır | Ürün açıklaması |
product_type | ProductType | Hayır | Ürün tipi (varsayılan: good) |
vat_rate | VATRate | Hayır | KDV oranı (varsayılan: 20) |
price | number | Hayır | Satış fiyatı |
price_currency | Currency | Hayır | Para birimi |
quantity | number | Hayır | Stok miktarı (varsayılan: 0) |
Örnekler
- cURL
- JavaScript
- PHP
- Python
- C#
# Temel ürün oluşturma
curl -X POST "https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/products" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Channel: YOUR_CHANNEL" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "name=Test Ürün"
# Detaylı ürün oluşturma
curl -X POST "https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/products" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Channel: YOUR_CHANNEL" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "name=Test Ürün&code=URN001&barcode=1234567890&product_type=good&vat_rate=20&price=100.00&price_currency=TRY&quantity=50"
async function createProduct(data) {
const formData = new URLSearchParams(data);
const response = await fetch(
"https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/products",
{
method: "POST",
headers: {
Authorization: `Bearer ${accessToken}`,
Channel: channel,
"Content-Type": "application/x-www-form-urlencoded",
},
body: formData,
}
);
return await response.json();
}
// Temel kullanım
const product = await createProduct({
name: "Test Ürün",
});
// Detaylı kullanım
const detailedProduct = await createProduct({
name: "Test Ürün",
code: "URN001",
barcode: "1234567890",
product_type: "good",
vat_rate: 20,
price: 100.0,
price_currency: "TRY",
quantity: 50,
});
function createProduct($data) {
$url = 'https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/products';
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query($data),
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $accessToken,
'Channel: ' . $channel,
'Content-Type: application/x-www-form-urlencoded'
],
CURLOPT_RETURNTRANSFER => true
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
// Temel kullanım
$product = createProduct([
'name' => 'Test Ürün'
]);
// Detaylı kullanım
$detailedProduct = createProduct([
'name' => 'Test Ürün',
'code' => 'URN001',
'barcode' => '1234567890',
'product_type' => 'good',
'vat_rate' => 20,
'price' => 100.00,
'price_currency' => 'TRY',
'quantity' => 50
]);
import requests
def create_product(data):
url = "https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/products"
headers = {
"Authorization": f"Bearer {access_token}",
"Channel": channel,
"Content-Type": "application/x-www-form-urlencoded"
}
response = requests.post(url, headers=headers, data=data)
return response.json()
# Temel kullanım
product = create_product({
"name": "Test Ürün"
})
# Detaylı kullanım
detailed_product = create_product({
"name": "Test Ürün",
"code": "URN001",
"barcode": "1234567890",
"product_type": "good",
"vat_rate": 20,
"price": 100.00,
"price_currency": "TRY",
"quantity": 50
})
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Newtonsoft.Json;
async Task<dynamic> CreateProductAsync(Dictionary<string, string> data)
{
using var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post,
"https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/products")
{
Content = new FormUrlEncodedContent(data)
};
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
request.Headers.Add("Channel", channel);
var response = await client.SendAsync(request);
var content = await response.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<dynamic>(content);
}
// Temel kullanım
var product = await CreateProductAsync(new Dictionary<string, string>
{
{ "name", "Test Ürün" }
});
// Detaylı kullanım
var detailedProduct = await CreateProductAsync(new Dictionary<string, string>
{
{ "name", "Test Ürün" },
{ "code", "URN001" },
{ "barcode", "1234567890" },
{ "product_type", "good" },
{ "vat_rate", "20" },
{ "price", "100.00" },
{ "price_currency", "TRY" },
{ "quantity", "50" }
});
Yanıt
- Başarılı Yanıt
{
"data": {
"id": 1,
"name": "Test Ürün",
"code": "URN001",
"barcode": "1234567890",
"product_type": "good",
"description": "Test ürün açıklaması",
"price": 100.0,
"price_currency": "TRY",
"vat_rate": 20,
"quantity": 50
}
}
Yanıt Alanları
Alan | Tip | Açıklama |
---|---|---|
id | integer | Oluşturulan ürün ID |
name | string | Ürün adı |
code | string | Ürün kodu |
barcode | string | Barkod |
product_type | string | Ürün tipi |
description | string | Açıklama |
price | number | Fiyat |
price_currency | string | Para birimi |
vat_rate | integer | KDV oranı |
quantity | number | Stok miktarı |
Kurallar
Önemli
- Ürün adı: Zorunlu alan
- KDV oranı: 0, 1, 8, 10, 18, 20 değerlerinden biri
- Fiyat: Pozitif sayı olmalı
- Stok: Negatif olabilir