Gönderi (Kargo) Oluştur
Açıklama
Section titled “Açıklama” POST
/v1/shipments/0 Alıcı, gönderici ve koli bilgileri girilerek yeni bir kargo taşıma kaydı oluşturulmasını sağlar.
Parametreler
Section titled “Parametreler”| Parametre | Konum | Tip | Açıklama | Varsayılan | Örnek |
|---|---|---|---|---|---|
| Authorization * | header | string | Bearer Yetkilendirme Tokeni (Örn: Bearer eyJhb...) | - | Bearer <TOKEN> |
| USER_ID * | path | string | İşlem yapan kullanıcının kimlik (ID) değeri. UUID formatındadır. | - | - |
İstek Gövdesi
Section titled “İstek Gövdesi”| Alan | Tip | Açıklama |
|---|---|---|
| title | string | Kullanıcının anlayacağı adres başlığı (Örn: 'Evim', 'Merkez Depo') |
| explanation | string | Gönderi ile ilgili ek açıklama veya not. |
| providerServiceCode | string | Seçilen kargo firmasının spesifik hizmet kodu (Örn: ptt_standart). |
| selectedSenderAddressId | string | Kayıtlı gönderici adresinin benzersiz kimlik (ID) numarası. |
| selectedReceiverAddressId | string | Kayıtlı alıcı adresinin benzersiz kimlik (ID) numarası. |
| packageInfo | object | Kargo paketinin ölçü, ağırlık ve içerik detayları. |
| buyerPayShipping | boolean | Kargo ücretini alıcının (alıcı ödemeli) ödeyip ödemeyeceğini belirtir. |
| buyerPayShippingPaymentType | string | Alıcı ödemeli kargolar için tahsilat tipi (cash veya creditcard). |
| buyerPayProduct | boolean | Kapıda ödeme (ürün bedelinin tahsilatı) işleminin yapılıp yapılmayacağını belirtir. |
{ "title":"Yurtici 2", "explanation":"", "providerServiceCode":"ptt_standart_2",
"selectedSenderAddressId": "68ff56a5741d301e0e57e3b0", // => 682f835b2d273102b62f0026 "selectedReceiverAddressId": "68feaa0d741d301e0e564a8b", // => 67fcc0f63f154d3f8d97a3a3
"packageInfo":{ "desiOrKg": "1", "width": "0.01", "height": "0.01", "depth": "0.01", "weight":"0.5", "itemsAmountCurrency":"try", "itemsTaxAmount":0, "itemsAmount":0, "items":[] },
"buyerPayShipping": false, "buyerPayShippingPaymentType":"creditcard", // => cash or creditcard "buyerPayProduct": false}Örnek Kod
Section titled “Örnek Kod”fetch('https://api.kargomucuz.com/v1/shipments/0', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer <YOUR_TOKEN>' }, body: JSON.stringify({ "title":"Yurtici 2", "explanation":"", "providerServiceCode":"ptt_standart_2",
"selectedSenderAddressId": "68ff56a5741d301e0e57e3b0", // => 682f835b2d273102b62f0026 "selectedReceiverAddressId": "68feaa0d741d301e0e564a8b", // => 67fcc0f63f154d3f8d97a3a3
"packageInfo":{ "desiOrKg": "1", "width": "0.01", "height": "0.01", "depth": "0.01", "weight":"0.5", "itemsAmountCurrency":"try", "itemsTaxAmount":0, "itemsAmount":0, "items":[] },
"buyerPayShipping": false, "buyerPayShippingPaymentType":"creditcard", // => cash or creditcard "buyerPayProduct": false })}).then(response => response.json()).then(data => console.log(data));$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.kargomucuz.com/v1/shipments/0');curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
$body = <<<'EOD'{ "title":"Yurtici 2", "explanation":"", "providerServiceCode":"ptt_standart_2",
"selectedSenderAddressId": "68ff56a5741d301e0e57e3b0", // => 682f835b2d273102b62f0026 "selectedReceiverAddressId": "68feaa0d741d301e0e564a8b", // => 67fcc0f63f154d3f8d97a3a3
"packageInfo":{ "desiOrKg": "1", "width": "0.01", "height": "0.01", "depth": "0.01", "weight":"0.5", "itemsAmountCurrency":"try", "itemsTaxAmount":0, "itemsAmount":0, "items":[] },
"buyerPayShipping": false, "buyerPayShippingPaymentType":"creditcard", // => cash or creditcard "buyerPayProduct": false}EOD;curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
$headers = array();$headers[] = 'Content-Type: application/json';$headers[] = 'Authorization: Bearer <YOUR_TOKEN>';curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);if (curl_errno($ch)) { echo 'Error:' . curl_error($ch);}curl_close($ch);echo $result;Yanıtlar
Section titled “Yanıtlar”200: Başarılı
{ "status": true, "message": "Endpoint bulunamadı.", "code": 500}401: Yetkisiz
{ "status": false, "message": "Herhangi bir giriş sağlanmadı.", "code": 500}