All Collections
Integrations & Apps
SwagUp API
SwagUp API: Managing Shipments
SwagUp API: Managing Shipments
Helen Rankin avatar
Written by Helen Rankin
Updated over a week ago

Calculate shipping prices

The SwagUp API provides a shipping price calculator to compute how much shipping will cost for a specific product to a specific address. For this, make a POST request to:

{
"quantities": [
{
"account_product": 22691,
"quantity": 1
}
],
"shipping_country": "US",
"shipping_state": "NJ",
"shipping_city": "Union City",
"shipping_zip": "07087",
"shipping_address1": "2607 New York Ave"
}

This will compute how much shipping costs to send the product 22691 to the address provided.

{
"delivery_methods": [
{
"id": 1,
"name": "Standard",
"turnaround_time_min_days": 3,
"turnaround_time_max_days": 5,
"turnaround_time": "3-5 business days",
"prices": {
"shipping_method": null,
"breakdown": [
{
"total_price": 12
}
],
"total_price": 12,
"total_packages": 1
}
},
{
"id": 3,
"name": "Express",
"turnaround_time_min_days": 1,
"turnaround_time_max_days": 1,
"turnaround_time": "1 business day",
"prices": {
"shipping_method": null,
"breakdown": [
{
"total_price": 16
}
],
"total_price": 16,
"total_packages": 1
}
}
]
}

The response gives you total_price for each delivery method. This is the cost of shipping for the provided information.

Receive swag delivery status updates

You can use the SwagUp API to receive webhook notifications anytime a shipment delivery status changes. For this, you must register a webhook by making a POST request here:

{
"event": "directory_order.changed",
"target": "{{url}}"
}

This will register a webhook notification that will trigger a request to ##{{url}} whenever a shipment status changes. If the registration was successful, you will get a response like this:

{
"id": 199,
"created": "2020-06-24T13:31:59.830219Z",
"updated": "2020-06-24T13:31:59.830264Z",
"event": "directory_order.changed",
"target": "{{url}}",
"is_active": true,
"user": 494
}

After subscription, a POST request will be made to ##{{url}} once a shipment status changes. The request payload will be similar to this:

{
"hook": {
"id": 199,
"event": "directory_order.changed",
"target": "{{url}}"
},
"data": {
"id": 3267,
"employee": {
"id": 3011,
"title": "Developer",
"first_name": "John",
"last_name": "Doe",
"birth_date": "1990-06-19",
"shipping_address1": "2607 New York Ave",
"shipping_address2": null,
"shipping_city": "Union City",
"shipping_state": "NJ",
"shipping_zip": "07087",
"shipping_country": "US",
"size": {
"id": 3,
"name": "M",
"category": "Apparel",
"modified_on": "2019-12-11T14:30:21.924795Z",
"sort_order": 4
},
"external_id": null,
"photo": null,
"email": "john.doe@mail.com",
"phone_number": "+1111111111",
"created_at": "2020-06-22T22:46:45.296906Z",
"modified_on": "2020-06-22T22:46:45.296906Z",
"source": null
},
"date": "2020-06-22",
"status": "Delivered",
"status_detail": "arrived_at_destination",
"status_updated_at": "2020-07-09T18:24:20Z",
"tracking": "EZ4000000004",
"products": [
...
],
"tracking_url": "https://track.easypost.com/EZ4000000004",
"order_no": "EO-20200622-00003267",
"shipping_date": "2020-06-28",
"shipping_notes": "",
"modified_on": "2020-06-24T14:34:29.761099Z",
"source": null,
"total_shipping": "12.21",
"delivery_method": {
"id": 1,
"name": "Standard",
"turnaround_time_min_days": 3,
"turnaround_time_max_days": 5,
"turnaround_time": "3-5 business days",
"country": "US"
},
"requested_by": "User",
"shipping_address1": "2607 New York Ave",
"shipping_address2": null,
"shipping_city": "Union City",
"shipping_state": "NJ",
"shipping_zip": "07087",
"shipping_country": "US"
}
}

This payload contains information about the shipments. Pay special attention to the status, status_detail, status_updated_at, tracking, and tracking_url keys. These keys will contain tracking information updates of the shipments.

Did this answer your question?