Skip to content

Latest commit

Β 

History

History
1425 lines (1020 loc) Β· 27.2 KB

reference.md

File metadata and controls

1425 lines (1020 loc) Β· 27.2 KB

Reference

Account

client.account.get() -> Account

πŸ“ Description

Read the organization and Test or Live mode selected by the API key.

πŸ”Œ Usage

client.account().get();

Feedback

client.feedback.create(request) -> CreateFeedbackResponse

πŸ“ Description

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.

πŸ”Œ Usage

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()
);

βš™οΈ Parameters

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> β€” The requestId of the response, as the API returned it: a UUID or its req_ form.

Medications

client.medications.list() -> SyncPagingIterable&lt;Medication&gt;

πŸ“ Description

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. requirements names the optional prescription fields this pharmacy requires; compoundingReasons and quantities list the accepted values when the pharmacy limits them, counted in quantityUnit. With a fill, price is per fill and each quantity counts quantityUnit, 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.

πŸ”Œ Usage

client.medications().list(
    ListMedicationsRequest
        .builder()
        .practiceId("prac_01j2y8m6jcc9tt24af5pw9x1bc")
        .build()
);

βš™οΈ Parameters

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

πŸ“ Description

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.

πŸ”Œ Usage

client.medications().get(
    "med_01j2y8m6jcc9tt24af5pw9x1bc",
    GetMedicationsRequest
        .builder()
        .practiceId("prac_01j2y8m6jcc9tt24af5pw9x1bc")
        .build()
);

βš™οΈ Parameters

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. variants adds the medication's other strengths, forms and pharmacies.

Orders

client.orders.list() -> SyncPagingIterable&lt;Order&gt;

πŸ“ Description

List accessible orders in the current mode, newest first. externalOrderId matches exactly, including case. updatedAfter accepts an ISO 8601 timestamp with a timezone and returns strictly later updates. Keep filters fixed while paging. sort takes patient (lowercase firstName + space + lastName A to Z, then order ID) or created (oldest first); a _desc suffix reverses. Creation time or patient name and the order ID determine cursor order, even when updatedAt changes.

πŸ”Œ Usage

client.orders().list(
    ListOrdersRequest
        .builder()
        .patientId("pat_01j2y8m6jcc9tt24af5pw9x1bc")
        .practiceId("prac_01j2y8m6jcc9tt24af5pw9x1bc")
        .build()
);

βš™οΈ Parameters

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

πŸ“ Description

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.

πŸ”Œ Usage

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()
);

βš™οΈ Parameters

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

πŸ“ Description

Read one order and its prescriptions in the API key's organization and mode.

πŸ”Œ Usage

client.orders().get(
    "ord_01j2y8m6jcc9tt24af5pw9x1bc",
    GetOrdersRequest
        .builder()
        .build()
);

βš™οΈ Parameters

orderId: String β€” The order ID.

client.orders.cancel(orderId) -> Order

πŸ“ Description

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.

πŸ”Œ Usage

client.orders().cancel(
    "ord_01j2y8m6jcc9tt24af5pw9x1bc",
    CancelOrdersRequest
        .builder()
        .idempotencyKey("Idempotency-Key")
        .build()
);

βš™οΈ Parameters

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.

Practices

client.practices.list() -> SyncPagingIterable&lt;Practice&gt;

πŸ“ Description

List the platform's practices, newest first. Available to platforms only. sort takes name or location (A to Z, practices without a location last), mode (without Live access, then with it) or created (oldest first); a _desc suffix reverses.

πŸ”Œ Usage

client.practices().list(
    ListPracticesRequest
        .builder()
        .build()
);

βš™οΈ Parameters

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

πŸ“ Description

Platforms only. Name, phone and address are required. The practice starts in Test; liveEnabled: true also 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.

πŸ”Œ Usage

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()
);

βš™οΈ Parameters

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

πŸ“ Description

Read one practice accessible to the API key. A platform can read its own practices.

πŸ”Œ Usage

client.practices().get(
    "prac_01j2y8m6jcc9tt24af5pw9x1bc",
    GetPracticesRequest
        .builder()
        .build()
);

βš™οΈ Parameters

practiceId: String β€” The practice ID.

client.practices.update(practiceId, request) -> Practice

πŸ“ Description

liveEnabled allows 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 send name, phone and address to 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.

πŸ”Œ Usage

client.practices().update(
    "prac_01j2y8m6jcc9tt24af5pw9x1bc",
    UpdatePracticesRequest
        .builder()
        .idempotencyKey("Idempotency-Key")
        .build()
);

βš™οΈ Parameters

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": null with the new line1, city, state and postalCode. 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.

Webhooks

client.webhooks.list() -> SyncPagingIterable&lt;WebhookEndpoint&gt;

πŸ“ Description

List webhook endpoints owned by the API key's organization in its current mode. Signing secrets are not returned.

πŸ”Œ Usage

client.webhooks().list(
    ListWebhooksRequest
        .builder()
        .build()
);

βš™οΈ Parameters

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

πŸ“ Description

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.

πŸ”Œ Usage

client.webhooks().create(
    CreateWebhooksRequest
        .builder()
        .idempotencyKey("Idempotency-Key")
        .url("url")
        .build()
);

βš™οΈ Parameters

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

πŸ“ Description

Events not delivered to it yet are dropped.

πŸ”Œ Usage

client.webhooks().remove(
    "whe_01j2y8m6jcc9tt24af5pw9x1bc",
    RemoveWebhooksRequest
        .builder()
        .build()
);

βš™οΈ Parameters

webhookEndpointId: String β€” The webhook endpoint ID.

client.webhooks.update(webhookEndpointId, request) -> WebhookEndpoint

πŸ“ Description

The signing secret stays the same.

πŸ”Œ Usage

client.webhooks().update(
    "whe_01j2y8m6jcc9tt24af5pw9x1bc",
    UpdateWebhooksRequest
        .builder()
        .idempotencyKey("Idempotency-Key")
        .url("url")
        .build()
);

βš™οΈ Parameters

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

πŸ“ Description

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.

πŸ”Œ Usage

client.webhooks().resendFailed(
    "whe_01j2y8m6jcc9tt24af5pw9x1bc",
    ResendFailedWebhooksRequest
        .builder()
        .idempotencyKey("Idempotency-Key")
        .build()
);

βš™οΈ Parameters

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.