Skip to main content

Calculate Domestics Cost

Overview​

The Calculate Domestic Cost endpoint enables you to check the estimated shipping cost for deliveries within Indonesia. This feature is particularly useful for platforms that integrate with multiple shipping providers, allowing them to present accurate cost options to their users in real time. By using this API, merchants and developers can dynamically calculate shipping fees based on the origin, destination, and courier service preferences.

This endpoint supports domestic couriers integrated with Komerce and is an essential tool for checkout flows and also shipping calculators.

Key Feature​

  • πŸ“¦ Multi-Courier Support
    Supports a wide range of domestic couriers integrated with Komerce API.

  • 🎯 Precise Cost Calculation
    Returns real-time cost estimates based on origin, destination, and package weight/dimensions.

  • πŸ”„ Flexible Input
    Accepts both exact destination IDs and subdistrict level or zip_code granularity for more accurate pricing.

  • 🧾 Courier Breakdown
    Displays available services, estimated costs, and estimated delivery times.

How it Works​

  1. Prepare the Required Data : You’ll need the origin and destination IDs, courier code, and package details such as weight and optional dimensions.
  2. Receive a detailed response containing available services, cost per service, and estimated delivery time.
  3. Use the returned data to display cost options at checkout, or calculate total shipping charges for the order.

Request Body​

curl --location 'https://rajaongkir.komerce.id/api/v1/calculate/domestic-cost' \
--header 'key: inputapikey' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'origin={{ origin.id }}' \
--data-urlencode 'destination={{ destination.id }}' \
--data-urlencode 'weight={{ weight.grams }}' \
--data-urlencode 'courier={{ courier.code }}' \
--data-urlencode 'price={{ lowest/highest }}'

Query Parameter​

Headers​

KeyTypeDescription
key*stringthis Value contain an secret APIKEY identic for Shipping Cost API

Body x-www-form-urlencoded​

KeyTypeDescription
origin*intthis Value containt an id during Search Domestics Destinations
destination*intthis Value containt an id during Search Domestics Destinations
weight*intthis Value containt an a package weight with grams estimated
courier*stringthis Value contain an Courier Name
pricebooleanthis Value Contain an boolean value, lowest or highest shipping cost
danger

For each header and parameter that has a * sign, it is a parameter that must be Required when making a request, otherwise there will be a system error that will warn the user regarding the request made.

Response​

Response Structure​

KeyValue (Description)
meta.messageResponse for searching address.
meta.codeAny response have different code.
meta.statusBoolean status for checking address.
data[].nameInformation about availability Courier Name
data[].codeInformation about availability Code of Courier
data[].serviceInformation about availability Service of Courier
data[].descriptionDescription about Courier
data[].costInformation about Courier Service Cost
data[].etdInformation about estimated time of courier delivery

Success Respons for Calculate Domestic Cost​

{
"meta": {
"message": "Success Calculate Domestic Shipping cost",
"code": 200,
"status": "success"
},
"data": [
{
"name": "{{ courier.name }}",
"code": "{{ courier.code }}",
"service": "{{ courier.service }}",
"description": "{{ courier.desc }}",
"cost": {{ shipping.cost }},
"etd": "{{ etd.info }}"
},
]
}

Error Respons for Calculate Domestic Cost​

{
"meta": {
"message": "{{ error.message }}",
"code": {{ error.code }},
"status": "{{ status }}"
},
"data": null
}

Status Code​

CodeStatusDescriptionHow to Fix
200Success
400ErrorCalculate Domestic Shipping Cost not foundThis error is unavoidable because the courier may not be able to provide the desired data.
400ErrorMissing ParamsMake sure the request parameters that are sent match the required parameters.
422ErrorInvalid CourierMake sure the courier code entered is correct according to the courier code guide available for checking.

Tips to Avoid Error​

  • πŸ“Œ Ensure subdistrict IDs are valid : Use the correct IDs from the Search Destination endpoint.
  • βš–οΈ Use appropriate weight : Weight must be in grams. 1kg = 1000g. Avoid using β€œ0” or negative numbers.
  • 🚚 Provide valid courier code : Supported courier codes include jne, jnt, sicepat, etc. Make sure the code matches supported ones from the 3PL list.
  • πŸ” Include Authorization Header : Always attach your Bearer Token using the Authorization: Bearer YOUR_API_KEY format.
  • πŸ“‰ Handle β€œno service available” gracefully : If no service is returned, inform the user that the route or courier may not be supported.