Endpoints Reference

Semua endpoint memakai prefix https://antarpaket.id/api/v1 dan header Authorization: Bearer <key>. Response sukses: {"success":true,"request_id":"…","data":…}.

POST /rates

Weight dalam gram; dimensi cm; declared_value rupiah (integer). Response: array rate berurut harga — courier_code, service_code, price, discount, final_price, estimated_days{min,max}, cod_supported, chargeable_weight_kg. Tidak ada provider cost/margin. Jika sebagian kurir gagal, field provider_errors berisi daftar kurir yang tidak tersedia — kurir lain tetap kembali.

curl -X POST https://antarpaket.id/api/v1/rates \
  -H "Authorization: Bearer ap_test_xxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "origin":      { "district_id": "14895" },
    "destination": { "district_id": "14918" },
    "package":     { "weight_grams": 1000, "length_cm": 10,
                     "width_cm": 10, "height_cm": 10,
                     "declared_value": 100000 },
    "cod": false
  }'
const res = await fetch("https://antarpaket.id/api/v1/rates", {
  method: "POST",
  headers: {
    Authorization: "Bearer ap_test_xxxx",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    origin: { district_id: "14895" },
    destination: { district_id: "14918" },
    package: { weight_grams: 1000, declared_value: 100000 },
    cod: false,
  }),
});
const { data } = await res.json();
console.log(data.rates);

POST /quotes

Body sama dengan /rates + courier_code & service_code yang dipilih. Response: quote_id, final_price, expires_at (TTL 15 menit). Harga dikunci — perubahan rule tidak memengaruhi quote aktif.

POST /shipments

Body: quote_id, sender/receiver (name, phone, address, district_id), items[], payment_method (WALLET/QRIS/MANUAL_TRANSFER), opsional cod_amount, insurance. Sertakan Idempotency-Key.

<?php
$ch = curl_init("https://antarpaket.id/api/v1/shipments");
curl_setopt_array($ch, [
  CURLOPT_POST => true,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer ap_test_xxxx",
    "Content-Type: application/json",
    "Idempotency-Key: order-12345",
  ],
  CURLOPT_POSTFIELDS => json_encode([
    "quote_id" => "q_xxx",
    "sender"   => ["name" => "Andi", "phone" => "081211111111",
                   "address" => "Jl. Mawar 1", "district_id" => "14895"],
    "receiver" => ["name" => "Budi", "phone" => "081222222222",
                   "address" => "Jl. Melati 2", "district_id" => "14918"],
    "items"    => [["name" => "Baju", "quantity" => 1, "price" => 100000]],
    "payment_method" => "WALLET",
  ]),
]);
echo curl_exec($ch);

WALLET lunas → booking: "PROCESSING"; QRIS → qr_string; MANUAL → status WAITING_CONFIRMATION.

GET /shipments/{id} · /shipments

Detail customer-safe: shipment_number, awb, status, payment_status, price, total_amount. List mendukung ?page & ?limit (max 50) & ?status.

POST /shipments/{id}/pay · /cancel

pay: {"method":"WALLET|QRIS|MANUAL_TRANSFER"}. cancel: body opsional {"reason":"…"}; hanya status tertentu yang bisa dibatalkan; refund otomatis ke wallet bila sudah dibayar.

GET /tracking/{awb}

Timeline kanonik: status, description, location, time (ISO 8601 UTC).

Pickup · Balance · Transactions · Webhooks

POST /pickups (shipment BOOKED, service mendukung pickup) · GET /balance (available/pending_cod/held) · GET /transactions (ledger) · webhook CRUD + rotate/test — lihat Webhooks.

Endpoints Reference — AntarPaket API