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.