client.account.get() -> Account
-
-
-
Read the organization and Test or Live mode selected by the API key.
-
-
-
client.account().get();
-
-
client.feedback.create(request) -> CreateFeedbackResponse
-
-
-
Send feedback without credentials, or with an API key to include its organization and mode. Do not include patient information. API-key callers are limited to 10 submissions per hour per key. Anonymous callers are limited to 10 submissions per hour per IP address. A 429 response includes Retry-After in seconds.
-
-
-
client.feedback().create( CreateFeedbackRequest .builder() .idempotencyKey("Idempotency-Key") .message("The error does not explain which field is invalid.") .pageUrl("https://docs.affinityrx.com/errors/") .requestId("6e562761-eff3-4626-a8b9-25ce7c670ccd") .build() );
-
-
-
idempotencyKey:
Stringβ A unique key per operation, 1 to 255 printable ASCII characters without spaces. Retry the same key and body to avoid repeating the action. The replay response depends on the operation. See https://docs.affinityrx.com/guides/#retry-safely.
-
message:
Stringβ Text with at least one visible character.
-
pageUrl:
Optional<String>
-
requestId:
Optional<String>β TherequestIdof the response, as the API returned it: a UUID or itsreq_form.
-
-
client.medications.list() -> SyncPagingIterable<Medication>
-
-
-
Every medication you can order in the current mode, A to Z by name, then by ID. Send query to find medications by name: every word must appear in the name, so check the spelling when nothing matches. Then choose by name, strength, form and pharmacy. Send practiceId to list what that practice can order, at its prices; without it, the caller's organization is used. Prices are in cents.
requirementsnames the optional prescription fields this pharmacy requires;compoundingReasonsandquantitieslist the accepted values when the pharmacy limits them, counted inquantityUnit. With afill,priceis per fill and each quantity countsquantityUnit, not fills: it is a whole number of fills in units. For a fill of 30 tablets, quantity 60 is two fills. For vials, quantity 1 is one vial and quantity 2 is two vials. A 2 mL vial lists quantities 1β10; its volume is separate from its quantity.
-
-
-
client.medications().list( ListMedicationsRequest .builder() .practiceId("prac_01j2y8m6jcc9tt24af5pw9x1bc") .build() );
-
-
-
practiceId:
Optional<String>β Quote prices and availability for this practice. A platform may select only its own child practices; a practice may select only itself. Omit to use the caller's organization.
-
limit:
Optional<Integer>β Maximum records per page, from 1 to 100. Defaults to 25.
-
startingAfter:
Optional<String>β Page forward using the previous response's nextCursor. Keep the same filters, sort, organization and mode.
-
query:
Optional<String>β Match medication names that contain every word of this text, in any order, ignoring case and accents. Each word must appear in the name, so a misspelled word matches nothing. Strength, form and pharmacy are not searched. An empty query lists every medication. Restart pagination after changing query.
-
-
client.medications.get(medicationId) -> GetMedicationsResponse
-
-
-
Read one available medication, its pricing, and pharmacy details for the current organization and mode. Pass expand=variants to include its other strengths, forms and pharmacies.
-
-
-
client.medications().get( "med_01j2y8m6jcc9tt24af5pw9x1bc", GetMedicationsRequest .builder() .practiceId("prac_01j2y8m6jcc9tt24af5pw9x1bc") .build() );
-
-
-
medicationId:
Stringβ The medication ID.
-
practiceId:
Optional<String>β Quote prices and availability for this practice. A platform may select only its own child practices; a practice may select only itself. Omit to use the caller's organization.
-
expand:
Optional<GetMedicationsRequestExpandItem>β Add related records to the response.variantsadds the medication's other strengths, forms and pharmacies.
-
-
client.orders.list() -> SyncPagingIterable<Order>
-
-
-
List accessible orders in the current mode, newest first.
externalOrderIdmatches exactly, including case.updatedAfteraccepts an ISO 8601 timestamp with a timezone and returns strictly later updates. Keep filters fixed while paging.sorttakespatient(lowercase firstName + space + lastName A to Z, then order ID) orcreated(oldest first); a_descsuffix reverses. Creation time or patient name and the order ID determine cursor order, even when updatedAt changes.
-
-
-
client.orders().list( ListOrdersRequest .builder() .patientId("pat_01j2y8m6jcc9tt24af5pw9x1bc") .practiceId("prac_01j2y8m6jcc9tt24af5pw9x1bc") .build() );
-
-
-
limit:
Optional<Integer>β Maximum records per page, from 1 to 100. Defaults to 25.
-
startingAfter:
Optional<String>β Page forward using the previous response's nextCursor. Keep the same filters, sort, organization and mode.
-
externalOrderId:
Optional<String>β Match the external order ID exactly, including case. Combine with practiceId when your platform reuses IDs across practices.
-
updatedAfter:
Optional<OffsetDateTime>β Return orders whose updatedAt is strictly later than this ISO 8601 timestamp. Sorting stays by creation time and ID unless sort is supplied. Keep this cutoff unchanged while paging.
-
patientId:
Optional<String>β Limit results to the patient with this pat_ ID.
-
practiceId:
Optional<String>β Limit results to the practice with this prac_ ID, within your authorized practices.
-
query:
Optional<String>β Search saved order snapshots: patient names, email, phone and external ID; order external ID; prescriber name and NPI; medication names and brands; pharmacy name. Whole ord_ and pat_ IDs and six-character order numbers also match. Text matches ignore case and allow substrings, word prefixes and similar spellings for alphanumeric words of four or more characters. Every one of the first eight words containing letters or numbers must match; punctuation-only words are ignored. An empty or punctuation-only query leaves the list unfiltered. Date of birth, separate strength fields, practice names, prac_ IDs and rx_ IDs are not searched. Restart pagination when filters change.
-
status:
Optional<ListOrdersRequestStatus>β Return only orders with this status. Omit to include all statuses.
-
cancelRequested:
Optional<ListOrdersRequestCancelRequested>β true returns only submitted or processing orders with a cancel the pharmacy has not confirmed yet (cancelRequestedAt set). false leaves those orders out. Omit to include both.
-
recentlyShipped:
Optional<ListOrdersRequestRecentlyShipped>β true returns only orders whose status is shipped and that shipped in the last 60 days; delivered orders are excluded. false leaves those orders out. Omit to include both.
-
sort:
Optional<ListOrdersRequestSort>β patient sorts the lowercase text firstName + space + lastName A to Z, then order ID; created sorts oldest first. A _desc suffix reverses the order. Defaults to created_desc. Restart pagination after changing sort.
-
-
client.orders.create(request) -> Order
-
-
-
One request creates the order, signs it and sends it to the pharmacy. Platforms must send practiceId; practice callers can omit it to use their own practice. With an API key, name the prescriber and send signatureAttestation. Optional prescriber phone and address each default to the practice; no account is looked up by NPI. In the app, the signed-in member signs with the NPI in their settings, or names the prescriber with the same attestation. With patient.id (a pat_ ID) or patient.externalId, the order reuses that patient of the practice and mode and updates the saved record; without them, each order creates a new patient. If id and externalId identify different patients, the request returns 422 invalid_order. When the pharmacy already holds the patient's name, a different firstName or lastName returns 422 invalid_order. Live orders require Live access on the practice and its platform. No payment method is required.
-
-
-
client.orders().create( OrderInput .builder() .idempotencyKey("Idempotency-Key") .patient( PatientInput .builder() .address( AddressInput .builder() .line1("line1") .city("city") .state("state") .postalCode("postalCode") .build() ) .dateOfBirth("dateOfBirth") .email("email") .firstName("firstName") .sex(PatientInputSex.FEMALE) .lastName("lastName") .phone("phone") .allergies( Arrays.asList( PatientInputAllergiesItem .builder() .category(PatientInputAllergiesItemCategory.DRUG) .display("display") .build() ) ) .build() ) .shipping( OrderInputShipping .builder() .optionId("shp_01j2y8m6jcc9tt24af5pw9x1bc") .build() ) .signatureAttestation(true) .prescriptions( Arrays.asList( PrescriptionInput .builder() .directions("directions") .medicationId("med_01j2y8m6jcc9tt24af5pw9x1bc") .quantity(1) .refills(1) .build() ) ) .build() );
-
-
-
idempotencyKey:
Stringβ A unique key per operation, 1 to 255 printable ASCII characters without spaces. Retry the same key and body to avoid repeating the action. The replay response depends on the operation. See https://docs.affinityrx.com/guides/#retry-safely.
-
externalOrderId:
Optional<String>β Your order identifier, unique within the practice and mode. A failed or cancelled order keeps it, so send a new one for a replacement order.
-
patient:
PatientInput
-
practiceId:
Optional<String>β Required with a platform API key. Send a child practice ID. Independent practice keys can omit this field to use their own practice.
-
prescriber:
Optional<PrescriberInput>
-
prescriptions:
List<PrescriptionInput>β The 1 to 20 prescriptions approved for this patient.
-
shipping:
OrderInputShippingβ The shipping option and destination.
-
signatureAttestation:
Booleanβ Must be true to attest that the named prescriber approved and signed these prescriptions.
-
-
client.orders.get(orderId) -> Order
-
-
-
Read one order and its prescriptions in the API key's organization and mode.
-
-
-
client.orders().get( "ord_01j2y8m6jcc9tt24af5pw9x1bc", GetOrdersRequest .builder() .build() );
-
-
-
orderId:
Stringβ The order ID.
-
-
client.orders.cancel(orderId) -> Order
-
-
-
200 with status cancelled when the cancel is confirmed. 202 with cancelRequestedAt when the pharmacy has not confirmed yet: you get order.cancelled when it confirms, or, when it refuses, cancelRequestedAt becomes null and you get order.updated. If an earlier ask may have reached the pharmacy, a refusal keeps cancelRequestedAt and sends no event until the pharmacy ends the order (order.cancelled or order.shipped). 409 cannot_cancel when the order is shipped, delivered or failed. 409 cancel_refused when the pharmacy refused the cancel, or when Affinity could not reach the pharmacy; only the second says to retry with a new Idempotency-Key.
-
-
-
client.orders().cancel( "ord_01j2y8m6jcc9tt24af5pw9x1bc", CancelOrdersRequest .builder() .idempotencyKey("Idempotency-Key") .build() );
-
-
-
orderId:
Stringβ The order ID.
-
idempotencyKey:
Stringβ A unique key per operation, 1 to 255 printable ASCII characters without spaces. Retry the same key and body to avoid repeating the action. The replay response depends on the operation. See https://docs.affinityrx.com/guides/#retry-safely.
-
-
client.practices.list() -> SyncPagingIterable<Practice>
-
-
-
List the platform's practices, newest first. Available to platforms only.
sorttakesnameorlocation(A to Z, practices without a location last),mode(without Live access, then with it) orcreated(oldest first); a_descsuffix reverses.
-
-
-
client.practices().list( ListPracticesRequest .builder() .build() );
-
-
-
limit:
Optional<Integer>β Maximum records per page, from 1 to 100. Defaults to 25.
-
startingAfter:
Optional<String>β Page forward using the previous response's nextCursor. Keep the same filters, sort, organization and mode.
-
externalId:
Optional<String>β Match the external practice ID exactly, including case. Keep this filter unchanged while paging.
-
query:
Optional<String>β Match practice names containing this text, ignoring case. Restart pagination after changing query.
-
sort:
Optional<ListPracticesRequestSort>β name and location sort A to Z; mode sorts practices without Live access before those with it; created sorts oldest first. A _desc suffix reverses the order. Defaults to created_desc. Missing locations sort last. Restart pagination after changing sort.
-
-
client.practices.create(request) -> Practice
-
-
-
Platforms only. Name, phone and address are required. The practice starts in Test;
liveEnabled: truealso allows new Live orders, which needs a platform with Live access and a Live caller: a Live key, or a session in Live mode. Turning Live off later preserves access to existing records. A retry with the same key and body returns the stored first response, even if the practice has changed. Use GET /v1/practices/{practiceId} to read the current practice.
-
-
-
client.practices().create( CreatePracticesRequest .builder() .idempotencyKey("Idempotency-Key") .address( PracticeAddressInput .builder() .line1("line1") .city("city") .state("state") .postalCode("postalCode") .build() ) .name("name") .phone("phone") .build() );
-
-
-
idempotencyKey:
Stringβ A unique key per operation, 1 to 255 printable ASCII characters without spaces. Retry the same key and body to avoid repeating the action. The replay response depends on the operation. See https://docs.affinityrx.com/guides/#retry-safely.
-
externalId:
Optional<String>β Your practice identifier, unique among your platform's active practices.
-
address:
PracticeAddressInput
-
liveEnabled:
Optional<Boolean>
-
name:
Stringβ The practice name. PerfectRx prints it: use Windows-1252 characters, without < or >.
-
phone:
Stringβ A US phone number: 10 digits, with or without +1 or 1 before them. Spaces, dashes, dots and parentheses are allowed, such as (512) 555-0100. Affinity stores and returns +15125550100.
-
-
client.practices.get(practiceId) -> Practice
-
-
-
Read one practice accessible to the API key. A platform can read its own practices.
-
-
-
client.practices().get( "prac_01j2y8m6jcc9tt24af5pw9x1bc", GetPracticesRequest .builder() .build() );
-
-
-
practiceId:
Stringβ The practice ID.
-
-
client.practices.update(practiceId, request) -> Practice
-
-
-
liveEnabledallows or refuses new Live orders. Existing records, cancellation, webhooks and billing keep working. Only its platform changes it; enabling requires platform Live access, and either change needs a Live caller: a Live key (403 live_key_required otherwise) or a session in Live mode (403 live_mode_required otherwise). Live orders sendname,phoneandaddressto the pharmacy, so a practice with Live access changes them only in Live mode, with a Live key or a session in Live mode (403 live_mode_required otherwise). A retry with the same key and body returns the stored first response, even if the practice has changed. Use GET /v1/practices/{practiceId} to read the current practice.
-
-
-
client.practices().update( "prac_01j2y8m6jcc9tt24af5pw9x1bc", UpdatePracticesRequest .builder() .idempotencyKey("Idempotency-Key") .build() );
-
-
-
practiceId:
Stringβ The practice ID.
-
idempotencyKey:
Stringβ A unique key per operation, 1 to 255 printable ASCII characters without spaces. Retry the same key and body to avoid repeating the action. The replay response depends on the operation. See https://docs.affinityrx.com/guides/#retry-safely.
-
externalId:
Optional<String>β Your practice identifier, unique among your platform's active practices. Send null to clear it.
-
address:
Optional<UpdatePracticesRequestAddress>β Affinity merges the address parts you send into the saved address. An omitted part keeps its saved value. To move to an address with no suite, send"line2": nullwith the newline1,city,stateandpostalCode. PerfectRx prints it: use Windows-1252 characters, without < or >. Line 1 and line 2 together: 70 characters or fewer.
-
liveEnabled:
Optional<Boolean>β Omit it or send null to leave Live unchanged.
-
name:
Optional<String>β The practice name. PerfectRx prints it: use Windows-1252 characters, without < or >.
-
phone:
Optional<String>β A US phone number: 10 digits, with or without +1 or 1 before them. Spaces, dashes, dots and parentheses are allowed, such as (512) 555-0100. Affinity stores and returns +15125550100. Empty text counts as null.
-
-
client.webhooks.list() -> SyncPagingIterable<WebhookEndpoint>
-
-
-
List webhook endpoints owned by the API key's organization in its current mode. Signing secrets are not returned.
-
-
-
client.webhooks().list( ListWebhooksRequest .builder() .build() );
-
-
-
limit:
Optional<Integer>β Maximum records per page, from 1 to 100. Defaults to 25.
-
startingAfter:
Optional<String>β Page forward using the previous response's nextCursor. Keep the same filters, sort, organization and mode.
-
-
client.webhooks.create(request) -> CreateWebhooksResponse
-
-
-
Platforms and independent practices can register up to 16 public HTTPS endpoints per mode. An API key acts only for its own organization and mode. Every event goes to every endpoint. The signing secret is returned by creation and its idempotent replay for 24 hours.
-
-
-
client.webhooks().create( CreateWebhooksRequest .builder() .idempotencyKey("Idempotency-Key") .url("url") .build() );
-
-
-
idempotencyKey:
Stringβ A unique key per operation, 1 to 255 printable ASCII characters without spaces. Retry the same key and body to avoid repeating the action. The replay response depends on the operation. See https://docs.affinityrx.com/guides/#retry-safely.
-
url:
Stringβ The public HTTPS URL that receives webhook events.
-
-
client.webhooks.remove(webhookEndpointId) -> RemoveWebhooksResponse
-
-
-
Events not delivered to it yet are dropped.
-
-
-
client.webhooks().remove( "whe_01j2y8m6jcc9tt24af5pw9x1bc", RemoveWebhooksRequest .builder() .build() );
-
-
-
webhookEndpointId:
Stringβ The webhook endpoint ID.
-
-
client.webhooks.update(webhookEndpointId, request) -> WebhookEndpoint
-
-
-
The signing secret stays the same.
-
-
-
client.webhooks().update( "whe_01j2y8m6jcc9tt24af5pw9x1bc", UpdateWebhooksRequest .builder() .idempotencyKey("Idempotency-Key") .url("url") .build() );
-
-
-
webhookEndpointId:
Stringβ The webhook endpoint ID.
-
idempotencyKey:
Stringβ A unique key per operation, 1 to 255 printable ASCII characters without spaces. Retry the same key and body to avoid repeating the action. The replay response depends on the operation. See https://docs.affinityrx.com/guides/#retry-safely.
-
url:
String
-
-
client.webhooks.resendFailed(webhookEndpointId) -> ResendFailedWebhooksResponse
-
-
-
Queue failed order event deliveries from the last 30 days for this endpoint. Only the current organization and mode apply. Each failed delivery gets up to 12 new attempts. Also make pending deliveries waiting on a later retry due now, without resetting their attempt counts. Keep the same event IDs, payloads, and per-order delivery sequence. The queued count includes both kinds. Pending deliveries already due, delivered events, and one-time test events stay unchanged. Send a unique Idempotency-Key for each request. Reuse that key after an uncertain response to return the original count. A request with a new key returns 0 when no eligible failures or pending deliveries waiting on a later retry remain.
-
-
-
client.webhooks().resendFailed( "whe_01j2y8m6jcc9tt24af5pw9x1bc", ResendFailedWebhooksRequest .builder() .idempotencyKey("Idempotency-Key") .build() );
-
-
-
webhookEndpointId:
Stringβ The webhook endpoint ID.
-
idempotencyKey:
Stringβ A unique key per operation, 1 to 255 printable ASCII characters without spaces. Retry the same key and body to avoid repeating the action. The replay response depends on the operation. See https://docs.affinityrx.com/guides/#retry-safely.
-
-