> ## Documentation Index
> Fetch the complete documentation index at: https://docs.landedfees.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Compare origins

> Runs the landed-cost engine in parallel for 1 to 6 origin
countries against a single HS + destination + value + freight
combination. Returns a compact per-origin breakdown (MFN,
Section 122 / 301 / 301-FL / 232 / 338, AD/CVD, MPF, HMF, VAT)
plus flags (denied-party, PGA, restriction, AD/CVD,
fta_opportunity). Per-origin failures do not fail the batch.




## OpenAPI

````yaml POST /v1/compare
openapi: 3.1.0
info:
  title: LandedFees API
  version: 1.0.0
  summary: Landed-cost, HS classification, and origin-comparison API.
  description: |
    LandedFees exposes five stable v1 endpoints for landed-cost calculation,
    HS classification, multi-origin comparison, and rate lookup. All requests
    require a bearer API key (format `sk_live_...`). Every response returns
    JSON. Rate limits are surfaced via `X-RateLimit-*` headers.

    Data provenance: rates resolve against the same live tables the
    LandedFees UI uses (USITC HTS, EU TARIC, HMRC UK Trade Tariff, WCO HS,
    CBP weekly FX per 19 CFR 141.62). No estimates.

    Idempotency: mutation-like endpoints (calc, calc/bulk, classify,
    compare) accept an `Idempotency-Key` header. Repeating the same key
    within 24 hours returns the cached response.
  contact:
    name: LandedFees Support
    url: https://www.landedfees.com/support
    email: support@landedfees.com
  license:
    name: Proprietary
    url: https://www.landedfees.com/terms
servers:
  - url: https://www.landedfees.com
    description: Production (v1)
security:
  - bearerAuth: []
tags:
  - name: Calculate
    description: Landed-cost calculation for single and bulk shipments.
  - name: Classify
    description: HS / HTS code classification from a product description.
  - name: Compare
    description: Side-by-side landed-cost comparison across origins.
  - name: Rates
    description: Duty and tax rate lookup by country and HS code.
