Label Proxy

Generate shipping labels through carrier APIs with automatic PII handling

Label Proxy API

The Label Proxy forwards carrier API requests with automatic PII placeholder replacement and response scrubbing. Your WMS sends requests with placeholders like {{ship_to_name}}, and Data Border injects real PII from Amazon, then scrubs the carrier response.

Forward Label Request

Proxies a request to a carrier API with PII injection.

POST /api/label-proxy/forward

Authentication

HeaderRequiredDescription
x-seller-access-tokenYesValid seller access token
x-amazon-token-secretYesSecret used during OAuth

Required Headers

HeaderDescription
x-original-urlFull URL of the carrier API endpoint
x-amazon-order-idAmazon order ID for PII lookup
x-unique-shipment-idYour unique identifier for this shipment

Optional Headers

HeaderDescription
authorizationForwarded to carrier (e.g., Bearer API_KEY)
x-api-keyForwarded to carrier for authentication

Request Body

JSON body to send to the carrier. Use PII placeholders for customer data:

{
  "shipment": {
    "to_address": {
      "name": "{{ship_to_name}}",
      "street1": "{{ship_to_address1}}",
      "street2": "{{ship_to_address2}}",
      "city": "{{ship_to_city}}",
      "state": "{{ship_to_state}}",
      "zip": "{{ship_to_zip}}",
      "country": "{{ship_to_country}}",
      "phone": "{{ship_to_phone}}"
    },
    "from_address": {
      "name": "Your Warehouse",
      "street1": "123 Warehouse Ave",
      "city": "Commerce City",
      "state": "CO",
      "zip": "80022",
      "country": "US"
    },
    "parcel": {
      "length": 10,
      "width": 8,
      "height": 4,
      "weight": 16
    }
  }
}

PII Placeholders

PlaceholderDescriptionAmazon Field
{{ship_to_name}}Recipient nameShippingAddress.Name
{{ship_to_address1}}Address line 1ShippingAddress.AddressLine1
{{ship_to_address2}}Address line 2ShippingAddress.AddressLine2
{{ship_to_address3}}Address line 3ShippingAddress.AddressLine3
{{ship_to_city}}CityShippingAddress.City
{{ship_to_state}}State/regionShippingAddress.StateOrRegion
{{ship_to_zip}}Postal codeShippingAddress.PostalCode
{{ship_to_country}}Country codeShippingAddress.CountryCode
{{ship_to_phone}}Phone numberShippingAddress.Phone
{{buyer_name}}Buyer nameBuyerInfo.BuyerName
{{buyer_email}}Buyer emailBuyerInfo.BuyerEmail

Whitelisted Carriers

CarrierAllowed Origins
EasyPosthttps://api.easypost.com
ShipStationhttps://ssapi.shipstation.com
Shippohttps://api.goshippo.com
UPShttps://onlinetools.ups.com, https://wwwcie.ups.com
FedExhttps://apis.fedex.com, https://apis-sandbox.fedex.com
USPShttps://secure.shippingapis.com
DHLhttps://express.api.dhl.com, https://api-sandbox.dhl.com

Response

{
  "success": true,
  "data": {
    "scrubbed_response": {
      "tracking_code": "1Z999AA10123456784",
      "label_url": "https://carrier.com/labels/abc123"
    },
    "shipment_id": "ship_abc123def456",
    "amazon_order_id": "123-4567890-1234567",
    "unique_shipment_id": "WMS-SHIP-001",
    "documents": [
      {
        "uuid": "550e8400-e29b-41d4-a716-446655440000",
        "path": "label.pdf"
      }
    ]
  }
}
FieldDescription
scrubbed_responseCarrier response with PII values redacted
shipment_idData Border shipment ID (use for printing)
amazon_order_idAssociated Amazon order
unique_shipment_idYour original shipment ID
documentsArray of unredacted document references

Example

curl -X POST "https://adb.example.com/api/label-proxy/forward" \
  -H "Content-Type: application/json" \
  -H "x-seller-access-token: YOUR_SELLER_TOKEN" \
  -H "x-amazon-token-secret: YOUR_TOKEN_SECRET" \
  -H "x-original-url: https://api.easypost.com/v2/shipments" \
  -H "x-amazon-order-id: 123-4567890-1234567" \
  -H "x-unique-shipment-id: WMS-SHIP-001" \
  -H "Authorization: Bearer EASYPOST_API_KEY" \
  -d '{
    "shipment": {
      "to_address": {
        "name": "{{ship_to_name}}",
        "street1": "{{ship_to_address1}}",
        "city": "{{ship_to_city}}",
        "state": "{{ship_to_state}}",
        "zip": "{{ship_to_zip}}",
        "country": "{{ship_to_country}}"
      },
      "from_address": {
        "name": "Warehouse",
        "street1": "123 Main St",
        "city": "Denver",
        "state": "CO",
        "zip": "80202",
        "country": "US"
      },
      "parcel": {
        "length": 10,
        "width": 8,
        "height": 4,
        "weight": 16
      }
    }
  }'

