API Documentation

Authentication

To authenticate and identify requests to the Shipbuy API, clients must acquire a temporary JWT (JSON Web Token) by providing a valid username and password. The acquired JWT must be included as a Bearer Token in the Authorization header of every API request. Example: Authorization: Bearer {token}.

JWTs are valid for a period of one hour from the time of issuance. Once a token has expired, a new token must be obtained to continue interacting with the API. Shipbuy mandates that all communication with the API is secured using TLS v1.2. Any requests made over HTTP or without a valid Bearer Token will be rejected.

Errors

In the event of a client or server error, the response will contain the standard 4xx or 5xx respectively, accompanied by a well-formed JSON body describing the issue, e.g., a required field was omitted, a purchase failed, etc.

Each client library will encapsulate these errors and raise an exception, in addition to other exceptional cases, such as network failures. It is recommended to handle exceptions gracefully and to report any issues to support@shipbuy.com.

Error Object

attribute type specification
code string Machine readable description of the problem
message string Human readable description of the problem

Shipment API

Shipment API for list rates, buy label, void label and tracking.

Rates

Get available shipping rates.

POST https://shipbuy.com/api/shipping/rates
Example of rates request
                                
curl -X POST https://shipbuy.com/api/shipping/rates \
  -H "Authorization: Bearer {token}" \
  -H 'Content-Type: application/json' \
  -d '{
    "shipping_account_name": null,
    "carrier_type": null,
    "service_type": null,
    "confirmation_type": null,
    "insurance_provider_type": null,
    "dimension_unit": "in",
    "weight_unit": "oz",
    "rate_id": null,
    "from": {
      "company": null,
      "name": "Kevin Wang",
      "phone": null,
      "email": null,
      "street1": "19335 balan rd",
      "street2": null,
      "city": "Rowland Heights",
      "state": "CA",
      "zip": "91748",
      "country": "US",
      "residential": true
    },
    "to": {
      "company": null,
      "name": "Amy Chu",
      "phone": "6268282990",
      "email": null,
      "street1": "Industrial Correa #5",
      "street2": null,
      "city": "Bayamón",
      "state": "PR",
      "zip": "00961",
      "country": "US",
      "residential": false
    },
    "packages": [
      {
        "package_type": null,
        "length": 10,
        "width": 8,
        "height": 6,
        "weight": 2,
        "insurance_amount": null
      }
    ],
    "options": {
      "ship_date": "2024-01-05",
      "print_custom1": "WOMAN-HAT-012*1",
      "print_custom2": null
    },
    "customs": {
      "contents_type": "merchandise",
      "contents_explanation": "online purchase products",
      "non_delivery_option": "return",
      "eel_pfc": null,
      "certify": null,
      "signer": "Kevin Wang",
      "items": [
        {
          "description": "Woman Hat",
          "quantity": 1,
          "value": 12.39,
          "currency": "usd",
          "weight": 2,
          "weight_unit": "oz",
          "tariff_number": null,
          "origin_country": "CN"
        }
      ]
    }
  }'
                                
                            
