API Documentation

Getting Started

Kiloships provides a simple and powerful API for creating and managing shipping labels. Our documentation will help you get up and running quickly.

Base URL

All API requests should be made to:

https://kiloships.com/api

API Endpoints

Create Shipping Label

POSThttps://kiloships.com/api/shipping-labels/domestic

Create a new domestic shipping label

Cancel Shipping Label

DELETEhttps://kiloships.com/api/shipping-labels/domestic/{trackingNumber}

Cancel a domestic shipping label using its tracking number

Track Label

GEThttps://kiloships.com/api/tracking/{trackingNumber}

Get tracking information for a label

City/State Lookup

GEThttps://kiloships.com/api/addresses/city-state?zipCode={zipCode}

Get city and state information for a ZIP code

ZIP Code Lookup

POSThttps://kiloships.com/api/addresses/zipcode

Get ZIP code information for an address

Address Standardization

POSThttps://kiloships.com/api/addresses/address

Get standardized address information

Create Domestic Label

Create a domestic shipping label for USPS services. This endpoint handles label generation, tracking number assignment, and automatic rate calculations.

Endpoint

POST https://kiloships.com/api/shipping-labels/domestic

Authentication

Requires an API key to be included in the request headers:

Authorization: Bearer YOUR_API_KEY

Request Body

Shipment Object

async (optional) - Boolean flag for asynchronous label creation (default: false)

addressTo (required) - Destination address object containing:

  • name (string) - Recipient's full name
  • street1 (string) - Primary street address
  • street2 (string, optional) - Secondary address line
  • city (string) - City name
  • state (string) - Two-letter state code
  • zip (string) - 5-digit or 9-digit ZIP code
  • country (string) - Two-letter country code (default: "US")
  • ignoreBadAddress (boolean, optional) - When set to true, bypasses address validation and allows label creation even with unverified addresses. When false or omitted, address validation is enforced (default: false)

addressFrom Object

Sender's address with the same fields as addressTo, including:

  • name (string) - Sender's full name
  • street1 (string) - Primary street address
  • street2 (string, optional) - Secondary address line
  • city (string) - City name
  • state (string) - Two-letter state code
  • zip (string) - 5-digit or 9-digit ZIP code
  • country (string) - Two-letter country code (default: "US")
  • ignoreBadAddress (boolean, optional) - When set to true, bypasses address validation and allows label creation even with unverified addresses. When false or omitted, address validation is enforced (default: false)

Parcels Array

Array containing a single parcel object with:

  • weight (string) - Package weight
  • massUnit (string) - Weight unit ("oz" or "lb")
  • length (string) - Package length
  • width (string) - Package width
  • height (string) - Package height
  • distanceUnit (string) - Dimension unit ("in" or "cm")

Service Level

servicelevelToken (required) - One of:

  • usps_ground_advantage - USPS Ground Advantage
  • usps_priority - USPS Priority Mail
  • usps_priority_express - USPS Priority Mail Express
  • usps_media_mail - USPS Media Mail

Metadata

metadata (optional) - Array of strings for custom messages or references

Example Request

1curl -X POST https://kiloships.com/api/shipping-labels/domestic \ 2 -H "Authorization: Bearer YOUR_API_KEY" \ 3 -H "Content-Type: application/json" \ 4 -d '{ 5 "shipment": { 6 "async": false, 7 "parcels": [{ 8 "width": "0.25", 9 "height": "6", 10 "length": "9", 11 "weight": "0.5", 12 "massUnit": "lb", 13 "distanceUnit": "in" 14 }], 15 "addressTo": { 16 "zip": "63118", 17 "city": "St. Louis", 18 "name": "asd Doe", 19 "state": "MO", 20 "country": "US", 21 "street1": "1100 Wyoming", 22 "street2": "Suite 150" 23 }, 24 "addressFrom": { 25 "zip": "63116", 26 "city": "St. Louis", 27 "name": "John Smith", 28 "state": "MO", 29 "country": "US", 30 "street1": "4120 Bingham" 31 } 32 }, 33 "servicelevelToken": "usps_ground_advantage", 34 "metadata": [ 35 "Message 1", 36 "Message 2", 37 "Message 3" 38 ] 39 }'