Errors

StatusMessageCause
400Missing required header: x-amazon-order-idRequired header missing
400Carrier origin not in whitelistURL not from approved carrier
400Invalid placeholders in request bodyUnknown placeholder used
401Invalid seller access tokenToken expired or invalid
404Order not foundOrder doesn't exist for seller

Flow Diagram

Loading diagram...

Carrier-Specific Examples

EasyPost

const response = await fetch(`${ADB_URL}/api/label-proxy/forward`, {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-seller-access-token': sellerToken,
    'x-amazon-token-secret': amazonSecret,
    'x-original-url': 'https://api.easypost.com/v2/shipments',
    'x-amazon-order-id': order.amazonOrderId,
    'x-unique-shipment-id': `${order.id}-${Date.now()}`,
    'Authorization': `Bearer ${EASYPOST_KEY}`
  },
  body: JSON.stringify({
    shipment: {
      to_address: {
        name: '{{ship_to_name}}',
        street1: '{{ship_to_address1}}',
        street2: '{{ship_to_address2}}',
        city: '{{ship_to_city}}',
        state: '{{ship_to_state}}',
        zip: '{{ship_to_zip}}',
        country: '{{ship_to_country}}',
        phone: '{{ship_to_phone}}'
      },
      from_address: warehouseAddress,
      parcel: parcelDimensions
    }
  })
})

ShipStation

const response = await fetch(`${ADB_URL}/api/label-proxy/forward`, {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-seller-access-token': sellerToken,
    'x-amazon-token-secret': amazonSecret,
    'x-original-url': 'https://ssapi.shipstation.com/shipments/createlabel',
    'x-amazon-order-id': order.amazonOrderId,
    'x-unique-shipment-id': order.id,
    'Authorization': `Basic ${SHIPSTATION_CREDENTIALS}`
  },
  body: JSON.stringify({
    carrierCode: 'ups',
    serviceCode: 'ups_ground',
    shipTo: {
      name: '{{ship_to_name}}',
      street1: '{{ship_to_address1}}',
      city: '{{ship_to_city}}',
      state: '{{ship_to_state}}',
      postalCode: '{{ship_to_zip}}',
      country: '{{ship_to_country}}',
      phone: '{{ship_to_phone}}'
    },
    shipFrom: warehouseAddress,
    weight: { value: 16, units: 'ounces' },
    dimensions: parcelDimensions
  })
})

Document Handling

What Gets Stored

Data Border stores unredacted versions of documents found in the carrier response:

  • Shipping labels (PDF, PNG, ZPL)
  • Commercial invoices
  • Customs documents
  • Packing slips

Using Document UUIDs

The documents array contains references to unredacted documents:

{
  "documents": [
    {
      "uuid": "550e8400-e29b-41d4-a716-446655440000",
      "path": "label.pdf"
    },
    {
      "uuid": "660e8400-e29b-41d4-a716-446655440001",
      "path": "commercial_invoice.pdf"
    }
  ]
}

Use these UUIDs with the Print API to send labels to Device Hub.


Response Scrubbing

Data Border automatically scrubs PII from carrier responses:

Original carrier response:

{
  "to_address": {
    "name": "John Doe",
    "street1": "123 Main Street",
    "city": "Anytown"
  },
  "tracking_code": "1Z999AA1"
}

Scrubbed response returned to WMS:

{
  "to_address": {
    "name": "[REDACTED]",
    "street1": "[REDACTED]",
    "city": "[REDACTED]"
  },
  "tracking_code": "1Z999AA1"
}

Best Practices

Use Unique Shipment IDs

// Good: Unique, traceable ID
const uniqueShipmentId = `${orderId}-${warehouseId}-${Date.now()}`

// Bad: Reused or non-unique
const uniqueShipmentId = orderId // Could conflict on re-ships

Handle Multiple Labels

const result = await createLabel(order)

// Store all document references
await db.shipments.create({
  orderId: order.id,
  adbShipmentId: result.shipment_id,
  trackingNumber: result.scrubbed_response.tracking_code,
  documents: result.documents // Store the full array
})

// Print all documents
for (const doc of result.documents) {
  await printLabel(result.shipment_id, [doc.uuid])
}

Error Handling

try {
  const result = await labelProxy.forward(request)
  return result
} catch (error) {
  if (error.message.includes('Carrier origin not in whitelist')) {
    // Configuration error - check your carrier URL
    throw new ConfigError('Invalid carrier URL')
  }
  if (error.message.includes('Invalid placeholders')) {
    // Check placeholder spelling
    throw new ValidationError('Invalid placeholder in request')
  }
  throw error
}

Next Steps

Print API

Send labels to Device Hub for printing.

Secure Printing

Understand the end-to-end print flow.