DutyFlow
Get started free
v1

DutyFlow API Documentation

Deterministic duty calculation for US imports and 200+ country pairs via WTO MFN and bilateral trade data. Pass an HTS code and origin country β€” get back a fully itemized duty breakdown with source citations.

Quickstart

Getting Started

DutyFlow gives you deterministic, source-cited duty calculations via a simple REST API. Make your first call in under 2 minutes.

  1. Create a free account and get your API key from the dashboard
  2. Make a POST request to /v1/duties/calculate
  3. Receive a breakdown of all applicable duties, fees, and landed cost
curl Β· First request
curl -X POST https://api.DutyFlow.com/v1/duties/calculate \
  -H "X-API-Key: dfl_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "htsCode": "8471.30.01.00",
    "originCountry": "CN",
    "quantity": 10,
    "unitPrice": 500,
    "shippingCost": 100
  }'
Security

Authentication

API KeyRecommended

Include your API key in the X-API-Key header. Get yours from the dashboard under API Keys.

Header
X-API-Key: dfl_your_api_key_here
JWT Bearer

Alternatively, include a JWT token obtained during login in the Authorization header.

Header
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9...

Never expose your API key in client-side code. Use environment variables and proxy through your backend.

Core endpoint

POST /v1/duties/calculate

Calculate the full duty breakdown for a single HTS code. Supports all US tariff stacking rules (Section 301, 232, IEEPA), CBP fees (MPF, HMF), and EU/UK/Canada destinations.

Request body

FieldTypeRequiredDescription
htsCodestringβœ“10-digit HTS code (dots optional)
originCountrystringβœ“ISO-2 country code (e.g. "CN", "VN")
quantitynumberβœ“Number of units (min: 0.001)
unitPricenumberβœ“Price per unit in USD
destCountrystringβ€”Destination ISO-2 (default: "US")
shippingCostnumberβ€”Total shipping in USD (default: 0)
insurancenumberβ€”Insurance amount in USD (default: 0)
transportModestringβ€”OCEAN | AIR | TRUCK | RAIL
Request Β· JS fetch
const res = await fetch(
  'https://api.DutyFlow.com/v1/duties/calculate',
  {
    method: 'POST',
    headers: {
      'X-API-Key': 'dfl_your_key',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      htsCode: '8471.30.01.00',
      originCountry: 'CN',
      quantity: 10,
      unitPrice: 500,
      shippingCost: 100,
      transportMode: 'OCEAN',
    }),
  }
)
const data = await res.json()
Request Β· Python
import httpx

res = httpx.post(
    "https://api.DutyFlow.com/v1/duties/calculate",
    headers={"X-API-Key": "dfl_your_key"},
    json={
        "htsCode": "8471.30.01.00",
        "originCountry": "CN",
        "quantity": 10,
        "unitPrice": 500,
        "shippingCost": 100,
        "transportMode": "OCEAN",
    },
)
data = res.json()
Response Β· 200 OK
{
  "calculationId": "clx9f3k2z0001...",
  "htsCode": "8471.30.01.00",
  "originCountry": "CN",
  "destCountry": "US",
  "lineItems": [
    {
      "type": "BASE",
      "description": "Base HTS duty",
      "rate": 0,
      "amount": 0,
      "source": "USITC HTS 2026 β€” Chapter 84"
    },
    {
      "type": "SECTION_301",
      "description": "Section 301 β€” China List 3 (25%)",
      "rate": 0.25,
      "amount": 1252.50,
      "source": "USTR β€” 84 FR 20459",
      "chapter99": "9903.88.03"
    },
    {
      "type": "MPF",
      "description": "Merchandise Processing Fee (capped)",
      "rate": 0.003464,
      "amount": 25.00,
      "source": "CBP 19 CFR 24.23"
    },
    {
      "type": "HMF",
      "description": "Harbor Maintenance Fee (ocean)",
      "rate": 0.00125,
      "amount": 6.25,
      "source": "CBP 19 CFR 24.24"
    }
  ],
  "baseRate": 0,
  "baseDuty": 0,
  "additionalDuty": 1252.50,
  "mpf": 25.00,
  "hmf": 6.25,
  "totalDuty": 1283.75,
  "landedCost": 6383.75,
  "effectiveRate": 0.2568,
  "currency": "USD",
  "disclaimer": "Estimate only Β· not legal or customs advice Β· verify with a licensed customs broker",
  "sources": ["USITC HTS 2026", "USTR Action", "CBP 19 CFR"]
}
Business+

POST /v1/duties/bulk

Requires Business plan. Max 200 items per request. Results returned in the same order as input.

Calculate duties for up to 200 HTS codes in a single request. Ideal for checkout flows, catalog enrichment, or compliance batch jobs.

Request Β· bulk
curl -X POST https://api.DutyFlow.com/v1/duties/bulk \
  -H "X-API-Key: dfl_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "items": [
      {
        "htsCode": "8471.30.01.00",
        "originCountry": "CN",
        "quantity": 10,
        "unitPrice": 500
      },
      {
        "htsCode": "6109.10.00.04",
        "originCountry": "VN",
        "quantity": 2000,
        "unitPrice": 5
      }
    ]
  }'

Rate Limits & Plans

Free

  • 50/mo calculations
  • 5 countries
  • βœ— Bulk endpoint

Starter

  • 500/mo calculations
  • 25 countries
  • βœ— Bulk endpoint

Business

  • 5,000/mo calculations
  • 200+ countries
  • βœ“ Bulk endpoint

Limits reset on the 1st of each month UTC. Exceeding the limit returns HTTP 429. Check remaining calls via GET /v1/users/me/usage.

Error Codes

HTTPCodeDescription
400INVALID_INPUTMissing or invalid request fields (check message)
401UNAUTHORIZEDMissing or invalid API key / JWT token
403FORBIDDENPlan does not support this feature (e.g. bulk endpoint)
404HTS_NOT_FOUNDHTS code not found in database
429RATE_LIMITEDMonthly calculation limit reached β€” upgrade plan
500INTERNAL_ERRORUnexpected server error β€” contact support
Error response shape
{
  "statusCode": 429,
  "error": "RATE_LIMITED",
  "message": "Monthly limit of 50 calculations reached. Upgrade to Starter for 500/mo.",
  "upgradeUrl": "https://DutyFlow.com/pricing"
}

SDKs & Libraries

SDKs are in development. Preview the API shape below and test endpoints live in the playground.

Try in Playground
⚑JavaScript / TypeScriptComing soon
@DutyFlow/sdk Β· TypeScript
import { DutyFlow } from '@DutyFlow/sdk'

const client = new DutyFlow({ apiKey: 'dfl_your_key' })

const result = await client.duties.resolve({
  htsCode: '8471.30.01.00',
  originCountry: 'CN',
  value: 5000,
})
🐍PythonComing soon
DutyFlow Β· Python
from DutyFlow import DutyFlow

client = DutyFlow(api_key="dfl_your_key")

result = client.duties.resolve(
    hts_code="8471.30.01.00",
    origin_country="CN",
    value=5000,
)

In the meantime, use the REST API directly or contact us for custom integrations.

Ready to start?

Free tier includes 50 calculations/month. No credit card required.