paths:
  /v1/compare:
    post:
      tags:
        - Compare
      summary: Compare landed cost across up to 6 origin countries.
      description: |
        Runs the landed-cost engine in parallel for 1 to 6 origin
        countries against a single HS + destination + value + freight
        combination. Returns a compact per-origin breakdown (MFN,
        Section 122 / 301 / 301-FL / 232 / 338, AD/CVD, MPF, HMF, VAT)
        plus flags (denied-party, PGA, restriction, AD/CVD,
        fta_opportunity). Per-origin failures do not fail the batch.
      operationId: compare
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CompareRequest'
            examples:
              cn_vn_mx_in:
                summary: 4-origin comparison for HS 8518.30
                value:
                  hs_code: 8518.30.20
                  destination: US
                  value: 64250
                  currency: USD
                  freight: 3200
                  insurance: 480
                  incoterm: FOB
                  transport_mode: ocean
                  origins:
                    - CN
                    - VN
                    - MX
                    - IN
      responses:
        '200':
          description: Comparison completed.
          headers:
            X-RateLimit-Limit:
              $ref: '#/components/headers/XRateLimitLimit'
            X-RateLimit-Remaining:
              $ref: '#/components/headers/XRateLimitRemaining'
            X-RateLimit-Reset:
              $ref: '#/components/headers/XRateLimitReset'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CompareResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/PaymentRequired'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: false
      description: |
        Client-generated unique string (recommended UUID v4). Repeating the
        same key within 24 hours returns the cached response for the original
        request body. Different bodies with the same key return HTTP 409.
      schema:
        type: string
        minLength: 8
        maxLength: 128
        example: e4c1d2a0-8f6b-4c9d-a123-2f8b7c5e9d10
  schemas:
    CompareRequest:
      type: object
      required:
        - hs_code
        - destination
        - value
        - origins
      properties:
        hs_code:
          type: string
          minLength: 6
          example: 8518.30.20
        destination:
          type: string
          minLength: 2
          maxLength: 2
          example: US
        value:
          type: number
          exclusiveMinimum: 0
        currency:
          type: string
          minLength: 3
          maxLength: 3
          default: USD
        freight:
          type: number
          minimum: 0
          default: 0
        insurance:
          type: number
          minimum: 0
          default: 0
        incoterm:
          $ref: '#/components/schemas/Incoterm'
          default: FOB
        transport_mode:
          $ref: '#/components/schemas/TransportMode'
          default: ocean
        origins:
          type: array
          minItems: 1
          maxItems: 6
          items:
            type: string
            minLength: 2
            maxLength: 2
        eu_member_state:
          type: string
          minLength: 2
          maxLength: 2
        br_state:
          type: string
          minLength: 2
          maxLength: 2
        ca_province:
          type: string
          minLength: 2
          maxLength: 2
        calculation_date:
          type: string
          format: date
    CompareResponse:
      type: object
      properties:
        hs_code:
          type: string
        destination:
          type: string
        currency:
          type: string
        value:
          type: number
        incoterm:
          type: string
        transport_mode:
          type: string
        freight:
          type: number
        insurance:
          type: number
        origins_requested:
          type: array
          items:
            type: string
        results:
          type: array
          items:
            $ref: '#/components/schemas/CompareOriginResult'
        calculated_at:
          type: string
          format: date-time
    Incoterm:
      type: string
      enum:
        - EXW
        - FCA
        - CPT
        - CIP
        - DAP
        - DPU
        - DDP
        - FAS
        - FOB
        - CFR
        - CIF
    TransportMode:
      type: string
      enum:
        - ocean
        - air
        - truck
        - rail
        - express
    CompareOriginResult:
      type: object
      properties:
        origin:
          type: string
        coverage:
          type: boolean
        coverage_message:
          type: string
          nullable: true
        error_code:
          type: string
          nullable: true
        total_landed_cost:
          type: number
        duty_amount:
          type: number
        tax_amount:
          type: number
        fees_amount:
          type: number
        customs_value:
          type: number
        currency:
          type: string
        delta_vs_cheapest:
          type: number
        delta_pct:
          type: number
        breakdown_summary:
          type: object
          additionalProperties:
            type: number
        flags:
          type: object
          properties:
            denied_party:
              type: boolean
            pga:
              type: boolean
            restriction:
              type: boolean
            ad_cvd:
              type: boolean
            fta_opportunity:
              type: boolean
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: string
        code:
          type: string
        message:
          type: string
        detail:
          type: string
        issues:
          type: array
          items:
            type: object
  headers:
    XRateLimitLimit:
      description: Total requests allowed in the current window.
      schema:
        type: integer
        example: 1000
    XRateLimitRemaining:
      description: Requests remaining in the current window.
      schema:
        type: integer
        example: 987
    XRateLimitReset:
      description: Unix epoch seconds when the window resets.
      schema:
        type: integer
        example: 1755273600
  responses:
    BadRequest:
      description: Request body failed validation.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: invalid body
            issues:
              - path:
                  - destination_country
                message: String must contain exactly 2 character(s)
    Unauthorized:
      description: Missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: unauthorized
    PaymentRequired:
      description: >-
        Quota exhausted for the current plan. Upgrade or wait for the monthly
        reset.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: quota_exceeded
            code: QUOTA_EXCEEDED
            message: >-
              Monthly quota exhausted. Upgrade at
              https://www.landedfees.com/pricing.
    TooManyRequests:
      description: Rate limit exceeded. Retry after the reset window.
      headers:
        Retry-After:
          description: Seconds to wait before retrying.
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: rate_limited
            code: RATE_LIMITED
            message: Too many requests. Retry after 60 seconds.
    InternalError:
      description: Unexpected server error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: internal
            detail: engine error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: sk_live
      description: |
        API key issued from the LandedFees dashboard under Settings > API keys.
        Format: `sk_live_...` (production) or `sk_test_...` (sandbox). Pass in
        the `Authorization: Bearer <key>` header.

````