Creating A Shipment
Great! You've got an order that needs to be shipped to a buyer.
Before buying a label, you first need to create a shipment in the Easyship system. To do this you will use the Shipment API, where you can add, update, delete and retrieve shipments.
Create the Shipment ID
Ok so now you've got an order that needs to be shipped.
The creation of the Shipment is handled by the shipment
endpoint. If you have already selected a rate using the rates
endpoint, you can add in the previously saved courier_id": "638ac885-8105-422c-b2cc-4c57152772f7
under the selected_courier_id
.
If you haven't yet selected a rate, the system will automatically assign the best value for money rate and include a list of all available rates for reference or changes. For the purpose of the example below, we'll assume a rate and courier has been chosen already.
{
"platform_name": "Amazon",
"platform_order_number": "#1234",
"selected_courier_id": "b8d528a7-a2d4-4510-a7ac-11cbbb6542cd",
"destination_country_alpha2": "US",
"destination_city": "New York",
"destination_postal_code": "10022",
"destination_state": "NY",
"destination_name": "Aloha Chen",
"destination_address_line_1": "300 Park Avenue",
"destination_address_line_2": null,
"destination_phone_number": "+1 234-567-890",
"destination_email_address": "[email protected]",
"items": [
{
"description": "Silk dress",
"sku": "test",
"actual_weight": 1.2,
"height": 10,
"width": 15,
"length": 20,
"category": "fashion",
"declared_currency": "SGD",
"declared_customs_value": 100
}
]
}
curl --include \
--request POST \
--header "Content-Type: application/json" \
--header "Authorization: Bearer <YOUR EASYSHIP API TOKEN>" \
--data-binary "{
\"platform_name\": \"Amazon\",
\"platform_order_number\": \"#1234\",
\"selected_courier_id\": \"b8d528a7-a2d4-4510-a7ac-11cbbb6542cd\",
\"destination_country_alpha2\": \"US\",
\"destination_city\": \"New York\",
\"destination_postal_code\": \"10022\",
\"destination_state\": \"NY\",
\"destination_name\": \"Aloha Chen\",
\"destination_address_line_1\": \"300 Park Avenue\",
\"destination_address_line_2\": null,
\"destination_phone_number\": \"+1 234-567-890\",
\"destination_email_address\": \"[email protected]\",
\"items\": [
{
\"description\": \"Silk dress\",
\"sku\": \"test\",
\"actual_weight\": 1.2,
\"height\": 10,
\"width\": 15,
\"length\": 20,
\"category\": \"fashion\",
\"declared_currency\": \"SGD\",
\"declared_customs_value\": 100
}
]
}" \
'https://api.easyship.com/shipment/v1/shipments'
require 'rubygems' if RUBY_VERSION < '1.9'
require 'rest_client'
values = '{
"platform_name": "Amazon",
"platform_order_number": "#1234",
"selected_courier_id": "b8d528a7-a2d4-4510-a7ac-11cbbb6542cd",
"destination_country_alpha2": "US",
"destination_city": "New York",
"destination_postal_code": "10022",
"destination_state": "NY",
"destination_name": "Aloha Chen",
"destination_address_line_1": "300 Park Avenue",
"destination_address_line_2": null,
"destination_phone_number": "+1 234-567-890",
"destination_email_address": "[email protected]",
"items": [
{
"description": "Silk dress",
"sku": "test",
"actual_weight": 1.2,
"height": 10,
"width": 15,
"length": 20,
"category": "fashion",
"declared_currency": "SGD",
"declared_customs_value": 100
}
]
}'
headers = {
:content_type => 'application/json',
:authorization => 'Bearer <YOUR EASYSHIP API TOKEN>'
}
response = RestClient.post 'https://api.easyship.com/shipment/v1/shipments', values, headers
puts response
var request = require('request');
request({
method: 'POST',
url: 'https://api.easyship.com/shipment/v1/shipments',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer <YOUR EASYSHIP API TOKEN>'
},
body: "{ \"platform_name\": \"Amazon\", \"platform_order_number\": \"#1234\", \"selected_courier_id\": \"b8d528a7-a2d4-4510-a7ac-11cbbb6542cd\", \"destination_country_alpha2\": \"US\", \"destination_city\": \"New York\", \"destination_postal_code\": \"10022\", \"destination_state\": \"NY\", \"destination_name\": \"Aloha Chen\", \"destination_address_line_1\": \"300 Park Avenue\", \"destination_address_line_2\": null, \"destination_phone_number\": \"+1 234-567-890\", \"destination_email_address\": \"[email protected]\", \"items\": [ { \"description\": \"Silk dress\", \"sku\": \"test\", \"actual_weight\": 1.2, \"height\": 10, \"width\": 15, \"length\": 20, \"category\": \"fashion\", \"declared_currency\": \"SGD\", \"declared_customs_value\": 100 } ]}"
}, function (error, response, body) {
console.log('Status:', response.statusCode);
console.log('Headers:', JSON.stringify(response.headers));
console.log('Response:', body);
});
from urllib2 import Request, urlopen
values = """
{
"platform_name": "Amazon",
"platform_order_number": "#1234",
"selected_courier_id": "b8d528a7-a2d4-4510-a7ac-11cbbb6542cd",
"destination_country_alpha2": "US",
"destination_city": "New York",
"destination_postal_code": "10022",
"destination_state": "NY",
"destination_name": "Aloha Chen",
"destination_address_line_1": "300 Park Avenue",
"destination_address_line_2": null,
"destination_phone_number": "+1 234-567-890",
"destination_email_address": "[email protected]",
"items": [
{
"description": "Silk dress",
"sku": "test",
"actual_weight": 1.2,
"height": 10,
"width": 15,
"length": 20,
"category": "fashion",
"declared_currency": "SGD",
"declared_customs_value": 100
}
]
}
"""
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer <YOUR EASYSHIP API TOKEN>'
}
request = Request('https://api.easyship.com/shipment/v1/shipments', data=values, headers=headers)
response_body = urlopen(request).read()
print response_body
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.easyship.com/shipment/v1/shipments");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{
\"platform_name\": \"Amazon\",
\"platform_order_number\": \"#1234\",
\"selected_courier_id\": \"b8d528a7-a2d4-4510-a7ac-11cbbb6542cd\",
\"destination_country_alpha2\": \"US\",
\"destination_city\": \"New York\",
\"destination_postal_code\": \"10022\",
\"destination_state\": \"NY\",
\"destination_name\": \"Aloha Chen\",
\"destination_address_line_1\": \"300 Park Avenue\",
\"destination_address_line_2\": null,
\"destination_phone_number\": \"+1 234-567-890\",
\"destination_email_address\": \"[email protected]\",
\"items\": [
{
\"description\": \"Silk dress\",
\"sku\": \"test\",
\"actual_weight\": 1.2,
\"height\": 10,
\"width\": 15,
\"length\": 20,
\"category\": \"fashion\",
\"declared_currency\": \"SGD\",
\"declared_customs_value\": 100
}
]
}");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
"Authorization: Bearer <YOUR EASYSHIP API TOKEN>"
));
$response = curl_exec($ch);
curl_close($ch);
var_dump($response);
Once you've sent the request, the response will contain the easyship_shipment_id
. This is the unique identifier assigned to each shipment created within our platform. You'll receive the following response:
{
"shipment" => {
"created_at": "2016-11-23T04:52:24.559Z",
"updated_at": "2016-11-23T04:52:30.386Z",
"easyship_shipment_id": "ESHK2325803",
"destination_name": "Aloha Chen",
"destination_address_line_1": "300 Park Avenue",
"destination_address_line_2": null,
"destination_city": "New York",
"destination_state": "NY",
"destination_postal_code": "10022",
"destination_phone_number": "+1 234-567-890",
"destination_email_address": "[email protected]",
"platform_name": "Amazon",
"platform_order_number": "#1234",
"currency": "HKD",
"total_customs_value": 573.06,
"total_actual_weight": 1.2,
"total_dimensional_weight": 0.6,
"total_volumetric_weight": 1.2,
"is_insured": false,
"origin_country": {
"name": "Hong Kong",
"alpha2": "HK"
},
"destination_country": {
"name": "United States",
"alpha2": "US"
},
"items": [
{
"id": "00015b1f-0cda-4dc5-ae64-b920ff9f2d25",
"description": "Silk dress",
"sku": "test-123",
"width": 15.0,
"length": 20.0,
"height": 10.0,
"actual_weight": 1.2,
"dimensional_weight": 0.6,
"volumetric_weight": 1.2,
"declared_customs_value": 100.0,
"declared_currency": "SGD",
"origin_customs_value": 573.06,
"origin_currency": "HKD",
"category": "fashion"
}
],
"box": {
"name": null,
"length": 20,
"width": 15,
"height": 10
},
"selected_courier": {
"id": "2a17f7aa-51f7-4d36-bca8-e77c164cb52a",
"name": "DHL Express",
"min_delivery_time": 2,
"max_delivery_time": 3,
"shipment_charge": 284.9,
"fuel_surcharge": 32.05125,
"remote_area_surcharge": 0,
"shipment_charge_total": 316.95125,
"warehouse_handling_fee": 0,
"insurance_fee": 0,
"ddp_handling_fee": 0,
"import_tax_charge": 0,
"import_duty_charge": 0,
"total_charge": 316.95,
"is_above_threshold": false,
"effective_incoterms": "DDU",
"estimated_import_tax": 0,
"estimated_import_duty": 0,
"courier_does_pickup": false,
"courier_dropoff_url": "https://www.easyship.com/drop-off/dhl/hk",
"courier_remarks": null,
"payment_recipient": "Easyship"
},
"rates": [
{
"courier_id": "b8d528a7-a2d4-4510-a7ac-11cbbb6542cd",
"courier_name": "UPS",
"min_delivery_time": 1,
"max_delivery_time": 3,
"value_for_money_rank": 1.0,
"delivery_time_rank": 1.0,
"shipment_charge": 237.50,
"fuel_surcharge": 22.56,
"remote_area_surcharge": 0,
"shipment_charge_total": 260.06,
"warehouse_handling_fee": 0,
"insurance_fee": 0.0,
"ddp_handling_fee": 0.0,
"import_tax_charge": 0.0,
"import_duty_charge": 0.0,
"total_charge": 260.06,
"is_above_threshold": false,
"effective_incoterms": "DDU",
"estimated_import_tax": 0,
"estimated_import_duty": 0,
"courier_does_pickup": true,
"courier_dropoff_url": "",
"tracking_rating": 3.0,
"courier_remarks": null,
"payment_recipient": "Easyship"
}
]
}
}
Updated over 6 years ago
Now you've created your shipment you can confirm the shipment and purchase the shipping labels and generate customs/tax documents.