Skip to content

Create, sign and submit an order

POST /v1/orders

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 PerfectRx already holds a different firstName or lastName for the patient, the order is still accepted: a Live order stays submitted until staff correct the name with PerfectRx, and a Test order fails with a failureReason. Live orders require Live access on the practice and its platform. A Live order needs its payer's default payment method (a card or a US bank account) or account credit that covers the order, or it returns 409 payment_method_required; the platform pays for its practices. A payer that Affinity bills on one invoice for its shipped Live orders needs neither.

Orders API key authentication Version 2026-11-01

Request example

Replace example values with your Test data. Check the field rules below before you send a request.

Use the current catalog item's accepted quantity and shipping option. Read the order guide before you send this synthetic Test example.

{
  "practiceId": "prac_01j9z3k4m5n6p7q8r9s0t1v2w3",
  "externalOrderId": "order-123",
  "prescriber": {
    "npi": "1234567893",
    "firstName": "Sam",
    "lastName": "Lee",
    "phone": "+15125550124",
    "address": {
      "line1": "300 Example St",
      "line2": null,
      "city": "Austin",
      "state": "TX",
      "postalCode": "78701"
    }
  },
  "signatureAttestation": true,
  "patient": {
    "externalId": "patient-88",
    "firstName": "Test",
    "middleName": null,
    "lastName": "Patient",
    "dateOfBirth": "1988-04-02",
    "phone": "+15125550100",
    "email": "test.patient@example.com",
    "address": {
      "line1": "100 Example St",
      "line2": null,
      "city": "Austin",
      "state": "TX",
      "postalCode": "78701"
    },
    "allergies": [
      {
        "display": "Penicillin",
        "category": "drug"
      }
    ],
    "sex": "female"
  },
  "prescriptions": [
    {
      "medicationId": "med_3v9r73nmfs8bmbjb960yd2pggg",
      "quantity": 6,
      "refills": 0,
      "directions": "Inject 0.25 mL (7.5 mg tirzepatide) under the skin once weekly.",
      "compoundingReason": "concentration_adjustment",
      "notes": null,
      "substitutionPermitted": true
    }
  ],
  "shipping": {
    "optionId": "shp_7yna882w139zfbmwzeyb16y24e"
  }
}
curl -X POST 'https://api.affinityrx.com/v1/orders' \
  -H "Authorization: Bearer $AFFINITY_API_KEY" \
  -H 'Affinity-Version: 2026-11-01' \
  -H 'Idempotency-Key: <Idempotency-Key>' \
  -H 'Content-Type: application/json' \
  --data @request.json

Response example

These examples show the body structure. Values can differ. Select a status code to see its response.

