Calculate shipping fees
const url = 'https://apibase.ecomweb.app/api/v1/public/stores/example/shipping/calculate';const options = { method: 'POST', headers: { 'x-storefront-api-key': '<x-storefront-api-key>', 'Content-Type': 'application/json' }, body: '{"province_id":"01","ward_id":"00001","postal_code":"700000","subtotal":320000,"currency":"VND","weight_gr":1800,"include_carrier_options":false}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://apibase.ecomweb.app/api/v1/public/stores/example/shipping/calculate \ --header 'Content-Type: application/json' \ --header 'x-storefront-api-key: <x-storefront-api-key>' \ --data '{ "province_id": "01", "ward_id": "00001", "postal_code": "700000", "subtotal": 320000, "currency": "VND", "weight_gr": 1800, "include_carrier_options": false }'Returns the shipping options for an address and an order, worked out from the store’s shipping zones and rates, one option per delivery type. Send province_id and ward_id, the codes from the areas route, the order subtotal and the total weight in grams. Set include_carrier_options to also get live quotes from the delivery partner. Nothing is created or reserved.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The store’s ref, as returned by GET /stores.
Request Bodyrequired
Section titled “Request Bodyrequired”object
Province code/ID (preferred over province name)
Example
01Ward code/ID (preferred over district name)
Example
00001Example
700000Order subtotal in smallest unit
Example
320000Currency code
Example
VNDTotal weight in grams
Example
1800Also return live carrier-calculated options (AllinGo). Defaults to false: callers that key options by rate_id keep getting fixed rates only.
Example
falseResponses
Section titled “Responses”The shipping options that apply, one per delivery type.
object
Carrier options only: the carrier, allingo.
<rate_id> for a fixed option, <rate_id>:<service_id> for a carrier option.
Shipping fee.
ISO 4217 currency code.
ID of the rate the option comes from.
Kind of delivery, such as STANDARD or EXPRESS.
Name to show the shopper.
Fastest estimated delivery in days, or null.
Slowest estimated delivery in days, or null.
Carrier options only: ID of the carrier service. Send it back as shipping_service_id when placing the order.
Carrier options only: name of the delivery partner, such as GHN.
Carrier options only: name of the partner’s service.
Carrier options only: logo URL of the delivery partner, or null.
Carrier options only: estimated delivery time as a label, or null.
Example
[ { "carrier_code": "allingo" }]The request is malformed or failed validation.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}The key is missing, invalid, revoked or expired.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}The key may not do this: a missing scope, a readonly key, a publishable key on a Store API route, or a disallowed origin.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}