X-InStockRx-Api-Key header. Send the whole
key.
This replaces v1’s
X-INVIEW-AUTH, which carried a group GUID. A v1 key is not a v2 key —
they are different credentials in different headers, and sending one to the other surface
does not work. See Migrating from v1.ik_live_… in production and ik_sandbox_… in the sandbox. The environment is
part of the key, so you cannot accidentally point a sandbox key at live inventory.
Three things a request can be refused for
Authentication, authorisation and context are separate checks, and they fail differently.1
Is the key real?
Missing, unknown, revoked or expired key →
401. There is no distinction in the
response between “no key” and “a key we don’t recognise”.2
Does it hold the scopes this endpoint needs?
→
403 insufficient-scope, carrying a required-scopes list of everything the
endpoint wanted. See Scopes.3
Which pharmacy are you acting as?
→
403 pharmacy-not-in-group or 400 missing-pharmacy-context. See below.Acting as a pharmacy
Your key belongs to a group, and a group can contain many pharmacies. Most endpoints need to know which one you are acting as, which you say with theX-Pharmacy-Id header.
Drafts are pharmacy-scoped rather than group-scoped, so draft-listing reads need the
header too —
GET /draft-listings/{id} and POST /draft-listings/search, not just the
writes.Acting as a user
The notification endpoints are per-person rather than per-pharmacy, so they need a third header,X-InStockRx-User-Id:
GET /notifications,PATCH /notifications/{id},POST /notifications/bulk-dismissGETandPUTon/pharmacies/{pharmacyId}/notification-preferences
400 missing-user-context. No other endpoint uses it.
Keys, in practice
One key, many pharmacies
A key is issued against a group and can act for every pharmacy in it. You do not need a
key per pharmacy.
Rotation overlaps
Rotating issues a new key carrying the old one’s scopes, and the old one keeps working
for a grace period — one hour on the sandbox. Deploy the new key, confirm, then let the
old one lapse.
On the sandbox you manage your own keys: issue, rotate and revoke them from your Home
page (Sandbox onboarding). Production keys are issued by us —
ask for access, and ask again to rotate or to narrow the scopes on an
existing key.