Response Fields

  • rate - Object containing pricing and service details
  • parcel - Object containing package details
  • status - Current label status
  • labelUrl - URL to download the shipping label PDF
  • trackingNumber - Carrier tracking number

Example Response

create-label-response.json
1{ 2 "rate": { 3 "amount": "3.74", 4 "currency": "USD", 5 "objectId": "DUXP0XXXU101080", 6 "provider": "usps", 7 "amountLocal": 3.74, 8 "currencyLocal": "USD", 9 "carrierAccount": "", 10 "servicelevelName": "usps_ground_advantage", 11 "servicelevelToken": "usps_ground_advantage" 12 }, 13 "parcel": { 14 "weight": 0.5, 15 "weightUOM": "LB" 16 }, 17 "status": "CREATED", 18 "labelUrl": "https://photo.kiloships.com/shipping-labels/domestic/label-1-1743838485434-9200190384072900005162.pdf", 19 "messages": [], 20 "metadata": [ 21 "Message 1", 22 "Message 2", 23 "Message 3" 24 ], 25 "objectId": "DUXP0XXXU101080", 26 "objectOwner": "", 27 "objectState": "CREATED", 28 "objectCreated": "2025-04-05T07:34:46.109Z", 29 "objectUpdated": "2025-04-05T07:34:46.109Z", 30 "trackingNumber": "9200190384072900005162", 31 "trackingStatus": "CREATED", 32 "trackingUrlProvider": "USPS", 33 "labelImageUrl": "https://photo.kiloships.com/shipping-labels/domestic/label-1-1743838485434-9200190384072900005162.pdf", 34 "chargeAmount": 3.74 35}

Cancel Domestic Label

Endpoint

DELETEhttps://kiloships.com/api/shipping-labels/domestic/{trackingNumber}

Cancel a domestic shipping label using its tracking number. This endpoint supports both session-based authentication and API key authentication.

Path Parameters

ParameterTypeRequiredDescription
trackingNumberstringYesThe tracking number of the label to cancel

Authentication

This endpoint supports two authentication methods:

  • Session Authentication: Use when making requests from a web browser with an active session
  • API Key Authentication: Use when making programmatic requests with an API key

Only one authentication method is required. The endpoint will first check for session authentication, and if that fails, it will check for API key authentication.

Example Request

curl
1curl -X DELETE \ 2 "https://kiloships.com/api/shipping-labels/domestic/9405511298370938473298" \ 3 -H "Authorization: Bearer YOUR_API_KEY"

Example Response

response.json
1{ 2 "success": true, 3 "data": { 4 "id": 123, 5 "trackingNumber": "9405511298370938473298", 6 "status": "CANCELLED", 7 "cancelledAt": "2024-04-21T12:00:00Z" 8 }, 9 "message": "Shipping label successfully canceled" 10}

The status field indicates the current state of the label:

  • CANCELLED - The label has been successfully canceled
  • DISPUTED - A refund request has been initiated for the label

SCAN Form API

The SCAN Form API allows you to create USPS SCAN (Shipment Confirmation Acceptance Notice) forms for multiple tracking numbers. This form serves as proof of shipment for multiple packages in a single document.

Create SCAN Form

POSThttps://kiloships.com/api/scan-form

Create a USPS SCAN form for multiple tracking numbers

Authentication

Requires an API key to be included in the request headers:

Authorization: Bearer YOUR_API_KEY

Request Body

Required Fields:

  • mailingDate - Format: YYYY-MM-DD
  • entryFacilityZIPCode - 5-digit or 9-digit ZIP code
  • destinationEntryFacilityType - One of:
    • "NONE"
    • "DESTINATION_NETWORK_DISTRIBUTION_CENTER"
    • "DESTINATION_SECTIONAL_CENTER_FACILITY"
    • "DESTINATION_DELIVERY_UNIT"
    • "DESTINATION_SERVICE_HUB"
  • fromAddress - Sender's address object
  • shipment.trackingNumbers - Array of tracking numbers

