Calculate rates
Name | Type | Description |
---|---|---|
shipment * | shipment | An instance of shipping freight or cargo |
async | boolean | enable async mode or not (set to false if not provided) |
is_document | boolean | If the shipment is document type. (set to false if not provided) |
shipper_accounts | array of reference | accounts for shipment Object reference |
ship_date | string | Ship Date in YYYY-MM-DD, if not provided, will be today of the shipper account timezone |
{
"shipper_accounts": [
{
"id": "00000000-0000-0000-0000-892432954ed7"
}
],
"shipment": {
"parcels": [
{
"description": "Food Bar",
"box_type": "custom",
"weight": {
"value": 6042,
"unit": "g"
},
"dimension": {
"width": 0.2,
"height": 0.3,
"depth": 0.34,
"unit": "m"
},
"items": [
{
"description": "Food Bar",
"item_id": "13131313",
"quantity": 1,
"price": {
"amount": 50.11,
"currency": "IDR"
},
"weight": {
"value": 6,
"unit": "kg"
}
},
{
"description": "Food Bar",
"item_id": "13131313",
"quantity": 7,
"price": {
"amount": 50,
"currency": "IDR"
},
"weight": {
"value": 6,
"unit": "g"
}
}
]
}
],
"ship_from": {
"contact_name": "Test Gojek send",
"phone": "6285201311111",
"postal_code": "12780",
"street1": "Jalan Pancoran Buntu I",
"city": "Kota Depok",
"state": "Jawa Barat",
"country": "IDN"
},
"ship_to": {
"contact_name": "Test Gojek received",
"phone": "6281254511111",
"street1": "Jalan Jatianom Pasar Minggu",
"postal_code": "12540",
"city": "Kota Depok",
"state": "Jawa Barat",
"country": "IDN"
}
},
"async": false
}
curl --request POST \
--url https://sandbox-api.postmen.com/v3/rates \
--header 'content-type: application/json' \
--header 'postmen-api-key: 8fc7966b-679b-4a57-911d-c5a663229c9e' \
--data '{"shipper_accounts":[{"id":"00000000-0000-0000-0000-892432954ed7"}],"shipment":{"parcels":[{"description":"Food Bar","box_type":"custom","weight":{"value":6042,"unit":"g"},"dimension":{"width":0.2,"height":0.3,"depth":0.34,"unit":"m"},"items":[{"description":"Food Bar","item_id":"13131313","quantity":1,"price":{"amount":50.11,"currency":"IDR"},"weight":{"value":6,"unit":"kg"}},{"description":"Food Bar","item_id":"13131313","quantity":7,"price":{"amount":50,"currency":"IDR"},"weight":{"value":6,"unit":"g"}}]}],"ship_from":{"contact_name":"Test Gojek send","phone":"6285201311111","postal_code":"12780","street1":"Jalan Pancoran Buntu I","city":"Kota Depok","state":"Jawa Barat","country":"IDN"},"ship_to":{"contact_name":"Test Gojek received","phone":"6281254511111","street1":"Jalan Jatianom Pasar Minggu","postal_code":"12540","city":"Kota Depok","state":"Jawa Barat","country":"IDN"}},"async":false}'
using System;
using System.Net;
using System.IO;
class ExamplePostmen
{
static void Main(string[] args)
{
WebRequest httpWebRequest = WebRequest.Create("https://sandbox-api.postmen.com/v3/rates");
string json = "{\"shipper_accounts\":[{\"id\":\"00000000-0000-0000-0000-892432954ed7\"}],\"shipment\":{\"parcels\":[{\"description\":\"Food Bar\",\"box_type\":\"custom\",\"weight\":{\"value\":6042,\"unit\":\"g\"},\"dimension\":{\"width\":0.2,\"height\":0.3,\"depth\":0.34,\"unit\":\"m\"},\"items\":[{\"description\":\"Food Bar\",\"item_id\":\"13131313\",\"quantity\":1,\"price\":{\"amount\":50.11,\"currency\":\"IDR\"},\"weight\":{\"value\":6,\"unit\":\"kg\"}},{\"description\":\"Food Bar\",\"item_id\":\"13131313\",\"quantity\":7,\"price\":{\"amount\":50,\"currency\":\"IDR\"},\"weight\":{\"value\":6,\"unit\":\"g\"}}]}],\"ship_from\":{\"contact_name\":\"Test Gojek send\",\"phone\":\"6285201311111\",\"postal_code\":\"12780\",\"street1\":\"Jalan Pancoran Buntu I\",\"city\":\"Kota Depok\",\"state\":\"Jawa Barat\",\"country\":\"IDN\"},\"ship_to\":{\"contact_name\":\"Test Gojek received\",\"phone\":\"6281254511111\",\"street1\":\"Jalan Jatianom Pasar Minggu\",\"postal_code\":\"12540\",\"city\":\"Kota Depok\",\"state\":\"Jawa Barat\",\"country\":\"IDN\"}},\"async\":false}";
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";
httpWebRequest.Headers["postmen-api-key"] = "8fc7966b-679b-4a57-911d-c5a663229c9e";
using (StreamWriter streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
streamWriter.Write(json);
streamWriter.Flush();
streamWriter.Close();
}
HttpWebResponse httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (StreamReader streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
string result = streamReader.ReadToEnd();
Console.WriteLine(result);
}
}
}
import com.squareup.okhttp.*;
public class test {
public static void main(String[] args) {
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"shipper_accounts\":[{\"id\":\"00000000-0000-0000-0000-892432954ed7\"}],\"shipment\":{\"parcels\":[{\"description\":\"Food Bar\",\"box_type\":\"custom\",\"weight\":{\"value\":6042,\"unit\":\"g\"},\"dimension\":{\"width\":0.2,\"height\":0.3,\"depth\":0.34,\"unit\":\"m\"},\"items\":[{\"description\":\"Food Bar\",\"item_id\":\"13131313\",\"quantity\":1,\"price\":{\"amount\":50.11,\"currency\":\"IDR\"},\"weight\":{\"value\":6,\"unit\":\"kg\"}},{\"description\":\"Food Bar\",\"item_id\":\"13131313\",\"quantity\":7,\"price\":{\"amount\":50,\"currency\":\"IDR\"},\"weight\":{\"value\":6,\"unit\":\"g\"}}]}],\"ship_from\":{\"contact_name\":\"Test Gojek send\",\"phone\":\"6285201311111\",\"postal_code\":\"12780\",\"street1\":\"Jalan Pancoran Buntu I\",\"city\":\"Kota Depok\",\"state\":\"Jawa Barat\",\"country\":\"IDN\"},\"ship_to\":{\"contact_name\":\"Test Gojek received\",\"phone\":\"6281254511111\",\"street1\":\"Jalan Jatianom Pasar Minggu\",\"postal_code\":\"12540\",\"city\":\"Kota Depok\",\"state\":\"Jawa Barat\",\"country\":\"IDN\"}},\"async\":false}");
Request request = new Request.Builder()
.url("https://sandbox-api.postmen.com/v3/rates")
.post(body)
.addHeader("postmen-api-key", "8fc7966b-679b-4a57-911d-c5a663229c9e")
.addHeader("content-type", "application/json")
.build();
try {
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
} catch (Exception e) {
System.err.println("Caught IOException: " + e.getMessage());
}
}
}
var request = require("request");
var options = {
method: 'POST',
url: 'https://sandbox-api.postmen.com/v3/rates',
headers: {
'content-type': 'application/json',
'postmen-api-key': '8fc7966b-679b-4a57-911d-c5a663229c9e'
},
body: '{"shipper_accounts":[{"id":"00000000-0000-0000-0000-892432954ed7"}],"shipment":{"parcels":[{"description":"Food Bar","box_type":"custom","weight":{"value":6042,"unit":"g"},"dimension":{"width":0.2,"height":0.3,"depth":0.34,"unit":"m"},"items":[{"description":"Food Bar","item_id":"13131313","quantity":1,"price":{"amount":50.11,"currency":"IDR"},"weight":{"value":6,"unit":"kg"}},{"description":"Food Bar","item_id":"13131313","quantity":7,"price":{"amount":50,"currency":"IDR"},"weight":{"value":6,"unit":"g"}}]}],"ship_from":{"contact_name":"Test Gojek send","phone":"6285201311111","postal_code":"12780","street1":"Jalan Pancoran Buntu I","city":"Kota Depok","state":"Jawa Barat","country":"IDN"},"ship_to":{"contact_name":"Test Gojek received","phone":"6281254511111","street1":"Jalan Jatianom Pasar Minggu","postal_code":"12540","city":"Kota Depok","state":"Jawa Barat","country":"IDN"}},"async":false}'
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
<?php
$url = 'https://sandbox-api.postmen.com/v3/rates';
$method = 'POST';
$headers = array(
"content-type: application/json",
"postmen-api-key: 8fc7966b-679b-4a57-911d-c5a663229c9e"
);
$body = '{"shipper_accounts":[{"id":"00000000-0000-0000-0000-892432954ed7"}],"shipment":{"parcels":[{"description":"Food Bar","box_type":"custom","weight":{"value":6042,"unit":"g"},"dimension":{"width":0.2,"height":0.3,"depth":0.34,"unit":"m"},"items":[{"description":"Food Bar","item_id":"13131313","quantity":1,"price":{"amount":50.11,"currency":"IDR"},"weight":{"value":6,"unit":"kg"}},{"description":"Food Bar","item_id":"13131313","quantity":7,"price":{"amount":50,"currency":"IDR"},"weight":{"value":6,"unit":"g"}}]}],"ship_from":{"contact_name":"Test Gojek send","phone":"6285201311111","postal_code":"12780","street1":"Jalan Pancoran Buntu I","city":"Kota Depok","state":"Jawa Barat","country":"IDN"},"ship_to":{"contact_name":"Test Gojek received","phone":"6281254511111","street1":"Jalan Jatianom Pasar Minggu","postal_code":"12540","city":"Kota Depok","state":"Jawa Barat","country":"IDN"}},"async":false}';
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => $url,
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_POSTFIELDS => $body
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
?>
# Make sure to install requests: pip install requests
import requests
url = 'https://sandbox-api.postmen.com/v3/rates'
payload = '''
{
"shipper_accounts": [
{
"id": "00000000-0000-0000-0000-892432954ed7"
}
],
"shipment": {
"parcels": [
{
"description": "Food Bar",
"box_type": "custom",
"weight": {
"value": 6042,
"unit": "g"
},
"dimension": {
"width": 0.2,
"height": 0.3,
"depth": 0.34,
"unit": "m"
},
"items": [
{
"description": "Food Bar",
"item_id": "13131313",
"quantity": 1,
"price": {
"amount": 50.11,
"currency": "IDR"
},
"weight": {
"value": 6,
"unit": "kg"
}
},
{
"description": "Food Bar",
"item_id": "13131313",
"quantity": 7,
"price": {
"amount": 50,
"currency": "IDR"
},
"weight": {
"value": 6,
"unit": "g"
}
}
]
}
],
"ship_from": {
"contact_name": "Test Gojek send",
"phone": "6285201311111",
"postal_code": "12780",
"street1": "Jalan Pancoran Buntu I",
"city": "Kota Depok",
"state": "Jawa Barat",
"country": "IDN"
},
"ship_to": {
"contact_name": "Test Gojek received",
"phone": "6281254511111",
"street1": "Jalan Jatianom Pasar Minggu",
"postal_code": "12540",
"city": "Kota Depok",
"state": "Jawa Barat",
"country": "IDN"
}
},
"async": false
}
'''
headers = {
'postmen-api-key': '8fc7966b-679b-4a57-911d-c5a663229c9e',
'content-type': 'application/json'
}
response = requests.request('POST', url, data=payload, headers=headers)
print(response.text)
require 'uri'
require 'net/http'
url = URI('https://sandbox-api.postmen.com/v3/rates')
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request['postmen-api-key'] = '8fc7966b-679b-4a57-911d-c5a663229c9e'
request['content-type'] = 'application/json'
request.body = '{"shipper_accounts":[{"id":"00000000-0000-0000-0000-892432954ed7"}],"shipment":{"parcels":[{"description":"Food Bar","box_type":"custom","weight":{"value":6042,"unit":"g"},"dimension":{"width":0.2,"height":0.3,"depth":0.34,"unit":"m"},"items":[{"description":"Food Bar","item_id":"13131313","quantity":1,"price":{"amount":50.11,"currency":"IDR"},"weight":{"value":6,"unit":"kg"}},{"description":"Food Bar","item_id":"13131313","quantity":7,"price":{"amount":50,"currency":"IDR"},"weight":{"value":6,"unit":"g"}}]}],"ship_from":{"contact_name":"Test Gojek send","phone":"6285201311111","postal_code":"12780","street1":"Jalan Pancoran Buntu I","city":"Kota Depok","state":"Jawa Barat","country":"IDN"},"ship_to":{"contact_name":"Test Gojek received","phone":"6281254511111","street1":"Jalan Jatianom Pasar Minggu","postal_code":"12540","city":"Kota Depok","state":"Jawa Barat","country":"IDN"}},"async":false}'
response = http.request(request)
puts response.read_body
Name | Type | Description |
---|---|---|
id | string | Calculate Rate ID |
status | string | Accepts: calculating ,calculated ,failed . |
rates | array of rate type | The amount of a charge or payment with reference to some basis of calculation. |
created_at | string | A formatted date. |
updated_at | string | A formatted date. |
Response example
{
"meta": {
"code": 200,
"message": "OK",
"details": []
},
"data": {
"created_at": "2021-08-06T08:14:26+00:00",
"id": "5793fcd9-421b-4b3b-9f9f-3e2df1d20ab6",
"updated_at": "2021-08-06T08:14:27+00:00",
"service_options": null,
"status": "calculated",
"rates": [
{
"shipper_account": {
"id": "00000000-0000-0000-0000-892432954ed7",
"slug": "gojek",
"description": "gojek"
},
"service_type": "gojek_instant",
"service_name": "Gojek Instant",
"pickup_deadline": null,
"booking_cut_off": null,
"delivery_date": null,
"transit_time": null,
"error_message": null,
"info_message": "1-2 HOURS",
"charge_weight": null,
"total_charge": {
"amount": 20000,
"currency": "IDR"
},
"detailed_charges": []
},
{
"shipper_account": {
"id": "00000000-0000-0000-0000-892432954ed7",
"slug": "gojek",
"description": "gojek"
},
"service_type": "gojek_same_day",
"service_name": "Gojek Same Day",
"pickup_deadline": null,
"booking_cut_off": null,
"delivery_date": null,
"transit_time": null,
"error_message": null,
"info_message": "6-8 HOURS",
"charge_weight": null,
"total_charge": {
"amount": 18000,
"currency": "IDR"
},
"detailed_charges": []
}
]
}
}
List all rates
Optional parameters
Name | Type | Description |
---|---|---|
status | string | Rate status Accepts: calculating ,calculated ,failed . |
limit | string | Number of records per page |
created_at_min | string | Start date and time of the record created (format YYYY-MM-DDTHH:MM:SSZ or YYYY-MM-DDTHH:MM:SS+00:00, default: 24hrs ago) |
created_at_max | string | End date and time of the record created (format YYYY-MM-DDTHH:MM:SSZ or YYYY-MM-DDTHH:MM:SS+00:00, default: NOW()) |
next_token | string | Next token |
Name | Type | Description |
---|---|---|
next_token | string or null | Any of string or null |
limit | number | Number of records per page |
rates | array of a rate record object | A rate record object |
Response example
No example available
Retrieve rates
Name | Type | Description |
---|---|---|
id | string | Calculate Rate ID |
status | string | Accepts: calculating ,calculated ,failed . |
rates | array of rate type | The amount of a charge or payment with reference to some basis of calculation. |
created_at | string | A formatted date. |
updated_at | string | A formatted date. |
Response example
No example available