{
  "id": "ord_01j9z3k4m5n6p7q8r9s0t1v2w7",
  "externalOrderId": "order-123",
  "mode": "test",
  "status": "submitted",
  "statusHistory": [
    {
      "status": "submitted",
      "createdAt": "2026-10-20T15:04:05.000Z"
    }
  ],
  "failureReason": null,
  "cancelRequestedAt": null,
  "trackingUrl": null,
  "practiceId": "prac_01j9z3k4m5n6p7q8r9s0t1v2w3",
  "practice": {
    "archivedAt": null,
    "name": "Example Practice",
    "phone": "+15125550123",
    "address": {
      "line1": "200 Example Ave",
      "line2": "Suite 4",
      "city": "Austin",
      "state": "TX",
      "postalCode": "78701"
    }
  },
  "patientId": "pat_01j9z3k4m5n6p7q8r9s0t1v2w8",
  "prescriber": {
    "npi": "1234567893",
    "firstName": "Sam",
    "lastName": "Lee",
    "phone": "+15125550124",
    "address": {
      "line1": "300 Example St",
      "line2": null,
      "city": "Austin",
      "state": "TX",
      "postalCode": "78701"
    }
  },
  "patient": {
    "firstName": "Test",
    "middleName": null,
    "lastName": "Patient",
    "dateOfBirth": "1988-04-02",
    "phone": "+15125550100",
    "email": "test.patient@example.com",
    "address": {
      "line1": "100 Example St",
      "line2": null,
      "city": "Austin",
      "state": "TX",
      "postalCode": "78701"
    },
    "allergies": [
      {
        "display": "Penicillin",
        "category": "drug"
      }
    ],
    "sex": "female"
  },
  "prescriptions": [
    {
      "id": "rx_01j9z3k4m5n6p7q8r9s0t1v2w9",
      "medication": {
        "id": "med_3v9r73nmfs8bmbjb960yd2pggg",
        "name": "Tirzepatide / B12",
        "strength": "30 mg/0.5 mg/mL",
        "form": "Vial",
        "quantityUnit": "vial",
        "fill": {
          "amount": 1,
          "container": "vial",
          "ingredients": [
            {
              "amount": 60,
              "name": "Tirzepatide",
              "unit": "mg"
            },
            {
              "amount": 1,
              "name": "B12",
              "unit": "mg"
            }
          ],
          "unit": "vial",
          "volume": {
            "amount": 2,
            "unit": "mL"
          }
        },
        "kit": null
      },
      "quantity": 6,
      "refills": 0,
      "directions": "Inject 0.25 mL (7.5 mg tirzepatide) under the skin once weekly.",
      "compoundingReason": "concentration_adjustment",
      "notes": null,
      "substitutionPermitted": true,
      "price": 165000,
      "pharmacy": {
        "id": "pharm_314xqfy8g09snbzq56416t1zb1",
        "name": "PerfectRx Pharmacy"
      },
      "status": "submitted",
      "failureReason": null
    }
  ],
  "shipments": [],
  "total": 167500,
  "createdAt": "2026-10-20T15:04:05.000Z",
  "updatedAt": "2026-10-20T15:04:05.000Z",
  "shipping": {
    "option": {
      "id": "shp_7yna882w139zfbmwzeyb16y24e",
      "name": "Ground Cold Chain",
      "price": 2500
    },
    "destination": {
      "type": "patient"
    }
  }
}
{
  "code": "<string>",
  "detail": "<string>",
  "title": "<string>",
  "type": "<string>",
  "issues": [
    {
      "code": "<string>",
      "field": "<string>",
      "message": "<string>",
      "path": [
        "<string>"
      ]
    }
  ],
  "instance": "<string>",
  "requestId": "<string>",
  "status": 400,
  "traceId": "<string>"
}
{
  "code": "<string>",
  "detail": "<string>",
  "title": "<string>",
  "type": "<string>",
  "issues": [
    {
      "code": "<string>",
      "field": "<string>",
      "message": "<string>",
      "path": [
        "<string>"
      ]
    }
  ],
  "instance": "<string>",
  "requestId": "<string>",
  "status": 401,
  "traceId": "<string>"
}
{
  "code": "<string>",
  "detail": "<string>",
  "title": "<string>",
  "type": "<string>",
  "issues": [
    {
      "code": "<string>",
      "field": "<string>",
      "message": "<string>",
      "path": [
        "<string>"
      ]
    }
  ],
  "instance": "<string>",
  "requestId": "<string>",
  "status": 403,
  "traceId": "<string>"
}
{
  "code": "<string>",
  "detail": "<string>",
  "title": "<string>",
  "type": "<string>",
  "issues": [
    {
      "code": "<string>",
      "field": "<string>",
      "message": "<string>",
      "path": [
        "<string>"
      ]
    }
  ],
  "instance": "<string>",
  "requestId": "<string>",
  "status": 404,
  "traceId": "<string>"
}
{
  "code": "<string>",
  "detail": "<string>",
  "title": "<string>",
  "type": "<string>",
  "issues": [
    {
      "code": "<string>",
      "field": "<string>",
      "message": "<string>",
      "path": [
        "<string>"
      ]
    }
  ],
  "instance": "<string>",
  "requestId": "<string>",
  "status": 409,
  "traceId": "<string>",
  "data": {
    "orderId": "ord_01j2y8m6jcc9tt24af5pw9x1bc",
    "practiceId": "prac_01j2y8m6jcc9tt24af5pw9x1bc"
  }
}
{
  "code": "<string>",
  "detail": "<string>",
  "title": "<string>",
  "type": "<string>",
  "issues": [
    {
      "code": "<string>",
      "field": "<string>",
      "message": "<string>",
      "path": [
        "<string>"
      ]
    }
  ],
  "instance": "<string>",
  "requestId": "<string>",
  "status": 413,
  "traceId": "<string>"
}
{
  "code": "unsupported_media_type",
  "detail": "<string>",
  "title": "<string>",
  "type": "<string>",
  "instance": "<string>",
  "requestId": "<string>",
  "status": 415,
  "traceId": "<string>"
}
{
  "code": "<string>",
  "detail": "<string>",
  "title": "<string>",
  "type": "<string>",
  "issues": [
    {
      "code": "<string>",
      "field": "<string>",
      "message": "<string>",
      "path": [
        "<string>"
      ]
    }
  ],
  "instance": "<string>",
  "requestId": "<string>",
  "status": 422,
  "traceId": "<string>"
}
{
  "code": "<string>",
  "detail": "<string>",
  "title": "<string>",
  "type": "<string>",
  "issues": [
    {
      "code": "<string>",
      "field": "<string>",
      "message": "<string>",
      "path": [
        "<string>"
      ]
    }
  ],
  "instance": "<string>",
  "requestId": "<string>",
  "status": 429,
  "traceId": "<string>",
  "data": {
    "retryAfterSeconds": 1
  }
}
{
  "code": "<string>",
  "detail": "<string>",
  "title": "<string>",
  "type": "<string>",
  "issues": [
    {
      "code": "<string>",
      "field": "<string>",
      "message": "<string>",
      "path": [
        "<string>"
      ]
    }
  ],
  "instance": "<string>",
  "requestId": "<string>",
  "status": 500,
  "traceId": "<string>"
}
{
  "code": "<string>",
  "detail": "<string>",
  "title": "<string>",
  "type": "<string>",
  "issues": [
    {
      "code": "<string>",
      "field": "<string>",
      "message": "<string>",
      "path": [
        "<string>"
      ]
    }
  ],
  "instance": "<string>",
  "requestId": "<string>",
  "status": 503,
  "traceId": "<string>"
}

Implementation specification

Use these field types and limits to build your integration. Download the OpenAPI document for the complete contract.

Headers

Authorizationstring

For API key authentication, send Authorization: Bearer <key> with an active API key.

Content-Typestringrequired

Send the JSON body with Content-Type: application/json.

Idempotency-Key string required

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.

Pattern: ^[\x21-\x7e]{1,255}$

Affinity-Version string required

The dated API version this request is written against.

Pin requests to 2026-11-01.

Allowed: "2026-11-01"

Default: "2026-11-01"

Request body specification application/json

Send the JSON body with Content-Type: application/json.

OrderInput

externalOrderId string | null

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.

Maximum length: 128

Pattern: ^\s*[^\s\x00-\x08\x0a-\x1f\x7f-\x9f](?:[^\x00-\x08\x0a-\x1f\x7f-\x9f]*[^\s\x00-\x08\x0a-\x1f\x7f-\x9f])?\s*$

patient PatientInput required

The patient details that the pharmacy receives.

No additional properties

Show patient fields
address AddressInput required

The US mailing address.

No additional properties

Show address fields
line1 string required

The street address.

Maximum length: 200

Pattern: ^\s*[^\s\x00-\x08\x0a-\x1f\x7f-\x9f](?:[^\x00-\x08\x0a-\x1f\x7f-\x9f]*[^\s\x00-\x08\x0a-\x1f\x7f-\x9f])?\s*$

line2 string | null

The apartment or suite, or null when there is none. Empty text, N/A, NA, none and - count as null. See notes, TBD and unknown return 422.

Maximum length: 200

Pattern: ^\s*(?:[^\s\x00-\x08\x0a-\x1f\x7f-\x9f](?:[^\x00-\x08\x0a-\x1f\x7f-\x9f]*[^\s\x00-\x08\x0a-\x1f\x7f-\x9f])?\s*)?$