Description of rates request
Field Name Type Required Description
shipping_account_name String No Name of the shipping account.
carrier_type String No Type of shipping carrier, e.g., 'usps'.
service_type String No Type of shipping service, e.g., 'usps_priority_mail'.
confirmation_type String No Type of delivery confirmation required, if any.
insurance_provider_type String No Insurance provider type, if insurance is required.
dimension_unit String Yes Unit of measurement for package dimensions, e.g., 'in' for inches.
weight_unit String Yes Unit of weight for packages, e.g., 'oz' for ounces.
rate_id String No Unique identifier for a specific rate quote, if applicable.
from.company String No Sender's company name, if applicable.
from.name String Yes Full name of the sender.
from.phone String No Sender's phone number.
from.email String No Sender's emaill address.
from.street1 String Yes Primary street address of the sender.
from.street2 String No Secondary street address of the sender.
from.city String Yes City of the sender's address.
from.state String Yes State of the sender's address.
from.zip String Yes Postal code of the sender's address.
from.country String Yes Country code of the sender's address.
from.residential Boolean Yes Indicates if the sender's address is residential.
to.company String No Recipient's company name, if applicable.
to.name String Yes Full name of the recipient.
to.phone String No Recipient's phone number.
to.email String No Recipient's emaill address.
to.street1 String Yes Primary street address of the recipient.
to.street2 String No Secondary street address of the recipient.
to.city String Yes City of the recipient's address.
to.state String Yes State of the recipient's address.
to.zip String Yes Postal code of the recipient's address.
to.country String Yes Country code of the recipient's address.
to.residential Boolean Yes Indicates if the recipient's address is residential.
packages[].package_type String No Type of package.
packages[].length Number Yes Length of the package.
packages[].width Number Yes Width of the package.
packages[].height Number Yes Height of the package.
packages[].weight Number Yes Weight of the package.
packages[].insurance_amount Number No Amount of insurance for the package.
options.ship_date Date String Yes The date the shipment is to be made.
options.print_custom1 String No Custom printing field 1.
options.print_custom2 String No Custom printing field 2.
customs.contents_type String Yes Type of contents, e.g., 'merchandise'.
customs.contents_explanation String Yes Explanation of the contents.
customs.non_delivery_option String Yes Action to take if delivery is not possible, e.g., 'return'.
customs.eel_pfc String No Electronic Export Information or Proof of Filing Citation.
customs.certify Boolean No Indicates whether the sender certifies the information.
customs.signer String Yes Name of the person signing the customs declaration.
customs.items[].description String Yes Description of the item.
customs.items[].quantity Number Yes Quantity of the item.
customs.items[].value Number Yes Value of the item.
customs.items[].currency String Yes Currency of the item's value.
customs.items[].weight Number Yes Weight of the item.
customs.items[].weight_unit String Yes Unit of weight for the item.
customs.items[].tariff_number String No Harmonized Tariff Schedule number for the item.
customs.items[].origin_country String Yes Country of origin for the item.
Example of rates response
                                
{
  "rates": [
    {
      "shipping_account_name": "stamps",
      "carrier_type": "usps",
      "service_type": "usps_priority_mail",
      "package_type": "package",
      "delivery_days": 3,
      "delivery_date": "2024-01-09 00:00:00",
      "currency": "usd",
      "list_rate": 0,
      "rate": 10.07,
      "insurance": 0,
      "surcharges": null,
      "rate_id": null
    }
  ],
  "alerts": [
    {
      "shipping_account_name": "ups",
      "message": "invalid ups credentials"
    }
  ]
}
                                
                            
Description of rates response
Field Name Type Description
Rates Array
shipping_account_name String Name of the shipping account.
carrier_type String Type of shipping carrier (e.g., 'usps').
service_type String Type of shipping service (e.g., 'usps_priority_mail').
package_type String Type of package.
delivery_days Integer Estimated number of days for delivery.
delivery_date String Estimated delivery date (format: 'YYYY-MM-DD HH:MM:SS').
currency String Currency code (e.g., 'usd').
list_rate Number Original list rate before discounts.
rate Number Final rate after discounts.
insurance Number Insurance cost.
surcharges Number or Null Additional surcharges, if any.
rate_id String or Null Unique identifier for the rate quote, if available.
Alerts Array
shipping_account_name String Name of the shipping account related to the alert.
message String Alert message description.

Buy

Buy a shipment.

POST https://shipbuy.com/api/shipping/buy
Example of buy request
                                
