Custom tracking integrations
Custom tracking integrations
Onport supports AfterShip for syncing of tracking details with customers, allowing monitoring of movements on shipments through hosted tracking pages or email/SMS alerts. If you're looking to use an alternative or custom build a solution, Onport provides a series or webhooks and endpoints to extract and sync this data externally.
Registering a new customer order
Depending on the implementation of your custom tracking integration, you may need to first register the customer sale, before registering the individual tracking details of each shipment (there may be multiple shipments in a multi-origin order). If this isn't the case, you can skip to the next step.
To register the sale in the external tracking integration, you'll need to listen for the creation of new sale
resources. While you can listen for the sale creation webhook, the complete sale data might yet been ready. Onport first creates the sale object, then populates the product and shipping lines, before finalizing the order.
The alternative then is to use the dropship
action on the sales resource. You can find that under Integrations > Api
. Select the sales
resource and dropship
as the action.
A convenient way to test this would be to either clone an existing order. Or, pushing through a test order. The received webhook usually isn't sufficient by itself. You may also need to know the line items or customer details associated with the sale. For this, once the webhook is received, you can make a GET request for additional information:
curl --request GET \--url 'https://api.jetti.io/api/sales/:id.json?include[0][model]=Customer&include[1][model]=SaleItem' \--header 'Authorization: Bearer {{token}}'
The above is an example of pulling in the sale resource, together with the SaleItem
and Customer
resource. From there, you can create the external container for the order in the tracking integration.
Listening for shipments
As a next step, you'll now want to listen for tracking events within Onport and update those within the custom tracking integration. We'll use a similar approach as before, listening for a webhook to a resource, then fetching any additional information needed. For tracking, the most relevant resource is dropshipments
. This represents a shipment of a dropship purchase from a dropship provider.
As with sales
in the previous step, not all data may be present if we just listen to the creation event. Instead, we should listen for when dropshipments are externally acknowledged in your channel:
Once the fulfillment webhook is sent, you'll then want to again do a GET
for the resource, including additional information.
curl --request GET \--url 'https://api.jetti.io/api/dropshipments/:id.json?include[0][model]=Purchase&include[1][model]=DropshipmentItem' \--header 'Authorization: Bearer {{token}}'
The above will load a list of the line items associated with the shipment and parent dropship purchase. Additional data can be side loaded as needed. For example, the ability to fetch details on the parent Sale. Or, further details on the line items themselves. We'd recommend limiting the scope of the includes to only the attributes needed to improve the response of the request.