On AffinityRx there is no automatic failover: the clinic picks the pharmacy for each order, and AffinityRx never moves an order to another pharmacy on its own. Compounding pharmacy failover is a planned human decision: you choose a backup pharmacy for each medication in advance, and when the first pharmacy can't fill, you confirm that the first order is cancelled or failed before the prescriber signs a new order at the backup.
This guide shows how a clinic or telehealth platform plans that backup and switches without sending the same prescription twice. AffinityRx publishes it; the AffinityRx rules quoted here come from the public docs at docs.affinityrx.com.
Why not switch pharmacies automatically?
A compounded prescription is written and signed for one preparation from one pharmacy. Moving it can change the formulation, the price, the shipping and the patient's allergy handling. An automatic resend after a timeout can also produce two orders, two shipments and two charges if the first pharmacy was still working on it. FDA notes that it "does not verify the safety, effectiveness or quality of compounded drugs before they are marketed" (FDA, Compounding Q&A, checked 2026-11-22), so a backup pharmacy is a clinical and quality choice, not only a technical one.
How does a pharmacy switch work on AffinityRx?
| Fact | What it means for your backup plan |
|---|
| The clinic picks the pharmacy for each order | Your backup choice is made by a person, per order |
| A medication ID names one strength, form, fill size and pharmacy | The same drug at a backup pharmacy has a different ID; check that it matches |
expand=variants on a medication read lists its other pharmacies, strengths and fill sizes | One request finds the backup options for a medication |
| All prescriptions in one order go to one pharmacy | A switch is a new order, not an edit |
| A signed order keeps its pharmacy, medication and prices | The original order never changes pharmacy |
| Canceled or unfilled orders are refunded in full | You do not pay twice for a switched order |
| A new order needs the prescriber's approval and signature | The prescriber signs again for the backup pharmacy |
AffinityRx works with a network of 30+ vetted pharmacies. Today a new clinic can order from four: Perfect Rx, ProCompounding, Rx Route and National Health Rx. A realistic backup plan uses those four, and some medications may have only one orderable pharmacy.
Step 1: Build a backup matrix before you need it
For each of your most-ordered medications, record:
| Column | Example of what to write |
|---|
| Medication, strength, form, fill size | The exact catalog entry you order |
| Primary pharmacy | Name and medication ID |
| Backup pharmacy | Name and medication ID of the matching variant |
| Differences | Fill size, strength text, receivesAllergies, requirements, restrictedStates |
| Price at each pharmacy | From the catalog, so the prescriber and finance know the change |
| Shipping | Cold chain needed or not; shipping is the same flat rate at every pharmacy on AffinityRx |
| Who approves the switch | The prescriber, and who tells the patient |
Check restrictedStates for every state you ship to. A backup that can't ship to the patient's state is not a backup. Also check receivesAllergies: when it is false, the patient's allergies do not reach that pharmacy, and the prescriber must know before signing.
Step 2: Decide by order stage
The safe action depends on the order's status.
| Status of the first order | Safe action |
|---|
| Not sent yet (your own queue) | Pick the backup pharmacy and send one order there |
submitted | Request a cancel; wait for cancelled before sending a new order |
processing | The pharmacy has it and may have filled it. Request a cancel and expect a possible refusal |
shipped or delivered | Do not send a backup order. Handle a delivery problem as a delivery problem |
failed | Read failureReason, then send a new order at the right pharmacy |
cancelled | Send the new order. Keep watching events: a pharmacy can ship after it confirms a cancel |
| No response from your request | Resend with the same Idempotency-Key and body; do not create a new order |
Facts behind this table, from the AffinityRx docs (checked 2026-11-22):
- A cancel request is not final until the order is
cancelled. While cancelRequestedAt is set, the pharmacy can still refuse, which returns 409 cancel_refused or sends order.updated.
- Perfect Rx refuses a cancel after it fills and verifies the order.
- A
cancelled order can still become shipped or delivered if the pharmacy shipped it. If that happens, the order is billed because it shipped.
- In Live mode, an order does not become
failed automatically. A failed order carries a written reason in failureReason.
Step 3: Prevent duplicates
Duplicates are the main risk of any pharmacy switch. Use these controls:
- One key per order attempt. Save the
Idempotency-Key with the order before the first request. A retry with the same key and body returns the first order. A new key with the same body creates a second order.
- Unique order IDs.
externalOrderId is unique per practice. A second order with the same value returns 409 order_already_exists, and a cancelled or failed order keeps its ID. Give the replacement a new ID and record that it replaces the first.
- Link the two orders. Store the first order's ID, its final status and the reason next to the replacement.
- Never two open orders for one prescription. Block a replacement while the first order is
submitted or processing without a confirmed cancel.
Step 4: Know the real state of every open order
- Webhooks. Each status change sends a signed event. Process each event ID once and keep the copy with the newest
updatedAt.
- Polling. To recover missed events, list orders with
GET /v1/orders?updatedAfter=… and follow every page.
- Watch the slow ones. List
GET /v1/orders?status=processing and review orders that have not moved in the time you expect for that medication.
- Delivery reports vary. Some pharmacies never report delivery, so a Live order can stay
shipped. Use each shipment's trackingUrl.
AffinityRx does not show turnaround per pharmacy. Build your own expected times from your order history.
Step 5: Tell the patient once
AffinityRx does not email or text patients. Your clinic or platform tells the patient about a delay, a cancel and a new pharmacy. Send one message per change, after the change is confirmed, so the patient never hears about two orders.
Step 6: Rehearse the switch
Run the switch in Test mode before you need it. Perfect Rx Test orders support outcome prefixes in notes:
test_fail_ makes the test pharmacy refuse the order, so you can practice a replacement.
test_cancel_refused_ makes a cancel fail after processing, so you can practice the "can't cancel" path.
test_split_shipment_ sends two packages, so you can practice partial delivery.
A rehearsal passes when your team can find the affected orders, confirm each one's final status, send one replacement per prescription, get the prescriber's signature, and tell each patient once.
FAQs
Does AffinityRx have automatic pharmacy failover?
No. The clinic picks the pharmacy for each order, and AffinityRx does not move orders between pharmacies on its own. If a pharmacy can't fill an order, the order is refunded in full, and the clinic can send a new order to another pharmacy after it sees that pharmacy's price.
How do I switch an order to another pharmacy on AffinityRx?
Cancel the first order and wait until it is cancelled, or read failureReason if it failed. Then send a new order for the matching medication at the other pharmacy, with a new externalOrderId and a new Idempotency-Key, signed by the prescriber.
Can I resend an order to a backup pharmacy after a timeout?
Not as a new order. Resend the same request with the same Idempotency-Key and body. AffinityRx returns the order the first request created, so you learn its real status without creating a duplicate.
How many backup pharmacies does a clinic need?
One per critical medication, at minimum, if the medication is available at more than one pharmacy you can order from. Today a new AffinityRx clinic can order from four pharmacies, so some medications may have one option only.
Can I cancel an order that is already processing?
You can ask. The pharmacy may already have filled it, and Perfect Rx refuses a cancel after filling and verification. Wait for the outcome before you send a replacement.
What does a pharmacy switch cost?
A canceled or unfilled order is refunded in full, and the new order is charged at the backup pharmacy's price plus the flat shipping rate. An order that ships after a cancel request is billed because it shipped.
Get started
Sign up free to see which pharmacies carry each of your medications and their prices, and send a first order the same day with a card or bank account at checkout. A demo is optional; request one here. For the API details, read the compounding pharmacy API integration guide. To compare pharmacies, see the pharmacy network.
This guide is operational guidance, not legal or clinical advice. Compounded medications are not FDA-approved.