fromAddress Object:

  • streetAddress - Primary street address (required)
  • city - City name (required)
  • state - Two-letter state code (required)
  • ZIPCode - 5-digit or 9-digit ZIP code (required)
  • firstName - Recipient's first name (optional)
  • lastName - Recipient's last name (optional)
  • firm - Company name (optional)
  • secondaryAddress - Suite, Apt, etc. (optional)
  • ZIPPlus4 - ZIP+4 code (optional)
  • urbanization - Urbanization code for Puerto Rico (optional)
  • ignoreBadAddress - Bypass address validation (optional)

Optional Fields:

  • overwriteMailingDate - Boolean to overwrite mailing date

Example Request

scan-form-request.json
1{ 2 "mailingDate": "2024-02-20", 3 "entryFacilityZIPCode": "12345", 4 "destinationEntryFacilityType": "NONE", 5 "fromAddress": { 6 "streetAddress": "123 Main St", 7 "city": "Anytown", 8 "state": "CA", 9 "ZIPCode": "12345" 10 }, 11 "shipment": { 12 "trackingNumbers": [ 13 "9400100000000000000000", 14 "9400100000000000000001" 15 ] 16 } 17}

Response Fields

  • form - Form type identifier
  • imageType - Type of image (PDF, TIFF, etc.)
  • labelType - Type of label
  • mailingDate - Confirmed mailing date
  • scanFormImage - URL to download the form
  • manifestNumber - Optional manifest number
  • shipment - Object containing confirmed tracking numbers
  • fromAddress - Confirmed sender address

Example Success Response

scan-form-response.json
1{ 2 "form": "5630", 3 "imageType": "PDF", 4 "labelType": "8.5x11LABEL", 5 "mailingDate": "2024-02-20", 6 "overwriteMailingDate": false, 7 "entryFacilityZIPCode": "12345", 8 "destinationEntryFacilityType": "NONE", 9 "shipment": { 10 "trackingNumbers": [ 11 "9400100000000000000000", 12 "9400100000000000000001" 13 ] 14 }, 15 "manifestNumber": "123456789", 16 "fromAddress": { 17 "streetAddress": "123 Main St", 18 "city": "Anytown", 19 "state": "CA", 20 "ZIPCode": "12345" 21 }, 22 "scanFormImage": "https://your-cloudflare-url.com/scan-forms/form.pdf" 23}

Important Notes

  • All tracking numbers must belong to your organization
  • The SCAN form will be generated as a PDF and stored in Cloudflare R2
  • The mailing date must be in YYYY-MM-DD format
  • ZIP codes must be either 5 digits or 9 digits (with hyphen)
  • All required fields are validated before making the request to USPS

Tracking Labels

Track your packages using our tracking API. Each tracking request requires authentication and has a small fee associated with it.

Track by Tracking Number

GEThttps://kiloships.com/api/tracking/{trackingNumber}

Get tracking information for a package

Query Parameters

ParameterTypeRequiredDescription
responseTypestringNoType of tracking response (SUMMARY or DETAIL)

Authentication

This endpoint requires either:

  • API Key in the Authorization header
  • Valid user session with organization access

Example Request

tracking-request.sh
1curl -X GET 'https://kiloships.com/api/tracking/9405511298370938472938?responseType=SUMMARY' \ 2 -H 'Authorization: Bearer YOUR_API_KEY'

Example Response

tracking-response.json
1{ 2 "data": { 3 "trackingNumber": "9405511298370938472938", 4 "status": "In Transit", 5 "statusCategory": "IN_TRANSIT", 6 "statusSummary": "Your package is moving within the USPS network", 7 "mailClass": "First-Class Package Service", 8 "mailType": "Package", 9 "originCity": "New York", 10 "originState": "NY", 11 "originZIP": "10001", 12 "destinationCity": "Los Angeles", 13 "destinationState": "CA", 14 "destinationZIP": "90001", 15 "trackingEvents": [ 16 { 17 "eventType": "In Transit", 18 "eventTimestamp": "2024-04-17T10:30:00Z", 19 "eventCity": "New York", 20 "eventState": "NY", 21 "eventZIP": "10001", 22 "eventCode": "IT" 23 } 24 ] 25 }, 26 "chargeAmount": 0.01 27}

