Quickstart
Get a token, create a shipment, buy its label and track it, all against the sandbox.
This guide walks through the five calls of a first integration. Every example uses the sandbox server, https://sandbox.weshipyou.com/api/v1, so nothing you do here is charged to your live wallet. See Test mode and live mode before you switch to live.
Before you start
- Your WeShipYou user. You get a sandbox token with your live login: the sandbox keeps a test copy of your user and accounts, with no balance.
- A terminal with
curl, or Node.js 18 or later (it hasfetchbuilt in).
1. Get an access token
Log in on live with "mode": "test". Live checks your username and password and answers a sandbox token. If two-factor authentication is on for your user, also send the current 6-digit code as twoFactorToken.
curl -X POST https://weshipyou.com/api/v1/authentication \
-H "Content-Type: application/json" \
-d '{"username": "janedoe", "password": "your-password", "mode": "test"}'Keep the accessToken in an environment variable. The examples below read it from WSY_ACCESS_TOKEN:
export WSY_ACCESS_TOKEN="eyJhbGciOi..."2. Find your account
Shipments belong to an account. List the accounts you are a member of and note the accountNumber (it starts with CU) of the one you ship from. Your sub-accounts are in the list too, each naming its parent in parentUid (see Sub-accounts).
curl https://sandbox.weshipyou.com/api/v1/accounts \
-H "Authorization: Bearer $WSY_ACCESS_TOKEN"3. Create a shipment
Send the sender, the recipient and the parcels. The answer is the shipment, with its uid and the services it can be sent with in parcel_rates.
curl -X POST https://sandbox.weshipyou.com/api/v1/shipments \
-H "Authorization: Bearer $WSY_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d @shipment.jsonThe Create a shipment reference has a complete shipment.json to start from.
4. Buy the label
Pick one of the parcel_rates and buy it. The price is taken from your wallet balance first; only what the balance does not cover is charged to paymentMethod.
curl -X POST https://sandbox.weshipyou.com/api/v1/shipments/labels \
-H "Authorization: Bearer $WSY_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"accountId": "CU1234567",
"handoverOptions": [{
"handoverOption": "dropoff",
"shipments": [{ "shipmentId": "<shipment uid>", "rateId": "<parcel_rates[].uid>" }]
}]
}'5. Track it
Read the shipment to get its tracking number (label.trackingNumber), then ask for its status and checkpoints.
curl https://sandbox.weshipyou.com/api/v1/tracking/WSY0000000000US \
-H "Authorization: Bearer $WSY_ACCESS_TOKEN"Next steps
- Authentication: token lifetime, two-factor codes and keeping tokens safe.
- Labels: rates, payment, handover options and cancelling.
- Sub-accounts: create them, list them and ship for one of them.
- Errors: what each status means and when to retry.