curl -X POST https://shipbuy.com/api/shipping/buy \
  -H "Authorization: Bearer {token}" \
  -H 'Content-Type: application/json' \
  -d '{
    "shipping_account_name": stamps,
    "carrier_type": "usps",
    "service_type": "usps_priority_mail",
    "confirmation_type": null,
    "insurance_provider_type": null,
    "dimension_unit": "in",
    "weight_unit": "oz",
    "rate_id": null,
    "from": {
      "company": null,
      "name": "Kevin Wang",
      "phone": null,
      "email": null,
      "street1": "19335 balan rd",
      "street2": null,
      "city": "Rowland Heights",
      "state": "CA",
      "zip": "91748",
      "country": "US",
      "residential": true
    },
    "to": {
      "company": null,
      "name": "Amy Chu",
      "phone": "6268282990",
      "email": null,
      "street1": "Industrial Correa #5",
      "street2": null,
      "city": "Bayamón",
      "state": "PR",
      "zip": "00961",
      "country": "US",
      "residential": false
    },
    "packages": [
      {
        "package_type": null,
        "length": 10,
        "width": 8,
        "height": 6,
        "weight": 2,
        "insurance_amount": null
      }
    ],
    "options": {
      "ship_date": "2024-01-05",
      "print_custom1": "WOMAN-HAT-012*1",
      "print_custom2": null
    },
    "customs": {
      "contents_type": "merchandise",
      "contents_explanation": "online purchase products",
      "non_delivery_option": "return",
      "eel_pfc": null,
      "certify": null,
      "signer": "Kevin Wang",
      "items": [
        {
          "description": "Woman Hat",
          "quantity": 1,
          "value": 12.39,
          "currency": "usd",
          "weight": 2,
          "weight_unit": "oz",
          "tariff_number": null,
          "origin_country": "CN"
        }
      ]
    }
  }'
                                
                            
Description of buy request
Field Name Type Required Description
shipping_account_name String Yes Name of the shipping account.
carrier_type String Yes Type of shipping carrier, e.g., 'usps'.
service_type String Yes Type of shipping service, e.g., 'usps_priority_mail'.
confirmation_type String No Type of delivery confirmation required, if any.
insurance_provider_type String No Insurance provider type, if insurance is required.
dimension_unit String Yes Unit of measurement for package dimensions, e.g., 'in' for inches.
weight_unit String Yes Unit of weight for packages, e.g., 'oz' for ounces.
rate_id String No Unique identifier for a specific rate quote, if applicable.
from.company String No Sender's company name, if applicable.
from.name String Yes Full name of the sender.
from.phone String No Sender's phone number.
from.email String No Sender's emaill address.
from.street1 String Yes Primary street address of the sender.
from.street2 String No Secondary street address of the sender.
from.city String Yes City of the sender's address.
from.state String Yes State of the sender's address.
from.zip String Yes Postal code of the sender's address.
from.country String Yes Country code of the sender's address.
from.residential Boolean Yes Indicates if the sender's address is residential.
to.company String No Recipient's company name, if applicable.
to.name String Yes Full name of the recipient.
to.phone String No Recipient's phone number.
to.email String No Recipient's emaill address.
to.street1 String Yes Primary street address of the recipient.
to.street2 String No Secondary street address of the recipient.
to.city String Yes City of the recipient's address.
to.state String Yes State of the recipient's address.
to.zip String Yes Postal code of the recipient's address.
to.country String Yes Country code of the recipient's address.
to.residential Boolean Yes Indicates if the recipient's address is residential.
packages[].package_type String No Type of package.
packages[].length Number Yes Length of the package.
packages[].width Number Yes Width of the package.
packages[].height Number Yes Height of the package.
packages[].weight Number Yes Weight of the package.
packages[].insurance_amount Number No Amount of insurance for the package.
options.ship_date Date String Yes The date the shipment is to be made.
options.print_custom1 String No Custom printing field 1.
options.print_custom2 String No Custom printing field 2.
customs.contents_type String Yes Type of contents, e.g., 'merchandise'.
customs.contents_explanation String Yes Explanation of the contents.
customs.non_delivery_option String Yes Action to take if delivery is not possible, e.g., 'return'.
customs.eel_pfc String No Electronic Export Information or Proof of Filing Citation.
customs.certify Boolean No Indicates whether the sender certifies the information.
customs.signer String Yes Name of the person signing the customs declaration.
customs.items[].description String Yes Description of the item.
customs.items[].quantity Number Yes Quantity of the item.
customs.items[].value Number Yes Value of the item.
customs.items[].currency String Yes Currency of the item's value.
customs.items[].weight Number Yes Weight of the item.
customs.items[].weight_unit String Yes Unit of weight for the item.
customs.items[].tariff_number String No Harmonized Tariff Schedule number for the item.
customs.items[].origin_country String Yes Country of origin for the item.
Example of buy response
                                
