Calculate Landed Cost
What this endpoint does
This REST API calculates the total landed cost for shipping a cart of products internationally. It determines all costs your customer will pay, including:
- Duties
- Import taxes
- Other customs-related charges
Showing a fully landed cost upfront gives your international customers transparency at checkout, reduces delivery surprises, and helps you offer Delivered Duty Paid (DDP) shipping.
When to Use This API
- During checkout: Calculate the total landed cost in real-time when the user enters a shipping address.
- In the shopping cart: Let shoppers see estimated import charges before they even reach checkout.
- Before creating a draft order: Validate total shipping costs so your system can show an accurate final price, including duties and taxes.
Key business benefits
- Eliminate unexpected customs charges that cause cart abandonment.
- Enable a DDP (Delivered Duty Paid) experience: you collect duties and taxes at checkout.
- Improve international conversion rates by being upfront about total cost.
- Optionally guarantee the estimate: if all required fields are provided, your business can absorb the final bill.
What this gives your merchants
- One shipment → One or more ship-from → One or more shipping rates → Multiple items
- The system returns duties, taxes, and fees* for each shipment and rate, so merchants can present accurate options at checkout.
How to ensure a guaranteed calculation
- All required fields must be accurate.
- Certain destination countries require Province/State and zip code to guarantee compliance.
- If fields are missing, your calculation may be non-guaranteed and final charges could differ.
curl --request POST \
--url https://api.openborder.com/api/direct/v1/landed-cost \
--header 'Content-Type: application/json' \
--header 'x-openborder-direct-api-key: <x-openborder-direct-api-key>' \
--data '
{
"ship_to": {
"country_code": "<string>",
"province": "<string>",
"postal_code": "<string>",
"address1": "<string>",
"address2": "<string>",
"city": "<string>",
"name": "<string>"
},
"caller_app": "<string>",
"currency_code": "<string>",
"order_discount": 123,
"shipments": [
{
"ship_from": {
"country_code": "<string>",
"province": "<string>",
"postal_code": "<string>",
"address1": "<string>",
"address2": "<string>",
"city": "<string>",
"name": "<string>"
},
"shipment_id": "<string>",
"shipping_rates": [
{
"shipping_rate_id": "<string>",
"shipping_rate": 123
}
],
"items": [
{
"source_line_id": "<string>",
"source_product_id": 123,
"source_variant_id": 123,
"quantity": 123,
"unit_price": 123,
"unit_discount": 123,
"sku": "<string>",
"product_name": "<string>",
"variant_name": "<string>",
"description": "<string>",
"origin_country_code": "<string>",
"category": "<string>",
"requires_shipping": true,
"weight": {
"per_unit": 123
},
"hs_code": "<string>"
}
]
}
],
"external_reference_id": "<string>",
"custom_properties": {}
}
'import requests
url = "https://api.openborder.com/api/direct/v1/landed-cost"
payload = {
"ship_to": {
"country_code": "<string>",
"province": "<string>",
"postal_code": "<string>",
"address1": "<string>",
"address2": "<string>",
"city": "<string>",
"name": "<string>"
},
"caller_app": "<string>",
"currency_code": "<string>",
"order_discount": 123,
"shipments": [
{
"ship_from": {
"country_code": "<string>",
"province": "<string>",
"postal_code": "<string>",
"address1": "<string>",
"address2": "<string>",
"city": "<string>",
"name": "<string>"
},
"shipment_id": "<string>",
"shipping_rates": [
{
"shipping_rate_id": "<string>",
"shipping_rate": 123
}
],
"items": [
{
"source_line_id": "<string>",
"source_product_id": 123,
"source_variant_id": 123,
"quantity": 123,
"unit_price": 123,
"unit_discount": 123,
"sku": "<string>",
"product_name": "<string>",
"variant_name": "<string>",
"description": "<string>",
"origin_country_code": "<string>",
"category": "<string>",
"requires_shipping": True,
"weight": { "per_unit": 123 },
"hs_code": "<string>"
}
]
}
],
"external_reference_id": "<string>",
"custom_properties": {}
}
headers = {
"x-openborder-direct-api-key": "<x-openborder-direct-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-openborder-direct-api-key': '<x-openborder-direct-api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
ship_to: {
country_code: '<string>',
province: '<string>',
postal_code: '<string>',
address1: '<string>',
address2: '<string>',
city: '<string>',
name: '<string>'
},
caller_app: '<string>',
currency_code: '<string>',
order_discount: 123,
shipments: [
{
ship_from: {
country_code: '<string>',
province: '<string>',
postal_code: '<string>',
address1: '<string>',
address2: '<string>',
city: '<string>',
name: '<string>'
},
shipment_id: '<string>',
shipping_rates: [{shipping_rate_id: '<string>', shipping_rate: 123}],
items: [
{
source_line_id: '<string>',
source_product_id: 123,
source_variant_id: 123,
quantity: 123,
unit_price: 123,
unit_discount: 123,
sku: '<string>',
product_name: '<string>',
variant_name: '<string>',
description: '<string>',
origin_country_code: '<string>',
category: '<string>',
requires_shipping: true,
weight: {per_unit: 123},
hs_code: '<string>'
}
]
}
],
external_reference_id: '<string>',
custom_properties: {}
})
};
fetch('https://api.openborder.com/api/direct/v1/landed-cost', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.openborder.com/api/direct/v1/landed-cost",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'ship_to' => [
'country_code' => '<string>',
'province' => '<string>',
'postal_code' => '<string>',
'address1' => '<string>',
'address2' => '<string>',
'city' => '<string>',
'name' => '<string>'
],
'caller_app' => '<string>',
'currency_code' => '<string>',
'order_discount' => 123,
'shipments' => [
[
'ship_from' => [
'country_code' => '<string>',
'province' => '<string>',
'postal_code' => '<string>',
'address1' => '<string>',
'address2' => '<string>',
'city' => '<string>',
'name' => '<string>'
],
'shipment_id' => '<string>',
'shipping_rates' => [
[
'shipping_rate_id' => '<string>',
'shipping_rate' => 123
]
],
'items' => [
[
'source_line_id' => '<string>',
'source_product_id' => 123,
'source_variant_id' => 123,
'quantity' => 123,
'unit_price' => 123,
'unit_discount' => 123,
'sku' => '<string>',
'product_name' => '<string>',
'variant_name' => '<string>',
'description' => '<string>',
'origin_country_code' => '<string>',
'category' => '<string>',
'requires_shipping' => true,
'weight' => [
'per_unit' => 123
],
'hs_code' => '<string>'
]
]
]
],
'external_reference_id' => '<string>',
'custom_properties' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-openborder-direct-api-key: <x-openborder-direct-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.openborder.com/api/direct/v1/landed-cost"
payload := strings.NewReader("{\n \"ship_to\": {\n \"country_code\": \"<string>\",\n \"province\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"address1\": \"<string>\",\n \"address2\": \"<string>\",\n \"city\": \"<string>\",\n \"name\": \"<string>\"\n },\n \"caller_app\": \"<string>\",\n \"currency_code\": \"<string>\",\n \"order_discount\": 123,\n \"shipments\": [\n {\n \"ship_from\": {\n \"country_code\": \"<string>\",\n \"province\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"address1\": \"<string>\",\n \"address2\": \"<string>\",\n \"city\": \"<string>\",\n \"name\": \"<string>\"\n },\n \"shipment_id\": \"<string>\",\n \"shipping_rates\": [\n {\n \"shipping_rate_id\": \"<string>\",\n \"shipping_rate\": 123\n }\n ],\n \"items\": [\n {\n \"source_line_id\": \"<string>\",\n \"source_product_id\": 123,\n \"source_variant_id\": 123,\n \"quantity\": 123,\n \"unit_price\": 123,\n \"unit_discount\": 123,\n \"sku\": \"<string>\",\n \"product_name\": \"<string>\",\n \"variant_name\": \"<string>\",\n \"description\": \"<string>\",\n \"origin_country_code\": \"<string>\",\n \"category\": \"<string>\",\n \"requires_shipping\": true,\n \"weight\": {\n \"per_unit\": 123\n },\n \"hs_code\": \"<string>\"\n }\n ]\n }\n ],\n \"external_reference_id\": \"<string>\",\n \"custom_properties\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-openborder-direct-api-key", "<x-openborder-direct-api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.openborder.com/api/direct/v1/landed-cost")
.header("x-openborder-direct-api-key", "<x-openborder-direct-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"ship_to\": {\n \"country_code\": \"<string>\",\n \"province\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"address1\": \"<string>\",\n \"address2\": \"<string>\",\n \"city\": \"<string>\",\n \"name\": \"<string>\"\n },\n \"caller_app\": \"<string>\",\n \"currency_code\": \"<string>\",\n \"order_discount\": 123,\n \"shipments\": [\n {\n \"ship_from\": {\n \"country_code\": \"<string>\",\n \"province\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"address1\": \"<string>\",\n \"address2\": \"<string>\",\n \"city\": \"<string>\",\n \"name\": \"<string>\"\n },\n \"shipment_id\": \"<string>\",\n \"shipping_rates\": [\n {\n \"shipping_rate_id\": \"<string>\",\n \"shipping_rate\": 123\n }\n ],\n \"items\": [\n {\n \"source_line_id\": \"<string>\",\n \"source_product_id\": 123,\n \"source_variant_id\": 123,\n \"quantity\": 123,\n \"unit_price\": 123,\n \"unit_discount\": 123,\n \"sku\": \"<string>\",\n \"product_name\": \"<string>\",\n \"variant_name\": \"<string>\",\n \"description\": \"<string>\",\n \"origin_country_code\": \"<string>\",\n \"category\": \"<string>\",\n \"requires_shipping\": true,\n \"weight\": {\n \"per_unit\": 123\n },\n \"hs_code\": \"<string>\"\n }\n ]\n }\n ],\n \"external_reference_id\": \"<string>\",\n \"custom_properties\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.openborder.com/api/direct/v1/landed-cost")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-openborder-direct-api-key"] = '<x-openborder-direct-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"ship_to\": {\n \"country_code\": \"<string>\",\n \"province\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"address1\": \"<string>\",\n \"address2\": \"<string>\",\n \"city\": \"<string>\",\n \"name\": \"<string>\"\n },\n \"caller_app\": \"<string>\",\n \"currency_code\": \"<string>\",\n \"order_discount\": 123,\n \"shipments\": [\n {\n \"ship_from\": {\n \"country_code\": \"<string>\",\n \"province\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"address1\": \"<string>\",\n \"address2\": \"<string>\",\n \"city\": \"<string>\",\n \"name\": \"<string>\"\n },\n \"shipment_id\": \"<string>\",\n \"shipping_rates\": [\n {\n \"shipping_rate_id\": \"<string>\",\n \"shipping_rate\": 123\n }\n ],\n \"items\": [\n {\n \"source_line_id\": \"<string>\",\n \"source_product_id\": 123,\n \"source_variant_id\": 123,\n \"quantity\": 123,\n \"unit_price\": 123,\n \"unit_discount\": 123,\n \"sku\": \"<string>\",\n \"product_name\": \"<string>\",\n \"variant_name\": \"<string>\",\n \"description\": \"<string>\",\n \"origin_country_code\": \"<string>\",\n \"category\": \"<string>\",\n \"requires_shipping\": true,\n \"weight\": {\n \"per_unit\": 123\n },\n \"hs_code\": \"<string>\"\n }\n ]\n }\n ],\n \"external_reference_id\": \"<string>\",\n \"custom_properties\": {}\n}"
response = http.request(request)
puts response.read_body{
"landedcost_request_id": "<string>",
"currency_code": "<string>",
"external_reference_id": "<string>",
"created_at": "<string>",
"usd_conversion_rate": 123,
"shipments": [
{
"shipment_id": "<string>",
"shipment_type": "cross_border",
"shipping_rate_taxes": [
{
"shipping_rate_id": "<string>",
"shipping_rate": 123,
"tax_transaction_id": "<string>",
"landed_cost": {
"duties": 123,
"total_taxes": 123,
"shipment_taxes": 123,
"product_taxes": 123,
"breakdown": [
{
"type": "shipment_tax",
"tax_name": "<string>",
"rate": 123,
"amount": 123,
"taxable_amount": 123,
"jurisdiction": {
"name": "<string>",
"type": "<string>"
},
"sku": "<string>"
}
]
}
}
]
}
],
"hs_codes": [
{
"sku": "<string>",
"hs_code": "<string>"
}
]
}{
"error": [
{
"field": "ship_from",
"error": "Name is required"
}
]
}Headers
OpenBorder merchant API token
Body
This API uses JSON.
The required fields ensure accurate and guaranteed landed cost calculations.
All keys below must be included for a guaranteed calculation.
Destination address.
Show child attributes
Show child attributes
Identifier for your app/service (e.g., "checkout-service").
ISO 4217 currency code (e.g., USD, EUR).
Total order-level discount in major currency units (e.g., 10.00 means $10 off). Discount is split proportionally across products for duties/taxes.
One or more shipments to calculate landed costs for. A shipment groups the items sent from a specific origin warehouse to the order's destination address.
Show child attributes
Show child attributes
External ID for traceability, like a cart ID or checkout session ID.
Any custom metadata your system wants to store (max 4 KB).
Response
Landed cost successfully calculated
Unique ID for this tax calculation request, must be submitted with the final order — store this for auditing or support.
ISO 4217 currency code used for all amounts (e.g., "CAD").
Your original reference ID (e.g., cart or session ID) — helps link this calculation back to your system.
ISO timestamp showing when the calculation was processed.
Conversion rate from the returned currency to USD at the time of calculation — useful for reporting.
List of results for each shipment you submitted.
Show child attributes
Show child attributes
The HS Code each product has been classified to. Availability Note: This field is conditionally populated in the response body. It will only be included if your merchant configuration requires the HS Code for proper processing (ex. international shipping or customs declaration). If the field is not required for your integration, a null value will be returned.
Show child attributes
Show child attributes
curl --request POST \
--url https://api.openborder.com/api/direct/v1/landed-cost \
--header 'Content-Type: application/json' \
--header 'x-openborder-direct-api-key: <x-openborder-direct-api-key>' \
--data '
{
"ship_to": {
"country_code": "<string>",
"province": "<string>",
"postal_code": "<string>",
"address1": "<string>",
"address2": "<string>",
"city": "<string>",
"name": "<string>"
},
"caller_app": "<string>",
"currency_code": "<string>",
"order_discount": 123,
"shipments": [
{
"ship_from": {
"country_code": "<string>",
"province": "<string>",
"postal_code": "<string>",
"address1": "<string>",
"address2": "<string>",
"city": "<string>",
"name": "<string>"
},
"shipment_id": "<string>",
"shipping_rates": [
{
"shipping_rate_id": "<string>",
"shipping_rate": 123
}
],
"items": [
{
"source_line_id": "<string>",
"source_product_id": 123,
"source_variant_id": 123,
"quantity": 123,
"unit_price": 123,
"unit_discount": 123,
"sku": "<string>",
"product_name": "<string>",
"variant_name": "<string>",
"description": "<string>",
"origin_country_code": "<string>",
"category": "<string>",
"requires_shipping": true,
"weight": {
"per_unit": 123
},
"hs_code": "<string>"
}
]
}
],
"external_reference_id": "<string>",
"custom_properties": {}
}
'import requests
url = "https://api.openborder.com/api/direct/v1/landed-cost"
payload = {
"ship_to": {
"country_code": "<string>",
"province": "<string>",
"postal_code": "<string>",
"address1": "<string>",
"address2": "<string>",
"city": "<string>",
"name": "<string>"
},
"caller_app": "<string>",
"currency_code": "<string>",
"order_discount": 123,
"shipments": [
{
"ship_from": {
"country_code": "<string>",
"province": "<string>",
"postal_code": "<string>",
"address1": "<string>",
"address2": "<string>",
"city": "<string>",
"name": "<string>"
},
"shipment_id": "<string>",
"shipping_rates": [
{
"shipping_rate_id": "<string>",
"shipping_rate": 123
}
],
"items": [
{
"source_line_id": "<string>",
"source_product_id": 123,
"source_variant_id": 123,
"quantity": 123,
"unit_price": 123,
"unit_discount": 123,
"sku": "<string>",
"product_name": "<string>",
"variant_name": "<string>",
"description": "<string>",
"origin_country_code": "<string>",
"category": "<string>",
"requires_shipping": True,
"weight": { "per_unit": 123 },
"hs_code": "<string>"
}
]
}
],
"external_reference_id": "<string>",
"custom_properties": {}
}
headers = {
"x-openborder-direct-api-key": "<x-openborder-direct-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-openborder-direct-api-key': '<x-openborder-direct-api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
ship_to: {
country_code: '<string>',
province: '<string>',
postal_code: '<string>',
address1: '<string>',
address2: '<string>',
city: '<string>',
name: '<string>'
},
caller_app: '<string>',
currency_code: '<string>',
order_discount: 123,
shipments: [
{
ship_from: {
country_code: '<string>',
province: '<string>',
postal_code: '<string>',
address1: '<string>',
address2: '<string>',
city: '<string>',
name: '<string>'
},
shipment_id: '<string>',
shipping_rates: [{shipping_rate_id: '<string>', shipping_rate: 123}],
items: [
{
source_line_id: '<string>',
source_product_id: 123,
source_variant_id: 123,
quantity: 123,
unit_price: 123,
unit_discount: 123,
sku: '<string>',
product_name: '<string>',
variant_name: '<string>',
description: '<string>',
origin_country_code: '<string>',
category: '<string>',
requires_shipping: true,
weight: {per_unit: 123},
hs_code: '<string>'
}
]
}
],
external_reference_id: '<string>',
custom_properties: {}
})
};
fetch('https://api.openborder.com/api/direct/v1/landed-cost', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.openborder.com/api/direct/v1/landed-cost",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'ship_to' => [
'country_code' => '<string>',
'province' => '<string>',
'postal_code' => '<string>',
'address1' => '<string>',
'address2' => '<string>',
'city' => '<string>',
'name' => '<string>'
],
'caller_app' => '<string>',
'currency_code' => '<string>',
'order_discount' => 123,
'shipments' => [
[
'ship_from' => [
'country_code' => '<string>',
'province' => '<string>',
'postal_code' => '<string>',
'address1' => '<string>',
'address2' => '<string>',
'city' => '<string>',
'name' => '<string>'
],
'shipment_id' => '<string>',
'shipping_rates' => [
[
'shipping_rate_id' => '<string>',
'shipping_rate' => 123
]
],
'items' => [
[
'source_line_id' => '<string>',
'source_product_id' => 123,
'source_variant_id' => 123,
'quantity' => 123,
'unit_price' => 123,
'unit_discount' => 123,
'sku' => '<string>',
'product_name' => '<string>',
'variant_name' => '<string>',
'description' => '<string>',
'origin_country_code' => '<string>',
'category' => '<string>',
'requires_shipping' => true,
'weight' => [
'per_unit' => 123
],
'hs_code' => '<string>'
]
]
]
],
'external_reference_id' => '<string>',
'custom_properties' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-openborder-direct-api-key: <x-openborder-direct-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.openborder.com/api/direct/v1/landed-cost"
payload := strings.NewReader("{\n \"ship_to\": {\n \"country_code\": \"<string>\",\n \"province\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"address1\": \"<string>\",\n \"address2\": \"<string>\",\n \"city\": \"<string>\",\n \"name\": \"<string>\"\n },\n \"caller_app\": \"<string>\",\n \"currency_code\": \"<string>\",\n \"order_discount\": 123,\n \"shipments\": [\n {\n \"ship_from\": {\n \"country_code\": \"<string>\",\n \"province\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"address1\": \"<string>\",\n \"address2\": \"<string>\",\n \"city\": \"<string>\",\n \"name\": \"<string>\"\n },\n \"shipment_id\": \"<string>\",\n \"shipping_rates\": [\n {\n \"shipping_rate_id\": \"<string>\",\n \"shipping_rate\": 123\n }\n ],\n \"items\": [\n {\n \"source_line_id\": \"<string>\",\n \"source_product_id\": 123,\n \"source_variant_id\": 123,\n \"quantity\": 123,\n \"unit_price\": 123,\n \"unit_discount\": 123,\n \"sku\": \"<string>\",\n \"product_name\": \"<string>\",\n \"variant_name\": \"<string>\",\n \"description\": \"<string>\",\n \"origin_country_code\": \"<string>\",\n \"category\": \"<string>\",\n \"requires_shipping\": true,\n \"weight\": {\n \"per_unit\": 123\n },\n \"hs_code\": \"<string>\"\n }\n ]\n }\n ],\n \"external_reference_id\": \"<string>\",\n \"custom_properties\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-openborder-direct-api-key", "<x-openborder-direct-api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.openborder.com/api/direct/v1/landed-cost")
.header("x-openborder-direct-api-key", "<x-openborder-direct-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"ship_to\": {\n \"country_code\": \"<string>\",\n \"province\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"address1\": \"<string>\",\n \"address2\": \"<string>\",\n \"city\": \"<string>\",\n \"name\": \"<string>\"\n },\n \"caller_app\": \"<string>\",\n \"currency_code\": \"<string>\",\n \"order_discount\": 123,\n \"shipments\": [\n {\n \"ship_from\": {\n \"country_code\": \"<string>\",\n \"province\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"address1\": \"<string>\",\n \"address2\": \"<string>\",\n \"city\": \"<string>\",\n \"name\": \"<string>\"\n },\n \"shipment_id\": \"<string>\",\n \"shipping_rates\": [\n {\n \"shipping_rate_id\": \"<string>\",\n \"shipping_rate\": 123\n }\n ],\n \"items\": [\n {\n \"source_line_id\": \"<string>\",\n \"source_product_id\": 123,\n \"source_variant_id\": 123,\n \"quantity\": 123,\n \"unit_price\": 123,\n \"unit_discount\": 123,\n \"sku\": \"<string>\",\n \"product_name\": \"<string>\",\n \"variant_name\": \"<string>\",\n \"description\": \"<string>\",\n \"origin_country_code\": \"<string>\",\n \"category\": \"<string>\",\n \"requires_shipping\": true,\n \"weight\": {\n \"per_unit\": 123\n },\n \"hs_code\": \"<string>\"\n }\n ]\n }\n ],\n \"external_reference_id\": \"<string>\",\n \"custom_properties\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.openborder.com/api/direct/v1/landed-cost")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-openborder-direct-api-key"] = '<x-openborder-direct-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"ship_to\": {\n \"country_code\": \"<string>\",\n \"province\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"address1\": \"<string>\",\n \"address2\": \"<string>\",\n \"city\": \"<string>\",\n \"name\": \"<string>\"\n },\n \"caller_app\": \"<string>\",\n \"currency_code\": \"<string>\",\n \"order_discount\": 123,\n \"shipments\": [\n {\n \"ship_from\": {\n \"country_code\": \"<string>\",\n \"province\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"address1\": \"<string>\",\n \"address2\": \"<string>\",\n \"city\": \"<string>\",\n \"name\": \"<string>\"\n },\n \"shipment_id\": \"<string>\",\n \"shipping_rates\": [\n {\n \"shipping_rate_id\": \"<string>\",\n \"shipping_rate\": 123\n }\n ],\n \"items\": [\n {\n \"source_line_id\": \"<string>\",\n \"source_product_id\": 123,\n \"source_variant_id\": 123,\n \"quantity\": 123,\n \"unit_price\": 123,\n \"unit_discount\": 123,\n \"sku\": \"<string>\",\n \"product_name\": \"<string>\",\n \"variant_name\": \"<string>\",\n \"description\": \"<string>\",\n \"origin_country_code\": \"<string>\",\n \"category\": \"<string>\",\n \"requires_shipping\": true,\n \"weight\": {\n \"per_unit\": 123\n },\n \"hs_code\": \"<string>\"\n }\n ]\n }\n ],\n \"external_reference_id\": \"<string>\",\n \"custom_properties\": {}\n}"
response = http.request(request)
puts response.read_body{
"landedcost_request_id": "<string>",
"currency_code": "<string>",
"external_reference_id": "<string>",
"created_at": "<string>",
"usd_conversion_rate": 123,
"shipments": [
{
"shipment_id": "<string>",
"shipment_type": "cross_border",
"shipping_rate_taxes": [
{
"shipping_rate_id": "<string>",
"shipping_rate": 123,
"tax_transaction_id": "<string>",
"landed_cost": {
"duties": 123,
"total_taxes": 123,
"shipment_taxes": 123,
"product_taxes": 123,
"breakdown": [
{
"type": "shipment_tax",
"tax_name": "<string>",
"rate": 123,
"amount": 123,
"taxable_amount": 123,
"jurisdiction": {
"name": "<string>",
"type": "<string>"
},
"sku": "<string>"
}
]
}
}
]
}
],
"hs_codes": [
{
"sku": "<string>",
"hs_code": "<string>"
}
]
}{
"error": [
{
"field": "ship_from",
"error": "Name is required"
}
]
}