Cari Hesap Oluşturma
Yeni cari hesap kaydı oluşturma.
Endpoint
POST /kolaybi/v1/associates
Parametreler
Parametre | Tip | Zorunlu | Açıklama |
---|---|---|---|
name | string | Evet | Cari adı (min 2 karakter) |
surname | string | Evet | Cari soyadı (min 2 karakter) |
identity_no | string | Evet | TCKN/VKN numarası (10-11 hane) |
associate_type | AssociateType | Hayır | Cari tipi (varsayılan: customer) |
tax_office | string | Hayır | Vergi dairesi (VKN için) |
phone | string | Hayır | Telefon numarası |
email | string | Hayır | E-posta adresi |
address | string | Hayır | Adres bilgisi |
city | string | Hayır | Şehir |
district | string | Hayır | İlçe |
country | string | Hayır | Ülke |
Örnekler
- cURL
- JavaScript
- PHP
- Python
- C#
# Temel cari hesap oluşturma
curl -X POST "https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/associates" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Channel: YOUR_CHANNEL" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "name=Ahmet&surname=Yılmaz&identity_no=12345678901"
# Detaylı cari hesap oluşturma
curl -X POST "https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/associates" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Channel: YOUR_CHANNEL" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "name=Ahmet&surname=Yılmaz&identity_no=12345678901&associate_type=customer&phone=+905123456789&email=ahmet@example.com&address=Test Mahallesi&city=Istanbul&district=Kadikoy"
async function createAssociate(data) {
const formData = new URLSearchParams(data);
const response = await fetch(
"https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/associates",
{
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 associate = await createAssociate({
name: "Ahmet",
surname: "Yılmaz",
identity_no: "12345678901",
});
// Detaylı kullanım
const detailedAssociate = await createAssociate({
name: "Ahmet",
surname: "Yılmaz",
identity_no: "12345678901",
associate_type: "customer",
phone: "+905123456789",
email: "ahmet@example.com",
address: "Test Mahallesi",
city: "Istanbul",
district: "Kadikoy",
});
function createAssociate($data) {
$url = 'https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/associates';
$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
$associate = createAssociate([
'name' => 'Ahmet',
'surname' => 'Yılmaz',
'identity_no' => '12345678901'
]);
// Detaylı kullanım
$detailedAssociate = createAssociate([
'name' => 'Ahmet',
'surname' => 'Yılmaz',
'identity_no' => '12345678901',
'associate_type' => 'customer',
'phone' => '+905123456789',
'email' => 'ahmet@example.com',
'address' => 'Test Mahallesi',
'city' => 'Istanbul',
'district' => 'Kadikoy'
]);
import requests
def create_associate(data):
url = "https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/associates"
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
associate = create_associate({
"name": "Ahmet",
"surname": "Yılmaz",
"identity_no": "12345678901"
})
# Detaylı kullanım
detailed_associate = create_associate({
"name": "Ahmet",
"surname": "Yılmaz",
"identity_no": "12345678901",
"associate_type": "customer",
"phone": "+905123456789",
"email": "ahmet@example.com",
"address": "Test Mahallesi",
"city": "Istanbul",
"district": "Kadikoy"
})
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> CreateAssociateAsync(Dictionary<string, string> data)
{
using var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/associates")
{
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 associate = await CreateAssociateAsync(new Dictionary<string, string>
{
{ "name", "Ahmet" },
{ "surname", "Yılmaz" },
{ "identity_no", "12345678901" }
});
Yanıt
- Başarılı Yanıt
{
"data": {
"id": 1,
"name": "Ahmet",
"surname": "Yılmaz",
"code": "CAR001",
"identity_no": "12345678901",
"associate_type": "customer",
"phone": "+905123456789",
"email": "ahmet@example.com",
"address": "Test Mahallesi",
"city": "Istanbul",
"district": "Kadikoy",
"country": "Turkey"
}
}
Yanıt Alanları
Alan | Tip | Açıklama |
---|---|---|
id | integer | Oluşturulan cari ID |
name | string | Cari adı |
surname | string | Cari soyadı |
code | string | Cari kodu |
identity_no | string | TCKN/VKN |
associate_type | string | Cari tipi |
phone | string | Telefon |
email | string | E-posta |
address | string | Adres |
city | string | Şehir |
district | string | İlçe |
country | string | Ülke |
Kurallar
Önemli
- Ad/Soyad: En az 2 karakter olmalı
- TCKN: 11 hane olmalı
- VKN: 10 hane olmalı (tax_office zorunlu)
- E-posta: Geçerli format olmalı
- Telefon: Uluslararası format (+90...)