Calculate shipping options
const url = 'https://apibase.ecomweb.app/api/v1/stores/example/shipping/calculate';const options = { method: 'POST', headers: {'x-api-key': '<x-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/stores/example/shipping/calculate \ --header 'Content-Type: application/json' \ --header 'x-api-key: <x-api-key>' \ --data '{ "province_id": "01", "ward_id": "00001", "postal_code": "700000", "subtotal": 320000, "currency": "VND", "weight_gr": 1800, "include_carrier_options": false }'Works out which of the store’s shipping zones covers an address and returns the options available for an order of the given value and weight. Unlike the storefront calculation, each option also carries the winning zone (zone_id, zone_name) and the zones it shadowed, so you can see why a fee applies. Carrier-calculated options are added only when include_carrier_options is true, which contacts the AllinGo carrier live; prices from a carrier account in test mode are left out. Unlike most POST routes, it answers 201 although it creates nothing.
Required scopes: read:shippings
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”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.
ID of the zone that won address resolution.
Name of the zone that won address resolution.
Zones that also matched the address but lost to zone_id.
object
Zone ID.
Zone name.
Rank of the zone in address resolution.
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"}