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
Generate a commercial invoice PDF
POST https://api.border.bot/v1/documents/invoice
Requires an access token from an API client (Authorization: Bearer <access_token>).
A commercial invoice (kind: commercial) or pro forma invoice (kind: proforma) as a PDF: the exporter, consignee and, when they differ, buyer and importer of record with their tax references; the reason for export, Incoterms, currency and transport details; the goods table (description, HS code, origin, quantity, unit price, net weight, amount) over as many pages as it needs; itemised charges and the total; further declarations and the signatory’s statement. A4 or Letter (paper), 1 to 3 copies. Validated before charging: a general description, a malformed HS code or non-Latin text answers 400 without a charge. You make the declaration on it: border.bot doesn’t check, value or file anything, and no carrier or authority has to accept it (Terms, Shipping documents: https://border.bot/legal/terms#shipping-documents). Costs 1 credit.
API client scope: documents.
Headers#
| Name | Type | Required | Description |
|---|---|---|---|
idempotency-key |
string | no | Make retries safe: a repeat with the same key returns the original result without charging again (keys are scoped to your workspace). |
Request body (JSON)#
| Name | Type | Required | Description |
|---|---|---|---|
kind |
"commercial" | "proforma" | no | |
number |
string | yes | |
date |
string (date) | yes | |
orderReference |
string | no | |
exporter |
object | yes | |
consignee |
object | yes | |
buyer |
object | no | |
importer |
object | no | |
reasonForExport |
"sale" | "gift" | "sample" | "return" | "repair" | "personal" | "other" | no | |
reasonDetail |
string | no | |
incoterm |
"EXW" | "FCA" | "CPT" | "CIP" | "DAP" | "DPU" | "DDP" | "FAS" | "FOB" | "CFR" | "CIF" | no | |
incotermPlace |
string | no | |
currency |
string | yes | |
paymentTerms |
string | no | |
carrier |
string | no | |
trackingNumber |
string | no | |
packages |
integer | no | |
weightUnit |
"kg" | "lb" | no | |
grossWeight |
number | no | |
netWeight |
number | no | |
portOfEntry |
string | no | |
marks |
string | no | |
lines |
object[] | yes | |
freight |
number | no | |
insurance |
number | no | |
packing |
number | no | |
otherCharges |
number | no | |
otherChargesLabel |
string | no | |
discount |
number | no | |
declarations |
string | no | |
signatory |
object | yes | |
paper |
"a4" | "letter" | no | |
copies |
integer | no |
Responses#
200: The PDF (base64) and the credits charged. (CommercialInvoiceResponse)400: Invalid input (invalid_input). (Error)401: Missing, invalid or expired access token, or a revoked or expired API client (unauthorized). (Error)402: Not enough credits (insufficient_credits). Nothing was charged. (Error)403: Workspace suspended, action disabled, or the client lacks the scope (org_suspended,action_disabled,forbidden). (Error)409: A request with this Idempotency-Key is still in progress (conflict). (Error)429: Rate limited (rate_limited). Retry afterRetry-Afterseconds;RateLimitsays which limit was hit (r=0,tseconds until its window ends) andRateLimit-Policyits quota. (Error)500: Unexpected error (internal). (Error)502: The engine failed (upstream_error). The credits are refunded automatically. (Error)504: The engine timed out (upstream_timeout). The credits are refunded automatically. (Error)
Example request#
curl -X POST https://api.border.bot/v1/documents/invoice \
-H "Authorization: Bearer $BORDERBOT_TOKEN" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"kind": "commercial",
"number": "INV-2026-0418",
"date": "2026-10-26",
"orderReference": "PO 88213",
"exporter": {
"name": "Northwind Apparel Ltd",
"contact": "Priya Shah",
"address": "Unit 4, Bath Road Trading Estate",
"city": "Hounslow",
"postcode": "TW4 6HG",
"country": "GB",
"phone": "+44 20 7946 0000",
"email": "exports@northwind.example",
"taxReferences": [
{
"label": "EORI",
"value": "GB123456789000"
},
{
"label": "VAT",
"value": "GB123456789"
}
]
},
"consignee": {
"name": "Harbor Street Retail Inc",
"contact": "Receiving dept.",
"address": "1200 Harbor Street, Suite 300",
"city": "Los Angeles",
"region": "CA",
"postcode": "90021",
"country": "US",
"phone": "+1 213 555 0100",
"taxReferences": [
{
"label": "EIN",
"value": "12-3456789"
}
]
},
"reasonForExport": "sale",
"incoterm": "DAP",
"incotermPlace": "Los Angeles",
"currency": "USD",
"paymentTerms": "Net 30",
"carrier": "DHL Express",
"trackingNumber": "1234567890",
"packages": 4,
"weightUnit": "kg",
"grossWeight": 86.4,
"portOfEntry": "Los Angeles, CA",
"marks": "HSR / LOS ANGELES / 1-4",
"lines": [
{
"description": "Men'\''s T-shirts, knitted, 100% cotton, short sleeves",
"sku": "NW-TEE-001",
"hsCode": "610910",
"origin": "PT",
"quantity": 300,
"unit": "pcs",
"unitPrice": 6.4,
"netWeight": 54
},
{
"description": "Women'\''s hooded sweatshirts, knitted, 80% cotton 20% polyester",
"sku": "NW-HOOD-014",
"hsCode": "611020",
"origin": "PT",
"quantity": 180,
"unit": "pcs",
"unitPrice": 14.75,
"netWeight": 27
},
{
"description": "Woven cotton tote bags, printed, with handles",
"sku": "NW-TOTE-003",
"hsCode": "420292",
"origin": "IN",
"quantity": 60,
"unit": "pcs",
"unitPrice": 3.1,
"netWeight": 3.6
}
],
"freight": 210,
"insurance": 18.5,
"signatory": {
"name": "Priya Shah",
"title": "Export manager",
"place": "Hounslow"
},
"paper": "a4",
"copies": 1
}'const response = await fetch('https://api.border.bot/v1/documents/invoice', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.BORDERBOT_TOKEN}`,
'Content-Type': 'application/json',
'Idempotency-Key': crypto.randomUUID(),
},
body: JSON.stringify({
"kind": "commercial",
"number": "INV-2026-0418",
"date": "2026-10-26",
"orderReference": "PO 88213",
"exporter": {
"name": "Northwind Apparel Ltd",
"contact": "Priya Shah",
"address": "Unit 4, Bath Road Trading Estate",
"city": "Hounslow",
"postcode": "TW4 6HG",
"country": "GB",
"phone": "+44 20 7946 0000",
"email": "exports@northwind.example",
"taxReferences": [
{
"label": "EORI",
"value": "GB123456789000"
},
{
"label": "VAT",
"value": "GB123456789"
}
]
},
"consignee": {
"name": "Harbor Street Retail Inc",
"contact": "Receiving dept.",
"address": "1200 Harbor Street, Suite 300",
"city": "Los Angeles",
"region": "CA",
"postcode": "90021",
"country": "US",
"phone": "+1 213 555 0100",
"taxReferences": [
{
"label": "EIN",
"value": "12-3456789"
}
]
},
"reasonForExport": "sale",
"incoterm": "DAP",
"incotermPlace": "Los Angeles",
"currency": "USD",
"paymentTerms": "Net 30",
"carrier": "DHL Express",
"trackingNumber": "1234567890",
"packages": 4,
"weightUnit": "kg",
"grossWeight": 86.4,
"portOfEntry": "Los Angeles, CA",
"marks": "HSR / LOS ANGELES / 1-4",
"lines": [
{
"description": "Men's T-shirts, knitted, 100% cotton, short sleeves",
"sku": "NW-TEE-001",
"hsCode": "610910",
"origin": "PT",
"quantity": 300,
"unit": "pcs",
"unitPrice": 6.4,
"netWeight": 54
},
{
"description": "Women's hooded sweatshirts, knitted, 80% cotton 20% polyester",
"sku": "NW-HOOD-014",
"hsCode": "611020",
"origin": "PT",
"quantity": 180,
"unit": "pcs",
"unitPrice": 14.75,
"netWeight": 27
},
{
"description": "Woven cotton tote bags, printed, with handles",
"sku": "NW-TOTE-003",
"hsCode": "420292",
"origin": "IN",
"quantity": 60,
"unit": "pcs",
"unitPrice": 3.1,
"netWeight": 3.6
}
],
"freight": 210,
"insurance": 18.5,
"signatory": {
"name": "Priya Shah",
"title": "Export manager",
"place": "Hounslow"
},
"paper": "a4",
"copies": 1
}),
});
const data = await response.json();import os, uuid
import requests
response = requests.post(
"https://api.border.bot/v1/documents/invoice",
headers={"Authorization": f"Bearer {os.environ['BORDERBOT_TOKEN']}", "Idempotency-Key": str(uuid.uuid4())},
json={
"kind": "commercial",
"number": "INV-2026-0418",
"date": "2026-10-26",
"orderReference": "PO 88213",
"exporter": {
"name": "Northwind Apparel Ltd",
"contact": "Priya Shah",
"address": "Unit 4, Bath Road Trading Estate",
"city": "Hounslow",
"postcode": "TW4 6HG",
"country": "GB",
"phone": "+44 20 7946 0000",
"email": "exports@northwind.example",
"taxReferences": [
{
"label": "EORI",
"value": "GB123456789000",
},
{
"label": "VAT",
"value": "GB123456789",
},
],
},
"consignee": {
"name": "Harbor Street Retail Inc",
"contact": "Receiving dept.",
"address": "1200 Harbor Street, Suite 300",
"city": "Los Angeles",
"region": "CA",
"postcode": "90021",
"country": "US",
"phone": "+1 213 555 0100",
"taxReferences": [
{
"label": "EIN",
"value": "12-3456789",
},
],
},
"reasonForExport": "sale",
"incoterm": "DAP",
"incotermPlace": "Los Angeles",
"currency": "USD",
"paymentTerms": "Net 30",
"carrier": "DHL Express",
"trackingNumber": "1234567890",
"packages": 4,
"weightUnit": "kg",
"grossWeight": 86.4,
"portOfEntry": "Los Angeles, CA",
"marks": "HSR / LOS ANGELES / 1-4",
"lines": [
{
"description": "Men's T-shirts, knitted, 100% cotton, short sleeves",
"sku": "NW-TEE-001",
"hsCode": "610910",
"origin": "PT",
"quantity": 300,
"unit": "pcs",
"unitPrice": 6.4,
"netWeight": 54,
},
{
"description": "Women's hooded sweatshirts, knitted, 80% cotton 20% polyester",
"sku": "NW-HOOD-014",
"hsCode": "611020",
"origin": "PT",
"quantity": 180,
"unit": "pcs",
"unitPrice": 14.75,
"netWeight": 27,
},
{
"description": "Woven cotton tote bags, printed, with handles",
"sku": "NW-TOTE-003",
"hsCode": "420292",
"origin": "IN",
"quantity": 60,
"unit": "pcs",
"unitPrice": 3.1,
"netWeight": 3.6,
},
],
"freight": 210,
"insurance": 18.5,
"signatory": {
"name": "Priya Shah",
"title": "Export manager",
"place": "Hounslow",
},
"paper": "a4",
"copies": 1,
},
)
data = response.json()<?php
$ch = curl_init('https://api.border.bot/v1/documents/invoice');
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([
'kind' => 'commercial',
'number' => 'INV-2026-0418',
'date' => '2026-10-26',
'orderReference' => 'PO 88213',
'exporter' => [
'name' => 'Northwind Apparel Ltd',
'contact' => 'Priya Shah',
'address' => 'Unit 4, Bath Road Trading Estate',
'city' => 'Hounslow',
'postcode' => 'TW4 6HG',
'country' => 'GB',
'phone' => '+44 20 7946 0000',
'email' => 'exports@northwind.example',
'taxReferences' => [
[
'label' => 'EORI',
'value' => 'GB123456789000',
],
[
'label' => 'VAT',
'value' => 'GB123456789',
],
],
],
'consignee' => [
'name' => 'Harbor Street Retail Inc',
'contact' => 'Receiving dept.',
'address' => '1200 Harbor Street, Suite 300',
'city' => 'Los Angeles',
'region' => 'CA',
'postcode' => '90021',
'country' => 'US',
'phone' => '+1 213 555 0100',
'taxReferences' => [
[
'label' => 'EIN',
'value' => '12-3456789',
],
],
],
'reasonForExport' => 'sale',
'incoterm' => 'DAP',
'incotermPlace' => 'Los Angeles',
'currency' => 'USD',
'paymentTerms' => 'Net 30',
'carrier' => 'DHL Express',
'trackingNumber' => '1234567890',
'packages' => 4,
'weightUnit' => 'kg',
'grossWeight' => 86.4,
'portOfEntry' => 'Los Angeles, CA',
'marks' => 'HSR / LOS ANGELES / 1-4',
'lines' => [
[
'description' => 'Men\'s T-shirts, knitted, 100% cotton, short sleeves',
'sku' => 'NW-TEE-001',
'hsCode' => '610910',
'origin' => 'PT',
'quantity' => 300,
'unit' => 'pcs',
'unitPrice' => 6.4,
'netWeight' => 54,
],
[
'description' => 'Women\'s hooded sweatshirts, knitted, 80% cotton 20% polyester',
'sku' => 'NW-HOOD-014',
'hsCode' => '611020',
'origin' => 'PT',
'quantity' => 180,
'unit' => 'pcs',
'unitPrice' => 14.75,
'netWeight' => 27,
],
[
'description' => 'Woven cotton tote bags, printed, with handles',
'sku' => 'NW-TOTE-003',
'hsCode' => '420292',
'origin' => 'IN',
'quantity' => 60,
'unit' => 'pcs',
'unitPrice' => 3.1,
'netWeight' => 3.6,
],
],
'freight' => 210,
'insurance' => 18.5,
'signatory' => [
'name' => 'Priya Shah',
'title' => 'Export manager',
'place' => 'Hounslow',
],
'paper' => 'a4',
'copies' => 1,
]),
]);
$data = json_decode(curl_exec($ch), true);Example response (200)#
{
"data": {
"number": "INV-2026-0418",
"filename": "Commercial-invoice-INV-2026-0418.pdf",
"pages": 1,
"contentType": "application/pdf",
"pdf": "string"
},
"credits": {
"charged": 0,
"remaining": 0,
"usageId": "string"
},
"replayed": false
}