city string required

The city name.

Maximum length: 100

Pattern: ^\s*[^\s\x00-\x08\x0a-\x1f\x7f-\x9f](?:[^\x00-\x08\x0a-\x1f\x7f-\x9f]*[^\s\x00-\x08\x0a-\x1f\x7f-\x9f])?\s*$

state string required

The two-letter US state or territory code, such as TX, in any letter case. Affinity stores and returns it in upper case.

Pattern: ^\s*(?:[Aa][Ll]|[Aa][Kk]|[Aa][Zz]|[Aa][Rr]|[Cc][Aa]|[Cc][Oo]|[Cc][Tt]|[Dd][Ee]|[Dd][Cc]|[Ff][Ll]|[Gg][Aa]|[Hh][Ii]|[Ii][Dd]|[Ii][Ll]|[Ii][Nn]|[Ii][Aa]|[Kk][Ss]|[Kk][Yy]|[Ll][Aa]|[Mm][Ee]|[Mm][Dd]|[Mm][Aa]|[Mm][Ii]|[Mm][Nn]|[Mm][Ss]|[Mm][Oo]|[Mm][Tt]|[Nn][Ee]|[Nn][Vv]|[Nn][Hh]|[Nn][Jj]|[Nn][Mm]|[Nn][Yy]|[Nn][Cc]|[Nn][Dd]|[Oo][Hh]|[Oo][Kk]|[Oo][Rr]|[Pp][Aa]|[Rr][Ii]|[Ss][Cc]|[Ss][Dd]|[Tt][Nn]|[Tt][Xx]|[Uu][Tt]|[Vv][Tt]|[Vv][Aa]|[Ww][Aa]|[Ww][Vv]|[Ww][Ii]|[Ww][Yy]|[Aa][Ss]|[Gg][Uu]|[Mm][Pp]|[Pp][Rr]|[Vv][Ii]|[Aa][Aa]|[Aa][Ee]|[Aa][Pp])\s*$

postalCode string required

The US ZIP code: 78701, or ZIP+4 as 78701-1234, 78701 1234 or 787011234. Affinity stores and returns 78701 or 78701-1234.

Pattern: ^\s*\d{5}(?:[ -]?\d{4})?\s*$

allergies object[] required

The reported allergies. Send [] when the patient reports no new allergies.

Maximum items: 50

Show allergies fields

Array items · object

category string required

The allergy category.

Allowed: "drug", "food", "insect", "latex", "mold", "pet", "pollen"

display string required

The reported allergy name. A whole-value no-allergy statement (NKDA, NKFA, none, unknown, denies, no, N/A and the same kind of phrase) returns 422, ignoring case, dots, hyphens, slashes, spaces and a trailing period. Send [] instead.

Minimum length: 1

Maximum length: 200

Pattern: ^\s*[^\s\x00-\x1f\x7f-\x9f](?:[^\x00-\x1f\x7f-\x9f]*[^\s\x00-\x1f\x7f-\x9f])?\s*$

dateOfBirth string required

A real calendar date in YYYY-MM-DD format, with a year from 1900 through 2099, today or earlier in UTC. Surrounding spaces are removed.

Pattern: ^\s*(?:(19|20)\d\d-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))\s*$

email string required

The patient's email address.

Maximum length: 254

Pattern: ^\s*[^\s@\x00-\x1f\x7f-\x9f]+@[^\s@\x00-\x1f\x7f-\x9f]+\.[^\s@\x00-\x1f\x7f-\x9f]+\s*$

firstName string required

The first name. N/A, TBD, unknown and none return 422.

Maximum length: 60

Pattern: ^\s*[^\s\x00-\x08\x0a-\x1f\x7f-\x9f](?:[^\x00-\x08\x0a-\x1f\x7f-\x9f]*[^\s\x00-\x08\x0a-\x1f\x7f-\x9f])?\s*$

sex string required

The patient's sex as sent to the pharmacy.

Allowed: "female", "male", "unknown"

lastName string required

The last name. N/A, TBD, unknown and none return 422.

Maximum length: 60

Pattern: ^\s*[^\s\x00-\x08\x0a-\x1f\x7f-\x9f](?:[^\x00-\x08\x0a-\x1f\x7f-\x9f]*[^\s\x00-\x08\x0a-\x1f\x7f-\x9f])?\s*$

middleName string | null

The patient's middle name, or null when there is none. Empty text counts as null.

Maximum length: 60

Pattern: ^\s*(?:[^\s\x00-\x08\x0a-\x1f\x7f-\x9f](?:[^\x00-\x08\x0a-\x1f\x7f-\x9f]*[^\s\x00-\x08\x0a-\x1f\x7f-\x9f])?\s*)?$

phone string required

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.

Maximum length: 40

Pattern: ^[\s\x28\x29\x2d\x2e֊־᐀᠆‐‑‒–—―⸗⸚⸺⸻⹀⹝〜〰゠︱︲﹘﹣-𐵮𐺭]*(?:\+[\s\x28\x29\x2d\x2e֊־᐀᠆‐‑‒–—―⸗⸚⸺⸻⹀⹝〜〰゠︱︲﹘﹣-𐵮𐺭]*1[\s\x28\x29\x2d\x2e֊־᐀᠆‐‑‒–—―⸗⸚⸺⸻⹀⹝〜〰゠︱︲﹘﹣-𐵮𐺭]*|1[\s\x28\x29\x2d\x2e֊־᐀᠆‐‑‒–—―⸗⸚⸺⸻⹀⹝〜〰゠︱︲﹘﹣-𐵮𐺭]*)?(?:[0-9][\s\x28\x29\x2d\x2e֊־᐀᠆‐‑‒–—―⸗⸚⸺⸻⹀⹝〜〰゠︱︲﹘﹣-𐵮𐺭]*){10}$

externalId string | null

Your patient identifier within the practice and mode. Omit it and id to create a new patient for each order. With id, send the saved patient's externalId or omit it. If the saved patient has none, this value is added to it.

Maximum length: 128

