Sub-accounts
Create sub-accounts, list them under their parent, and ship for one of them.
A sub-account is an account under one of yours: one per store, branch or client, for example. It has its own account number, its own forwarding address and its own shipments. You are not a member of a sub-account; you reach it through the parent account you belong to, with the same access token.
Create a sub-account
Send the parent's uid in accountUid and the details of the new account. When you belong to a single account, accountUid can be left out: the sub-account is created under that account.
curl -X POST https://sandbox.weshipyou.com/api/v1/add-sub-account \
-H "Authorization: Bearer $WSY_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"accountUid": "h4jupn7wtfqp",
"name": "Acme Imports Orlando",
"displayName": "Acme Imports Orlando",
"email": "orlando@example.com",
"notificationEmail": "orlando@example.com",
"phone": "+13055550100",
"emergencyPhone": "+13055550101",
"website": "https://example.com",
"systemUnits": "imperial",
"isBusiness": true,
"language": "en"
}'The answer is the new account: its uid, its accountNumber, its parent in parentUid, and in locker the forwarding address that packages for it are sent to. Keep the uid: it is how you name the sub-account in every other call.
List your sub-accounts
GET /accounts returns the accounts you belong to and all their sub-accounts in one list. Tell them apart with parentUid: it is null on an account you belong to, and the parent's uid on a sub-account.
{
"total": 2,
"limit": 20,
"skip": 0,
"data": [
{ "uid": "h4jupn7wtfqp", "accountNumber": "000ACC1X16", "name": "Acme Imports", "parentUid": null },
{ "uid": "85js5f5clt2u", "accountNumber": "CUDHMFEDA9", "name": "Acme Imports Orlando", "parentUid": "h4jupn7wtfqp" }
]
}To get only the sub-accounts of one account, pass its uid, account number or external account number in parentUid. The list is paged: up to 20 accounts by default, 500 with $limit, and $skip for the next page.
curl "https://sandbox.weshipyou.com/api/v1/accounts?parentUid=h4jupn7wtfqp" \
-H "Authorization: Bearer $WSY_ACCESS_TOKEN"Read a single sub-account by its uid with Get an account.
Ship for a sub-account
Your token works for every sub-account of your accounts: name the sub-account in accountId. To create a shipment that belongs to the sub-account, send its uid as accountId:
curl -X POST https://sandbox.weshipyou.com/api/v1/shipments \
-H "Authorization: Bearer $WSY_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d @shipment.jsonwith "accountId": "85js5f5clt2u" in shipment.json. Then buy its label as described in Labels.
List a sub-account's shipments
Without accountId, GET /shipments lists the shipments of your accounts and of all their sub-accounts together. Pass the sub-account's uid or account number in accountId to get only its shipments.
curl "https://sandbox.weshipyou.com/api/v1/shipments?accountId=85js5f5clt2u" \
-H "Authorization: Bearer $WSY_ACCESS_TOKEN"Who sees what
Only the members of the parent account see its sub-accounts. A parentUid that names an account you cannot access returns an empty list, and an accountId or account uid you cannot access is refused.