These docs are for v1.0. Click to read the latest docs for v2024.09.

🚧

Limitation

You can only cancel shipment if label is pending or generated or failed
and shipment is not yet delivered

curl - -include \
     - -request PATCH \
     - -header "Content-Type: application/json" \
     - -header "Authorization: Bearer 4e2b327e2ef5471885cd0bc50a0c9fe52481793bd309b2c4f2a6bdac3f10ae1f" \
'https://api.easyship.com/shipment/v1/shipments/{easyship_shipment_id}/cancel'
var request = require('request');

request({
  method: 'PATCH',
  url: 'https://api.easyship.com/shipment/v1/shipments/{easyship_shipment_id}/cancel',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer 4e2b327e2ef5471885cd0bc50a0c9fe52481793bd309b2c4f2a6bdac3f10ae1f'
  },
  body: ""
}, function (error, response, body) {
  console.log('Status:', response.statusCode);
  console.log('Headers:', JSON.stringify(response.headers));
  console.log('Response:', body);
});
require 'rubygems' if RUBY_VERSION < '1.9'
require 'rest_client'

values = ''

headers = {
  :content_type => 'application/json',
  :authorization => 'Bearer 4e2b327e2ef5471885cd0bc50a0c9fe52481793bd309b2c4f2a6bdac3f10ae1f'
}

response = RestClient.patch 'https://api.easyship.com/shipment/v1/shipments/{easyship_shipment_id}/cancel', values, headers
puts response
from urllib2 import Request, urlopen

values = """
"""

headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer 4e2b327e2ef5471885cd0bc50a0c9fe52481793bd309b2c4f2a6bdac3f10ae1f'
}
request = Request('https://api.easyship.com/shipment/v1/shipments/{easyship_shipment_id}/cancel', data=values, headers=headers)
request.get_method = lambda: 'PATCH'

response_body = urlopen(request).read()
print response_body
<?php
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://api.easyship.com/shipment/v1/shipments/{easyship_shipment_id}/cancel");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PATCH");

curl_setopt($ch, CURLOPT_POSTFIELDS, "");

curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  "Content-Type: application/json",
  "Authorization: Bearer 4e2b327e2ef5471885cd0bc50a0c9fe52481793bd309b2c4f2a6bdac3f10ae1f"
));

$response = curl_exec($ch);
curl_close($ch);

var_dump($response);
var request = new XMLHttpRequest();

request.open('PATCH', 'https://api.easyship.com/shipment/v1/shipments/{easyship_shipment_id}/cancel');

request.setRequestHeader('Content-Type', 'application/json');
request.setRequestHeader('Authorization', 'Bearer 4e2b327e2ef5471885cd0bc50a0c9fe52481793bd309b2c4f2a6bdac3f10ae1f');

request.onreadystatechange = function () {
  if (this.readyState === 4) {
    console.log('Status:', this.status);
    console.log('Headers:', this.getAllResponseHeaders());
    console.log('Body:', this.responseText);
  }
};

var body = {};

request.send(JSON.stringify(body));
##Response
{
    "shipment" => {
        "easyship_shipment_id": "ESHK2325803",
        "message": "Shipment is successfully cancelled and refunded"
    }
}
Language
Credentials
Header
Click Try It! to start a request and see the response here!