ShipStation Webhook Integration Guide

Recently WP EasyCart integrated with ShipStation and found that their Webhook API documentation was seriously lacking (or just impossible to find?). We wanted to post this information in case other developers were having the same issue we came across.

First, the webhook information does not come back as a POST or GET variable as it seems in their docs. Instead you should capture this data via the body of the output:

$json = file_get_contents( 'php://input' );
$obj = json_decode( $json );

Second, this information is not actually about your shipment, this is an endpoint to call to get data on the recently shipped item. You can grab this data via a call like:

$endpoint = $obj->resource_url;
$response = $this->get_response( $endpoint, array( ) );
$obj_response = json_decode( $response );

Your get response function should be a simple CURL call.

Third, the response will be a shipment response and will look like:

{

"shipments":[

{

"shipmentId":000000000,
 "orderId":000000000,
 "orderKey":"product-orderid-shipment",
 "userId":"aadfasdfasd-asdfasd-asdf-asdfasd
 "customerEmail":"youremail@email.com",
 "orderNumber":"orderid-shipmentid",
 "createDate":"2017-11-22T10:07:40.2670000",
 "shipDate":"2017-11-22",
 "shipmentCost":5.75,
 "insuranceCost":0.0,
 "trackingNumber":"000000000000000000",
 "isReturnLabel":false,
 "batchNumber":null,
 "carrierCode":"stamps_com",
 "serviceCode":"usps_priority_mail",
 "packageCode":"flat_rate_envelope",
 "confirmation":"delivery",
 "warehouseId":000000,
 "voided":false,
 "voidDate":null,
 "marketplaceNotified":true,
 "notifyErrorMessage":null,
 "shipTo":{

"name":"Ron",
 "company":null,
 "street1":"ST",
 "street2":"",
 "street3":null,
 "city":"LA",
 "state":"CA",
 "postalCode":"00000-0000",
 "country":"US",
 "phone":"",
 "residential":null,
 "addressVerified":null

},
 "weight":{

"value":48.0,
 "units":"ounces",
 "WeightUnits":1

},
 "dimensions":{

"units":"inches",
 "length":10.00,
 "width":12.00,
 "height":3.00

},
 "insuranceOptions":{

"provider":null,
 "insureShipment":false,
 "insuredValue":0.0

},
 "advancedOptions":{

"billToParty":null,
 "billToAccount":null,
 "billToPostalCode":null,
 "billToCountryCode":null,
 "storeId":000000

},
 "shipmentItems":null,
 "labelData":null,
 "formData":null

}

],
 "total":1,
 "page":1,
 "pages":0

}

I hope this information can help out developers that may be integrating with ShipStation and their webhook system.

If you are a store owner, we recommend using our ShipStation integration! Its already setup for you and allows you to make shipping easier than ever.