API keys and authentication
Developers
This page is for Developers, so it isn't in your menu.
Every request to the Shipr API, except the health check, carries an API key. The key tells Shipr which merchant account the request is for and what it may do.
Get an API key
Section titled “Get an API key”Ask Shipr support for an API key. Tell them:
- what the integration does, so they can give the key the scopes it needs and no more
- whether it should work for every location or only some (see Keys limited to some locations)
You receive the key once. Shipr keeps only a fingerprint of it, so nobody can look it up later. If you lose it, ask for a new one.
Production keys start with sk_live_. Keys for Shipr’s test environments start with sk_test_.
Send the key
Section titled “Send the key”Put the key in the Authorization header as a bearer token on every request.
curl https://api.shipr.tech/v1/locations \ -H "Authorization: Bearer $SHIPR_API_KEY"const res = await fetch('https://api.shipr.tech/v1/locations', { headers: { Authorization: `Bearer ${process.env.SHIPR_API_KEY}` },});const locations = await res.json();import osimport requests
res = requests.get( "https://api.shipr.tech/v1/locations", headers={"Authorization": f"Bearer {os.environ['SHIPR_API_KEY']}"},)locations = res.json()A missing, mistyped or revoked key gets 401 with the message Invalid API key. A key that lacks a scope the endpoint needs gets 403 with Insufficient scope. See Errors, limits and retries.
Scopes
Section titled “Scopes”Each key has a list of scopes. An endpoint checks for the scope it needs and refuses the request without it.
| Scope | What it allows |
|---|---|
deliveries:read |
Get quotes. List and get deliveries, their tracking and labels. Print store delivery labels. |
deliveries:write |
Create, change, re-pack, cancel and rebook deliveries. |
manifests:read |
List and get manifests and download a manifest summary. |
manifests:write |
Create manifests. |
returns:read |
List and get returns. |
returns:write |
Create returns. |
webhooks:read |
List and get webhook endpoints and their delivery history. |
webhooks:write |
Create, change, delete and test webhook endpoints, change their signing secret and resend events. |
locations:read |
List and get locations and their self-delivery settings. |
locations:write |
Create, change and delete locations and change self-delivery settings. |
drivers:read |
List your store delivery drivers and invitations. |
drivers:write |
Invite drivers, change their locations and remove them. |
rate_overrides:read |
Read your rate overrides. You change them in the dashboard; the API can’t. |
box_configs:read |
Read the box configurations Shipr packs parcels into. |
Shipr sets up your carrier accounts for you, so an integration doesn’t need carrier scopes. If a carrier account needs changing, ask Shipr support.
A key with only deliveries:read and deliveries:write covers the usual flow: quote, book, label and track. Add webhooks:write if your code registers its own webhook endpoint.
Keys limited to some locations
Section titled “Keys limited to some locations”A key can work for every location, or only for the locations Shipr support names when they make it. A limited key suits a single store’s point-of-sale system.
A key limited to some locations:
- only sees deliveries, manifests, returns and trips from its locations
- must send
origin.location_idwith one of its locations to quote or book. Any other location gets400withInvalid origin location - keeps only these scopes, whatever else it was given:
deliveries:read,deliveries:write,manifests:read,manifests:write,returns:read,returns:write,locations:read,box_configs:read,drivers:read,drivers:write - can’t manage webhooks, read rate overrides or change locations. Those endpoints answer
403withNot available to users limited to specific locations
Replace a key
Section titled “Replace a key”Keys don’t expire. A key works until Shipr revokes it. Your account can have more than one key at once, so you can replace a key without downtime.
- Ask Shipr support for a new key with the same scopes and locations.
- Put the new key into your integration and deploy it.
- Check your requests succeed with the new key.
- Ask Shipr support to revoke the old key. From then on it gets
401.
If a key may have leaked, ask Shipr support to revoke it straight away, then follow the steps above.