Pattern: ^\s*[^\s\x00-\x08\x0a-\x1f\x7f-\x9f](?:[^\x00-\x08\x0a-\x1f\x7f-\x9f]*[^\s\x00-\x08\x0a-\x1f\x7f-\x9f])?\s*$

id string

The pat_ ID of a saved patient of the order's practice, in the same Test or Live mode. The order reuses that patient and updates it from the sent fields. Send all other patient fields as usual. GET /v1/orders returns the patientId of each order. An unknown ID, or an ID of a different practice or mode, returns 404 not_found.

Pattern: ^pat_[0-7][0-9a-hjkmnp-tv-z]{25}$

practiceId string

Required with a platform API key. Send a child practice ID. Independent practice keys can omit this field to use their own practice.

Pattern: ^prac_[0-7][0-9a-hjkmnp-tv-z]{25}$

prescriber PrescriberInput

Required with an API key. Send the prescribing clinician's NPI, firstName and lastName. Session callers can omit this field to sign with their own profile.

No additional properties

Show prescriber fields
phone string | null

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. When the phone is omitted, null or blank, the order uses the practice phone.

Maximum length: 40

Pattern: ^(?:\s*|[\s\x28\x29\x2d\x2e֊־᐀᠆‐‑‒–—―⸗⸚⸺⸻⹀⹝〜〰゠︱︲﹘﹣-𐵮𐺭]*(?:\+[\s\x28\x29\x2d\x2e֊־᐀᠆‐‑‒–—―⸗⸚⸺⸻⹀⹝〜〰゠︱︲﹘﹣-𐵮𐺭]*1[\s\x28\x29\x2d\x2e֊־᐀᠆‐‑‒–—―⸗⸚⸺⸻⹀⹝〜〰゠︱︲﹘﹣-𐵮𐺭]*|1[\s\x28\x29\x2d\x2e֊־᐀᠆‐‑‒–—―⸗⸚⸺⸻⹀⹝〜〰゠︱︲﹘﹣-𐵮𐺭]*)?(?:[0-9][\s\x28\x29\x2d\x2e֊־᐀᠆‐‑‒–—―⸗⸚⸺⸻⹀⹝〜〰゠︱︲﹘﹣-𐵮𐺭]*){10})$

address AddressInput

The US mailing address.

No additional properties

Show address fields
line1 string required

The street address.

Maximum length: 200

Pattern: ^\s*[^\s\x00-\x08\x0a-\x1f\x7f-\x9f](?:[^\x00-\x08\x0a-\x1f\x7f-\x9f]*[^\s\x00-\x08\x0a-\x1f\x7f-\x9f])?\s*$

line2 string | null

The apartment or suite, or null when there is none. Empty text, N/A, NA, none and - count as null. See notes, TBD and unknown return 422.

Maximum length: 200

Pattern: ^\s*(?:[^\s\x00-\x08\x0a-\x1f\x7f-\x9f](?:[^\x00-\x08\x0a-\x1f\x7f-\x9f]*[^\s\x00-\x08\x0a-\x1f\x7f-\x9f])?\s*)?$

city string required

The city name.

Maximum length: 100

Pattern: ^\s*[^\s\x00-\x08\x0a-\x1f\x7f-\x9f](?:[^\x00-\x08\x0a-\x1f\x7f-\x9f]*[^\s\x00-\x08\x0a-\x1f\x7f-\x9f])?\s*$

state string required

The two-letter US state or territory code, such as TX, in any letter case. Affinity stores and returns it in upper case.

Pattern: ^\s*(?:[Aa][Ll]|[Aa][Kk]|[Aa][Zz]|[Aa][Rr]|[Cc][Aa]|[Cc][Oo]|[Cc][Tt]|[Dd][Ee]|[Dd][Cc]|[Ff][Ll]|[Gg][Aa]|[Hh][Ii]|[Ii][Dd]|[Ii][Ll]|[Ii][Nn]|[Ii][Aa]|[Kk][Ss]|[Kk][Yy]|[Ll][Aa]|[Mm][Ee]|[Mm][Dd]|[Mm][Aa]|[Mm][Ii]|[Mm][Nn]|[Mm][Ss]|[Mm][Oo]|[Mm][Tt]|[Nn][Ee]|[Nn][Vv]|[Nn][Hh]|[Nn][Jj]|[Nn][Mm]|[Nn][Yy]|[Nn][Cc]|[Nn][Dd]|[Oo][Hh]|[Oo][Kk]|[Oo][Rr]|[Pp][Aa]|[Rr][Ii]|[Ss][Cc]|[Ss][Dd]|[Tt][Nn]|[Tt][Xx]|[Uu][Tt]|[Vv][Tt]|[Vv][Aa]|[Ww][Aa]|[Ww][Vv]|[Ww][Ii]|[Ww][Yy]|[Aa][Ss]|[Gg][Uu]|[Mm][Pp]|[Pp][Rr]|[Vv][Ii]|[Aa][Aa]|[Aa][Ee]|[Aa][Pp])\s*$

postalCode string required

The US ZIP code: 78701, or ZIP+4 as 78701-1234, 78701 1234 or 787011234. Affinity stores and returns 78701 or 78701-1234.

Pattern: ^\s*\d{5}(?:[ -]?\d{4})?\s*$

firstName string required

The first name.

Maximum length: 60

Pattern: ^\s*[^\s\x00-\x08\x0a-\x1f\x7f-\x9f](?:[^\x00-\x08\x0a-\x1f\x7f-\x9f]*[^\s\x00-\x08\x0a-\x1f\x7f-\x9f])?\s*$

lastName string required

The last name.

Maximum length: 60

Pattern: ^\s*[^\s\x00-\x08\x0a-\x1f\x7f-\x9f](?:[^\x00-\x08\x0a-\x1f\x7f-\x9f]*[^\s\x00-\x08\x0a-\x1f\x7f-\x9f])?\s*$

npi string required

The prescribing clinician's 10-digit National Provider Identifier (NPI). Surrounding spaces are removed.

Pattern: ^\s*(?:\d{10})\s*$

