# AgenWebsite Rate API: full documentation > REST API for Indonesian shipping rates (cek ongkir): 14 couriers behind one endpoint, incl. same-city instant (Lalamove, GoSend), x-api-key auth, JSON responses, prices in IDR, daily quota per plan. Generated 2026-11-25 from https://www.agenwebsite.com/documentation/agenwebsite-rate-api/ and the integration guide https://www.agenwebsite.com/developer-api/prompt.md. If parts disagree, trust in this order: OpenAPI spec (https://api.agenwebsite.com/v1/openapi.json), then Part 1, then Part 2. --- # Part 1: Integration guide (checked against the live API) These are official instructions from AgenWebsite for integrating the **AgenWebsite Rate API** (Indonesian shipping rates, "cek ongkir") into the user's project. Every endpoint, field and code below was checked against the live API and its OpenAPI spec (last checked 2026-11-17). Do the steps yourself: read the project, write the code, run the checks. Only two things need the user: creating the API key (step 1) and pasting it where you tell them. - Get an API key from the user (never invent one) - Store it server-side as `AGENWEBSITE_API_KEY` - Verify the key with `GET /v1/usage` - Build the flow: location search, rates, show services (plus coordinates if the shop wants instant couriers) - Handle errors, quota and retries; add caching - Report back with the status block at the end Machine-readable spec (public, no key): https://api.agenwebsite.com/v1/openapi.json, reference UI: https://api.agenwebsite.com/docs. If anything here disagrees with the spec, the spec wins. Full reference: https://www.agenwebsite.com/developer-api/llms-full.txt --- ## What the API does - One REST endpoint returns shipping rates from 14 Indonesian couriers for a route (origin, destination, weight in grams), including same-city instant couriers (Lalamove, GoSend) when you send coordinates. - It calculates rates only. It does **not** create orders, book pickups, print AWB/resi, track parcels or handle COD. - Base URL: `https://api.agenwebsite.com/v1`. JSON in, JSON out. Money is IDR as integers (no decimals). - Auth: one header, `x-api-key`. No OAuth, no bearer token. | Method | Path | Use | |---|---|---| | GET | `/v1/usage` | Plan, daily limit, used, remaining. Use it to verify the key. | | GET | `/v1/locations/search?q=&limit=` | Address autocomplete (kelurahan, kecamatan, kota, provinsi, kodepos). | | GET | `/v1/couriers` | The 14 courier codes, names and logos. | | POST | `/v1/rates` | Rates for a route. The main endpoint. | Every `/v1` call, including `/v1/usage`, counts 1 against the daily quota. --- ## 1. Get an API key (human step) Check the environment first: if `AGENWEBSITE_API_KEY` is already set, skip to step 2. Otherwise stop and tell the user to do this, then wait for them to give you the key: 1. Log in or create an account at https://www.agenwebsite.com/account/developer-api/ 2. Submit the access request there (a short description of the use case). The AgenWebsite team approves it. 3. After approval, click **Generate** to create a key. The secret is shown **once**; copy it. A key looks like `awk_live_` followed by 32 lowercase hex characters (`awk_live_0123456789abcdef0123456789abcdef`). Reject anything else before calling the API. Never make up a key, never use a placeholder key in committed code, and never print the full key back in chat or logs (show the last 4 characters at most). ## 2. Store the key server-side - Put it in the server environment as `AGENWEBSITE_API_KEY` (`.env`, `.env.local`, hosting dashboard, or secret manager). Add the file to `.gitignore` if it is not there already. - Add `AGENWEBSITE_API_KEY=` (empty) to `.env.example` if the project has one. - **Server-side only.** Never ship the key in browser JavaScript, a `NEXT_PUBLIC_`/`VITE_`/`EXPO_PUBLIC_` variable, a mobile app bundle, or HTML. The API sends no CORS headers, so browser calls fail anyway. The browser calls *your* backend; your backend calls AgenWebsite. - Quota is per account and shared by all its keys. Extra keys do not add quota; use them to separate staging and production. ## 3. Verify the key ```bash curl -s https://api.agenwebsite.com/v1/usage -H "x-api-key: $AGENWEBSITE_API_KEY" ``` Expected (`200`): ```json { "success": true, "data": { "plan": "free", "limit": 150, "used": 1, "remaining": 149, "reset_at": "2026-11-18T00:00:00+07:00" } } ``` `401 unauthorized` means the key is missing, mistyped, revoked, or the access request is not approved yet. Ask the user to check the key in https://www.agenwebsite.com/account/developer-api/. Do not keep retrying. ## 4. Build the integration flow ### 4a. Location search (address autocomplete) ```bash curl -s -G https://api.agenwebsite.com/v1/locations/search \ -H "x-api-key: $AGENWEBSITE_API_KEY" \ --data-urlencode "q=coblong" --data-urlencode "limit=5" ``` ```json { "success": true, "data": [ { "subdistrict_id": null, "postal_code": "40132", "subdistrict": "Lebak Siliwangi", "district": "Coblong", "city": "Bandung", "province": "Jawa Barat", "label": "Lebak Siliwangi, Coblong, Bandung, Jawa Barat, 40132" } ], "meta": { "count": 1, "query": "coblong" } } ``` - `q`: 2 to 100 characters. Matches kelurahan, kecamatan, kota or provinsi names; a number also matches the start of a kodepos. `limit`: 1 to 50, default 10. - Indonesian address levels: `subdistrict` = kelurahan/desa, `district` = kecamatan, `city` = kota/kabupaten, `province` = provinsi, `postal_code` = kodepos (5 digits). - `data` is a flat array. Show `label` in the dropdown. `subdistrict_id` can be `null`; do not depend on it (`/v1/rates` does not accept it). - Debounce input (300 ms) and only search from 3 characters in your UI. Every search costs 1 quota. ### 4b. Rates ```bash curl -s -X POST https://api.agenwebsite.com/v1/rates \ -H "x-api-key: $AGENWEBSITE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "shipper": { "province": "Jawa Barat", "city": "Bandung", "district": "Coblong", "subdistrict": "Lebak Siliwangi" }, "destination": { "zipcode": "10110" }, "weight": 1200, "couriers": ["jne", "jnt", "sicepat"], "sort": "cheapest" }' ``` Request body: | Field | Type | Required | Notes | |---|---|---|---| | `shipper`, `destination` | object | yes | Each is **either** `{ "zipcode": "40132" }` **or** `{ "province", "city", "district" }` plus optional `"subdistrict"`. | | `weight` | integer | yes | Grams, greater than 0. `1200` = 1.2 kg. The server converts to each courier's unit. | | `dimensions` | object | no | `{ "length", "width", "height" }` in cm, all three required when sent. | | `shipper.latlng`, `destination.latlng` | string | no | `"latitude,longitude"` in decimal degrees, e.g. `"-6.2245,106.8296"`. Sits next to `zipcode`/region, never instead of it. Needed on **both** parties for instant couriers (section 4d). | | `couriers` | string[] | no | Up to 14 codes from section 5. Omit to get all couriers (still 1 quota). | | `sort` | string | no | `"cheapest"` (by cost) or `"fastest"` (by `etd_max_days`). | - The field is `zipcode`, not `postal_code`. Unknown fields are silently dropped, so `{ "postal_code": "40132" }` arrives as an empty location and returns `400 validation_error`. - Most precise: pass the `province`, `city`, `district` and `subdistrict` from the location the user picked. A kodepos alone works but can cover several kelurahan. Real response (`200`), captured 2026-11-17 for `40132` → `10110`, 1000 g, all couriers, `sort: "cheapest"`. It had 37 lines from 11 couriers; shown here trimmed to the cheapest and the fastest line: ```json { "success": true, "currency": "IDR", "data": { "rates": [ { "courier_code": "sicepat", "courier_name": "SiCepat", "courier_logo_url": "https://assets-agenwebsite.b-cdn.net/images/couriers/sicepat.png", "service_code": "sicepat_halu", "service_name": "EKONOMIS", "service_type": "regular", "cost": 7500, "cost_formatted": "Rp 7.500", "etd_min_days": 3, "etd_max_days": 5, "etd_text": "3-5 days", "estimated_delivery": { "from": "2026-11-20", "to": "2026-11-22" }, "cheapest": true, "fastest": false, "source": "live" }, { "courier_code": "anteraja", "courier_name": "AnterAja", "courier_logo_url": "https://assets-agenwebsite.b-cdn.net/images/couriers/anteraja.png", "service_code": "anteraja_sd", "service_name": "Anteraja Same Day", "service_type": "regular", "cost": 35300, "cost_formatted": "Rp 35.300", "etd_min_days": 0, "etd_max_days": 0, "etd_text": "0 days", "estimated_delivery": { "from": "2026-11-17", "to": "2026-11-17" }, "cheapest": false, "fastest": true, "source": "live" } ], "cheapest": { "service_code": "sicepat_halu", "cost": 7500 }, "fastest": { "service_code": "anteraja_sd", "etd_max_days": 0 }, "summary": { "count": 37, "cost_range": { "min": 7500, "max": 1200000 } } }, "rate_limit": { "limit": 30000, "remaining": 29964, "reset_at": "2026-11-18T00:00:00+07:00" } } ``` On that route SiCepat, POS, Lion, SPX, J&T, AnterAja, SAP, JNE, RPX, Paxel and J&T Cargo answered. TIKI had no service, and GoSend/Lalamove were left out because no coordinates were sent. The result also contains cargo and special services (e.g. `pos_kargo_motor` Rp 405.000, `jne_jtr_200` Rp 1.200.000); filter them in your UI if they don't fit the shop. ### 4c. Show the services - One row per item in `data.rates`: logo (`courier_logo_url`), `courier_name` + `service_name`, price, estimate. - Price: `cost` is an integer in Rupiah. Display `cost_formatted` ("Rp 14.000", dot as thousands separator). Never show decimals. - Estimate: `etd_text` is English ("2-3 days", "1-3 hours"). For Indonesian UI build it from `etd_min_days`/`etd_max_days`: "2-3 hari" (or "3 hari" when equal, "hari ini" for 0). For `service_type: "instant"` the days are 0 and `etd_text` holds hours: show it as "1-3 jam". `estimated_delivery.from/to` are `YYYY-MM-DD` dates in WIB. - Badges: `cheapest` and `fastest` are already computed per row; `data.cheapest`/`data.fastest` are shortcuts. - `service_code` values carry the courier prefix (`jne_reg`, `sicepat_halu`, `lalamove_motorcycle`). Still store `courier_code` + `service_code` together for the chosen rate. - Re-validate the chosen rate on your server at checkout (call `/v1/rates` again or read your cache). Never trust a price posted from the browser. ### 4d. Instant couriers and coordinates (optional) Lalamove and GoSend (and Paxel's instant services) price by distance, so they need the exact pickup and drop-off point: - Add `latlng: "latitude,longitude"` to **both** `shipper` and `destination`, next to the `zipcode` or region (never instead of it). - Without coordinates they are left out of the result. If the request asks **only** for `lalamove` and/or `gosend` without them, the API returns `400 validation_error` with `field` `"shipper.latlng"` or `"destination.latlng"`. A malformed `latlng` is also a 400. - Same-city routes only. On an intercity route they return no lines. - Their lines have `service_type: "instant"`, `etd_min_days`/`etd_max_days` = 0, an hour range in `etd_text` ("1-3 hours"; GoSend Sameday "8-12 hours") and today's date in `estimated_delivery`. They usually win `fastest`. - Service codes: `lalamove_motorcycle`, `lalamove_sedan`, `lalamove_mpv`, `lalamove_van`, `gosend_instantgojek`, `gosend_samedaygojek`. Ask the user whether the shop wants instant delivery before building this. If yes: 1. Store the shop's pickup coordinates in server config next to its origin address. 2. After the buyer picks an address, ask for a map pin (or the browser's geolocation) and send it as `destination.latlng`. A kodepos alone is not enough for distance pricing. 3. Send `latlng` only when the buyer is in the shop's city; otherwise leave it out and show regular couriers. ```bash curl -s -X POST https://api.agenwebsite.com/v1/rates \ -H "x-api-key: $AGENWEBSITE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "shipper": { "zipcode": "12190", "latlng": "-6.2245,106.8296" }, "destination": { "zipcode": "10310", "latlng": "-6.1951,106.8231" }, "weight": 3000, "couriers": ["lalamove", "gosend"], "sort": "cheapest" }' ``` Live result on 2026-11-17 (Jakarta Selatan → Jakarta Pusat, 3 kg): Lalamove Motorcycle Rp 11.446, Sedan Rp 47.932, MPV Rp 50.487, Van Rp 65.510 (all "1-3 hours"); GoSend Sameday Rp 16.800 ("8-12 hours"), GoSend Instant Rp 19.425 ("1-3 hours"). ## 5. Couriers `GET /v1/couriers` returns `data[]` with `courier_code`, `courier_name`, `logo_url`, `cod_supported`, `insurance_supported`. Valid codes for `couriers[]`: | Code | Courier | Code | Courier | |---|---|---|---| | `jnt` | J&T Express | `gosend` | GoSend | | `jne` | JNE | `rpx` | RPX | | `sicepat` | SiCepat | `lion` | Lion Parcel | | `pos` | POS Indonesia | `sap` | SAP Express | | `anteraja` | AnterAja | `spx` | SPX Express | | `tiki` | TIKI | `jtc` | J&T Cargo | | `paxel` | Paxel | `lalamove` | Lalamove | `cod_supported` means a shipment with that courier can be booked as cash on delivery through AgenWebsite; `insurance_supported` means shipping insurance can be added. COD is not available for POS Indonesia, Paxel, GoSend and Lalamove. Insurance is available for every courier except GoSend and Lalamove (TIKI and RPX are listed as supported). The Rate API itself never adds COD or insurance fees to `cost`. Read the flags from the endpoint rather than hardcoding them. Any other code returns `422 unsupported_courier` (codes are case-insensitive). Not every courier serves every route; a courier with no service simply has no rows. Lalamove and GoSend also need coordinates (section 4d). ## 6. Errors, quota and retries Every error has the same shape. Check `success`, not only the HTTP status, and log `request_id`. ```json { "success": false, "error": { "code": "validation_error", "message": "...", "field": "shipper", "request_id": "req_mwkix1miy8vj39u9" } } ``` | HTTP | `code` | Meaning | Do | |---|---|---|---| | 400 | `validation_error` | Bad body or query; `field` names the culprit (e.g. `shipper`, `weight`, `destination.latlng`). | Fix the input. Do not retry. | | 401 | `unauthorized` | Key missing, malformed, unknown or revoked. | Stop. Ask the user to check the key. | | 422 | `unsupported_courier` | A code outside the 14 above. | Fix `couriers[]`. | | 429 | `rate_limit_exceeded` | Per-minute burst or daily quota used up. | Wait `Retry-After` seconds. | | 502 | `courier_upstream_error` | No usable rate came back: courier outage, or a location that cannot be resolved / has no service. | Retry once or twice with backoff; if it persists for the same input, ask the user to pick the address again from location search. | | 500 | `internal_error` | Server error. | Retry with backoff; report `request_id` if it persists. | Rate limit headers on authenticated responses: - `X-RateLimit-Limit`: daily quota of the plan. - `X-RateLimit-Remaining`: requests left today. - `X-RateLimit-Reset`: Unix time (seconds) of the next reset, 00:00 WIB (UTC+7). - `Retry-After` (on 429 only): seconds to wait. About a minute for a burst limit; until 00:00 WIB when the daily quota is gone. - On a burst 429, `X-RateLimit-Remaining` reads `0` even if daily quota is left. On 401 and other pre-auth errors these headers describe a per-IP guard (1200 requests/minute), not your plan. | Plan | Requests/day | Requests/minute | Active keys | Price | |---|---|---|---|---| | Free | 150 | 20 | 2 | Rp 0 | | Pro | 30.000 | 300 | 5 | Rp 129.000/month | | Max | 60.000 | 600 | 20 | Rp 229.000/month | Retry policy: retry only 429, 502, 500 and network errors. At most 3 attempts, exponential backoff with jitter (1 s, 2 s, 4 s), and always honour `Retry-After`. Never retry 400, 401 or 422. Use a request timeout of about 15 seconds. ## 7. Caching - `/v1/couriers`: cache 24 hours. - `/v1/locations/search`: cache per normalized `q` for 24 hours. Address data barely changes. - `/v1/rates`: cache per (origin, destination, weight, couriers) for 15 to 30 minutes. The API caches identical requests for 30 minutes, but every call still costs quota, so cache on your side too. - Call rates only when the user has an origin, a destination and a weight. Not on every keystroke, not on product listing pages. - Request all couriers in one call instead of one call per courier. --- ## 8. Recipes Pick the one that matches the project. Keep the key in the environment in every case. ### Node.js / Next.js (App Router route handlers) `lib/agenwebsite.ts`: ```ts const BASE = "https://api.agenwebsite.com/v1"; export class AgenWebsiteError extends Error { constructor(public status: number, public code: string, message: string, public requestId?: string) { super(message); } } export async function aw(path: string, init: RequestInit = {}, attempt = 1): Promise { const key = process.env.AGENWEBSITE_API_KEY; if (!key) throw new Error("AGENWEBSITE_API_KEY is not set"); const res = await fetch(BASE + path, { ...init, headers: { "x-api-key": key, "Content-Type": "application/json", ...(init.headers || {}) }, signal: AbortSignal.timeout(15000), cache: "no-store", }); const json = await res.json().catch(() => null); if (res.ok && json?.success) return json as T; const retryable = res.status === 429 || res.status >= 500; if (retryable && attempt < 3) { const wait = Number(res.headers.get("retry-after")) * 1000 || 2 ** attempt * 500 + Math.random() * 250; if (wait <= 10000) { await new Promise((r) => setTimeout(r, wait)); return aw(path, init, attempt + 1); } } const e = json?.error ?? {}; throw new AgenWebsiteError(res.status, e.code ?? "http_error", e.message ?? res.statusText, e.request_id); } ``` `app/api/shipping/locations/route.ts`: ```ts import { aw } from "@/lib/agenwebsite"; export async function GET(req: Request) { const q = new URL(req.url).searchParams.get("q")?.trim() ?? ""; if (q.length < 3) return Response.json({ data: [] }); const json = await aw<{ data: unknown[] }>(`/locations/search?q=${encodeURIComponent(q)}&limit=10`); return Response.json({ data: json.data }, { headers: { "Cache-Control": "public, max-age=86400" } }); } ``` `app/api/shipping/rates/route.ts`: ```ts import { aw, AgenWebsiteError } from "@/lib/agenwebsite"; const cache = new Map(); const TTL = 20 * 60 * 1000; export async function POST(req: Request) { const { shipper, destination, weight, couriers } = await req.json(); const body = { shipper, destination, weight: Math.max(1, Math.round(Number(weight))), couriers, sort: "cheapest" }; const key = JSON.stringify(body); const hit = cache.get(key); if (hit && Date.now() - hit.at < TTL) return Response.json(hit.body); try { const json = await aw<{ data: unknown }>("/rates", { method: "POST", body: key }); cache.set(key, { at: Date.now(), body: json.data }); return Response.json(json.data); } catch (e) { if (e instanceof AgenWebsiteError) { return Response.json({ error: e.code, message: e.message }, { status: e.status === 401 ? 500 : e.status }); } throw e; } } ``` On serverless, the in-memory `Map` is per instance; use the platform cache (Redis/KV) if the project already has one. Express/Fastify: same `aw()` helper inside a route. ### Laravel `config/services.php`: `'agenwebsite' => ['key' => env('AGENWEBSITE_API_KEY')],` `app/Services/AgenWebsiteRates.php`: ```php withHeaders(['x-api-key' => config('services.agenwebsite.key')]) ->acceptJson() ->timeout(15) ->retry(3, fn (int $attempt) => 2 ** $attempt * 500, function ($e) { $status = optional($e->response ?? null)->status(); return $status === null || $status === 429 || $status >= 500; }, throw: false); } public function searchLocations(string $q): array { return Cache::remember('aw:loc:' . md5(mb_strtolower(trim($q))), 86400, fn () => $this->client()->get('/locations/search', ['q' => $q, 'limit' => 10])->throw()->json('data')); } public function rates(array $shipper, array $destination, int $grams, ?array $couriers = null): array { $body = array_filter(compact('shipper', 'destination', 'couriers') + ['weight' => max(1, $grams), 'sort' => 'cheapest']); return Cache::remember('aw:rates:' . md5(json_encode($body)), 1200, fn () => $this->client()->post('/rates', $body)->throw()->json('data')); } } ``` Expose it through your own controller (`Route::post('/shipping/rates', ...)`), validate the input with a FormRequest, and catch `Illuminate\Http\Client\RequestException` to map `error.code` to a friendly message. ### Plain PHP (cURL) ```php $method, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 15, CURLOPT_HTTPHEADER => ['x-api-key: ' . getenv('AGENWEBSITE_API_KEY'), 'Content-Type: application/json'], CURLOPT_POSTFIELDS => $body === null ? null : json_encode($body), ]); $raw = curl_exec($ch); $status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE); curl_close($ch); $json = json_decode((string) $raw, true); if ($status !== 200 || empty($json['success'])) { $code = $json['error']['code'] ?? 'http_' . $status; throw new RuntimeException($code . ': ' . ($json['error']['message'] ?? 'request failed'), $status); } return $json; } $rates = agenwebsite_request('POST', '/rates', [ 'shipper' => ['zipcode' => '40132'], 'destination' => ['zipcode' => '10110'], 'weight' => 1000, ])['data']['rates']; ``` Wrap it in a retry for 429/5xx (honour `Retry-After`) and cache results in APCu, Redis or a file cache. ### Python ```python import os, time, random, requests BASE = "https://api.agenwebsite.com/v1" session = requests.Session() session.headers.update({"x-api-key": os.environ["AGENWEBSITE_API_KEY"]}) class AgenWebsiteError(Exception): def __init__(self, status, code, message, request_id=None): super().__init__(f"{status} {code}: {message}") self.status, self.code, self.request_id = status, code, request_id def aw(method, path, **kwargs): for attempt in range(1, 4): r = session.request(method, BASE + path, timeout=15, **kwargs) body = r.json() if r.headers.get("content-type", "").startswith("application/json") else {} if r.ok and body.get("success"): return body if (r.status_code == 429 or r.status_code >= 500) and attempt < 3: wait = float(r.headers.get("Retry-After") or (2 ** attempt * 0.5 + random.random() / 4)) if wait <= 10: time.sleep(wait) continue err = body.get("error", {}) raise AgenWebsiteError(r.status_code, err.get("code", "http_error"), err.get("message", r.reason), err.get("request_id")) locations = aw("GET", "/locations/search", params={"q": "coblong", "limit": 5})["data"] rates = aw("POST", "/rates", json={ "shipper": {"zipcode": "40132"}, "destination": {"zipcode": "10110"}, "weight": 1000, })["data"]["rates"] ``` In Django/Flask/FastAPI, call `aw()` from your own endpoint and cache with the framework cache (`django.core.cache`, Redis, `functools.lru_cache` with a TTL wrapper). ### Headless WooCommerce The storefront (Next.js, Nuxt, etc.) talks to WooCommerce through its REST API; rates come from the Rate API through your backend: 1. Checkout address form uses your `/api/shipping/locations` route (recipe above) for kecamatan/kelurahan autocomplete. 2. Origin = the store's warehouse address (store it in server config). Weight = sum of `weight × quantity` of the cart items in grams. WooCommerce stores weight in the unit set under WooCommerce > Settings > Products (often kg), so convert. 3. Call your `/api/shipping/rates` route and let the buyer pick a service. 4. When creating the order server-side (`POST /wp-json/wc/v3/orders` with the store's consumer key, never from the browser), re-fetch the rate and add it as a shipping line: ```json "shipping_lines": [ { "method_id": "agenwebsite_rate_api", "method_title": "JNE - Layanan Reguler (2-3 hari)", "total": "14000" } ] ``` If the store uses the normal WooCommerce checkout (not headless), tell the user that the AgenWebsite Shipping plugin already does this inside WooCommerce: https://www.agenwebsite.com/products/agenwebsite-shipping/. Only build a custom `WC_Shipping_Method` on the Rate API if they still want it. ### Joomla / EasyStore Keep the key on the server in a Joomla plugin and let the checkout call it through `com_ajax`. System plugin `plugins/system/agenwebsiterates/agenwebsiterates.php` (Joomla 4/5; add the usual XML manifest with a `api_key` field of `type="password"`): ```php getInput(); $key = getenv('AGENWEBSITE_API_KEY') ?: $this->params->get('api_key'); $http = HttpFactory::getHttp(); $head = ['x-api-key' => $key, 'Content-Type' => 'application/json']; $base = 'https://api.agenwebsite.com/v1'; if ($input->getCmd('task') === 'locations') { $res = $http->get($base . '/locations/search?limit=10&q=' . rawurlencode($input->getString('q')), $head, 15); } else { $body = [ 'shipper' => ['zipcode' => $this->params->get('origin_zipcode')], 'destination' => ['zipcode' => $input->getString('zipcode')], 'weight' => max(1, $input->getInt('weight')), ]; $res = $http->post($base . '/rates', json_encode($body), $head, 15); } return json_decode($res->body, true); } } ``` Call it from the checkout with `index.php?option=com_ajax&plugin=agenwebsiterates&group=system&format=json&task=rates&zipcode=10110&weight=1200`. For EasyStore, find how the installed version defines shipping methods (look in the site's `plugins/` folder and EasyStore's settings) and feed the chosen rate into it. Ask the user before editing EasyStore's own files; prefer a separate plugin that survives updates. --- ## 9. Done checklist Confirm each item before you report: - [ ] `AGENWEBSITE_API_KEY` is read from the server environment; `grep -rE "awk_(live|test)_[0-9a-f]{32}" .` finds no key in the code, and no client-side bundle references it. - [ ] `GET /v1/usage` returns `200` with the user's plan. - [ ] Location search returns results for "coblong" and the UI shows `label`. - [ ] A rates call for `40132` to `10110`, 1000 g returns at least one rate, shown with Rupiah price and estimate. - [ ] If instant delivery was wanted: a same-city call with `latlng` on both parties returns Lalamove/GoSend lines, shown with "jam" estimates. - [ ] Errors map to messages (400/401/422/429/502), retries only on 429/5xx, `Retry-After` honoured. - [ ] Couriers, locations and rates are cached as in section 7. - [ ] The chosen rate is re-checked server-side before an order is saved. Then tell the user: ``` ┌─ AgenWebsite Rate API ready ─────────────────────────┐ │ ✓ Key AGENWEBSITE_API_KEY (…last4), │ │ ✓ Verify GET /v1/usage → 200, left │ │ ✓ Flow locations → rates → services UI │ │ ✓ Files │ │ ✓ Cache couriers 24h · locations 24h · rates Nm │ │ │ │ Quota resets 00:00 WIB · plans: agenwebsite.com │ └──────────────────────────────────────────────────────┘ ``` --- ## Links - Docs index for AI: https://www.agenwebsite.com/developer-api/llms.txt - Full docs in one file: https://www.agenwebsite.com/developer-api/llms-full.txt - OpenAPI spec: https://api.agenwebsite.com/v1/openapi.json - Human docs (Bahasa Indonesia): https://www.agenwebsite.com/documentation/agenwebsite-rate-api/ (each page has a Markdown version at `index.md`) - Account, keys and plans: https://www.agenwebsite.com/account/developer-api/ · https://www.agenwebsite.com/products/developer-api/ - Support: https://support.agenwebsite.com/ --- # Part 2: Documentation pages (Bahasa Indonesia) --- # AgenWebsite Rate API > REST API cek ongkir Indonesia untuk developer — 14 kurir dalam satu endpoint, termasuk kurir instant dalam kota. Source: https://www.agenwebsite.com/documentation/agenwebsite-rate-api/ · Updated: 2026-11-17 · Language: Bahasa Indonesia **Ringkasan** ### Apa itu AgenWebsite Rate API **AgenWebsite Rate API** adalah REST API cek ongkos kirim untuk developer. Kirim alamat asal, alamat tujuan, dan berat paket; API mengembalikan tarif dari **14 kurir Indonesia** dalam satu format JSON yang konsisten, lengkap dengan estimasi waktu tiba dan penanda layanan termurah serta tercepat. Kurir instant dalam kota (Lalamove, GoSend) ikut tampil bila Anda mengirim titik koordinat asal dan tujuan. Base URL: `https://api.agenwebsite.com/v1` · Autentikasi lewat header `x-api-key`. > **Cakupan:** API ini khusus **menghitung ongkir**. API tidak membuat order, tidak menerbitkan AWB/resi, tidak melacak paket, dan tidak menghitung biaya COD. ### Endpoint | Method | Path | Fungsi | | --- | --- | --- | | POST | `/v1/rates` | Tarif semua kurir untuk satu rute. [Referensi](https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-rates/) | | GET | `/v1/locations/search` | Autocomplete alamat (kelurahan, kecamatan, kota, provinsi, kode pos). [Referensi](https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-locations/) | | GET | `/v1/couriers` | Daftar 14 kurir: kode, nama, logo. [Referensi](https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-couriers/) | | GET | `/v1/usage` | Paket aktif dan sisa kuota hari ini. [Referensi](https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-usage/) | ### Kurir yang didukung J&T Express, JNE, SiCepat, POS Indonesia, AnterAja, TIKI, Paxel, GoSend, RPX, Lion Parcel, SAP Express, SPX Express, J&T Cargo, dan Lalamove. Tidak semua kurir melayani setiap rute; kurir instant (Lalamove, GoSend) hanya untuk rute dalam kota dan butuh koordinat. Kode kurirnya ada di [GET /v1/couriers](https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-couriers/). ### Paket dan kuota Kuota dihitung per akun per hari dan di-reset setiap pukul 00:00 WIB. Semua API key dalam satu akun berbagi kuota yang sama. | Paket | Kuota / hari | Burst / menit | Key aktif | Harga | | --- | --- | --- | --- | --- | | Free | 150 | 20 | 2 | Rp 0 | | Pro | 30.000 | 300 | 5 | Rp 129.000 / bulan | | Max | 60.000 | 600 | 20 | Rp 229.000 / bulan | ### Alur integrasi 1. Buat akun dan ajukan akses di [Akun → Developer API](https://www.agenwebsite.com/account/developer-api/). Setelah disetujui tim AgenWebsite, buat (generate) API key. [Panduan Quickstart](https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-quickstart/) 2. Simpan key di environment variable server (mis. `AGENWEBSITE_API_KEY`), jangan di browser atau aplikasi mobile. 3. Pembeli mengisi alamat lewat `/v1/locations/search`. 4. Server Anda memanggil `/v1/rates` dan menampilkan pilihan kurir. 5. Tangani error dan kuota sesuai [Penanganan Error](https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-errors/) dan [Batas & Kuota](https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-rate-limits/). ### Untuk AI coding agent Dokumentasi ini siap dibaca AI: - [prompt.md](https://www.agenwebsite.com/developer-api/prompt.md): instruksi langkah demi langkah yang diikuti agent untuk memasang Rate API di proyek Anda. - [llms.txt](https://www.agenwebsite.com/developer-api/llms.txt) dan [llms-full.txt](https://www.agenwebsite.com/developer-api/llms-full.txt): indeks dan seluruh dokumentasi dalam satu file. - [OpenAPI spec](https://api.agenwebsite.com/v1/openapi.json): skema request dan response yang bisa dibaca mesin. > **Pakai AI coding agent?** Tempel kalimat ini ke Claude Code, Cursor, Codex, atau Copilot: `Fetch and follow https://www.agenwebsite.com/developer-api/prompt.md to integrate AgenWebsite Rate API`. Setiap halaman dokumentasi ini juga tersedia sebagai Markdown di `index.md`. ## Articles ### Memulai - [Memulai / Quickstart](https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-quickstart/index.md): Dapatkan API key, kirim request cek ongkir pertama, dan pahami struktur respons dalam beberapa menit. - [Autentikasi (x-api-key)](https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-authentication/index.md): Cara mengautentikasi request dengan header x-api-key, format key awk_live_, serta praktik keamanan, rotasi, dan revoke. - [Batas & Kuota (Rate Limits)](https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-rate-limits/index.md): Kuota harian per tier Free/Pro/Max, batas burst per menit, header X-RateLimit-*, respons 429, dan praktik terbaik. ### Endpoint - [POST /v1/rates — Cek Ongkir](https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-rates/index.md): Endpoint utama cek ongkir: request body lengkap, contoh curl, response asli dengan penjelasan tiap field, kurir instant dengan koordinat, helper termurah/tercepat. - [GET /v1/couriers](https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-couriers/index.md): Daftar 14 kurir yang didukung: contoh response dan tabel courier_code (JNE, J&T, SiCepat, POS, AnterAja, TIKI, Paxel, GoSend, RPX, Lion, SAP, SPX, J&T Cargo, Lalamove). - [GET /v1/locations/search](https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-locations/index.md): Autocomplete kelurahan, kecamatan & kode pos: query param, contoh response, dan cara mengirim lokasi terpilih ke /v1/rates. - [GET /v1/usage](https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-usage/index.md): Pantau kuota harian: window saat ini, contoh response, dan cara memantau sisa kuota via header X-RateLimit tanpa panggilan ekstra. ### Referensi - [Penanganan Error](https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-errors/index.md): Envelope error standar, tabel semua kode (400/401/422/429/502/500), dan contoh respons untuk tiap kasus. - [Changelog](https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-changelog/index.md): Riwayat versi API: rilis perdana v1.0 (Juli 2026) dengan rates/couriers/locations/usage, plus roadmap COD & pelacakan AWB. ## For AI agents - [Integration prompt](https://www.agenwebsite.com/developer-api/prompt.md) - [llms.txt](https://www.agenwebsite.com/developer-api/llms.txt) · [llms-full.txt](https://www.agenwebsite.com/developer-api/llms-full.txt) - [OpenAPI spec](https://api.agenwebsite.com/v1/openapi.json) --- # Memulai / Quickstart > Dapatkan API key, kirim request cek ongkir pertama, dan pahami struktur respons dalam beberapa menit. Source: https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-quickstart/ · Updated: 2026-11-17 · Language: Bahasa Indonesia **Memulai** ### Ringkasan Panduan ini membawa Anda dari nol sampai request cek ongkir pertama: membuat API key, menyimpannya dengan aman, memverifikasi key, lalu memanggil `POST /v1/rates`. Base URL: `https://api.agenwebsite.com/v1` · Autentikasi lewat header `x-api-key`. ### 1. Dapatkan API key 1. Masuk atau daftar akun di [https://www.agenwebsite.com/account/developer-api/](https://www.agenwebsite.com/account/developer-api/). 2. Ajukan permintaan akses: jelaskan singkat untuk apa API akan dipakai. Tim AgenWebsite meninjau dan menyetujui permintaan. 3. Setelah disetujui, klik **Generate** untuk membuat key. **Secret hanya ditampilkan sekali**, jadi langsung salin dan simpan. Format key: `awk_live_` diikuti 32 karakter heksadesimal huruf kecil, mis. `awk_live_0123456789abcdef0123456789abcdef`. Paket Free aktif otomatis untuk setiap akun. ### 2. Simpan key di server **.env (jangan di-commit)** ``` AGENWEBSITE_API_KEY=awk_live_0123456789abcdef0123456789abcdef ``` > **Hanya dari server.** Jangan menaruh key di JavaScript browser, variabel `NEXT_PUBLIC_`/`VITE_`, atau aplikasi mobile. API ini tidak mengirim header CORS, jadi panggilan langsung dari browser memang tidak akan berhasil. Browser memanggil backend Anda, backend Anda memanggil AgenWebsite. ### 3. Verifikasi key **Request · cURL** ```bash curl https://api.agenwebsite.com/v1/usage \ -H "x-api-key: $AGENWEBSITE_API_KEY" ``` **Response · 200 OK** ```json { "success": true, "data": { "plan": "free", "limit": 150, "used": 3, "remaining": 147, "reset_at": "2026-11-18T00:00:00+07:00" } } ``` Jika mendapat `401 unauthorized`, key salah ketik, sudah dicabut, atau permintaan akses belum disetujui. Cek kembali di halaman akun. ### 4. Request cek ongkir pertama Payload minimum hanya butuh asal, tujuan, dan berat (gram). Tiap pihak bisa memakai `zipcode` (kode pos) atau kombinasi `province` + `city` + `district`. **Request · cURL (minimum)** ```bash curl -X POST https://api.agenwebsite.com/v1/rates \ -H "x-api-key: $AGENWEBSITE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "shipper": { "zipcode": "40132" }, "destination": { "zipcode": "10110" }, "weight": 1000 }' ``` Response berisi `data.rates[]` (satu baris per layanan kurir), pintasan `data.cheapest` / `data.fastest`, dan sisa kuota di `rate_limit`. Penjelasan setiap field ada di [POST /v1/rates](https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-rates/). ### 5. Contoh di kode **Node.js (fetch)** ```javascript const res = await fetch("https://api.agenwebsite.com/v1/rates", { method: "POST", headers: { "x-api-key": process.env.AGENWEBSITE_API_KEY, "Content-Type": "application/json", }, body: JSON.stringify({ shipper: { zipcode: "40132" }, destination: { zipcode: "10110" }, weight: 1000, sort: "cheapest", }), }); const json = await res.json(); if (!json.success) throw new Error(json.error.code + ": " + json.error.message); for (const r of json.data.rates) { console.log(r.courier_name, r.service_name, r.cost_formatted); } ``` **PHP (WordPress)** ``` $res = wp_remote_post( 'https://api.agenwebsite.com/v1/rates', array( 'timeout' => 15, 'headers' => array( 'x-api-key' => getenv( 'AGENWEBSITE_API_KEY' ), 'Content-Type' => 'application/json', ), 'body' => wp_json_encode( array( 'shipper' => array( 'zipcode' => '40132' ), 'destination' => array( 'zipcode' => '10110' ), 'weight' => 1000, ) ), ) ); $json = json_decode( wp_remote_retrieve_body( $res ), true ); if ( empty( $json['success'] ) ) { error_log( $json['error']['code'] . ': ' . $json['error']['message'] ); } ``` ### Langkah berikutnya - [GET /v1/locations/search](https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-locations/): kolom alamat dengan autocomplete kecamatan dan kode pos. - [Penanganan Error](https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-errors/) dan [Batas & Kuota](https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-rate-limits/): retry yang aman dan hemat kuota. > **Pakai AI coding agent?** Tempel kalimat ini ke Claude Code, Cursor, Codex, atau Copilot: `Fetch and follow https://www.agenwebsite.com/developer-api/prompt.md to integrate AgenWebsite Rate API`. Setiap halaman dokumentasi ini juga tersedia sebagai Markdown di `index.md`. --- # Autentikasi (x-api-key) > Cara mengautentikasi request dengan header x-api-key, format key awk_live_, serta praktik keamanan, rotasi, dan revoke. Source: https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-authentication/ · Updated: 2026-11-17 · Language: Bahasa Indonesia **Autentikasi** ### Header x-api-key Setiap request ke endpoint `/v1` wajib menyertakan API key di header `x-api-key`. Tidak ada OAuth atau bearer token; cukup satu header. Base URL: `https://api.agenwebsite.com/v1` · Autentikasi lewat header `x-api-key`. **cURL · header wajib** ```bash curl https://api.agenwebsite.com/v1/usage \ -H "x-api-key: $AGENWEBSITE_API_KEY" ``` Jika header hilang, formatnya salah, key tidak dikenal, atau key sudah dicabut, API membalas HTTP 401: **Response · 401 Unauthorized** ```json { "success": false, "error": { "code": "unauthorized", "message": "Invalid or missing API key.", "request_id": "req_mwkix1ut826mcdck" } } ``` Untuk key yang sudah dicabut, pesannya `API key sudah dinonaktifkan.` ### Format key Key berbentuk `awk_live_` diikuti 32 karakter heksadesimal huruf kecil (total 41 karakter). Request dengan format lain langsung ditolak dengan 401 sebelum key dicari. AgenWebsite hanya menyimpan hash SHA-256 dari key, bukan teks aslinya. Karena itu secret **hanya ditampilkan sekali** saat dibuat. Di halaman akun, key ditampilkan dengan prefix dan 4 karakter terakhir. ### Mendapatkan key 1. Masuk di [Akun → Developer API](https://www.agenwebsite.com/account/developer-api/). 2. Ajukan permintaan akses (jelaskan kegunaannya). Key baru bisa dibuat setelah permintaan disetujui tim AgenWebsite. 3. Klik **Generate** dan salin secret-nya. Jumlah key aktif per paket: Free 2, Pro 5, Max 20. **Kuota bersifat per akun**: semua key berbagi kuota harian yang sama, jadi key tambahan tidak menambah kuota. Gunakan key terpisah untuk staging dan produksi agar mudah dirotasi. ### Praktik keamanan - **Panggil dari server saja.** Jangan menaruh key di JavaScript browser atau aplikasi mobile; key yang bocor bisa menghabiskan kuota Anda. API tidak mengirim header CORS, jadi panggilan dari browser tidak akan berhasil. - **Simpan di environment variable atau secret manager**, jangan di-commit ke Git. - **Jangan mencetak key penuh di log.** Cukup 4 karakter terakhir. - **Rotasi bila curiga bocor** (lihat di bawah). **Contoh · key dari environment variable** ```bash # .env (jangan di-commit) AGENWEBSITE_API_KEY=awk_live_0123456789abcdef0123456789abcdef // Node.js const res = await fetch("https://api.agenwebsite.com/v1/couriers", { headers: { "x-api-key": process.env.AGENWEBSITE_API_KEY }, }); ``` ### Rotasi dan pencabutan key Key dikelola dari halaman [Akun → Developer API](https://www.agenwebsite.com/account/developer-api/), bukan lewat API. | Aksi | Efek | | --- | --- | | Generate | Membuat key baru; secret tampil sekali. | | Rotate | Menerbitkan secret baru dan menonaktifkan yang lama. Pakai saat key diduga bocor. | | Revoke | Menonaktifkan key; request berikutnya dibalas 401. | | Delete | Menghapus key yang sudah dicabut dari daftar. | Data key di-cache di server hingga 5 menit. Perubahan status biasanya berlaku hampir seketika, paling lama 5 menit. --- # Batas & Kuota (Rate Limits) > Kuota harian per tier Free/Pro/Max, batas burst per menit, header X-RateLimit-*, respons 429, dan praktik terbaik. Source: https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-rate-limits/ · Updated: 2026-11-17 · Language: Bahasa Indonesia **Batas & Kuota** ### Dua lapis pembatasan Rate API membatasi **kuota harian** (jumlah request per hari) dan **burst per menit** (kecepatan request). Kuota harian dihitung per akun dan dibagi oleh semua API key Anda; burst dihitung per key. Setiap request ke `/v1` dihitung 1, termasuk `/v1/usage`, berapa pun jumlah kurir yang diminta. ### Kuota per paket | Paket | Kuota / hari | Burst / menit | Key aktif | Harga | | --- | --- | --- | --- | --- | | Free | 150 | 20 | 2 | Rp 0 | | Pro | 30.000 | 300 | 5 | Rp 129.000 / bulan | | Max | 60.000 | 600 | 20 | Rp 229.000 / bulan | Kuota di-reset setiap hari pukul **00:00 WIB** (Asia/Jakarta, UTC+7). Burst per menit memakai jendela menit kalender (reset di detik ke-00). ### Header X-RateLimit-* Setiap response dari endpoint ber-autentikasi menyertakan header berikut: | Header | Isi | | --- | --- | | `X-RateLimit-Limit` | Kuota harian paket Anda, mis. `150`. | | `X-RateLimit-Remaining` | Sisa request hari ini. | | `X-RateLimit-Reset` | Waktu reset berikutnya (00:00 WIB) dalam **Unix timestamp detik**, mis. `1794934800`. | | `Retry-After` | Hanya pada 429: jumlah detik sebelum boleh mencoba lagi. | Informasi yang sama tersedia di blok `rate_limit` pada response `/v1/rates` (dengan `reset_at` berformat ISO 8601, +07:00), dan lewat [GET /v1/usage](https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-usage/). > **Catatan:** pada 429 karena burst, `X-RateLimit-Remaining` bernilai `0` walau kuota harian masih ada. Pada 401 dan error lain sebelum key dikenali, header X-RateLimit-* menggambarkan batas pengaman per IP (1.200 request/menit), bukan paket Anda. ### Respons 429 dan Retry-After Bila kuota harian habis atau burst per menit terlampaui, API membalas **HTTP 429** dengan kode `rate_limit_exceeded` dan header `Retry-After`. | Penyebab | Pesan | Retry-After | | --- | --- | --- | | Burst per menit terlampaui | `Per-minute request limit exceeded. Please try again shortly.` | Sisa detik menuju menit berikutnya (maks. 60). | | Kuota harian habis | `Your daily API quota has been exhausted.` | Detik menuju 00:00 WIB. | **Response · 429** ```http HTTP/1.1 429 Too Many Requests Retry-After: 43 X-RateLimit-Limit: 150 X-RateLimit-Remaining: 0 X-RateLimit-Reset: 1794934800 { "success": false, "error": { "code": "rate_limit_exceeded", "message": "Per-minute request limit exceeded. Please try again shortly.", "request_id": "req_9c3e11ab" } } ``` Request yang ditolak karena kuota harian tidak mengurangi kuota. ### Praktik terbaik - **Hormati Retry-After.** Jangan langsung mengulang setelah 429. - **Retry hanya untuk 429, 5xx, dan error jaringan**, maksimal 3 kali dengan exponential backoff (1 s, 2 s, 4 s) plus jitter. Jangan retry 400, 401, atau 422. - **Cache di sisi Anda.** Daftar kurir dan hasil pencarian lokasi bisa di-cache 24 jam, tarif 15–30 menit per kombinasi asal-tujuan-berat. Server juga meng-cache tarif identik 30 menit, tetapi setiap panggilan tetap memotong kuota. - **Satu request untuk semua kurir.** Tanpa field `couriers`, satu panggilan mengembalikan semua kurir dan tetap dihitung 1. - **Debounce kolom pencarian alamat** (mis. 300 ms) dan mulai cari dari 3 karakter. - **Pantau X-RateLimit-Remaining** dan beri notifikasi internal saat mendekati batas. --- # POST /v1/rates — Cek Ongkir > Endpoint utama cek ongkir: request body lengkap, contoh curl, response asli dengan penjelasan tiap field, kurir instant dengan koordinat, helper termurah/tercepat. Source: https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-rates/ · Updated: 2026-11-17 · Language: Bahasa Indonesia **Endpoint Utama** ### Ringkasan **POST /v1/rates** adalah endpoint inti Rate API. Kirim asal (`shipper`), tujuan (`destination`), dan berat paket; API mengembalikan tarif dari kurir yang melayani rute itu, ternormalisasi ke satu format, dengan estimasi waktu tiba dan penanda **termurah** serta **tercepat**. Base URL: `https://api.agenwebsite.com/v1` · Autentikasi lewat header `x-api-key` · Content-Type `application/json`. > **Cakupan:** hanya menghitung ongkir. Tidak membuat order atau AWB dan tidak menghitung biaya COD. Berat **selalu dalam gram** (bilangan bulat). ### Request body | Field | Tipe | Wajib | Keterangan | | --- | --- | --- | --- | | `shipper` | object | Ya | Lokasi asal. Isi **salah satu** bentuk di bawah. | | `shipper.zipcode` | string | Salah satu* | Kode pos 4–6 digit, mis. `"40132"`. | | `shipper.province` / `city` / `district` | string | Salah satu* | Provinsi, kota/kabupaten, dan kecamatan. Ketiganya wajib bila tidak memakai `zipcode`. | | `shipper.subdistrict` | string | Opsional | Kelurahan/desa, untuk hasil yang lebih presisi. | | `destination` | object | Ya | Lokasi tujuan, struktur sama dengan `shipper`. | | `weight` | integer | **Ya** | Berat dalam **gram**, lebih dari 0. `1200` = 1,2 kg. Konversi ke satuan tiap kurir dilakukan server. | | `dimensions` | object | Opsional | `length`, `width`, `height` dalam cm (angka > 0). Bila dikirim, ketiganya wajib. | | `shipper.latlng` / `destination.latlng` | string | Opsional | Koordinat `"latitude,longitude"` (derajat desimal), mis. `"-6.2245,106.8296"`. Dikirim **di samping** `zipcode`/wilayah, bukan penggantinya. Wajib di kedua pihak untuk kurir instant (lihat bagian di bawah). | | `couriers` | array | Opsional | Maksimal 14 kode dari [daftar kurir](https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-couriers/). Kosongkan untuk semua kurir. | | `sort` | string | Opsional | `"cheapest"` (berdasarkan `cost`) atau `"fastest"` (berdasarkan `etd_max_days`). | *Untuk tiap pihak kirim `zipcode` **atau** `province` + `city` + `district`. > **Nama field-nya `zipcode`, bukan `postal_code`.** Field yang tidak dikenal diabaikan, sehingga `{ "postal_code": "40132" }` dianggap lokasi kosong dan dibalas `400 validation_error`. Paling presisi: kirim `province`, `city`, `district`, dan `subdistrict` dari hasil [/v1/locations/search](https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-locations/) yang dipilih pengguna. Satu kode pos bisa mencakup beberapa kelurahan. ### Contoh request **Request · cURL (lengkap)** ```bash curl -X POST https://api.agenwebsite.com/v1/rates \ -H "x-api-key: $AGENWEBSITE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "shipper": { "province": "Jawa Barat", "city": "Bandung", "district": "Coblong", "subdistrict": "Lebak Siliwangi" }, "destination": { "zipcode": "10110" }, "weight": 1200, "dimensions": { "length": 20, "width": 15, "height": 10 }, "couriers": ["jne", "jnt", "sicepat"], "sort": "cheapest" }' ``` Payload minimum hanya butuh asal, tujuan, dan berat: **Request · cURL (minimum)** ```bash curl -X POST https://api.agenwebsite.com/v1/rates \ -H "x-api-key: $AGENWEBSITE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "shipper": { "zipcode": "40132" }, "destination": { "zipcode": "10110" }, "weight": 1000 }' ``` ### Struktur response Response asli tanggal 17 November 2026 untuk 40132 → 10110, 1 kg, semua kurir, `sort: "cheapest"`. Aslinya 37 layanan dari 11 kurir; di sini dipersingkat menjadi layanan termurah dan tercepat. **Response · 200 OK** ```json { "success": true, "currency": "IDR", "data": { "rates": [ { "courier_code": "sicepat", "courier_name": "SiCepat", "courier_logo_url": "https://assets-agenwebsite.b-cdn.net/images/couriers/sicepat.png", "service_code": "sicepat_halu", "service_name": "EKONOMIS", "service_type": "regular", "cost": 7500, "cost_formatted": "Rp 7.500", "etd_min_days": 3, "etd_max_days": 5, "etd_text": "3-5 days", "estimated_delivery": { "from": "2026-11-20", "to": "2026-11-22" }, "cheapest": true, "fastest": false, "source": "live" }, { "courier_code": "anteraja", "courier_name": "AnterAja", "courier_logo_url": "https://assets-agenwebsite.b-cdn.net/images/couriers/anteraja.png", "service_code": "anteraja_sd", "service_name": "Anteraja Same Day", "service_type": "regular", "cost": 35300, "cost_formatted": "Rp 35.300", "etd_min_days": 0, "etd_max_days": 0, "etd_text": "0 days", "estimated_delivery": { "from": "2026-11-17", "to": "2026-11-17" }, "cheapest": false, "fastest": true, "source": "live" } ], "cheapest": { "service_code": "sicepat_halu", "cost": 7500 }, "fastest": { "service_code": "anteraja_sd", "etd_max_days": 0 }, "summary": { "count": 37, "cost_range": { "min": 7500, "max": 1200000 } } }, "rate_limit": { "limit": 30000, "remaining": 29964, "reset_at": "2026-11-18T00:00:00+07:00" } } ``` ### Penjelasan field response | Field | Tipe | Keterangan | | --- | --- | --- | | `success` | boolean | Selalu `true` untuk response sukses. | | `currency` | string | Selalu `"IDR"`. | | `data.rates[]` | array | Satu baris = satu layanan kurir. | | `rates[].courier_code` | string | Kode kurir, mis. `jne`. | | `rates[].courier_name` | string | Nama tampilan kurir. | | `rates[].courier_logo_url` | string | URL logo kurir, siap dipakai di UI. | | `rates[].service_code` | string | Kode layanan, berawalan kode kurir (mis. `jne_reg`, `sicepat_halu`). Simpan bersama `courier_code` untuk layanan yang dipilih. | | `rates[].service_name` | string | Nama layanan. | | `rates[].service_type` | string | `"regular"` atau `"instant"` (kurir instant berbasis jarak). | | `rates[].cost` | integer | Ongkir dalam Rupiah (tanpa desimal). | | `rates[].cost_formatted` | string | `cost` berformat Rupiah, mis. `"Rp 14.000"`. | | `rates[].etd_min_days` / `etd_max_days` | integer | Estimasi hari tiba minimum dan maksimum. | | `rates[].etd_text` | string | Estimasi dalam bahasa Inggris, mis. `"2-3 days"`, atau rentang jam untuk kurir instant (`"1-3 hours"`). Untuk UI berbahasa Indonesia, susun sendiri: “2-3 hari”, atau “1-3 jam” untuk instant. | | `rates[].estimated_delivery` | object | `{ from, to }`: rentang tanggal perkiraan tiba (`YYYY-MM-DD`, WIB). | | `rates[].cheapest` / `fastest` | boolean | Penanda layanan termurah dan tercepat. | | `rates[].source` | string | Sumber tarif, `"live"`. | | `data.cheapest` | object\|null | Pintasan layanan termurah: `{ service_code, cost }`. | | `data.fastest` | object\|null | Pintasan layanan tercepat: `{ service_code, etd_max_days }`. | | `data.summary` | object | `count` (jumlah layanan) dan `cost_range { min, max }`. | | `rate_limit` | object | `limit`, `remaining`, dan `reset_at` (ISO 8601, +07:00) kuota harian. | ### Kurir instant (GoSend, Lalamove) dan koordinat Lalamove, GoSend, dan layanan instant Paxel menghitung tarif berdasarkan **jarak**, jadi butuh titik jemput dan titik antar yang tepat. - Tambahkan `latlng` berformat `"latitude,longitude"` di **kedua** pihak (`shipper` dan `destination`), di samping `zipcode` atau wilayah. - Tanpa koordinat, kurir instant tidak muncul di hasil. Bila request **hanya** meminta `lalamove` dan/atau `gosend` tanpa koordinat, API membalas `400 validation_error` dengan `field` `shipper.latlng` atau `destination.latlng`. - Hanya untuk rute **dalam kota**. Rute antarkota tidak mengembalikan layanan instant. - Baris instant punya `service_type: "instant"`, `etd_min_days`/`etd_max_days` = 0, rentang jam di `etd_text` (“1-3 hours”, GoSend Sameday “8-12 hours”), dan tanggal hari ini di `estimated_delivery`. Biasanya baris ini menjadi `fastest`. - Kode layanan: `lalamove_motorcycle`, `lalamove_sedan`, `lalamove_mpv`, `lalamove_van`, `gosend_instantgojek`, `gosend_samedaygojek`. Cara memakainya di checkout: simpan koordinat toko di konfigurasi server, lalu minta pembeli menaruh **pin di peta** (atau memakai lokasi perangkat) setelah memilih alamat. Kirim koordinat hanya bila pembeli berada di kota yang sama dengan toko. **Request · cURL (instant)** ```bash curl -X POST https://api.agenwebsite.com/v1/rates \ -H "x-api-key: $AGENWEBSITE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "shipper": { "zipcode": "12190", "latlng": "-6.2245,106.8296" }, "destination": { "zipcode": "10310", "latlng": "-6.1951,106.8231" }, "weight": 3000, "couriers": ["lalamove", "gosend"], "sort": "cheapest" }' ``` Hasil asli 17 November 2026 (Jakarta Selatan → Jakarta Pusat, 3 kg): Lalamove Motorcycle Rp 11.446, Sedan Rp 47.932, MPV Rp 50.487, Van Rp 65.510 (semua “1-3 hours”); GoSend Sameday Rp 16.800 (“8-12 hours”), GoSend Instant Rp 19.425 (“1-3 hours”). ### Menampilkan hasil **Helper · JavaScript** ```javascript const json = await res.json(); // Pintasan const termurah = json.data.rates.find((r) => r.cheapest); const tercepat = json.data.rates.find((r) => r.fastest); // Label estimasi dalam bahasa Indonesia const etd = (r) => r.service_type === "instant" ? r.etd_text.replace("hours", "jam") : r.etd_min_days === r.etd_max_days ? (r.etd_max_days === 0 ? "hari ini" : `${r.etd_max_days} hari`) : `${r.etd_min_days}-${r.etd_max_days} hari`; console.log(termurah.courier_name, termurah.service_name, termurah.cost_formatted, etd(termurah)); ``` ### Catatan penting - **Panggil dari server.** Hitung ulang tarif yang dipilih di server saat checkout; jangan percaya harga yang dikirim dari browser. - **1 request = 1 kuota**, berapa pun jumlah kurir yang diminta. - **Cache 30 menit di server** untuk request identik, tetapi tetap memotong kuota. Cache juga di sisi Anda (15–30 menit). - **Tidak semua kurir melayani semua rute.** Kurir tanpa layanan tidak muncul di `data.rates` (pada contoh di atas TIKI tidak punya layanan, dan GoSend/Lalamove tidak ikut karena tanpa koordinat). Bila tidak ada tarif sama sekali, API membalas `502 courier_upstream_error`. - **Hasil bisa memuat layanan kargo dan khusus** (mis. `pos_kargo_motor`, `jne_jtr_200`). Saring di UI bila tidak sesuai dengan toko Anda. --- # GET /v1/couriers > Daftar 14 kurir yang didukung: contoh response dan tabel courier_code (JNE, J&T, SiCepat, POS, AnterAja, TIKI, Paxel, GoSend, RPX, Lion, SAP, SPX, J&T Cargo, Lalamove). Source: https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-couriers/ · Updated: 2026-11-17 · Language: Bahasa Indonesia **Referensi Endpoint** ### Ringkasan `GET /v1/couriers` mengembalikan daftar kurir yang didukung: kode, nama tampilan, dan URL logo. Pakai untuk membangun filter kurir di UI atau memvalidasi nilai `couriers` sebelum memanggil [POST /v1/rates](https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-rates/). Daftarnya statis, jadi aman di-cache 24 jam. Base URL: `https://api.agenwebsite.com/v1` · Autentikasi lewat header `x-api-key`. ### Contoh request **Request · cURL** ```bash curl https://api.agenwebsite.com/v1/couriers \ -H "x-api-key: $AGENWEBSITE_API_KEY" ``` ### Contoh response **Response · 200 OK (dipersingkat)** ```json { "success": true, "data": [ { "courier_code": "jnt", "courier_name": "J&T Express", "logo_url": "https://assets-agenwebsite.b-cdn.net/images/couriers/jnt.png", "cod_supported": true, "insurance_supported": true }, { "courier_code": "jne", "courier_name": "JNE", "logo_url": "https://assets-agenwebsite.b-cdn.net/images/couriers/jne.png", "cod_supported": true, "insurance_supported": true }, ... ], "meta": { "count": 14 } } ``` ### Tabel kurir didukung Nilai `courier_code` di bawah ini yang dipakai di array `couriers` pada `POST /v1/rates` dan yang muncul di `rates[].courier_code`. | courier_code | Nama kurir | COD | Asuransi | Logo | | --- | --- | --- | --- | --- | | `jnt` | J&T Express | Ya | Ya | [jnt.png](https://assets-agenwebsite.b-cdn.net/images/couriers/jnt.png) | | `jne` | JNE | Ya | Ya | [jne.png](https://assets-agenwebsite.b-cdn.net/images/couriers/jne.png) | | `sicepat` | SiCepat | Ya | Ya | [sicepat.png](https://assets-agenwebsite.b-cdn.net/images/couriers/sicepat.png) | | `pos` | POS Indonesia | **Tidak** | Ya | [pos.png](https://assets-agenwebsite.b-cdn.net/images/couriers/pos.png) | | `anteraja` | AnterAja | Ya | Ya | [anteraja.png](https://assets-agenwebsite.b-cdn.net/images/couriers/anteraja.png) | | `tiki` | TIKI | Ya | Ya | [tiki.png](https://assets-agenwebsite.b-cdn.net/images/couriers/tiki.png) | | `paxel` | Paxel | **Tidak** | Ya | [paxel.png](https://assets-agenwebsite.b-cdn.net/images/couriers/paxel.png) | | `gosend` | GoSend | **Tidak** | **Tidak** | [gosend.png](https://assets-agenwebsite.b-cdn.net/images/couriers/gosend.png) | | `rpx` | RPX | Ya | Ya | [rpx.png](https://assets-agenwebsite.b-cdn.net/images/couriers/rpx.png) | | `lion` | Lion Parcel | Ya | Ya | [lion.png](https://assets-agenwebsite.b-cdn.net/images/couriers/lion.png) | | `sap` | SAP Express | Ya | Ya | [sap.png](https://assets-agenwebsite.b-cdn.net/images/couriers/sap.png) | | `spx` | SPX Express | Ya | Ya | [spx.png](https://assets-agenwebsite.b-cdn.net/images/couriers/spx.png) | | `jtc` | J&T Cargo | Ya | Ya | [jnt-cargo.png](https://assets-agenwebsite.b-cdn.net/images/couriers/jnt-cargo.png) | | `lalamove` | Lalamove | **Tidak** | **Tidak** | [lalamove.png](https://assets-agenwebsite.b-cdn.net/images/couriers/lalamove.png) | COD tidak tersedia untuk POS Indonesia, Paxel, GoSend, dan Lalamove. Asuransi tersedia untuk semua kurir kecuali GoSend dan Lalamove. Nilai untuk TIKI dan RPX tercantum sebagai didukung. ### Field response | Field | Tipe | Keterangan | | --- | --- | --- | | `courier_code` | string | Kode kurir untuk request tarif. | | `courier_name` | string | Nama tampilan kurir. | | `logo_url` | string | URL logo kurir. | | `cod_supported` | boolean | Pengiriman dengan kurir ini bisa dipesan sebagai COD (bayar di tempat) lewat AgenWebsite. Rate API sendiri tidak menghitung biaya COD. | | `insurance_supported` | boolean | Asuransi pengiriman bisa ditambahkan untuk kurir ini. Rate API sendiri tidak menghitung biaya asuransi. | | `meta.count` | integer | Jumlah kurir (14). | **Lalamove dan GoSend adalah kurir instant**: tarifnya hanya muncul bila `shipper` dan `destination` sama-sama membawa `latlng`, dan hanya untuk rute dalam kota. Detailnya di [POST /v1/rates](https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-rates/). > **Kode di luar daftar?** Mengirim kode lain di `couriers` pada `POST /v1/rates` dibalas `422 unsupported_courier`. Kode tidak peka huruf besar/kecil. --- # GET /v1/locations/search > Autocomplete kelurahan, kecamatan & kode pos: query param, contoh response, dan cara mengirim lokasi terpilih ke /v1/rates. Source: https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-locations/ · Updated: 2026-11-17 · Language: Bahasa Indonesia **Referensi Endpoint** ### Ringkasan `GET /v1/locations/search` adalah autocomplete alamat untuk seluruh Indonesia. Pakai untuk kolom alamat pembeli, lalu kirim lokasi yang dipilih ke [POST /v1/rates](https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-rates/). Base URL: `https://api.agenwebsite.com/v1` · Autentikasi lewat header `x-api-key`. ### Query parameter | Parameter | Tipe | Wajib | Keterangan | | --- | --- | --- | --- | | `q` | string | Ya | Kata kunci 2–100 karakter: nama kelurahan, kecamatan, kota, atau provinsi. Angka juga dicocokkan dengan awalan kode pos. | | `limit` | integer | Opsional | Jumlah hasil maksimum, 1–50. Default 10. | > Gunakan debounce (mis. 300 ms) dan mulai cari dari 3 karakter di UI Anda. Setiap pencarian memotong 1 kuota. Hasil pencarian jarang berubah, jadi aman di-cache 24 jam per kata kunci. ### Contoh request **Request · cURL** ```bash curl -G https://api.agenwebsite.com/v1/locations/search \ -H "x-api-key: $AGENWEBSITE_API_KEY" \ --data-urlencode "q=coblong" \ --data-urlencode "limit=5" ``` ### Contoh response **Response · 200 OK** ```json { "success": true, "data": [ { "subdistrict_id": null, "postal_code": "40132", "subdistrict": "Lebak Siliwangi", "district": "Coblong", "city": "Bandung", "province": "Jawa Barat", "label": "Lebak Siliwangi, Coblong, Bandung, Jawa Barat, 40132" }, { "subdistrict_id": null, "postal_code": "40132", "subdistrict": "Lebak Gede", "district": "Coblong", "city": "Bandung", "province": "Jawa Barat", "label": "Lebak Gede, Coblong, Bandung, Jawa Barat, 40132" } ], "meta": { "count": 2, "query": "coblong" } } ``` ### Field response `data` adalah array datar; setiap item satu kelurahan/desa. | Field | Tipe | Keterangan | | --- | --- | --- | | `subdistrict` | string | Kelurahan/desa, mis. “Lebak Siliwangi”. | | `district` | string | Kecamatan, mis. “Coblong”. | | `city` | string | Kota/kabupaten. | | `province` | string | Provinsi. | | `postal_code` | string | Kode pos. Kirim sebagai `zipcode` ke `/v1/rates`. | | `label` | string | Alamat lengkap siap tampil di dropdown. | | `subdistrict_id` | integer\|null | ID internal; bisa `null`. Tidak dipakai oleh `/v1/rates`. | | `meta.count` / `meta.query` | integer / string | Jumlah hasil dan kata kunci. | ### Mengirim hasil ke /v1/rates Setelah pengguna memilih satu lokasi, susun pihak `shipper` atau `destination` dari field-field-nya. Bentuk paling presisi: **Body /v1/rates · dari hasil pencarian** ```json { "shipper": { "zipcode": "40132" }, "destination": { "province": "Jawa Barat", "city": "Bandung", "district": "Coblong", "subdistrict": "Lebak Siliwangi" }, "weight": 1000 } ``` Perhatikan pemetaannya: `postal_code` dari hasil pencarian dikirim sebagai `zipcode`. Kode pos saja sudah cukup, tetapi satu kode pos bisa mencakup beberapa kelurahan (contoh di atas: 40132 mencakup Lebak Siliwangi dan Lebak Gede). --- # GET /v1/usage > Pantau kuota harian: window saat ini, contoh response, dan cara memantau sisa kuota via header X-RateLimit tanpa panggilan ekstra. Source: https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-usage/ · Updated: 2026-11-17 · Language: Bahasa Indonesia **Referensi Endpoint** ### Ringkasan `GET /v1/usage` menampilkan pemakaian kuota hari ini: paket aktif, batas harian, jumlah terpakai, sisa, dan waktu reset. Cocok untuk memverifikasi API key dan untuk dashboard internal. Request ini sendiri dihitung 1 kuota. Base URL: `https://api.agenwebsite.com/v1` · Autentikasi lewat header `x-api-key`. Kuota bersifat harian dan per akun, di-reset setiap 00:00 WIB (UTC+7). Semua API key dalam satu akun berbagi satu kuota. ### Contoh request **Request · cURL** ```bash curl https://api.agenwebsite.com/v1/usage \ -H "x-api-key: $AGENWEBSITE_API_KEY" ``` ### Contoh response **Response · 200 OK** ```json { "success": true, "data": { "plan": "free", "limit": 150, "used": 3, "remaining": 147, "reset_at": "2026-11-18T00:00:00+07:00" } } ``` ### Field response | Field | Tipe | Keterangan | | --- | --- | --- | | `plan` | string | Paket aktif: `free`, `pro`, atau `max`. | | `limit` | integer | Kuota per hari (Free 150 · Pro 30.000 · Max 60.000). | | `used` | integer | Request yang sudah dipakai hari ini (WIB). | | `remaining` | integer | Sisa kuota hari ini. | | `reset_at` | string (ISO 8601) | Reset berikutnya, 00:00 WIB, mis. `2026-11-18T00:00:00+07:00`. | ### Memantau kuota tanpa panggilan ekstra Setiap response ber-autentikasi sudah membawa header kuota, jadi Anda tidak perlu memanggil `/v1/usage` sebelum setiap request: **Response headers** ```http X-RateLimit-Limit: 150 X-RateLimit-Remaining: 147 X-RateLimit-Reset: 1794934800 ``` `X-RateLimit-Reset` berisi Unix timestamp dalam detik. Penjelasan lengkap dan respons 429 ada di [Batas & Kuota](https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-rate-limits/). Butuh kuota lebih besar? Lihat paket di [halaman Rate API](https://www.agenwebsite.com/products/developer-api/). --- # Penanganan Error > Envelope error standar, tabel semua kode (400/401/422/429/502/500), dan contoh respons untuk tiap kasus. Source: https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-errors/ · Updated: 2026-11-17 · Language: Bahasa Indonesia **Error Handling** ### Envelope error Rate API tidak pernah membalas 200 kosong. Setiap kegagalan memakai kode status HTTP yang sesuai dan envelope JSON yang sama. `field` hanya muncul bila ada parameter tertentu yang bermasalah; `request_id` selalu ada. **Struktur error** ```json { "success": false, "error": { "code": "validation_error", "message": "Provide a zipcode OR a combination of province + city + district (subdistrict optional).", "field": "shipper", "request_id": "req_mwkix1miy8vj39u9" } } ``` > **Selalu periksa `success`**, jangan hanya kode HTTP. Simpan `request_id` di log Anda dan sertakan saat menghubungi support. ### Tabel kode error | HTTP | Kode | Kapan terjadi | Yang perlu dilakukan | | --- | --- | --- | --- | | 400 | `validation_error` | Body atau query tidak valid: `weight` hilang atau bukan bilangan bulat positif, lokasi tanpa `zipcode` maupun `province`+`city`+`district`, `q` kurang dari 2 karakter, `sort` tidak dikenal, `latlng` salah format, atau request hanya untuk `lalamove`/`gosend` tanpa `latlng` di kedua pihak. Juga dipakai untuk path yang tidak ada (HTTP 404). | Perbaiki input. Jangan retry. | | 401 | `unauthorized` | Header `x-api-key` hilang, format salah, key tidak dikenal, atau sudah dicabut. | Cek key di halaman akun. Jangan retry. | | 422 | `unsupported_courier` | Ada kode di `couriers` di luar 14 kode yang didukung. | Perbaiki daftar kurir. | | 429 | `rate_limit_exceeded` | Burst per menit terlampaui atau kuota harian habis. | Tunggu sesuai `Retry-After`. | | 502 | `courier_upstream_error` | Tidak ada tarif yang bisa dikembalikan: layanan kurir sedang gangguan, atau lokasi tidak dapat dikenali / tidak ada layanan untuk rute itu. | Retry 1–2 kali dengan backoff. Bila tetap gagal untuk input yang sama, minta pengguna memilih ulang alamat dari pencarian lokasi. | | 500 | `internal_error` | Kesalahan di server. | Retry dengan backoff; laporkan `request_id` bila berulang. | ### Contoh respons per kasus #### 400 · validation_error Field yang tidak dikenal diabaikan tanpa pesan. Mengirim `postal_code` (bukan `zipcode`) membuat lokasi dianggap kosong: **400 Bad Request** ```json { "success": false, "error": { "code": "validation_error", "message": "Provide a zipcode OR a combination of province + city + district (subdistrict optional).", "field": "shipper", "request_id": "req_mwkix1miy8vj39u9" } } ``` #### 401 · unauthorized **401 Unauthorized** ```json { "success": false, "error": { "code": "unauthorized", "message": "Invalid or missing API key.", "request_id": "req_mwkix1ut826mcdck" } } ``` #### 422 · unsupported_courier **422 Unprocessable Entity** ```json { "success": false, "error": { "code": "unsupported_courier", "message": "Courier 'ninja' is not supported. Available couriers: jnt, jne, sicepat, pos, anteraja, tiki, paxel, gosend, rpx, lion, sap, spx, jtc, lalamove.", "field": "couriers", "request_id": "req_0b91de7a" } } ``` #### 502 · courier_upstream_error **502 Bad Gateway** ```json { "success": false, "error": { "code": "courier_upstream_error", "message": "Failed to fetch rates from couriers.", "request_id": "req_e5f7a1c2" } } ``` Bila hanya sebagian kurir yang tidak punya layanan, API tetap membalas 200 dengan tarif dari kurir yang tersedia. Kurir yang tidak melayani rute itu tidak muncul di `data.rates`. Contoh 429 dan penjelasan header ada di [Batas & Kuota](https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-rate-limits/). ### Pola penanganan yang disarankan - **400 / 422**: kesalahan input. Tampilkan pesan yang jelas ke pengguna, jangan retry. - **401**: masalah kredensial. Hentikan dan periksa key. - **429**: tunggu `Retry-After`. - **502 / 500 / timeout**: retry maksimal 3 kali dengan exponential backoff. Gunakan timeout request sekitar 15 detik. --- # Changelog > Riwayat versi API: rilis perdana v1.0 (Juli 2026) dengan rates/couriers/locations/usage, plus roadmap COD & pelacakan AWB. Source: https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-changelog/ · Updated: 2026-11-17 · Language: Bahasa Indonesia **Riwayat Versi** ### Ringkasan Halaman ini mencatat perubahan pada AgenWebsite Rate API. Versi ada di prefix path (`/v1`). Perubahan yang tidak merusak kompatibilitas, seperti field baru di response, bisa terjadi kapan saja di `v1`. > Ikuti prinsip **tolerant reader**: jangan gagal saat menemukan field baru, dan jangan bergantung pada urutan properti JSON. ### 17 November 2026 · Lalamove dan koordinat - Kurir baru: **Lalamove** (`lalamove`), total 14 kurir. - Parameter opsional `latlng` (“latitude,longitude”) di `shipper` dan `destination` untuk kurir instant (Lalamove, GoSend, layanan instant Paxel). Baris instant memakai `service_type: "instant"` dan estimasi dalam jam. ### November 2026 · Dokumentasi untuk AI - Instruksi integrasi untuk AI coding agent: [prompt.md](https://www.agenwebsite.com/developer-api/prompt.md). - [llms.txt](https://www.agenwebsite.com/developer-api/llms.txt) dan [llms-full.txt](https://www.agenwebsite.com/developer-api/llms-full.txt). - Versi Markdown setiap halaman dokumentasi di `index.md`. - Dokumentasi diselaraskan dengan API live: daftar kurir lengkap, lokasi berupa `zipcode` atau `province`/`city`/`district`, format response pencarian lokasi, dan header `X-RateLimit-Reset` berupa Unix timestamp. ### v1.0 · Rilis perdana (Juli 2026) | Area | Detail | | --- | --- | | **Endpoint** | `POST /v1/rates`, `GET /v1/couriers`, `GET /v1/locations/search`, `GET /v1/usage` | | **Kurir** | Daftar terbaru di [GET /v1/couriers](https://www.agenwebsite.com/documentation/agenwebsite-rate-api/agenwebsite-rate-api-couriers/) | | **Cakupan** | Khusus menghitung ongkir; tidak membuat order/AWB dan tidak menghitung biaya COD. | | **Autentikasi** | Header `x-api-key` | | **Kuota** | Harian per akun: Free 150 · Pro 30.000 · Max 60.000 (reset 00:00 WIB) | | **Fitur tarif** | Penanda termurah/tercepat, estimasi tanggal tiba, logo kurir, sort cheapest/fastest | ### Roadmap Rencana berikut belum tersedia di v1 dan bisa berubah: | Fitur | Status | Catatan | | --- | --- | --- | | **Perhitungan biaya COD** | Roadmap | v1 menghitung ongkir saja. Field `cod_supported` di `/v1/couriers` hanya menandai apakah COD bisa dipesan lewat AgenWebsite, bukan biaya COD. | | **Pelacakan AWB / resi** | Roadmap | Cek status perjalanan paket berdasarkan nomor resi. | | **Pembuatan order / AWB** | Belum direncanakan di v1 | Rate API khusus menghitung tarif. | Penambahan fitur akan berupa field atau endpoint baru, sehingga integrasi `v1` Anda tetap kompatibel.