Skip to content

Changelog

New API and documentation releases from AffinityRx.

  1. Search matches word starts and typos

    API

    GET /v1/medications and GET /v1/practices now match the start of each word of query, and a word of letters can have typos: 1 typo from 4 letters, 2 typos from 6 letters. A word with a digit matches only as typed. Each word must still match.

    query on GET /v1/medications now also reads ingredients, strength, form, route, brands, category and pharmacy name. Results keep the order of the list. The paths, parameters and responses do not change.

    Choose a medication
  2. An API key can cancel an order that waits for approval

    API

    POST /v1/orders/{orderId}/cancel now cancels an order that waits for approval for any caller that can cancel orders, an API key included: 200 with status cancelled. Before, an API key got 403 dashboard_only. Nothing reaches the pharmacy.

    Only an admin of the organization, signed in to the Affinity app, can send such an order to the pharmacy.

    Connect an AI agent
  3. Medications name the prescription fields their pharmacy cannot receive

    API

    Each medication can have unsupportedFields: the prescription fields that its pharmacy cannot receive. For notes, send none. For substitutionPermitted, send true or leave it out. The field is absent when the pharmacy receives all fields.

    An order that sets one of these fields is still accepted. In Live mode, Affinity staff handle it. In Test mode, the order fails when it is sent.

    Choose a medication
  4. Refills follow each medication's maxRefills

    API

    Each medication now has maxRefills: the largest refills value that its prescriptions accept. 0 means no refills; send a new order for each fill. A larger refills value returns 422 invalid_order.

    Choose a medication
  5. A kit lists its vials

    API

    Each medication now has kit. For a kit, it lists the vials or bottles that ship together, in the sequence of use, each with its strength. It is null for a medication that is not a kit.

    Choose a medication
  6. Medications tell if they are for research use only

    API

    Each medication now has researchUseOnly. It is true when the medication is for research use only. Only an organization that has access to these medications gets them in its catalog.

    Choose a medication
  7. Medications show which pharmacy Affinity prefers

    API

    A medication can have pharmacyRank: Affinity's preference for the pharmacy that dispenses it, from 0 for the most preferred. When two pharmacies have the same item at the same price, choose the lower rank. The field is absent when Affinity has no preference.

  8. Every word of an order search narrows the list

    API

    The query of GET /v1/orders and POST /v1/orders/search now uses every word. Before, it used only the first eight words. Each word that contains letters or numbers must match, so each added word makes the list smaller or keeps it the same.

    Find and cancel orders
  9. Patient search uses every word

    API

    The query of GET /v1/patients and POST /v1/patients/search now uses every word that contains a letter or a number. Before, it used only the first eight words. Each word must match, so a word that matches no patient gives an empty list.

  10. Order search finds a date of birth and a tracking number

    API

    The query of GET /v1/orders and POST /v1/orders/search now also matches the patient's date of birth and the tracking number of each shipment. Type the date as 1985-03-02, 03/02/1985, 3/2/1985 or 03021985. Type all of a tracking number or a part of it.

    A date of birth is patient data. Send it in the body of POST /v1/orders/search, not in a URL.

    Find and cancel orders
  11. Prescriptions take daysSupply

    API

    A prescription now takes daysSupply: the number of days that the prescribed quantity lasts. Send it when the medication's requirements include daysSupply; otherwise it is optional. An order that misses a required daysSupply returns 422 with the field's path, for example prescriptions[0].daysSupply.

    Send an order
  12. API 2026-11-01: forward-only lists and _desc sorts

    API

    To upgrade from API 2026-10-28, make these changes:

    1. Send Affinity-Version: 2026-11-01. A missing header or 2026-10-28 returns 400 unsupported_api_version.

    2. Every list pages forward only, including GET /v1/orders, GET /v1/practices and GET /v1/webhook-endpoints. Remove endingBefore and send nextCursor as startingAfter for the next page. endingBefore returns 400 invalid_request.

    3. Change each descending sort from -<field> to <field>_desc. GET /v1/orders: -patient is patient_desc and -created is created_desc. GET /v1/practices: -name is name_desc, -location is location_desc, -mode is mode_desc and -created is created_desc. The default is created_desc.

    Missing request fields now return their expected value or type, such as signatureAttestation: A required value is missing. Expected true.

    Find and cancel orders
  13. Tracking links open the carrier's page

    API

    Each shipment's trackingUrl is now the carrier's own tracking page for that package, with the tracking number filled in (FedEx, UPS, USPS and OnTrac). For another carrier it is the pharmacy's link, or null. The order's trackingUrl is the newest package's link, or null before the order ships. It is no longer an Affinity tracking page.

    Carrier scans no longer change the order status. An order becomes delivered when the pharmacy reports the delivery.

    Find and cancel orders
  14. The medication list has no search or filters

    API

    GET /v1/medications returns every medication that you can order in the mode of your key, A to Z by name, then by ID. It no longer accepts query, name, names, category or pharmacyId. A request with one of them returns 400 invalid_request. Read all the pages, then select by name, strength, form and pharmacy.

    Each medication still has its category. GET /v1/medications/{medicationId}?expand=variants still adds the other strengths, forms and pharmacies.

    Choose a medication
  15. First release: API 2026-10-28

    API

    Send Affinity-Version: 2026-10-28 with every request. A missing or unknown version returns 400 unsupported_api_version.

    One POST /v1/orders request creates, signs and submits an order, and it requires an Idempotency-Key. There are no draft, sign or submit routes. The order names the prescriber as prescriber: { npi, firstName, lastName } with signatureAttestation: true. The patient is part of the order and is found again by patient.externalId. The patient has sex (female, male or unknown) and allergies: [{ display, category }].

    Send shipping: { optionId, destination }. destination is { type: patient } (the default), { type: practice } or { type: address, address }. Orders return shipping: { option, destination }.

    Routes: GET /v1/account, GET /v1/medications and GET /v1/medications/{medicationId}, POST and GET /v1/orders, GET /v1/orders/{orderId}, POST /v1/orders/{orderId}/cancel, POST, GET and PATCH on /v1/practices, webhook endpoints under /v1/webhook-endpoints, and POST /v1/feedback.

    Practices accept an optional externalId, unique among the platform's active practices across Test and Live. A create or update with a used externalId returns 409 practice_already_exists with data.practiceId. Practice responses always include externalId, or null when unset. PATCH can change or clear it. Archiving frees it. GET /v1/practices?externalId=… matches it exactly, including case. Two practices can share a name and address.

    Orders return practice, trackingUrl, shipments: [{ carrier, trackingNumber, trackingUrl }] and statusHistory: [{ status, createdAt }]. Each prescription returns pharmacy, status and failureReason. Statuses are submitted, processing, shipped, delivered, cancelled and failed. Cancel answers 200 (cancelled), 202 (cancelRequestedAt set, pharmacy not confirmed yet) or 409.

    Medications return category, fullName, fill and quantityUnit. For a vial product, quantity counts vials. GET /v1/medications accepts a category filter, and GET /v1/medications/{medicationId}?expand=variants adds the other strengths, forms and pharmacies.

    Webhook events are order.submitted, order.processing, order.shipped, order.delivered, order.cancelled, order.failed, order.updated, prescription.failed, prescription.cancelled and webhook_endpoint.test. data.order holds only id, externalOrderId, status, failureReason, cancelRequestedAt, trackingUrl, shipments, prescriptions: [{ id, status, failureReason }] and updatedAt; read GET /v1/orders/{orderId} for the whole order. Events are signed with Affinity-Signature: t=…,v1=….

    API keys can create, list, update and delete webhook endpoints for their own organization and mode. Platforms and independent practices can have up to 16 endpoints per mode. Admins can also manage endpoints in Settings → API.

    Idempotency-Key is required for order creation, practice creation and updates, order cancellation, webhook endpoint creation and URL updates, dashboard test sends, failed-delivery resends, and feedback. Retry an uncertain response with the same key and body to replay the original result. A changed body returns 409 idempotency_key_reused. DELETE routes do not require a key.

    Errors are flat problem documents with lowercase snake_case codes. Field problems include issues with code, field, message and path. Malformed fields return 400 invalid_request; rule failures return 422.

    Every list of values in a response or webhook can get new values. Ignore fields and values that you do not know.

    Prices are integers in cents, and counts are integers. A request over the rate limit returns 429 with Retry-After.

    Get started

Send feedback

Don't include patient information.

Type to search…

↑↓ navigate ↵ select Esc close