Address APIs

The Address APIs provide utilities for validating and standardizing address information, including city/state lookup, ZIP code lookup, and address standardization. These endpoints help ensure accurate shipping addresses and improve delivery success rates.

City/State Lookup

Get city and state information for a given ZIP code.

Endpoint

GET https://kiloships.com/api/addresses/city-state?zipCode={zipCode}

Parameters

zipCode (required) - 5-digit ZIP code

Response

  • city - City name
  • state - Two-letter state code
  • ZIPCode - 5-digit ZIP code

Example Request

city-state-lookup.sh
1curl -X GET "https://kiloships.com/api/addresses/city-state?zipCode=10001" \ 2 -H "Authorization: Bearer YOUR_API_KEY"

Example Response

city-state-response.json
1{ 2 "city": "New York", 3 "state": "NY", 4 "ZIPCode": "10001" 5}

ZIP Code Lookup

Get ZIP code information for a given address.

Endpoint

POST https://kiloships.com/api/addresses/zipcode

Request Body

  • streetAddress (required) - Primary street address
  • city (required) - City name
  • state (required) - Two-letter state code AA AE AL AK AP AS AZ AR CA CO CT DE DC FM FL GA GU HI ID IL IN IA KS KY LA ME MH MD MA MI MN MS MO MP MT NE NV NH NJ NM NY NC ND OH OK OR PW PA PR RI SC SD TN TX UT VT VI VA WA WV WI WY
  • secondaryAddress (optional) - Apartment, suite, etc.
  • firm (optional) - Company or organization name
  • urbanization (optional) - Urbanization code (Puerto Rico only)

Response

  • address - Object containing:
    • streetAddress - Standardized street address
    • city - City name
    • state - Two-letter state code
    • ZIPCode - 5-digit ZIP code
    • ZIPPlus4 - ZIP+4 code (if available)
    • secondaryAddress - Standardized secondary address

Example Request

zipcode-lookup-request.json
1curl -X POST "https://kiloships.com/api/addresses/zipcode" \ 2 -H "Authorization: Bearer YOUR_API_KEY" \ 3 -H "Content-Type: application/json" \ 4 -d '{ 5 "streetAddress": "350 5th Ave", 6 "city": "New York", 7 "state": "NY", 8 "secondaryAddress": "Suite 3000" 9 }'

Example Response

zipcode-lookup-response.json
1{ 2 "address": { 3 "streetAddress": "350 5TH AVE", 4 "secondaryAddress": "STE 3000", 5 "city": "NEW YORK", 6 "state": "NY", 7 "ZIPCode": "10118", 8 "ZIPPlus4": "0110" 9 } 10}

Address Standardization

Get standardized address information and validate address components.

Endpoint

POST https://kiloships.com/api/addresses/address

Request Body

  • streetAddress (required) - Primary street address
  • city (required*) - City name (*either city or ZIP code required)
  • state (required) - Two-letter state code AA AE AL AK AP AS AZ AR CA CO CT DE DC FM FL GA GU HI ID IL IN IA KS KY LA ME MH MD MA MI MN MS MO MP MT NE NV NH NJ NM NY NC ND OH OK OR PW PA PR RI SC SD TN TX UT VT VI VA WA WV WI WY
  • secondaryAddress (optional) - Apartment, suite, etc.
  • firm (optional) - Company or organization name
  • urbanization (optional) - Urbanization code (Puerto Rico only)
  • ZIPCode (optional*) - 5-digit ZIP code (*either city or ZIP code required)