prescriptions PrescriptionInput[] required

The 1 to 20 prescriptions approved for this patient.

Minimum items: 1

Maximum items: 20

Show prescriptions fields

Array items · PrescriptionInput

compoundingReason string | null

One of the medication's compoundingReasons values, required when the medication's requirements include it. Another value returns 422. Empty text counts as null.

Maximum length: 200

Pattern: ^\s*(?:[^\s\x00-\x08\x0a-\x1f\x7f-\x9f](?:[^\x00-\x08\x0a-\x1f\x7f-\x9f]*[^\s\x00-\x08\x0a-\x1f\x7f-\x9f])?\s*)?$

daysSupply integer | null

The number of days the prescribed quantity lasts, required when the medication's requirements include it. Null counts as not sent.

Minimum: 1

Maximum: 365

directions string required

The prescriber's directions for use, as the clinician wrote them. None, N/A, NA, TBD, unknown and see notes return 422.

Maximum length: 2000

Pattern: ^\s*[^\s\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f](?:[^\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f]*[^\s\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f])?\s*$

medicationId string required

The medication's public identifier from the current catalog.

Pattern: ^med_[0-7][0-9a-hjkmnp-tv-z]{25}$

notes string | null

The prescriber's additional notes to the pharmacy. Empty text counts as null.

Maximum length: 1000

Pattern: ^\s*(?:[^\s\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f](?:[^\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f]*[^\s\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f])?\s*)?$

quantity integer required

The prescribed quantity in quantityUnit, not a count of fills. With a fill, send a whole number of fills in units: two fills of 30 tablets is 60. A vial's unit is vial, so 2 is two vials.

Minimum: 1

Maximum: 10000

refills integer required

The number of authorized refills in addition to the first fill. It cannot be more than the medication's maxRefills: a larger value returns 422 invalid_order.

Minimum: 0

Maximum: 99

substitutionPermitted boolean

Whether the prescriber permits substitution; defaults to true when omitted.

Default: true

shipping object required

The shipping option and destination.

No additional properties

Show shipping fields
optionId string required

The shipping option identifier from the medication's shippingOptions.

Pattern: ^shp_[0-7][0-9a-hjkmnp-tv-z]{25}$

destination ShippingDestinationInput

Defaults to the patient's address. State restrictions and pharmacy coverage use the destination's state.

Show destination fields
When type is patient:
type ShippingDestinationPatientType required

Use patient, practice or address to select the shipping destination.

Allowed: "patient"

When type is practice:
type ShippingDestinationPracticeType required

Use patient, practice or address to select the shipping destination.

Allowed: "practice"

When type is address:
type ShippingDestinationAddressType required

Use patient, practice or address to select the shipping destination.

Allowed: "address"

address AddressInput required

The US mailing address.

No additional properties

Show address fields
line1 string required

The street address.

Maximum length: 200

Pattern: ^\s*[^\s\x00-\x08\x0a-\x1f\x7f-\x9f](?:[^\x00-\x08\x0a-\x1f\x7f-\x9f]*[^\s\x00-\x08\x0a-\x1f\x7f-\x9f])?\s*$

line2 string | null

The apartment or suite, or null when there is none. Empty text, N/A, NA, none and - count as null. See notes, TBD and unknown return 422.

Maximum length: 200

Pattern: ^\s*(?:[^\s\x00-\x08\x0a-\x1f\x7f-\x9f](?:[^\x00-\x08\x0a-\x1f\x7f-\x9f]*[^\s\x00-\x08\x0a-\x1f\x7f-\x9f])?\s*)?$

city string required

The city name.

Maximum length: 100

Pattern: ^\s*[^\s\x00-\x08\x0a-\x1f\x7f-\x9f](?:[^\x00-\x08\x0a-\x1f\x7f-\x9f]*[^\s\x00-\x08\x0a-\x1f\x7f-\x9f])?\s*$

state string required

The two-letter US state or territory code, such as TX, in any letter case. Affinity stores and returns it in upper case.

Pattern: ^\s*(?:[Aa][Ll]|[Aa][Kk]|[Aa][Zz]|[Aa][Rr]|[Cc][Aa]|[Cc][Oo]|[Cc][Tt]|[Dd][Ee]|[Dd][Cc]|[Ff][Ll]|[Gg][Aa]|[Hh][Ii]|[Ii][Dd]|[Ii][Ll]|[Ii][Nn]|[Ii][Aa]|[Kk][Ss]|[Kk][Yy]|[Ll][Aa]|[Mm][Ee]|[Mm][Dd]|[Mm][Aa]|[Mm][Ii]|[Mm][Nn]|[Mm][Ss]|[Mm][Oo]|[Mm][Tt]|[Nn][Ee]|[Nn][Vv]|[Nn][Hh]|[Nn][Jj]|[Nn][Mm]|[Nn][Yy]|[Nn][Cc]|[Nn][Dd]|[Oo][Hh]|[Oo][Kk]|[Oo][Rr]|[Pp][Aa]|[Rr][Ii]|[Ss][Cc]|[Ss][Dd]|[Tt][Nn]|[Tt][Xx]|[Uu][Tt]|[Vv][Tt]|[Vv][Aa]|[Ww][Aa]|[Ww][Vv]|[Ww][Ii]|[Ww][Yy]|[Aa][Ss]|[Gg][Uu]|[Mm][Pp]|[Pp][Rr]|[Vv][Ii]|[Aa][Aa]|[Aa][Ee]|[Aa][Pp])\s*$

postalCode string required

The US ZIP code: 78701, or ZIP+4 as 78701-1234, 78701 1234 or 787011234. Affinity stores and returns 78701 or 78701-1234.

Pattern: ^\s*\d{5}(?:[ -]?\d{4})?\s*$

signatureAttestation boolean required

Must be true to attest that the named prescriber approved and signed these prescriptions.

Response specifications

200 OK

application/json

Order

cancelRequestedAt string | null required

When cancellation was requested, or null when no cancellation is waiting.

Format: date-time

createdAt string required

When the record was created.

