Taslak Gönderi Oluştur
Bu API, taslak (draft) gönderi oluşturmak için kullanılır. Taslak gönderiler, tüm bilgiler henüz hazır olmadığında veya daha sonra işlenmek üzere kaydedilmek istendiğinde kullanılır.
Endpoint Bilgileri
| Özellik |
Değer |
| URL |
{{BASE_URL}}/api/v1/consignments/draft |
| HTTP Metodu |
POST |
| İçerik Türü |
application/json |
| Kimlik Doğrulama |
APIKEY header |
Idempotency: Bu endpoint tekrarlanan istek korumasını destekler. Detaylı bilgi için Idempotency sayfasına bakın.
Taslak Gönderi Nedir?
Taslak gönderiler, normal gönderilerden farklı olarak:
| Özellik |
Normal Gönderi |
Taslak Gönderi |
| Zorunlu Alanlar |
Tüm temel alanlar zorunlu |
Sadece consignor ve consignee zorunlu |
| Kargo Etiketi |
Hemen oluşturulur |
Oluşturulmaz |
| Durum |
SENDED_TO_PROVIDER |
NEW_DRAFT (status: 24) |
| İşlem |
Anında işlenir |
Daha sonra Process ile işlenir |
Ne Zaman Kullanılır?
- Paket bilgileri henüz belli değilse
- Toplu gönderi girişi yapılacaksa
- Gönderi bilgilerinin daha sonra tamamlanması gerekiyorsa
- Sipariş alındığında gönderi kaydı oluşturup, paketleme sonrası işlemek istiyorsanız
İstek Parametreleri
Temel Parametreler
| Parametre Adı |
Parametre Tipi |
Zorunluluk |
Açıklama |
preference |
Integer |
KOŞULLU |
Kargo sağlayıcı tercihi. provider_id belirtilmemişse zorunludur. Kullanılabilir Değerler |
provider_id |
Integer |
KOŞULLU |
Kargo sağlayıcı ID'si. preference 0 ise zorunludur. Kullanılabilir Değerler |
address_resolver_type |
Integer |
OPSİYONEL |
Adres çözümleme türü. Varsayılan: 0. Kullanılabilir Değerler |
reference_no |
String (MAX 255) |
OPSİYONEL |
Referans numarası |
invoice_number |
String (MAX 255) |
OPSİYONEL |
Fatura numarası |
incoterms_type |
Integer |
OPSİYONEL |
Gümrük teslim koşulu. Varsayılan: 2 (DDU). Kullanılabilir Değerler |
specific_shipping_method |
String (MAX 255) |
OPSİYONEL |
Sağlayıcı gönderim metodu. Kullanılabilir Değerler |
generate_provider_barcode |
Bool |
OPSİYONEL |
Otomatik barkod atama. Varsayılan: false |
specific_provider_barcode |
String (MAX 255) |
OPSİYONEL |
Özel barkod tanımlama |
Gönderen Bilgileri
| Parametre Adı |
Parametre Tipi |
Zorunluluk |
Açıklama |
consignor.name |
String (MAX 255) |
OPSİYONEL |
Gönderen adı |
consignor.attention_name |
String (MAX 255) |
OPSİYONEL |
Gönderici diğer ad |
consignor.country |
String (2-3 KARAKTER) |
OPSİYONEL |
Ülke kodu (ISO2 veya ISO3 formatında) |
consignor.state |
String (MAX 100) |
OPSİYONEL |
İl/Eyalet |
consignor.city |
String (MAX 100) |
OPSİYONEL |
İlçe |
consignor.postal_code |
String (MAX 30) |
OPSİYONEL |
Posta kodu |
consignor.address |
String (MAX 1000) |
OPSİYONEL |
Tam adres |
consignor.phone_number |
String (MAX 20) |
OPSİYONEL |
Telefon numarası |
consignor.email |
String (MAX 255) |
OPSİYONEL |
E-posta adresi |
consignor.tax_number |
String (MAX 255) |
OPSİYONEL |
Vergi numarası |
consignor.eori_number |
String (MAX 255) |
OPSİYONEL |
EORI numarası (AB ülkeleri için) |
consignor.state_code |
String (MAX 255) |
KOŞULLU |
Eyalet kodu (ABD, Kanada, İrlanda için zorunlu) |
Alıcı Bilgileri
| Parametre Adı |
Parametre Tipi |
Zorunluluk |
Açıklama |
consignee.name |
String (MAX 255) |
OPSİYONEL |
Alıcı adı |
consignee.attention_name |
String (MAX 255) |
OPSİYONEL |
Alıcı diğer ad |
consignee.country |
String (2-3 KARAKTER) |
OPSİYONEL |
Ülke kodu (ISO2 veya ISO3 formatında) |
consignee.state |
String (MAX 100) |
OPSİYONEL |
İl/Eyalet |
consignee.city |
String (MAX 100) |
OPSİYONEL |
İlçe |
consignee.postal_code |
String (MAX 30) |
OPSİYONEL |
Posta kodu |
consignee.address |
String (MAX 1000) |
OPSİYONEL |
Tam adres |
consignee.phone_number |
String (MAX 20) |
OPSİYONEL |
Telefon numarası |
consignee.email |
String (MAX 255) |
OPSİYONEL |
E-posta adresi |
consignee.tax_number |
String (MAX 255) |
OPSİYONEL |
Vergi numarası |
consignee.eori_number |
String (MAX 255) |
OPSİYONEL |
EORI numarası |
consignee.state_code |
String (MAX 255) |
KOŞULLU |
Eyalet kodu (ABD, Kanada, İrlanda için zorunlu) |
Paket Bilgileri (Opsiyonel)
Taslak gönderilerde paket bilgileri opsiyoneldir. Daha sonra Taslak Güncelle veya Process aşamasında eklenebilir.
| Parametre Adı |
Parametre Tipi |
Zorunluluk |
Açıklama |
packages.package_type |
Integer |
OPSİYONEL |
Paket türü. 1 (Box) veya 2 (Envelope) |
packages.provider_packaging_type |
String |
OPSİYONEL |
Sağlayıcı özel paketleme türü |
packages.post_type |
Integer |
OPSİYONEL |
Gönderi türü |
packages.weight |
Float |
OPSİYONEL |
Paket ağırlığı (kg) |
packages.length |
Float |
OPSİYONEL |
Paket uzunluğu (cm) |
packages.width |
Float |
OPSİYONEL |
Paket genişliği (cm) |
packages.height |
Float |
OPSİYONEL |
Paket yüksekliği (cm) |
packages.dangerous_goods |
Boolean |
OPSİYONEL |
Tehlikeli madde içeriyor mu? |
Paket İçerik Bilgileri (Opsiyonel)
| Parametre Adı |
Parametre Tipi |
Zorunluluk |
Açıklama |
packages.items.description |
String (MAX 255) |
OPSİYONEL |
Ürün açıklaması |
packages.items.gtip |
String (MAX 16) |
OPSİYONEL |
GTİP kodu (yurtdışı için) |
packages.items.origin |
String (2-3 KARAKTER) |
OPSİYONEL |
Menşei ülke |
packages.items.currency_code |
String (3 KARAKTER) |
OPSİYONEL |
Para birimi kodu |
packages.items.unit_price |
Float |
OPSİYONEL |
Birim fiyat |
packages.items.quantity |
Integer |
OPSİYONEL |
Miktar |
packages.items.category |
String (MAX 255) |
OPSİYONEL |
Kategori |
Döküman Bilgileri (Opsiyonel)
| Parametre Adı |
Parametre Tipi |
Zorunluluk |
Açıklama |
documents.id |
Integer |
ZORUNLU |
Daha önce yüklenmiş döküman ID'si |
Ek Hizmet Bilgileri (Opsiyonel)
| Parametre Adı |
Parametre Tipi |
Zorunluluk |
Açıklama |
special_services.service_type |
String |
ZORUNLU |
Hizmet tipi (örn. CASH_ON_DELIVERY) |
special_services.details.$dinamik |
Dinamik |
KOŞULLU |
Her hizmet tipi için dinamik parametreler |
Not: Ek hizmetler hakkında detaylı bilgi için Ek Hizmetler sayfasını inceleyin.
Örnek Kullanım
Minimal Taslak Oluşturma (Sadece Adres Bilgileri)
curl -X POST "{{BASE_URL}}/api/v1/consignments/draft" \
-H "Content-Type: application/json" \
-H "APIKEY: {{APIKEY}}" \
-d '{
"provider_id": 7,
"preference": 0,
"consignor": {
"name": "Gönderen Firma A.Ş.",
"country": "TR",
"state": "İstanbul",
"city": "Kadıköy",
"postal_code": "34758",
"address": "Moda Caddesi No:1",
"phone_number": "+902161234567",
"email": "info@firma.com"
},
"consignee": {
"name": "Hans Mueller",
"country": "DE",
"state": "Hamburg",
"city": "Altona",
"postal_code": "22765",
"address": "Beispielstraße 123",
"phone_number": "+4940123456",
"email": "hans@example.de"
}
}'
<?php
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', '{{BASE_URL}}/api/v1/consignments/draft', [
'headers' => [
'Content-Type' => 'application/json',
'APIKEY' => '{{APIKEY}}'
],
'json' => [
'provider_id' => 7,
'preference' => 0,
'consignor' => [
'name' => 'Gönderen Firma A.Ş.',
'country' => 'TR',
'state' => 'İstanbul',
'city' => 'Kadıköy',
'postal_code' => '34758',
'address' => 'Moda Caddesi No:1',
'phone_number' => '+902161234567',
'email' => 'info@firma.com'
],
'consignee' => [
'name' => 'Hans Mueller',
'country' => 'DE',
'state' => 'Hamburg',
'city' => 'Altona',
'postal_code' => '22765',
'address' => 'Beispielstraße 123',
'phone_number' => '+4940123456',
'email' => 'hans@example.de'
]
]
]);
$body = json_decode($response->getBody(), true);
// Taslak ID'sini saklayın - daha sonra process için kullanılacak
$draftId = $body['data']['id'];
$draftUuid = $body['data']['uuid'];
print_r($body);
<?php
$payload = [
'provider_id' => 7,
'preference' => 0,
'consignor' => [
'name' => 'Gönderen Firma A.Ş.',
'country' => 'TR',
'state' => 'İstanbul',
'city' => 'Kadıköy',
'postal_code' => '34758',
'address' => 'Moda Caddesi No:1',
'phone_number' => '+902161234567',
'email' => 'info@firma.com'
],
'consignee' => [
'name' => 'Hans Mueller',
'country' => 'DE',
'state' => 'Hamburg',
'city' => 'Altona',
'postal_code' => '22765',
'address' => 'Beispielstraße 123',
'phone_number' => '+4940123456',
'email' => 'hans@example.de'
]
];
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => '{{BASE_URL}}/api/v1/consignments/draft',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'APIKEY: {{APIKEY}}'
]
]);
$response = curl_exec($ch);
$result = json_decode($response, true);
// Taslak ID'sini saklayın
$draftId = $result['data']['id'];
curl_close($ch);
Tam Taslak Oluşturma (Paket Bilgileri Dahil)
{
"provider_id": 7,
"preference": 0,
"incoterms_type": 2,
"reference_no": "ORDER-2024-001",
"consignor": {
"name": "Gönderen Firma A.Ş.",
"country": "TR",
"state": "İstanbul",
"city": "Kadıköy",
"postal_code": "34758",
"address": "Moda Caddesi No:1",
"phone_number": "+902161234567",
"tax_number": "1234567890"
},
"consignee": {
"name": "Hans Mueller",
"country": "DE",
"state": "Hamburg",
"city": "Altona",
"postal_code": "22765",
"address": "Beispielstraße 123",
"phone_number": "+4940123456"
},
"packages": [
{
"package_type": 1,
"post_type": 4,
"weight": 1.5,
"length": 30,
"width": 20,
"height": 15,
"dangerous_goods": false,
"items": [
{
"description": "Electronic Device",
"gtip": "854370900000",
"origin": "TR",
"currency_code": "EUR",
"unit_price": 150.00,
"quantity": 1
}
]
}
]
}
API Cevabı
Başarılı Yanıt
{
"status": true,
"message": "Draft consignment created",
"data": {
"id": 242,
"uuid": "aa203bc1-c2f0-46c3-a635-f59abccd1c4a",
"provider_id": 7,
"preference": 0,
"barcode": null,
"reference_no": null,
"invoice_number": null,
"status": 24,
"status_message": "New draft",
"weight": 0,
"desi": 0,
"consignor": {
"name": "Gönderen Firma A.Ş.",
"attention_name": null,
"country": "Turkey",
"country_iso3": "TUR",
"state": "İstanbul",
"city": "Kadıköy",
"address": "Moda Caddesi No:1",
"postal_code": "34758",
"phone": "+902161234567",
"email": "info@firma.com"
},
"consignee": {
"name": "Hans Mueller",
"attention_name": null,
"country": "Germany",
"country_iso3": "DEU",
"state": "Hamburg",
"city": "Altona",
"address": "Beispielstraße 123",
"postal_code": "22765",
"phone": "+4940123456",
"email": "hans@example.de"
},
"packages": [],
"documents": [],
"special_services": [],
"consignment_type": 2,
"incoterms_type": 2,
"specific_shipping_method": null,
"specific_provider_barcode": null,
"created_at": "2025-05-07 18:14:45",
"updated_at": "2025-05-07 18:14:45"
}
}
Response Alanları
| Alan |
Tip |
Açıklama |
id |
Integer |
Taslak gönderi ID'si |
uuid |
String |
Taslak gönderi UUID'si |
status |
Integer |
Gönderi durumu. 24 = New Draft |
status_message |
String |
Durum açıklaması |
consignment_type |
Integer |
Gönderi tipi. 1 = Yurtiçi, 2 = Yurtdışı |
incoterms_type |
Integer |
Incoterms değeri |
packages |
Array |
Paket listesi (boş olabilir) |
Hata Yanıtları
{
"status": false,
"errors": [
{
"message": "reference_no: Reference number \"ORDER-2024-001\" has already been used. Please provide a unique reference number."
}
]
}
Yaygın Hata Senaryoları
| Hata |
Açıklama |
Çözüm |
Reference number has already been used |
Aynı referans daha önce kullanılmış |
Benzersiz referans numarası kullanın |
When preference is specific, provider_id not be null |
preference: 0 ise provider_id zorunlu |
provider_id ekleyin veya farklı preference kullanın |
Sonraki Adımlar
Taslak gönderi oluşturduktan sonra:
- Güncelleme: Eksik bilgileri Taslak Güncelle ile tamamlayın
- İşleme: Tüm bilgiler tamamlandığında Taslak İşle ile gönderiyi aktif hale getirin
- Silme: Gerekirse taslağı silebilirsiniz
Önemli: Taslak gönderiler işlenene kadar kargo firmasına iletilmez ve etiket oluşturulmaz.