SwagUp API: Managing Shipments

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:

 

https://api.swagup.com/api/v1.01/shipping-prices/

 

Example request:
{
"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.

 

Example response*:
{
"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 examples in this guide have been truncated to show less data.

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:

 

https://api.swagup.com/core/api/v1/webhooks/

 

Example payload:
{
 "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:

 

Example response*:
{
 "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
}

* The response examples in this guide have been truncated to show less data.

 

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

 

Example payload:
{
"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"
}
}

* The response examples in this guide have been truncated to show less data.

 

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.

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.

Articles in this section

Ask a question
Not sure how something works or how to make changes? Don’t worry, we’ll answer all your questions.
Our help desk hours:
9:00am - 4:00pm EST Monday to Friday
Follow us on Twitter
Get the latest news and updates first