Response

  • firm - Standardized company name (if provided)
  • address - Object containing:
    • streetAddress - Standardized street address
    • streetAddressAbbreviation - Abbreviated street address
    • secondaryAddress - Standardized secondary address
    • city - Standardized city name
    • cityAbbreviation - Abbreviated city name
    • state - Two-letter state code
    • ZIPCode - 5-digit ZIP code
    • ZIPPlus4 - ZIP+4 code
  • additionalInfo - Object containing:
    • deliveryPoint - Delivery point code
    • carrierRoute - Carrier route code
    • DPVConfirmation - Delivery point validation status
    • DPVCMRA - Commercial mail receiving agency status
    • business - Business address indicator
    • centralDeliveryPoint - Central delivery point indicator
    • vacant - Vacant address indicator
  • corrections - Array of correction codes and descriptions
  • matches - Array of match codes and descriptions
  • warnings - Array of warning messages

Example Request

address-standardization-request.json
1curl -X POST "https://kiloships.com/api/addresses/address" \ 2 -H "Authorization: Bearer YOUR_API_KEY" \ 3 -H "Content-Type: application/json" \ 4 -d '{ 5 "streetAddress": "350 5th Ave", 6 "city": "New York", 7 "state": "NY", 8 "secondaryAddress": "Suite 3000" 9 }'

Example Response

address-standardization-response.json
1{ 2 "address": { 3 "streetAddress": "350 5TH AVE", 4 "streetAddressAbbreviation": "350 5TH AVE", 5 "secondaryAddress": "STE 3000", 6 "city": "NEW YORK", 7 "cityAbbreviation": "NEW YORK", 8 "state": "NY", 9 "ZIPCode": "10118", 10 "ZIPPlus4": "0110" 11 }, 12 "additionalInfo": { 13 "deliveryPoint": "00", 14 "carrierRoute": "C006", 15 "DPVConfirmation": "Y", 16 "DPVCMRA": "N", 17 "business": "Y", 18 "centralDeliveryPoint": "N", 19 "vacant": "N" 20 }, 21 "matches": [ 22 { 23 "code": "A", 24 "text": "Exact match" 25 } 26 ] 27}

Get Zone

GEThttps://kiloships.com/api/addresses/zone/number?originZIPCode={originZIPCode}&destinationZIPCode={destinationZIPCode}&mailingDate={mailingDate}

Get the shipping zone between two ZIP codes for a specific mailing date

Query Parameters

originZIPCode(required) - Origin ZIP code
destinationZIPCode(required) - Destination ZIP code
mailingDate(required) - Mailing date in YYYY-MM-DD format

Response

get-zone-response.json
1{ 2 "zone": 5 3}

Example Request

get-zone-request.sh
1curl -X GET "https://kiloships.com/api/addresses/zone?originZIPCode=90210&destinationZIPCode=10001&mailingDate=2024-04-15" \ 2 -H "Authorization: Bearer YOUR_API_KEY"

Error Handling

Error Response Format

When an error occurs, the API will return a JSON response with the following structure:

  • success - Boolean indicating if the request was successful
  • message - A general error message
  • code - HTTP status code
  • error - Detailed error object:
    • code - Error code
    • message - Error message
    • errors - Array of specific error details:
      • title - Error type
      • detail - Detailed error message
      • source - Object indicating the error source

Common Error Codes

  • 400 - Bad Request - Invalid input parameters or validation errors
  • 401 - Unauthorized - Invalid or missing API key
  • 402 - Payment Required - Insufficient balance
  • 404 - Not Found - Resource not found
  • 429 - Too Many Requests - Rate limit exceeded
  • 500 - Internal Server Error - Server-side error

Example Error Response

error-response.json
1{ 2 "success": false, 3 "message": "Bad Request", 4 "code": "400", 5 "error": { 6 "code": "400", 7 "message": "Bad Request", 8 "errors": [ 9 { 10 "title": "Bad Request", 11 "detail": "five digits are required", 12 "source": { 13 "parameter": "toAddress.ZIPCode" 14 } 15 } 16 ] 17 } 18}

Common Validation Errors

  • toAddress.ZIPCode - ZIP code must be exactly 5 digits
  • fromAddress.ZIPCode - ZIP code must be exactly 5 digits
  • servicelevelToken - Must be a valid service level
  • weight - Must be a positive number
  • dimensions - Length, width, and height must be positive numbers