Format: date-time

externalOrderId string | null required

Your order identifier, unique within the practice and mode. A failed or cancelled order keeps it.

failureReason string | null required

Why the order failed, for a person to read. Null unless the order failed; a refused cancel leaves it null.

id string required

The public record identifier.

Pattern: ^ord_[0-7][0-9a-hjkmnp-tv-z]{25}$

mode string required

The Test or Live mode of this record.

Known values: "test", "live"

patient Patient required

The patient details saved when the order was signed.

Show patient fields
address Address required

The US mailing address.

Show address fields
line1 string required

The street address.

line2 string | null required

The apartment or suite, or null when there is none.

city string required

The city name.

state string required

The two-letter US state code.

postalCode string required

The US ZIP code.

allergies Allergy[] required

The reported allergies; an empty list means no new allergies reported.

Show allergies fields

Array items · Allergy

category string required

The allergy category.

Known values: "drug", "food", "insect", "latex", "mold", "pet", "pollen"

display string required

The reported allergy name.

dateOfBirth string required

The patient's birth date in YYYY-MM-DD format.

Format: date

email string required

The patient's email address.

firstName string required

The first name.

sex string required

The patient's sex as sent to the pharmacy.

Known values: "female", "male", "unknown"

lastName string required

The last name.

middleName string | null required

The patient's middle name, or null when there is none.

phone string required

The contact phone number.

patientId string required

The patient's public identifier.

Pattern: ^pat_[0-7][0-9a-hjkmnp-tv-z]{25}$

practice object | null required

The practice contact details saved when the order was signed, or null for historical orders without a snapshot.

Show practice fields
Any of · 1: object
address Address required

The US mailing address.

Show address fields
line1 string required

The street address.

line2 string | null required

The apartment or suite, or null when there is none.

city string required

The city name.

state string required

The two-letter US state code.

postalCode string required

The US ZIP code.

name string required

The name.

phone string required

The contact phone number.

archivedAt string | null required

When the practice was archived, or null while it is active.

Format: date-time

Any of · 2: null

null

practiceId string required

The practice's public identifier.

Pattern: ^prac_[0-7][0-9a-hjkmnp-tv-z]{25}$

prescriber object | null required

The prescribing clinician's details saved when the order was signed.

Show prescriber fields
Any of · 1: object
firstName string required

The first name.

lastName string required

The last name.

npi string required

The prescribing clinician's 10-digit National Provider Identifier (NPI).

phone string | null required

The contact phone number.

address Address | null required

The US mailing address.

Show address fields
Any of · 1: Address
line1 string required

The street address.

line2 string | null required

The apartment or suite, or null when there is none.

city string required

The city name.

state string required

The two-letter US state code.

postalCode string required

The US ZIP code.

Any of · 2: null

null

Any of · 2: null

null

prescriptions Prescription[] required

The prescriptions for this order's patient.

Show prescriptions fields

Array items · Prescription

compoundingReason string | null required

The reason for compounding, required when the medication's requirements include it.

daysSupply integer

The number of days the prescribed quantity lasts. Absent when the order sent none.

Minimum: 1

Maximum: 365

directions string required

The prescriber's directions for use.

id string required

The public record identifier.

Pattern: ^rx_[0-7][0-9a-hjkmnp-tv-z]{25}$

pharmacy PharmacyReference required

The dispensing pharmacy.

Show pharmacy fields
id string required

The public record identifier.

Pattern: ^pharm_[0-7][0-9a-hjkmnp-tv-z]{25}$

name string required

The name.

status string required

The order's current status; every prescription of the order has the same value.

Known values: "awaiting_approval", "submitted", "processing", "shipped", "delivered", "cancelled", "failed"

failureReason string | null required

Why the order failed, for a person to read; every prescription of the order has the same value. Null unless the order failed; a refused cancel leaves it null.

medication object required

The medication details saved when the order was signed.

Show medication fields
fill Fill | null required

What the pharmacy dispenses for one price, or null when the complete fill is unknown.

Show fill fields
Any of · 1: Fill
amount integer required

How much one fill holds, in unit.

Minimum: 1

Maximum: 9007199254740991

container string | null required

What holds one fill, such as vial. Null when the pharmacy does not say.

ingredients object[] required

Each active ingredient's total in one fill: a 2 mL vial of 30 mg/mL is 60 mg.

Show ingredients fields

Array items · object

amount number required

The amount in the specified unit.

name string required

The name.

unit string required

The unit used to measure the amount.

unit string required

The unit of amount, the same as quantityUnit: vial for a vial product.

volume object | null required

What one vial holds, such as 2 mL. Null for a product that is not a vial.

Show volume fields
Any of · 1: object
amount number required

The amount in the specified unit.

unit string required

The unit used to measure the amount.

Any of · 2: null

null

Any of · 2: null

null

form string | null required

The dosage form, or null when it is unknown.

id string required

The public record identifier.

Pattern: ^med_[0-7][0-9a-hjkmnp-tv-z]{25}$

kit Kit | null required

The vials or bottles a kit holds, in the order they are used; null for anything that is not a kit.

Show kit fields
Any of · 1: Kit
days integer required

How many days the kit lasts.

Minimum: 1

Maximum: 9007199254740991

vials object[] required

Each vial or bottle in the order it is used. fill.volume is what one holds.

Show vials fields

Array items · object

ingredients object[] required

Each active ingredient's total in this vial.

Show ingredients fields

Array items · object

amount number required

The amount in the specified unit.

name string required

The name.

unit string required

The unit used to measure the amount.

strength string required

This vial's strength, such as 5 mg/mL.

Any of · 2: null

null

name string required

The name.

quantityUnit string | null required

The unit used to count the prescribed quantity, or null when it is unknown.

strength string | null required

The pharmacy's strength text, or null when it is unknown.

notes string | null required

The prescriber's additional notes to the pharmacy.

price integer required

The prescription's price in integer cents: with a fill, the price per fill times the number of fills.

Minimum: 0

Maximum: 9007199254740991

quantity integer required

