Articles on: Automation Rules

Save your shipping and time cost with AfterShip Shipping Rule-based Label API

Still headache on which carrier and service to choose to fulfill your order? AfterShip Shipping Rule-based Label API can help you save your cost.


The Rule-based Label API is in Beta testing and only applicable to Enterprise plan now, consult with your Account Executive if you want to test it out.


How to enable the feature?



It’s very simple!

Case 1: Let AfterShip Shipping to help you choose the cheapest service according to your carrier account and rule setting.



Setup your carrier account as usual, only enable the preferred services.
Follow these steps to setup your automation rules.
Now you can setup the Action - Use carrier/service with the Cheapest or Fastest, and specify the delivery speed

You can set as: For all orders, always use the cheapest service.



For AfterShip Shipping Label API, update the request payload as below:
a. Remove fields: shipper_account, service_type
b. Add field: automatic, it's a boolean field, please always use the value true in request payload.

Now AfterShip Shipping can check all your preferred services and choose the cheapest service for you !

A sample of the request will be as below:
{
    "automatic": true,
    "order_number":"test-order1",
    "shipment": {
        "ship_from": {
            "contact_name": "Test Test",
            "phone": "(111) 111-1234",
            "email": "test@test.com",
            "street1": "2432 Quaking Cove",
            "street2": "Content, Mississippi",
            "city": "New York",
            "postal_code": "10001",
            "state": "NY",
            "country": "USA",
            "type": "residential"
        },
        "ship_to": {
            "contact_name": "xxx Test",
            "phone": "(222) 222-5678",
            "email": "test@test.com",
            "street1": "2432 Quaking Cove",
            "street2": "Content, Mississippi",
            "city": "New York",
            "postal_code": "10001",
            "state": "NY",
            "country": "USA",
            "type": "residential"
        },
        "parcels": [
            {
                "description": "Food XS",
                "box_type": "custom",
                "weight": {
                    "value": 1,
                    "unit": "kg"
                },
                "dimension": {
                    "width": 1,
                    "height": 1,
                    "depth": 1,
                    "unit": "cm"
                },
                "items": [
                    {
                        "description": "Food Bar",
                        "origin_country": "USA",
                        "quantity": 1,
                        "price": {
                            "amount": 500,
                            "currency": "USD"
                        },
                        "weight": {
                            "value": 0.6,
                            "unit": "kg"
                        },
                        "sku": "imac2014"
                    }
                ]
            }
        ]
    }
}


Case 2: You setup the preferred carrier and service in Shipping rules, and specify carrier account in Labels API.


Setup your carrier account as usual, only enable the preferred services.
In "Actions" setting, set service only.



In Labels API, specify the carrier account id to use. It can refer to the input id and pre-set service to create shipping labels.
A sample of the request will be as below:
{
    "automatic": true,
    "order_number":"test-order1",
    "shipper_account": {
    "id": "11111111-1111-1111-1111-111111111111"
  },
    "shipment": {
        "ship_from": {
            "contact_name": "Test Test",
            "phone": "(111) 111-1234",
            "email": "test@test.com",
            "street1": "2432 Quaking Cove",
            "street2": "Content, Mississippi",
            "city": "New York",
            "postal_code": "10001",
            "state": "NY",
            "country": "USA",
            "type": "residential"
        },
        "ship_to": {
            "contact_name": "xxx Test",
            "phone": "(222) 222-5678",
            "email": "test@test.com",
            "street1": "2432 Quaking Cove",
            "street2": "Content, Mississippi",
            "city": "New York",
            "postal_code": "10001",
            "state": "NY",
            "country": "USA",
            "type": "residential"
        },
        "parcels": [
            {
                "description": "Food XS",
                "box_type": "custom",
                "weight": {
                    "value": 1,
                    "unit": "kg"
                },
                "dimension": {
                    "width": 1,
                    "height": 1,
                    "depth": 1,
                    "unit": "cm"
                },
                "items": [
                    {
                        "description": "Food Bar",
                        "origin_country": "USA",
                        "quantity": 1,
                        "price": {
                            "amount": 500,
                            "currency": "USD"
                        },
                        "weight": {
                            "value": 0.6,
                            "unit": "kg"
                        },
                        "sku": "imac2014"
                    }
                ]
            }
        ]
    }
}



country must be in 3-letter iso country code as the basic label API.

In case you have any more questions, our chat support team is just a message away.

Updated on: 24/11/2023

Was this article helpful?

Share your feedback

Cancel

Thank you!