Adding tracking to a shipment
This snippet uses the /shipments/ PUT endpoint to add a tracking number to a shipment (and send a notification email to the customer).
$.ajax({
url: 'https://api.cratejoy.com/v1/shipments/62619521654545/',
method: 'PUT',
data: {
shipped_at: "2015-09-01 12:30:00Z",
adjusted_ordered_at: "2015-08-25 00:00:00Z",
tracking_number: "D2FA3GA57H0NDSF9FAE8G6AR3H4AT",
status: "shipped",
carrier_name: "USPS", // Optional
tracking_link: "https:\\tools.usps.com\go\TrackConfirmAction.action?tLabels=D2FA3GA57H0NDSF9FAE8G6AR3H4AT" // Optional
},
});
Notes
- On Line 7, with
tracking_number:
, we're adding a tracking number. - On Line 8, with
status: "shipped"
, we're changing the status of shipment to shipped, which will trigger the notification to the customer.
Shipment-level product feedback settings
In the Cratejoy interface, admins can set store-level product feedback settings. Setting shipment-level product feedback settings will override any store-level product feedback settings.
To set shipment-level settings, include X-Cratejoy-ProductFeedback-Enabled
(true or false) and/or X-Cratejoy-ProductFeedback-Interval
(the number of days after which the feedback survey should be sent) in the headers, like below.
$.ajax({
url: 'https://api.cratejoy.com/v1/shipments/62619521654545/',
headers: {
// Header should also contain authorization.
'X-Cratejoy-ProductFeedback-Enabled': true,
'X-Cratejoy-ProductFeedback-Interval': 15
},
method: 'PUT',
data: {
shipped_at: "2015-09-01T12:30:00Z",
adjusted_ordered_at: "2015-08-25 00:00:00Z",
tracking_number: "1Z9999999999999999",
status: "shipped"
},
});
The response will not include confirmation that the feedback survey and interval settings were set, but users can see scheduled product feedback surveys in the Analytics > Notifications page in the Cratejoy interface.
How shipment-level product feedback settings interact with store-level settings##
Shipment-level product feedback settings will always override store-level settings. In the absence of shipment-level settings, the default is store-level settings, like below.