Docs menu
Get started
Using the API
API reference
Classification
Landed cost
Compliance
- POSTRegulate: find an agency product code
- POSTCheck restricted goods
- GETRestricted-goods checks
- GETAgency filing checks
- POSTCheck agency filings (Comply)
- POSTCross: classify, restrict, comply, regulate and calculate in one call
- GETYour restricted-goods rules
- POSTAdd a restricted-goods rule
- DELETERemove a restricted-goods rule
- POSTScreen a person or company
- GETYour screening checks
Reference
Origin
Shipping documents
Bulk
Catalogue
- GETList products
- POSTCreate a product
- GETGet a product
- PATCHUpdate a product
- POSTArchive a product
- GETA product’s history
- GETA product’s codes
- POSTAdd a code
- POSTSuggest codes
- POSTApprove a code
- POSTReject a code
- POSTClassify many products
- GETYour imports
- POSTImport a CSV file
- GETAn import
- GETExport as CSV
- POSTSync records from a source
- GETApproved codes to write back
- GETCatalogue vocabularies
- GETSource kinds
- GETDefault target markets
- POSTSet default target markets
Quickstart
Create a border.bot API client, get an access token, classify a product, then calculate its landed cost, with curl.
1. Create an API client#
Sign in to the dashboard and open Developers → API clients. Create a client for your workspace. You get a client ID, a client secret and the token URL. The secret is shown once, so put it in your secrets manager straight away.
export BORDERBOT_TOKEN_URL=https://api.border.bot/oauth2/token
export BORDERBOT_CLIENT_ID=client_...
export BORDERBOT_CLIENT_SECRET=...Trade them for an access token. It lasts about an hour (expires_in), so fetch a new one before it runs out or after a 401:
export BORDERBOT_TOKEN=$(curl -s -X POST "$BORDERBOT_TOKEN_URL" \
-d grant_type=client_credentials \
-d client_id="$BORDERBOT_CLIENT_ID" \
-d client_secret="$BORDERBOT_CLIENT_SECRET" | jq -r .access_token)Check the token works. GET /v1/me is free and returns the workspace, the API client and its scopes, and the credit balance:
curl https://api.border.bot/v1/me \
-H "Authorization: Bearer $BORDERBOT_TOKEN"2. Classify a product#
Send a description or a product URL with the destination country. Add the origin if you know it.
curl -X POST https://api.border.bot/v1/classify \
-H "Authorization: Bearer $BORDERBOT_TOKEN" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"description": "Men'\''s cotton crew-neck t-shirt, knitted",
"destinationCountry": "US",
"originCountry": "PT"
}'const response = await fetch('https://api.border.bot/v1/classify', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.BORDERBOT_TOKEN}`,
'Content-Type': 'application/json',
'Idempotency-Key': crypto.randomUUID(),
},
body: JSON.stringify({
"description": "Men's cotton crew-neck t-shirt, knitted",
"destinationCountry": "US",
"originCountry": "PT"
}),
});
const data = await response.json();import os, uuid
import requests
response = requests.post(
"https://api.border.bot/v1/classify",
headers={"Authorization": f"Bearer {os.environ['BORDERBOT_TOKEN']}", "Idempotency-Key": str(uuid.uuid4())},
json={
"description": "Men's cotton crew-neck t-shirt, knitted",
"destinationCountry": "US",
"originCountry": "PT",
},
)
data = response.json()<?php
$ch = curl_init('https://api.border.bot/v1/classify');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('BORDERBOT_TOKEN'),
'Content-Type: application/json',
'Idempotency-Key: ' . bin2hex(random_bytes(16)),
],
CURLOPT_POSTFIELDS => json_encode([
'description' => 'Men\'s cotton crew-neck t-shirt, knitted',
'destinationCountry' => 'US',
'originCountry' => 'PT',
]),
]);
$data = json_decode(curl_exec($ch), true);The response has the code in the destination's format, the official description at each level, a confidence score, the reasoning and alternatives. The X-Credits-Charged and X-Credits-Remaining headers say what the call cost.
3. Calculate landed cost#
Pass the code, the origin and destination, the goods value and the shipping cost:
curl -X POST https://api.border.bot/v1/calculate \
-H "Authorization: Bearer $BORDERBOT_TOKEN" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"hsCode": "6109.10.00.12",
"originCountry": "PT",
"destinationCountry": "US",
"value": 120,
"currency": "USD",
"shippingCost": 15
}'const response = await fetch('https://api.border.bot/v1/calculate', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.BORDERBOT_TOKEN}`,
'Content-Type': 'application/json',
'Idempotency-Key': crypto.randomUUID(),
},
body: JSON.stringify({
"hsCode": "6109.10.00.12",
"originCountry": "PT",
"destinationCountry": "US",
"value": 120,
"currency": "USD",
"shippingCost": 15
}),
});
const data = await response.json();import os, uuid
import requests
response = requests.post(
"https://api.border.bot/v1/calculate",
headers={"Authorization": f"Bearer {os.environ['BORDERBOT_TOKEN']}", "Idempotency-Key": str(uuid.uuid4())},
json={
"hsCode": "6109.10.00.12",
"originCountry": "PT",
"destinationCountry": "US",
"value": 120,
"currency": "USD",
"shippingCost": 15,
},
)
data = response.json()<?php
$ch = curl_init('https://api.border.bot/v1/calculate');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('BORDERBOT_TOKEN'),
'Content-Type: application/json',
'Idempotency-Key: ' . bin2hex(random_bytes(16)),
],
CURLOPT_POSTFIELDS => json_encode([
'hsCode' => '6109.10.00.12',
'originCountry' => 'PT',
'destinationCountry' => 'US',
'value' => 120,
'currency' => 'USD',
'shippingCost' => 15,
]),
]);
$data = json_decode(curl_exec($ch), true);You get every duty, tax and fee line with its legal basis and the total landed cost. The reference for this endpoint lists every field, including shipping terms, preferential rates and seller-collected taxes.
Next#
- Authentication: API clients, tokens and scopes.
- Credits and retries: what each call costs and how to retry without paying twice.
- Errors and rate limits.
- API reference: every endpoint, in cURL, JavaScript, Python and PHP.
- Postman collection: every endpoint to import into Postman.
Last updated