Every v2 request carries an API key in the 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.
Keys look like 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 the X-Pharmacy-Id header.
The single-pharmacy convenience is a trap to design around. An integration that works today because the group has one pharmacy will start returning 400 on every affected call the moment a second is added — and that is a change made in our admin, not in your code. Send the header explicitly if there is any chance the group will grow.
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-dismiss
  • GET and PUT on /pharmacies/{pharmacyId}/notification-preferences
Omitting it is 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.
Treat the key as a password. It grants everything its scopes allow for every pharmacy in the group, and the request is not otherwise bound to you — there is no IP pinning and no second factor. If one leaks, revoke it — from Home on the sandbox, or by asking us in production. Revocation takes effect immediately.