{
  "id": 41071243,
  "tracking_number": "9400100207552006001767",
  "shipping_account_name": "stamps",
  "carrier_type": "usps",
  "service_type": "usps_ground_advantage",
  "insurance_provider_type": null,
  "insurance_cost": 0,
  "shipping_cost": 4.13,
  "currency": "usd",
  "dimension_unit": "in",
  "weight_unit": "oz",
  "delivery_days": 4,
  "delivery_date": null,
  "ship_date": "2024-01-05",
  "from": {
    "name": "Kevin Wang",
    "company": null,
    "phone": null,
    "email": null,
    "street1": "19335 balan rd",
    "street2": null,
    "city": "Rowland Heights",
    "state": "CA",
    "zip": "91748",
    "country": "US",
    "residential": false
  },
  "to": {
    "name": "Amy Chu",
    "company": null,
    "phone": "6268282990",
    "email": null,
    "street1": "Industrial Correa #5",
    "street2": null,
    "city": "Bayamón",
    "state": "PR",
    "zip": "00961",
    "country": "US",
    "residential": false
  },
  "packages": [
    {
      "package_type": "package",
      "insurance_amount": 0,
      "length": 10,
      "width": 8,
      "height": 6,
      "weight": 2,
      "tracking_number": "9400100207552006001767",
      "label_url": "https://shipbuy-dev.s3.us-west-1.amazonaws.com/labels/20240105/1e72afaf5c704792b95d127895b16bcf.png"
    }
  ],
  "forms": [
    {
      "type": "commercial_invoice",
      "url": "https://shipbuy-dev.s3.us-west-1.amazonaws.com/labels/20240105/5f2cfde936ce4e6d8b93560b348f07ce.pdf"
    }
  ],
  "created_at": "2024-01-05 12:13:47"
}
                                
                            
Description of buy response
Field Name Type Description
id Integer Unique identifier for the shipping label.
tracking_number String Tracking number of the shipping label.
shipping_account_name String Name of the shipping account used.
carrier_type String Type of shipping carrier (e.g., 'usps').
service_type String Type of shipping service (e.g., 'usps_ground_advantage').
insurance_provider_type String or Null Insurance provider type, if applicable.
insurance_cost Number Cost of the insurance, if any.
shipping_cost Number Cost of shipping.
currency String Currency of the shipping cost (e.g., 'usd').
dimension_unit String Unit of dimension for packages (e.g., 'in').
weight_unit String Unit of weight for packages (e.g., 'oz').
delivery_days Integer Estimated number of days for delivery.
delivery_date String or Null Estimated delivery date, if available.
ship_date String Date when the shipment was made.
from.name String Sender's full name.
from.company String or Null Sender's company name.
from.phone String or Null Sender's phone number.
from.email String or Null Sender's email address.
from.street1 String Primary street address of the sender.
from.street2 String or Null Secondary street address of the sender.
from.city String City of the sender's address.
from.state String State of the sender's address.
from.zip String Postal code of the sender's address.
from.country String Country code of the sender's address.
from.residential Boolean Indicates if the sender's address is residential.
to.name String Recipient's full name.
to.company String or Null Recipient's company name.
to.phone String or Null Recipient's phone number.
to.email String or Null Recipient's email address.
to.street1 String Primary street address of the recipient.
to.street2 String or Null Secondary street address of the recipient.
to.city String City of the recipient's address.
to.state String State of the recipient's address.
to.zip String Postal code of the recipient's address.
to.country String Country code of the recipient's address.
to.residential Boolean Indicates if the recipient's address is residential.
packages[].package_type String or Null Type of package.
packages[].insurance_amount Number Amount of insurance for the package.
packages[].length Number Length of the package.
packages[].width Number Width of the package.
packages[].height Number Height of the package.
packages[].weight Number Weight of the package.
packages[].tracking_number String Tracking number for the package.
packages[].label_url String URL for the shipping label of the package.
forms[].type String Type of the form, e.g., 'commercial_invoice'.
forms[].url String URL to access the form.
created_at String Timestamp of when the label was created.

Refund

Refund a shipment.

POST https://shipbuy.com/api/shipping/refund
Example of refund request
                                
curl -X POST https://shipbuy.com/api/shipping/refund \
  -H "Authorization: Bearer {token}" \
  -H 'Content-Type: application/json' \
  -d '{
    "id": 41071243
  }'
                                
                            
Description of refund request
Field Name Type Required Description
id Integer Yes Unique identifier for the shipping label.
                                
