API Quick Start
AfterShip Protection helps eCommerce businesses insure their packages against loss, theft, and damage.
This quick start guide will walk you through the three most common scenarios for using the AfterShip Protection API.
1. What is Protection API?
As a merchant, you can sell shipping protection to your customers, or cover the cost of protection yourself, to help protect your bottom line when things go wrong with a shipment. The API allows you to calculate the premium, add protection to orders, and check the status of an order's coverage.
2. API Endpoint
All endpoints are only accessible via HTTPS
.
3. Using the sandbox environment for API testing
We have created a sandbox environment where you can test the Protection API. Any protection created in the sandbox environment will not be charged or take effect, but will still display on your AfterShip Protection admin. After creating coverage in the sandbox environment, you can file a test claim from the admin to check the resolution process.
Once testing is complete, you only need to modify the host to switch to the production environment. The table below shows the hosts and other details used for the sandbox and production environments.
Item | Sandbox | Live |
---|---|---|
API Host | sandbox-api.aftership.com | api.aftership.com |
Charge for coverage | ❎ | ✅ |
API Key | Same as live |
4. Common scenarios
Scenario 1. Calculate Premium
By sending the order subtotal and shipping fee (optional), we will calculate the premium for insuring the order. You can then display this premium to your customers on the checkout page or anywhere else you wish.
preparing...
Response
preparing...
Scenario 2. Create coverage
1. If the order has already been shipped, you can include the tracking number to activate the coverage.
After calling the API, open the AfterShip Protection admin to confirm that the coverage has been created successfully and its status is activate.
preparing...
2. If the order has not yet shipped, you can create coverage without the tracking number and update it later to activate the coverage.
You can create coverage using the 'Create Coverage' API without providing any tracking information. In this scenario, the coverage will be inactive until you ship the order and update the tracking information.
preparing...
After shipping the order, you can use the 'Update a coverage tracking info' API to update the tracking information and activate the coverage.
preparing...
Scenario 3. Void coverage
This API allows you to void coverage only if its status is inactive. Once voided, you will not be charged for the coverage.
preparing...