The prescribed quantity in quantityUnit, not a count of fills. With a fill, it is a whole number of fills in units: two fills of 30 tablets is 60. A vial's unit is vial, so 2 is two vials.

Minimum: 1

Maximum: 9007199254740991

refills integer required

The number of authorized refills in addition to the first fill.

Minimum: 0

Maximum: 9007199254740991

substitutionPermitted boolean required

Whether the prescriber permits substitution; defaults to true when omitted.

shipping object required

The shipping option and destination.

Show shipping fields
option object | null required

The shipping option saved at signing, or null for historical orders without an option.

Show option fields
Any of · 1: object
id string required

The public record identifier.

Pattern: ^shp_[0-7][0-9a-hjkmnp-tv-z]{25}$

name string required

The name.

price integer required

The shipping price charged, in integer cents.

Minimum: 0

Maximum: 9007199254740991

Any of · 2: null

null

destination ShippingDestination required

The shipping destination; defaults to the patient's address when omitted.

Show destination fields
When type is patient:
type ShippingDestinationPatientType required

Use patient, practice or address to select the shipping destination.

Allowed: "patient"

When type is practice:
type ShippingDestinationPracticeType required

Use patient, practice or address to select the shipping destination.

Allowed: "practice"

When type is address:
type ShippingDestinationAddressType required

Use patient, practice or address to select the shipping destination.

Allowed: "address"

address Address required

The US mailing address.

Show address fields
line1 string required

The street address.

line2 string | null required

The apartment or suite, or null when there is none.

city string required

The city name.

state string required

The two-letter US state code.

postalCode string required

The US ZIP code.

shipments Shipment[] required

The shipped packages, oldest first; a split shipment or reshipment adds a package.

Show shipments fields

Array items · Shipment

carrier string | null required

The carrier name, or null when it is unknown.

trackingNumber string required

The package tracking number.

trackingUrl string | null required

The carrier's tracking page for this package, or null when the carrier has none.

Format: uri

status string required

The current fulfillment status.

Known values: "awaiting_approval", "submitted", "processing", "shipped", "delivered", "cancelled", "failed"

trackingUrl string | null required

The carrier's tracking page for the newest package. Null when there is no package yet or the carrier has no tracking page.

Format: uri

statusHistory StatusHistoryEntry[] required

The order's status changes, oldest first.

Show statusHistory fields

Array items · StatusHistoryEntry

createdAt string required

When the record was created.

Format: date-time

status string required

The current fulfillment status.

Known values: "awaiting_approval", "submitted", "processing", "shipped", "delivered", "cancelled", "failed"

total integer required

The total order price in integer cents, including medication and shipping.

Minimum: 0

Maximum: 9007199254740991

updatedAt string required

When the record was last updated.

Format: date-time

400 Bad Request

application/problem+json

Problem

code string required

A stable code for the problem. Branch on it, not on detail.

detail string required

What went wrong and what to do, for a person to read.

title string required

A short summary of the problem's type.

type string required

A URI that names the problem's type.

issues object[]

One entry for each field that the request got wrong, when the problem is about fields.

Show issues fields

Array items · object

code string required

A stable code for this field's problem.

field string required

The field as one string, such as patient.address.state or prescriptions[0].quantity.

message string required

What is wrong with the field and what to send, for a person to read.

path string | integer[] required

The field as a list of property names and array indexes.

Show path fields

Array items · string | integer

string | integer

instance string required

The path of the request.

requestId string required

Identifies the request, as its X-Request-Id header does. Send it when you report a problem.

status integer required

The HTTP status code of the response.

traceId string

The request trace ID.

401 Unauthorized

application/problem+json

Problem

code string required

A stable code for the problem. Branch on it, not on detail.

detail string required

What went wrong and what to do, for a person to read.

title string required

A short summary of the problem's type.

type string required

A URI that names the problem's type.

issues object[]

One entry for each field that the request got wrong, when the problem is about fields.

Show issues fields

Array items · object

code string required

A stable code for this field's problem.

field string required

The field as one string, such as patient.address.state or prescriptions[0].quantity.

message string required

What is wrong with the field and what to send, for a person to read.

path string | integer[] required

The field as a list of property names and array indexes.

Show path fields

Array items · string | integer

string | integer

instance string required

The path of the request.

requestId string required

Identifies the request, as its X-Request-Id header does. Send it when you report a problem.

status integer required

The HTTP status code of the response.

traceId string

The request trace ID.

403 Forbidden

application/problem+json

Problem

code string required

A stable code for the problem. Branch on it, not on detail.

detail string required

What went wrong and what to do, for a person to read.

title string required

A short summary of the problem's type.

type string required

A URI that names the problem's type.

issues object[]

One entry for each field that the request got wrong, when the problem is about fields.

Show issues fields

Array items · object

code string required

A stable code for this field's problem.

field string required

The field as one string, such as patient.address.state or prescriptions[0].quantity.

message string required

What is wrong with the field and what to send, for a person to read.

path string | integer[] required

The field as a list of property names and array indexes.

Show path fields

Array items · string | integer

string | integer

instance string required

The path of the request.

requestId string required

Identifies the request, as its X-Request-Id header does. Send it when you report a problem.

status integer required

The HTTP status code of the response.

traceId string

The request trace ID.

404 Not Found

application/problem+json

Problem

code string required

A stable code for the problem. Branch on it, not on detail.

detail string required

What went wrong and what to do, for a person to read.

title string required

A short summary of the problem's type.

type string required

A URI that names the problem's type.

issues object[]

One entry for each field that the request got wrong, when the problem is about fields.

Show issues fields

Array items · object

code string required

A stable code for this field's problem.

field string required

The field as one string, such as patient.address.state or prescriptions[0].quantity.

message string required

What is wrong with the field and what to send, for a person to read.

path string | integer[] required

The field as a list of property names and array indexes.

Show path fields

Array items · string | integer

string | integer

instance string required

The path of the request.

requestId string required

Identifies the request, as its X-Request-Id header does. Send it when you report a problem.

status integer required

The HTTP status code of the response.

traceId string

The request trace ID.