{
  "id": 41071243,
  "refund_status": "submitted"
}
                                
                            
Description of refund request
Field Name Type Description
id Integer Unique identifier for the shipping label.
refund_status String Refund status of the shipping label.

Field Value Options

Enum values for API field

Dimension Unit

Option Value Description
cm Centimeters.
in Inches.

Weight Unit

Option Value Description
oz Ounces.
lb Pounds.
g Grams.
kg Kilograms.

Insurance Provider Type

Option Value Description
shipsurance Shipsurance Insurance Services, Inc.
shipping_provider Insurance provided by the shipping carrier.

Confirmation Type

Option Value Description
signature Standard signature confirmation.
adult_signature Confirmation requiring the signature of an adult.
indirect_signature Indirect signature confirmation, allowing delivery to a neighbor or building manager.

Carrier Type

Option Value Description
usps United States Postal Service
ups United Parcel Service
fedex Federal Express
dhl_express DHL Express
dhl_ecommerce_solutions DHL eCommerce Solutions

Service Type

Option Value Description
usps_priority_mailUSPS Priority Mail service.
usps_first_class_mail_internationalUSPS First Class Mail International service.
usps_media_mailUSPS Media Mail service.
usps_express_mailUSPS Express Mail service.
usps_express_mail_internationalUSPS Express Mail International service.
usps_priority_mail_internationalUSPS Priority Mail International service.
usps_first_class_package_internationalUSPS First Class Package International service.
usps_ground_advantageUSPS Ground Advantage service.
ups_next_day_air_earlyUPS Next Day Air Early service.
ups_worldwide_saverUPS Worldwide Saver service.
ups_worldwide_express_plusUPS Worldwide Express Plus service.
ups_worldwide_expressUPS Worldwide Express service.
ups_worldwide_expeditedUPS Worldwide Expedited service.
ups_standardUPS Standard service.
ups_next_day_air_saverUPS Next Day Air Saver service.
ups_next_day_airUPS Next Day Air service.
ups_groundUPS Ground service.
ups_3day_selectUPS 3 Day Select service.
ups_2nd_day_air_amUPS 2nd Day Air A.M. service.
ups_2nd_day_airUPS 2nd Day Air service.
fedex_groundFedEx Ground service.
fedex_standard_overnightFedEx Standard Overnight service.
fedex_priority_overnightFedEx Priority Overnight service.
fedex_international_priorityFedEx International Priority service.
fedex_international_groundFedEx International Ground service.
fedex_international_firstFedEx International First service.
fedex_home_deliveryFedEx Home Delivery service.
fedex_2dayFedEx 2Day service.
fedex_2day_amFedEx 2Day A.M. service.
fedex_express_saverFedEx Express Saver service.
fedex_international_economyFedEx International Economy service.
fedex_first_overnightFedEx First Overnight service.
dhl_express_globalmail_businessDHL Global Mail Business service.
dhl_express_express_easy_non_docDHL Express Easy for non-documents.
dhl_express_express_envelopeDHL Express Envelope service.
dhl_express_express_worldwideDHL Express Worldwide service.
dhl_express_express_worldwide_b2cDHL Express Worldwide for B2C.
dhl_express_express_worldwide_b2c_non_docDHL Express Worldwide B2C for non-documents.
dhl_express_express_worldwide_ecxDHL Express Worldwide ECX service.
dhl_express_express_worldwide_non_docDHL Express Worldwide for non-documents.
dhl_express_freight_worldwideDHL Freight Worldwide service.
dhl_express_jet_lineDHL Jet Line service.
dhl_express_jumbo_boxDHL Jumbo Box service.
dhl_express_logistics_servicesDHL Logistics Services.
dhl_express_same_dayDHL Same Day service.
dhl_express_secure_lineDHL Secure Line service.
dhl_express_sprint_lineDHL Sprint Line service.
dhl_express_domestic_express_1200DHL Domestic Express 12:00 service.
dhl_express_express_900_non_docDHL Express 9:00 Non-Document service.
dhl_express_break_bulk_economyDHL Break Bulk Economy service.
dhl_express_break_bulk_expressDHL Break Bulk Express service.
dhl_express_domestic_economy_selectDHL Domestic Economy Select service.
dhl_express_domestic_expressDHL Domestic Express service.
dhl_express_domestic_express_1030DHL Domestic Express 10:30 service.
dhl_express_economy_selectDHL Economy Select service.
dhl_express_economy_select_non_docDHL Economy Select for Non-Documents.
dhl_express_euro_pack_non_docDHL Euro Pack Non-Document service.
dhl_express_express_1030DHL Express 10:30 service.
dhl_express_express_1030_non_docDHL Express 10:30 Non-Document service.
dhl_express_express_1200_non_docDHL Express 12:00 Non-Document service.
dhl_express_express_1200DHL Express 12:00 service.
dhl_express_express_900DHL Express 9:00 service.
dhl_express_express_easyDHL Express Easy service.
dhl_express_euro_packDHL Euro Pack service.
dhl_ecommerce_solutions_parcel_international_direct_standardDHL eCommerce Solutions Parcel International Direct Standard.
dhl_ecommerce_solutions_parcel_international_direct_priorityDHL eCommerce Solutions Parcel International Direct Priority.
dhl_ecommerce_solutions_packet_internationalDHL eCommerce Solutions Packet International.
dhl_ecommerce_solutions_parcel_international_standardDHL eCommerce Solutions Parcel International Standard.
dhl_ecommerce_solutions_parcel_international_directDHL eCommerce Solutions Parcel International Direct.
dhl_ecommerce_solutions_bpm_groundDHL eCommerce Solutions BPM Ground.
dhl_ecommerce_solutions_bpm_expeditedDHL eCommerce Solutions BPM Expedited.
dhl_ecommerce_solutions_parcel_groundDHL eCommerce Solutions Parcel Ground.
dhl_ecommerce_solutions_parcel_expedited_maxDHL eCommerce Solutions Parcel Expedited Max.
dhl_ecommerce_solutions_parcel_expeditedDHL eCommerce Solutions Parcel Expedited.

