API Quick Start
AfterShip Shipping helps calculate rates, generate labels, generate invoices and manifests across multiple couriers. You can add your multiple courier accounts in the AfterShip Shipping app and generate labels as per your negotiated rates with the courier.
This API Quick Start guide intends to walk you through 4 common scenarios, and hopefully, after this journey, you will know how to use the AfterShip Shipping API to integrate AfterShip Shipping with your website to calculate rates and generate labels.
The AfterShip Shipping API is a flexible, modern API that aggregates shipping APIs into one. It allows you to programmatically build applications that interface with AfterShip Shipping. The API can be used to calculate rates, generate labels and manifest with multiple carriers like UPS, USPS, FedEx and more. Thousands of developers are already using it to automate their shipping process.
Please refer to supported couriers to get a list of all the couriers supported by AfterShip Shipping.
A shipping label contains the information a courier needs to get your package from its origin to the destination. It includes a scannable barcode with a tracking number that enables the courier to provide delivery updates.
Note: You will not be charged for generating shipping labels in the AfterShip Shipping sandbox environment.
AfterShip Shipping verifies a user's request by adding an as-api-key in the header. So you shall get the as-api-key first.
You can generate multiple API keys from the API Keys page. Same API key can be used in both sandbox and production environment.
All endpoints are only accessible via
step 1: Please login in Shipping admin page. Please enable Test mode if in sandbox environment, otherwise disable Test mode.
step 2: Please select the carrier you want to add shipper account in select a carrer page.
step 3: please input the necessary information and submit the form. For example,
step 4: Please copy the Account it, and this is your shipper account you can use in the API.
Once you get the
label url in the response, please click the URL and preview the label layout in your browser.
While generating labels, we suggest you provide all the required fields in the request. Please check the full payload in the endpoint instructions for more details.
But when you are not sure what fields are required in
/labels, AfterShip Shipping will validate and return an error message like the one shown below. If you get this error, please update the specific fields and try it again.
You will get the shipping rates of your shipment in the response.
You will get all the label information you generated in the response. Feel free to download all the labels in the browser.
A webhook lets an application share real-time information with other apps. Since data transfer happens instantly, the popularity of webhooks is increasing rapidly these days. With AfterShip Shipping webhook, you can receive the push update when the API is made asynchronously.
To set up your webhook, go to AfterShip Shipping Settings and click the Webhooks option to fill in your webhook URL and save it. You can add multiple webhook URLs, and we will push notifications to all those URLs.
Webhooks include a calculated digital signature for verification. Each webhook request includes an am-webhook-signature header. The signature is a base64-encoded HMAC generated using the sha256 algorithm with the webhook request body and the webhook secret of your account. The following Node.js example demonstrates the computation of a webhook signature.
Each webhook request could be verified by comparing the computed HMAC digest and the attached HMAC digest in the header.
Sample encrypted signature(Node.js)
Sample webhook body