409 Conflict

application/problem+json

Problem409

All of · 1: Problem
code string required

A stable code for the problem. Branch on it, not on detail.

detail string required

What went wrong and what to do, for a person to read.

title string required

A short summary of the problem's type.

type string required

A URI that names the problem's type.

issues object[]

One entry for each field that the request got wrong, when the problem is about fields.

Show issues fields

Array items · object

code string required

A stable code for this field's problem.

field string required

The field as one string, such as patient.address.state or prescriptions[0].quantity.

message string required

What is wrong with the field and what to send, for a person to read.

path string | integer[] required

The field as a list of property names and array indexes.

Show path fields

Array items · string | integer

string | integer

instance string required

The path of the request.

requestId string required

Identifies the request, as its X-Request-Id header does. Send it when you report a problem.

status integer required

The HTTP status code of the response.

traceId string

The request trace ID.

All of · 2: object
data object
Show data fields
orderId string

Pattern: ^ord_[0-7][0-9a-hjkmnp-tv-z]{25}$

practiceId string

Pattern: ^prac_[0-7][0-9a-hjkmnp-tv-z]{25}$

413 Content Too Large

application/problem+json

Problem

code string required

A stable code for the problem. Branch on it, not on detail.

detail string required

What went wrong and what to do, for a person to read.

title string required

A short summary of the problem's type.

type string required

A URI that names the problem's type.

issues object[]

One entry for each field that the request got wrong, when the problem is about fields.

Show issues fields

Array items · object

code string required

A stable code for this field's problem.

field string required

The field as one string, such as patient.address.state or prescriptions[0].quantity.

message string required

What is wrong with the field and what to send, for a person to read.

path string | integer[] required

The field as a list of property names and array indexes.

Show path fields

Array items · string | integer

string | integer

instance string required

The path of the request.

requestId string required

Identifies the request, as its X-Request-Id header does. Send it when you report a problem.

status integer required

The HTTP status code of the response.

traceId string

The request trace ID.

415 Unsupported Media Type

application/problem+json

code "unsupported_media_type" required

A stable code for the problem. Branch on it, not on detail.

detail string required

What went wrong and what to do, for a person to read.

title string required

A short summary of the problem's type.

type string required

A URI that names the problem's type.

instance string required

The path of the request.

requestId string required

Identifies the request, as its X-Request-Id header does. Send it when you report a problem.

status integer required

The HTTP status code of the response.

traceId string

The request trace ID.

422 Unprocessable Content

application/problem+json

Problem

code string required

A stable code for the problem. Branch on it, not on detail.

detail string required

What went wrong and what to do, for a person to read.

title string required

A short summary of the problem's type.

type string required

A URI that names the problem's type.

issues object[]

One entry for each field that the request got wrong, when the problem is about fields.

Show issues fields

Array items · object

code string required

A stable code for this field's problem.

field string required

The field as one string, such as patient.address.state or prescriptions[0].quantity.

message string required

What is wrong with the field and what to send, for a person to read.

path string | integer[] required

The field as a list of property names and array indexes.

Show path fields

Array items · string | integer

string | integer

instance string required

The path of the request.

requestId string required

Identifies the request, as its X-Request-Id header does. Send it when you report a problem.

status integer required

The HTTP status code of the response.

traceId string

The request trace ID.

429 Too Many Requests

application/problem+json

Problem429

All of · 1: Problem
code string required

A stable code for the problem. Branch on it, not on detail.

detail string required

What went wrong and what to do, for a person to read.

title string required

A short summary of the problem's type.

type string required

A URI that names the problem's type.

issues object[]

One entry for each field that the request got wrong, when the problem is about fields.

Show issues fields

Array items · object

code string required

A stable code for this field's problem.

field string required

The field as one string, such as patient.address.state or prescriptions[0].quantity.

message string required

What is wrong with the field and what to send, for a person to read.

path string | integer[] required

The field as a list of property names and array indexes.

Show path fields

Array items · string | integer

string | integer

instance string required

The path of the request.

requestId string required

Identifies the request, as its X-Request-Id header does. Send it when you report a problem.

status integer required

The HTTP status code of the response.

traceId string

The request trace ID.

All of · 2: object
data object
Show data fields
retryAfterSeconds integer required

Minimum: 1

Maximum: 9007199254740991

500 Internal Server Error

application/problem+json

Problem

code string required

A stable code for the problem. Branch on it, not on detail.

detail string required

What went wrong and what to do, for a person to read.

title string required

A short summary of the problem's type.

type string required

A URI that names the problem's type.

issues object[]

One entry for each field that the request got wrong, when the problem is about fields.

Show issues fields

Array items · object

code string required

A stable code for this field's problem.

field string required

The field as one string, such as patient.address.state or prescriptions[0].quantity.

message string required

What is wrong with the field and what to send, for a person to read.

path string | integer[] required

The field as a list of property names and array indexes.

Show path fields

Array items · string | integer

string | integer

instance string required

The path of the request.

requestId string required

Identifies the request, as its X-Request-Id header does. Send it when you report a problem.

status integer required

The HTTP status code of the response.

traceId string

The request trace ID.

503 Service Unavailable

application/problem+json

Problem

code string required

A stable code for the problem. Branch on it, not on detail.

detail string required

What went wrong and what to do, for a person to read.

title string required

A short summary of the problem's type.

type string required

A URI that names the problem's type.

issues object[]

One entry for each field that the request got wrong, when the problem is about fields.

Show issues fields

Array items · object

code string required

A stable code for this field's problem.

field string required

The field as one string, such as patient.address.state or prescriptions[0].quantity.

message string required

What is wrong with the field and what to send, for a person to read.

path string | integer[] required

The field as a list of property names and array indexes.

Show path fields

Array items · string | integer

string | integer

instance string required

The path of the request.

requestId string required

Identifies the request, as its X-Request-Id header does. Send it when you report a problem.

status integer required

The HTTP status code of the response.

traceId string

The request trace ID.

Send feedback

Don't include patient information.

Type to search…

↑↓ navigate ↵ select Esc close