İçinde Ayarlar → API ve entegrasyonlar „Yeni anahtar”a basın ve „Yalnızca sefer yayını”nı seçin. Bir anahtarla başlayın: Test: yayınladığınız borsada görünmez.
Anahtarı kodda değil, bir ortam değişkeninde tutun:
export GOCARGO_API_KEY="gc_test_..."curl https://gocargo.ro/api/v1/me \
-H "Authorization: Bearer $GOCARGO_API_KEY"Yanıt firmayı, anahtarın izinlerini ve istek limitini gösterir.
Yükü şununla gönderin: external_id = TMS'inizdeki ID. Yeniden gönderirseniz yenisini oluşturmak yerine güncelleriz (upsert), dolayısıyla senkronizasyon basittir.
Yüklerinizin listesi:
curl "https://gocargo.ro/api/v1/loads?limit=20" \
-H "Authorization: Bearer $GOCARGO_API_KEY"curl -X POST https://gocargo.ro/api/v1/loads \
-H "Authorization: Bearer $GOCARGO_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"external_id": "TMS-10045",
"origin_country": "RO",
"origin_city": "Cluj-Napoca",
"dest_country": "DE",
"dest_city": "Stuttgart",
"cargo": "Piese auto, 12 paleti",
"loading_date": "2026-12-03",
"vehicle_kind": "prelata",
"weight_kg": 8000,
"price": 1450,
"currency": "EUR"
}'Her istek şu başlığı taşır: Authorization: Bearer gc_live_… (veya gc_test_…). Temel adres: https://gocargo.ro/api/v1. Yalnızca HTTPS.
X-Request-Id; yardım istediğimizde bunu gönderin.Gerekli izni olmayan bir istek 403 alır scope_missing.
| İzin | Neye izin verir |
|---|---|
loads:read | Firmanın yüklerini okur |
loads:write | Yükleri yayınla, değiştir ve geri çek |
trucks:read | Firmanın boş kamyonlarını okur |
trucks:write | Boş kamyonları yayınla, değiştir ve geri çek |
orders:read | Siparişleri okur |
orders:write | Sipariş durumlarını değiştirir ve GPS konumu gönderir |
marketplace:read | Herkese açık borsada ara (yükler ve kamyonlar) |
webhooks:manage | Webhook'ları API ile yönetin |
export:read | Verileri dışa aktar (Business ve Enterprise planları) |
HTTP/1.1 400 Bad Request
X-Request-Id: 5f0c2e7a9b1d4c3e
Content-Type: application/json
{
"error": {
"code": "invalid_request",
"message": "Datele trimise nu sunt valide.",
"fields": { "loading_date": "Data de încărcare nu poate fi în trecut." }
}
}| HTTP | Kod | Ne zaman |
|---|---|---|
| 400 | invalid_request | Geçersiz veri; alan ayrıntıları „fields” içindedir |
| 401 | unauthorized | Anahtar eksik, yanlış veya iptal edilmiş |
| 401 | key_expired | Anahtarın süresi doldu |
| 402 | plan_required | Bu özellik firmanın planına dahil değil |
| 403 | forbidden | Firmanız için izin verilmeyen işlem |
| 403 | scope_missing | Anahtarda istenen izin yok (mesajda belirtilir) |
| 403 | ip_not_allowed | Talep, anahtarın listesinde olmayan bir IP'den geliyor |
| 404 | not_found | Kaynak mevcut değil veya firmaya ait değil |
| 409 | conflict | Uyumsuz durum veya Idempotency-Key farklı gövdeyle yeniden kullanıldı |
| 429 | rate_limited | Çok fazla istek; Retry-After'ın belirttiği süre kadar bekleyin |
| 429 | quota_exceeded | Firmanın aylık istek kotası bitti |
| 500 | server_error | Bizim tarafımızda hata; tekrar deneyin ve bize X-Request-Id gönderin |
| Plan / lisans | Anahtar başına dakikadaki istek | Firma başına aylık istek | Alan adları |
|---|---|---|---|
| Pro | 60 | 50.000 | 1 |
| Business | 300 | 300.000 | 1 |
| Enterprise | 1200 | 2.000.000 | 3 |
| Yazılım entegratörü | 600 | 1.000.000 | 10 |
| Borsa ortağı / toplayıcı | 1200 | 5.000.000 | 25 |
X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset. Limit aşılırsa: 429 ile Retry-After (secunde).X-Quota-Limit ve X-Quota-Remaining; test anahtarları dahil tüm anahtarları tüketir. Ek paketler ve ticari lisanslar: API fiyatları.?limit=100&cursor=…, yanıt {data, next_cursor}. Senkronizasyon için şunu kullanın: updated_since.curl -X POST https://gocargo.ro/api/v1/loads/bulk \
-H "Authorization: Bearer $GOCARGO_API_KEY" \
-H "Content-Type: application/json" \
-d '{"items": [ {...}, {...} ]}'
# Răspuns: fiecare element are rezultatul lui
{"results": [
{"index": 0, "ok": true, "ref": "GC1A2B3C4D"},
{"index": 1, "ok": false, "error": {"code": "invalid_request", "message": "..."}}
]}Herhangi birinde POST başlığı gönderin Idempotency-Key benzersiz bir değerle (örn. UUID). Ağ kesilirse ve aynı değerle yeniden denerseniz, tamamen aynı yanıtı alırsınız; ikinci bir yük oluşmaz. Yanıt 24 saat saklanır. Aynı değer farklı gövdeyle → 409 conflict.
Şuraya bir HTTPS URL'si ekleyin: Ayarlar → API ve entegrasyonlar → Webhook'lar (veya şu yolla: POST /webhooks) ve olayları seçin. Gizli anahtar whsec_… yalnızca bir kez gösterilir.
| Olay | Ne zaman |
|---|---|
load.created | Bir yük yayınlandı |
load.updated | Bir yük değiştirildi |
load.booked | Bir yük rezerve edildi |
load.withdrawn | Bir yük geri çekildi |
quote.received | Bir fiyat teklifi aldınız |
order.created | Bir sipariş oluşturuldu |
order.status_changed | Siparişin durumu değişti |
order.document_added | Siparişe bir belge eklendi (CMR, fatura) |
order.position_updated | Kamyonun konumu güncellendi |
message.received | Bir mesaj aldınız |
POST /gocargo/webhook HTTP/1.1
Content-Type: application/json
GoCargo-Signature: t=1760180000,v1=8f3c...e91a
{
"id": "evt_2b7f0c9e1a4d",
"type": "order.status_changed",
"created_at": "2026-10-11T09:30:00Z",
"data": { ... }
}id tekrarları yok saymak için.Başlık GoCargo-Signature: t=<unix>,v1=<hex>, burada v1 = webhook gizli anahtarıyla HMAC-SHA256 (tamamı, şununla: whsec_) üzerinde {t}.{corpul brut}. 5 dakikadan eski imzaları reddedin.
# pip install flask
import hashlib
import hmac
import os
import time
from flask import Flask, abort, request
SECRET = os.environ["GOCARGO_WEBHOOK_SECRET"] # whsec_..., întreg
app = Flask(__name__)
def verify(header: str, body: bytes, tolerance: int = 300) -> bool:
parts = dict(p.strip().split("=", 1) for p in header.split(",") if "=" in p)
t, sig = parts.get("t", ""), parts.get("v1", "")
if not t.isdigit() or abs(time.time() - int(t)) > tolerance:
return False
expected = hmac.new(SECRET.encode(), t.encode() + b"." + body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, sig)
@app.post("/gocargo/webhook")
def webhook():
# Semnătura se calculează pe corpul BRUT, exact cum a sosit.
if not verify(request.headers.get("GoCargo-Signature", ""), request.get_data()):
abort(400)
event = request.get_json()
print(event["type"], event["data"])
return "", 204Oluştururken „HMAC imzası zorunlu” kutusunu işaretlerseniz bir imzalama anahtarı da alırsınız. Her istekte ayrıca şu başlıklar bulunmalıdır: X-GoCargo-Timestamp (unix saniye) ve X-GoCargo-Signature = şunun üzerinde hex HMAC-SHA256: {timestamp}.{METODĂ}.{cale}.{corp}.
cale sunucudaki tam yol artı gönderdiğiniz haliyle tam sorgudur (varsa), ör. /api/v1/loads sau /api/v1/loads?status=active. GET için gövde boştur (mesaj „.” ile biter).import hashlib
import hmac
import json
import os
import time
import requests
ORIGIN = "https://gocargo.ro"
PATH = "/api/v1/loads"
KEY = os.environ["GOCARGO_API_KEY"]
SIGNING_SECRET = os.environ["GOCARGO_SIGNING_SECRET"]
body = json.dumps({"origin_city": "Cluj-Napoca", "dest_country": "DE", "dest_city": "Stuttgart",
"cargo": "Piese auto", "loading_date": "2026-12-03"}).encode()
ts = str(int(time.time()))
message = ts.encode() + b".POST." + PATH.encode() + b"." + body
signature = hmac.new(SIGNING_SECRET.encode(), message, hashlib.sha256).hexdigest()
r = requests.post(ORIGIN + PATH, data=body, timeout=30, headers={
"Authorization": "Bearer " + KEY,
"Content-Type": "application/json",
"X-GoCargo-Timestamp": ts,
"X-GoCargo-Signature": signature,
})
print(r.status_code, r.text)GET /export/{set}?format=csv|xlsx|json&from=AAAA-LL-ZZ&to=AAAA-LL-ZZ, küme ∈ ile loads, trucks, orders, quotes, reviews. Anahtarın şu izne ihtiyacı var: export:read. İstek başına en fazla 50.000 satır ve 366 gün. CSV, Excel'de doğru açılması için UTF-8 BOM ve „;” ayırıcı içerir.
curl -o comenzi.xlsx \
"https://gocargo.ro/api/v1/export/orders?format=xlsx&from=2026-01-01&to=2026-06-30" \
-H "Authorization: Bearer $GOCARGO_API_KEY"Kodsuz: Ayarlar → Veri dışa aktarma.
API anahtarını asla tarayıcıdaki HTML veya JavaScript'e koymayın. Sayfayı açan herkes bunu görür (Kaynağı Görüntüle, DevTools) ve firmanız adına yayın yapabilir. Anahtar yalnızca sunucuda durur: form sizin bir betiğinize gönderir, betik de GoCargo'yu çağırır.
<!-- formularul din site: trimite la scriptul PHP de pe serverul vostru, NU la GoCargo -->
<form method="post" action="/publica.php">
<input name="origin_city" placeholder="De la" required>
<input name="dest_city" placeholder="Până la" required>
<input name="dest_country" value="RO" maxlength="2">
<input name="cargo" placeholder="Marfă" required>
<input name="loading_date" type="date" required>
<button>Publică pe GoCargo</button>
</form><?php // publica.php — cheia stă doar aici, pe server
$key = getenv('GOCARGO_API_KEY');
$load = [
'origin_country' => 'RO', 'origin_city' => $_POST['origin_city'] ?? '',
'dest_country' => strtoupper($_POST['dest_country'] ?? 'RO'), 'dest_city' => $_POST['dest_city'] ?? '',
'cargo' => $_POST['cargo'] ?? '', 'loading_date' => $_POST['loading_date'] ?? '',
];
$ch = curl_init('https://gocargo.ro/api/v1/loads');
curl_setopt_array($ch, [CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $key, 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode($load, JSON_UNESCAPED_UNICODE)]);
$res = curl_exec($ch);
http_response_code(curl_getinfo($ch, CURLINFO_HTTP_CODE) ?: 502);
header('Content-Type: application/json');
echo $res;Betiği koruyun (yalnızca sitenizde giriş yapmış kullanıcılar, CSRF belirteci) ve şunu ayarlayın: GOCARGO_API_KEY sunucu yapılandırmasında, dosyada değil. İdeali yalnızca şu izne sahip bir anahtar loads:write ve sunucunun IP'sine kısıtlama.
API, Pro, Business ve Enterprise planlarına dahildir. Risksiz, bir test anahtarıyla başlayın.