Package Type

Option Value Description
usps_letter USPS standard letter.
usps_small_envelope USPS small envelope.
usps_envelope USPS regular envelope.
usps_legal_envelope USPS legal size envelope.
usps_padded_envelope USPS padded envelope.
usps_small_box USPS small box.
usps_medium_box USPS medium box.
usps_large_box USPS large box.
ups_letter UPS standard letter.
ups_pak UPS pak.
ups_tube UPS tube for rolled items.
ups_10kg_box UPS box with a 10 kg limit.
ups_25kg_box UPS box with a 25 kg limit.
ups_express_box UPS Express box.
ups_express_small_box UPS Express small box.
ups_express_medium_box UPS Express medium box.
ups_express_large_box UPS Express large box.
fedex_envelope FedEx standard envelope.
fedex_pak FedEx pak.
fedex_tube FedEx tube for rolled items.
fedex_10kg_box FedEx box with a 10 kg limit.
fedex_25kg_box FedEx box with a 25 kg limit.
fedex_box FedEx standard box.
fedex_small_box FedEx small box.
fedex_medium_box FedEx medium box.
fedex_large_box FedEx large box.
fedex_extra_large_box FedEx extra large box.
dhl_express_document DHL Express document package.
dhl_express_express_document DHL Express document package (express service).
dhl_express_flyer DHL Express flyer package.
dhl_express_domestic DHL Express domestic package.
dhl_express_envelope DHL Express envelope.
dhl_express_parcel DHL Express parcel package.
dhl_express_jumbo_document DHL Express jumbo document package.
dhl_express_jumbo_parcel DHL Express jumbo parcel.
dhl_express_jumbo_box DHL Express jumbo box.
dhl_express_jumbo_junior_document DHL Express jumbo junior document package.
dhl_express_jumbo_junior_box DHL Express jumbo junior box.
dhl_express_jumbo_junior_parcel DHL Express jumbo junior parcel.

Contents Type

Option Value Description
merchandise Goods being shipped for sale.
documents Paper-based items such as letters or forms.
gift Items sent as a gift.
returned_goods Items being returned to the sender.
sample Sample products, typically for promotional or review purposes.

Non Delivery Option

Option Value Description
abandon If delivery cannot be completed, the package will be abandoned.
return If delivery cannot be completed, the package will be returned to sender.