{"openapi":"3.1.0","info":{"title":"Affinity API","version":"2026-11-01","contact":{"email":"support@affinityrx.com","name":"Affinity API Support","url":"https://docs.affinityrx.com"},"license":{"name":"AffinityRx Terms of Service","url":"https://affinityrx.com/legal/terms"},"termsOfService":"https://affinityrx.com/legal/terms","description":"Affinity API for platforms and practices that order from the pharmacy network. If a response or a page is wrong or unclear, send `POST /v1/feedback` with an `Idempotency-Key`, a short message and the `requestId` from the response. Do not include patient information."},"paths":{"/v1/account":{"get":{"tags":["Account"],"operationId":"account.get","parameters":[{"description":"The dated API version this request is written against.","in":"header","name":"Affinity-Version","required":true,"schema":{"default":"2026-11-01","enum":["2026-11-01"],"type":"string"}}],"security":[{"apiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"title":"AccountGetResponse","$ref":"#/components/schemas/Account"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"400":{"description":"Bad Request","content":{"application/problem+json":{"schema":{"title":"AccountGet400Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"401":{"description":"Unauthorized","content":{"application/problem+json":{"schema":{"title":"AccountGet401Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"403":{"description":"Forbidden","content":{"application/problem+json":{"schema":{"title":"AccountGet403Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"404":{"description":"Not Found","content":{"application/problem+json":{"schema":{"title":"AccountGet404Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"429":{"description":"Too Many Requests","content":{"application/problem+json":{"schema":{"title":"AccountGet429Response","$ref":"#/components/schemas/Problem429"}}},"headers":{"Retry-After":{"$ref":"#/components/headers/Retry-After"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"500":{"description":"Internal Server Error","content":{"application/problem+json":{"schema":{"title":"AccountGet500Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"503":{"description":"Service Unavailable","content":{"application/problem+json":{"schema":{"title":"AccountGet503Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}}}},"description":"Read the organization and Test or Live mode selected by the API key.","summary":"Read the organization and mode you act as"}},"/v1/consults":{"post":{"tags":["Consults"],"operationId":"consults.create","parameters":[{"name":"Idempotency-Key","in":"header","schema":{"type":"string","pattern":"^[\\x21-\\x7e]{1,255}$","description":"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."},"required":true,"description":"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."},{"description":"The dated API version this request is written against.","in":"header","name":"Affinity-Version","required":true,"schema":{"default":"2026-11-01","enum":["2026-11-01"],"type":"string"}}],"security":[{"apiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"title":"ConsultsCreateResponse","$ref":"#/components/schemas/Consult"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"400":{"description":"Bad Request","content":{"application/problem+json":{"schema":{"title":"ConsultsCreate400Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"401":{"description":"Unauthorized","content":{"application/problem+json":{"schema":{"title":"ConsultsCreate401Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"403":{"description":"Forbidden","content":{"application/problem+json":{"schema":{"title":"ConsultsCreate403Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"404":{"description":"Not Found","content":{"application/problem+json":{"schema":{"title":"ConsultsCreate404Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"409":{"description":"Conflict","content":{"application/problem+json":{"schema":{"title":"ConsultsCreate409Response","$ref":"#/components/schemas/Problem409"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"413":{"description":"Content Too Large","content":{"application/problem+json":{"schema":{"title":"ConsultsCreate413Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"415":{"description":"Unsupported Media Type","content":{"application/problem+json":{"schema":{"title":"ConsultsCreate415Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"422":{"description":"Unprocessable Content","content":{"application/problem+json":{"schema":{"title":"ConsultsCreate422Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"429":{"description":"Too Many Requests","content":{"application/problem+json":{"schema":{"title":"ConsultsCreate429Response","$ref":"#/components/schemas/Problem429"}}},"headers":{"Retry-After":{"$ref":"#/components/headers/Retry-After"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"500":{"description":"Internal Server Error","content":{"application/problem+json":{"schema":{"title":"ConsultsCreate500Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"503":{"description":"Service Unavailable","content":{"application/problem+json":{"schema":{"title":"ConsultsCreate503Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}}}},"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConsultInput"}}},"required":true,"description":"Send the JSON body with Content-Type: application/json."},"description":"Files the patient's proposed prescriptions and intake for a clinician of the network that reviews your platform's consults in this mode. Only a platform API key files consults: another key returns 403 forbidden, and a platform with no network linked in the key's mode returns 403 network_not_linked. The prescriptions are checked as a signed order with the same lines would be now (catalog, quantities, refills, requirements, shipping and price), so the consult is refused now for what its order would be refused for. A medication that the practice's catalog does not list in the key's mode returns 422 medication_not_visible. Every other broken rule returns one 422 invalid_order with one issue for each problem: an empty answer, a repeated intake id, a schedule rule, a patient in one of the network's blocked states (live_visit_required at patient.address.state), each missing required answer (required at intake, naming the id) and the order's own rules. A Live consult needs its payer's payment method or covering credit, or it returns 409 payment_method_required. Send an Idempotency-Key: a retry with the same key and body returns the consult with its current status and 200; the same key with a different body returns 409 idempotency_key_reused. A used externalConsultId returns 409 consult_already_exists with data.consultId. In Test mode, a first prescription's notes that start with test_consult_approve or test_consult_decline make a test clinician approve or decline the consult at once; Live never does this. A clinician decides a Live consult, and the consult.approved or consult.declined event tells you.","summary":"File a consult for a network clinician"},"get":{"tags":["Consults"],"operationId":"consults.list","parameters":[{"name":"limit","in":"query","schema":{"description":"Maximum records per page, from 1 to 100. Defaults to 25.","type":"integer","minimum":1,"maximum":100},"required":false,"description":"Maximum records per page, from 1 to 100. Defaults to 25."},{"name":"startingAfter","in":"query","schema":{"type":"string","maxLength":2048,"description":"Page forward using the previous response's nextCursor. Keep the same filters, sort, organization and mode."},"required":false,"description":"Page forward using the previous response's nextCursor. Keep the same filters, sort, organization and mode."},{"name":"status","in":"query","schema":{"type":"string","enum":["waiting","approved","declined"],"description":"Return only consults with this status. Omit to include every status."},"required":false,"description":"Return only consults with this status. Omit to include every status."},{"name":"practiceId","in":"query","schema":{"type":"string","pattern":"^prac_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"Limit results to the practice with this prac_ ID, within your authorized practices.","examples":["prac_01j2y8m6jcc9tt24af5pw9x1bc"]},"required":false,"description":"Limit results to the practice with this prac_ ID, within your authorized practices."},{"name":"externalConsultId","in":"query","schema":{"type":"string","minLength":1,"maxLength":128,"description":"Match the external consult ID exactly, including case. Combine with practiceId when your platform reuses IDs across practices."},"required":false,"description":"Match the external consult ID exactly, including case. Combine with practiceId when your platform reuses IDs across practices."},{"description":"The dated API version this request is written against.","in":"header","name":"Affinity-Version","required":true,"schema":{"default":"2026-11-01","enum":["2026-11-01"],"type":"string"}}],"security":[{"apiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"title":"ConsultsListResponse","$ref":"#/components/schemas/ConsultList"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"400":{"description":"Bad Request","content":{"application/problem+json":{"schema":{"title":"ConsultsList400Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"401":{"description":"Unauthorized","content":{"application/problem+json":{"schema":{"title":"ConsultsList401Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"403":{"description":"Forbidden","content":{"application/problem+json":{"schema":{"title":"ConsultsList403Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"404":{"description":"Not Found","content":{"application/problem+json":{"schema":{"title":"ConsultsList404Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"429":{"description":"Too Many Requests","content":{"application/problem+json":{"schema":{"title":"ConsultsList429Response","$ref":"#/components/schemas/Problem429"}}},"headers":{"Retry-After":{"$ref":"#/components/headers/Retry-After"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"500":{"description":"Internal Server Error","content":{"application/problem+json":{"schema":{"title":"ConsultsList500Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"503":{"description":"Service Unavailable","content":{"application/problem+json":{"schema":{"title":"ConsultsList503Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}}}},"description":"List the consults accessible to your API key in the current mode, newest first. Each row is the consult without its intake answers: read one consult for those. externalConsultId matches exactly, including case. Keep filters fixed while paging.","summary":"List consults","x-pier-pagination":{"backward":false,"cursorField":"id","kind":"cursor"}}},"/v1/consults/{consultId}":{"get":{"tags":["Consults"],"operationId":"consults.get","parameters":[{"name":"consultId","in":"path","schema":{"type":"string","pattern":"^cns_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The consult ID.","examples":["cns_01j2y8m6jcc9tt24af5pw9x1bc"]},"required":true,"description":"The consult ID."},{"description":"The dated API version this request is written against.","in":"header","name":"Affinity-Version","required":true,"schema":{"default":"2026-11-01","enum":["2026-11-01"],"type":"string"}}],"security":[{"apiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"title":"ConsultsGetResponse","$ref":"#/components/schemas/Consult"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"400":{"description":"Bad Request","content":{"application/problem+json":{"schema":{"title":"ConsultsGet400Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"401":{"description":"Unauthorized","content":{"application/problem+json":{"schema":{"title":"ConsultsGet401Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"403":{"description":"Forbidden","content":{"application/problem+json":{"schema":{"title":"ConsultsGet403Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"404":{"description":"Not Found","content":{"application/problem+json":{"schema":{"title":"ConsultsGet404Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"429":{"description":"Too Many Requests","content":{"application/problem+json":{"schema":{"title":"ConsultsGet429Response","$ref":"#/components/schemas/Problem429"}}},"headers":{"Retry-After":{"$ref":"#/components/headers/Retry-After"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"500":{"description":"Internal Server Error","content":{"application/problem+json":{"schema":{"title":"ConsultsGet500Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"503":{"description":"Service Unavailable","content":{"application/problem+json":{"schema":{"title":"ConsultsGet503Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}}}},"description":"Read one consult accessible to your API key in the current mode, with its intake answers. A malformed consult ID returns 400 invalid_request. A well-formed ID returns 404 not_found when no consult has it, when it is another kind of ID, or when your API key cannot access the consult or it is of another mode.","summary":"Read a consult"}},"/v1/consults/{consultId}/prescription":{"get":{"tags":["Consults"],"operationId":"consults.prescription","parameters":[{"name":"consultId","in":"path","schema":{"type":"string","pattern":"^cns_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The consult ID.","examples":["cns_01j2y8m6jcc9tt24af5pw9x1bc"]},"required":true,"description":"The consult ID."},{"description":"The dated API version this request is written against.","in":"header","name":"Affinity-Version","required":true,"schema":{"default":"2026-11-01","enum":["2026-11-01"],"type":"string"}}],"security":[{"apiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/pdf":{"schema":{"description":"The signed prescription as a PDF.","format":"binary","type":"string"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"400":{"description":"Bad Request","content":{"application/problem+json":{"schema":{"title":"ConsultsPrescription400Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"401":{"description":"Unauthorized","content":{"application/problem+json":{"schema":{"title":"ConsultsPrescription401Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"403":{"description":"Forbidden","content":{"application/problem+json":{"schema":{"title":"ConsultsPrescription403Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"404":{"description":"Not Found","content":{"application/problem+json":{"schema":{"title":"ConsultsPrescription404Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"429":{"description":"Too Many Requests","content":{"application/problem+json":{"schema":{"title":"ConsultsPrescription429Response","$ref":"#/components/schemas/Problem429"}}},"headers":{"Retry-After":{"$ref":"#/components/headers/Retry-After"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"500":{"description":"Internal Server Error","content":{"application/problem+json":{"schema":{"title":"ConsultsPrescription500Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"503":{"description":"Service Unavailable","content":{"application/problem+json":{"schema":{"title":"ConsultsPrescription503Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}}},"description":"The signed prescription as a PDF, made once when the consult was approved: every download returns the same file. A malformed consult ID returns 400 invalid_request. A consult that is not approved returns 404 not_found, as does a well-formed ID that no consult has, another kind of ID, or a consult your API key cannot access or of another mode.","summary":"Download a consult's signed prescription"}},"/v1/consults/{consultId}/attachments/{attachmentId}/check":{"post":{"tags":["Consults"],"operationId":"consults.checkAttachment","parameters":[{"name":"consultId","in":"path","schema":{"type":"string","pattern":"^cns_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The consult ID.","examples":["cns_01j2y8m6jcc9tt24af5pw9x1bc"]},"required":true,"description":"The consult ID."},{"name":"attachmentId","in":"path","schema":{"type":"string","pattern":"^att_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The attachment ID that the upload start returned.","examples":["att_01j2y8m6jcc9tt24af5pw9x1bc"]},"required":true,"description":"The attachment ID that the upload start returned."},{"description":"The dated API version this request is written against.","in":"header","name":"Affinity-Version","required":true,"schema":{"default":"2026-11-01","enum":["2026-11-01"],"type":"string"}}],"security":[{"apiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"title":"ConsultsCheckAttachmentResponse","$ref":"#/components/schemas/ConsultAttachment"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"400":{"description":"Bad Request","content":{"application/problem+json":{"schema":{"title":"ConsultsCheckAttachment400Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"401":{"description":"Unauthorized","content":{"application/problem+json":{"schema":{"title":"ConsultsCheckAttachment401Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"403":{"description":"Forbidden","content":{"application/problem+json":{"schema":{"title":"ConsultsCheckAttachment403Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"404":{"description":"Not Found","content":{"application/problem+json":{"schema":{"title":"ConsultsCheckAttachment404Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"409":{"description":"Conflict","content":{"application/problem+json":{"schema":{"title":"ConsultsCheckAttachment409Response","$ref":"#/components/schemas/Problem409"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"413":{"description":"Content Too Large","content":{"application/problem+json":{"schema":{"title":"ConsultsCheckAttachment413Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"422":{"description":"Unprocessable Content","content":{"application/problem+json":{"schema":{"title":"ConsultsCheckAttachment422Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"429":{"description":"Too Many Requests","content":{"application/problem+json":{"schema":{"title":"ConsultsCheckAttachment429Response","$ref":"#/components/schemas/Problem429"}}},"headers":{"Retry-After":{"$ref":"#/components/headers/Retry-After"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"500":{"description":"Internal Server Error","content":{"application/problem+json":{"schema":{"title":"ConsultsCheckAttachment500Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"503":{"description":"Service Unavailable","content":{"application/problem+json":{"schema":{"title":"ConsultsCheckAttachment503Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}}}},"description":"Checks the bytes you sent: they are the declared type and size, and a photo is at most 8192 pixels on a side. A photo is kept without its camera details, such as its location. Returns the attachment once kept; a check of a kept file returns it again. 404 not_found: not an upload of this consult's patient, or already sent. 422 attachment_missing: the bytes never arrived. 422 attachment_wrong_type: the bytes are not the declared type. 422 attachment_dimensions_too_large: the photo is too large. A refused upload is deleted: start a new one. 503 service_unavailable: the check is busy, so retry with backoff. Your key has 120 checks in 10 minutes, then 429 rate_limit_exceeded with Retry-After. Only a platform API key: another key returns 403 forbidden. The consult must be one your key reads with GET /v1/consults/{consultId}, else 404 not_found; a consult filed without patientContact platform returns 409 patient_contact_affinity.","summary":"Check the patient's uploaded file"}},"/v1/consults/{consultId}/messages/{messageId}":{"get":{"tags":["Consults"],"operationId":"consults.getMessage","parameters":[{"name":"consultId","in":"path","schema":{"type":"string","pattern":"^cns_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The consult ID.","examples":["cns_01j2y8m6jcc9tt24af5pw9x1bc"]},"required":true,"description":"The consult ID."},{"name":"messageId","in":"path","schema":{"type":"string","pattern":"^msg_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The message ID.","examples":["msg_01j2y8m6jcc9tt24af5pw9x1bc"]},"required":true,"description":"The message ID."},{"description":"The dated API version this request is written against.","in":"header","name":"Affinity-Version","required":true,"schema":{"default":"2026-11-01","enum":["2026-11-01"],"type":"string"}}],"security":[{"apiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"title":"ConsultsGetMessageResponse","$ref":"#/components/schemas/ConsultMessage"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"400":{"description":"Bad Request","content":{"application/problem+json":{"schema":{"title":"ConsultsGetMessage400Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"401":{"description":"Unauthorized","content":{"application/problem+json":{"schema":{"title":"ConsultsGetMessage401Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"403":{"description":"Forbidden","content":{"application/problem+json":{"schema":{"title":"ConsultsGetMessage403Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"404":{"description":"Not Found","content":{"application/problem+json":{"schema":{"title":"ConsultsGetMessage404Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"409":{"description":"Conflict","content":{"application/problem+json":{"schema":{"title":"ConsultsGetMessage409Response","$ref":"#/components/schemas/Problem409"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"429":{"description":"Too Many Requests","content":{"application/problem+json":{"schema":{"title":"ConsultsGetMessage429Response","$ref":"#/components/schemas/Problem429"}}},"headers":{"Retry-After":{"$ref":"#/components/headers/Retry-After"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"500":{"description":"Internal Server Error","content":{"application/problem+json":{"schema":{"title":"ConsultsGetMessage500Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"503":{"description":"Service Unavailable","content":{"application/problem+json":{"schema":{"title":"ConsultsGetMessage503Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}}}},"description":"One message, as consult.message.created and consult.message.updated name it. A message of another consult returns 404 not_found. Only a platform API key: another key returns 403 forbidden. The consult must be one your key reads with GET /v1/consults/{consultId}, else 404 not_found; a consult filed without patientContact platform returns 409 patient_contact_affinity.","summary":"Read a consult message"}},"/v1/consults/{consultId}/messages":{"get":{"tags":["Consults"],"operationId":"consults.listMessages","parameters":[{"name":"consultId","in":"path","schema":{"type":"string","pattern":"^cns_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The consult ID.","examples":["cns_01j2y8m6jcc9tt24af5pw9x1bc"]},"required":true,"description":"The consult ID."},{"name":"limit","in":"query","schema":{"description":"Maximum records per page, from 1 to 100. Defaults to 25.","type":"integer","minimum":1,"maximum":100},"required":false,"description":"Maximum records per page, from 1 to 100. Defaults to 25."},{"name":"startingAfter","in":"query","schema":{"type":"string","maxLength":2048,"description":"Page forward using the previous response's nextCursor. Keep the same filters, sort, organization and mode."},"required":false,"description":"Page forward using the previous response's nextCursor. Keep the same filters, sort, organization and mode."},{"description":"The dated API version this request is written against.","in":"header","name":"Affinity-Version","required":true,"schema":{"default":"2026-11-01","enum":["2026-11-01"],"type":"string"}}],"security":[{"apiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"title":"ConsultsListMessagesResponse","$ref":"#/components/schemas/ConsultMessageList"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"400":{"description":"Bad Request","content":{"application/problem+json":{"schema":{"title":"ConsultsListMessages400Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"401":{"description":"Unauthorized","content":{"application/problem+json":{"schema":{"title":"ConsultsListMessages401Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"403":{"description":"Forbidden","content":{"application/problem+json":{"schema":{"title":"ConsultsListMessages403Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"404":{"description":"Not Found","content":{"application/problem+json":{"schema":{"title":"ConsultsListMessages404Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"409":{"description":"Conflict","content":{"application/problem+json":{"schema":{"title":"ConsultsListMessages409Response","$ref":"#/components/schemas/Problem409"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"429":{"description":"Too Many Requests","content":{"application/problem+json":{"schema":{"title":"ConsultsListMessages429Response","$ref":"#/components/schemas/Problem429"}}},"headers":{"Retry-After":{"$ref":"#/components/headers/Retry-After"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"500":{"description":"Internal Server Error","content":{"application/problem+json":{"schema":{"title":"ConsultsListMessages500Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"503":{"description":"Service Unavailable","content":{"application/problem+json":{"schema":{"title":"ConsultsListMessages503Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}}}},"description":"The conversation of a consult filed with patientContact platform, newest message first: the clinician's and the care team's messages, and the patient's that you posted. nextCursor reads the older page. A conversation keeps at most 500 messages, 250 from each side. Only a platform API key: another key returns 403 forbidden. The consult must be one your key reads with GET /v1/consults/{consultId}, else 404 not_found; a consult filed without patientContact platform returns 409 patient_contact_affinity.","summary":"List a consult's messages","x-pier-pagination":{"backward":false,"cursorField":"id","kind":"cursor"}},"post":{"tags":["Consults"],"operationId":"consults.createMessage","parameters":[{"name":"consultId","in":"path","schema":{"type":"string","pattern":"^cns_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The consult ID.","examples":["cns_01j2y8m6jcc9tt24af5pw9x1bc"]},"required":true,"description":"The consult ID."},{"name":"Idempotency-Key","in":"header","schema":{"type":"string","pattern":"^[\\x21-\\x7e]{1,255}$","description":"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."},"required":true,"description":"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."},{"description":"The dated API version this request is written against.","in":"header","name":"Affinity-Version","required":true,"schema":{"default":"2026-11-01","enum":["2026-11-01"],"type":"string"}}],"security":[{"apiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"title":"ConsultsCreateMessageResponse","$ref":"#/components/schemas/ConsultMessage"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"400":{"description":"Bad Request","content":{"application/problem+json":{"schema":{"title":"ConsultsCreateMessage400Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"401":{"description":"Unauthorized","content":{"application/problem+json":{"schema":{"title":"ConsultsCreateMessage401Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"403":{"description":"Forbidden","content":{"application/problem+json":{"schema":{"title":"ConsultsCreateMessage403Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"404":{"description":"Not Found","content":{"application/problem+json":{"schema":{"title":"ConsultsCreateMessage404Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"409":{"description":"Conflict","content":{"application/problem+json":{"schema":{"title":"ConsultsCreateMessage409Response","$ref":"#/components/schemas/Problem409"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"413":{"description":"Content Too Large","content":{"application/problem+json":{"schema":{"title":"ConsultsCreateMessage413Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"415":{"description":"Unsupported Media Type","content":{"application/problem+json":{"schema":{"title":"ConsultsCreateMessage415Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"429":{"description":"Too Many Requests","content":{"application/problem+json":{"schema":{"title":"ConsultsCreateMessage429Response","$ref":"#/components/schemas/Problem429"}}},"headers":{"Retry-After":{"$ref":"#/components/headers/Retry-After"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"500":{"description":"Internal Server Error","content":{"application/problem+json":{"schema":{"title":"ConsultsCreateMessage500Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"503":{"description":"Service Unavailable","content":{"application/problem+json":{"schema":{"title":"ConsultsCreateMessage503Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}}}},"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConsultMessageInput"}}},"required":true,"description":"Send the JSON body with Content-Type: application/json."},"description":"Posts what your patient wrote in your app, as the patient: text, files or both. Post only what the patient wrote after your app signed them in; Affinity records each post with your API key. The clinician sees it as the patient's reply, and the consult's patientMessages.awaiting becomes network. A message with neither text nor a file, a file that is not the patient's checked upload in this consult, one sent before, or one listed twice returns 400 invalid_request with issues. 250 patient messages return 409 conversation_full, and 50 posts a day in the conversation return 429 rate_limit_exceeded with Retry-After. Send a new Idempotency-Key for each message: a retry with the same key and body returns 200 with the same message, and the same key with another body, or a key the care team used on this consult, returns 409 idempotency_key_reused. No event is sent for the patient's own messages. In Test mode, a body that starts with test_care_team_reply gets a reply from a test clinician (authorName Test Clinician) in the same request, with its consult.message.created event, unless the care team already sent 250 messages; a retry writes no second reply, and Live never does this. Only a platform API key: another key returns 403 forbidden. The consult must be one your key reads with GET /v1/consults/{consultId}, else 404 not_found; a consult filed without patientContact platform returns 409 patient_contact_affinity.","summary":"Post the patient's message"}},"/v1/consults/{consultId}/attachments":{"post":{"tags":["Consults"],"operationId":"consults.createAttachment","parameters":[{"name":"consultId","in":"path","schema":{"type":"string","pattern":"^cns_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The consult ID.","examples":["cns_01j2y8m6jcc9tt24af5pw9x1bc"]},"required":true,"description":"The consult ID."},{"description":"The dated API version this request is written against.","in":"header","name":"Affinity-Version","required":true,"schema":{"default":"2026-11-01","enum":["2026-11-01"],"type":"string"}}],"security":[{"apiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"title":"ConsultsCreateAttachmentResponse","$ref":"#/components/schemas/ConsultAttachmentUpload"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"400":{"description":"Bad Request","content":{"application/problem+json":{"schema":{"title":"ConsultsCreateAttachment400Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"401":{"description":"Unauthorized","content":{"application/problem+json":{"schema":{"title":"ConsultsCreateAttachment401Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"403":{"description":"Forbidden","content":{"application/problem+json":{"schema":{"title":"ConsultsCreateAttachment403Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"404":{"description":"Not Found","content":{"application/problem+json":{"schema":{"title":"ConsultsCreateAttachment404Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"409":{"description":"Conflict","content":{"application/problem+json":{"schema":{"title":"ConsultsCreateAttachment409Response","$ref":"#/components/schemas/Problem409"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"413":{"description":"Content Too Large","content":{"application/problem+json":{"schema":{"title":"ConsultsCreateAttachment413Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"415":{"description":"Unsupported Media Type","content":{"application/problem+json":{"schema":{"title":"ConsultsCreateAttachment415Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"429":{"description":"Too Many Requests","content":{"application/problem+json":{"schema":{"title":"ConsultsCreateAttachment429Response","$ref":"#/components/schemas/Problem429"}}},"headers":{"Retry-After":{"$ref":"#/components/headers/Retry-After"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"500":{"description":"Internal Server Error","content":{"application/problem+json":{"schema":{"title":"ConsultsCreateAttachment500Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"503":{"description":"Service Unavailable","content":{"application/problem+json":{"schema":{"title":"ConsultsCreateAttachment503Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}}}},"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConsultAttachmentInput"}}},"required":true,"description":"Send the JSON body with Content-Type: application/json."},"description":"Starts one upload of a photo or PDF the patient sent in your app. PUT the bytes to upload.url with upload.headers within 10 minutes, then check the upload, then post it on a message. JPEG, PNG and GIF up to 10 MB and PDF up to 25 MB; a larger file returns 400 invalid_request at byteSize. Every upload started counts toward the patient's day in this conversation, 20 files and 100 MB, sent or not, unless its check refuses it: past it, 429 rate_limit_exceeded with Retry-After. Your key has 120 starts in 10 minutes, then 429 rate_limit_exceeded with Retry-After. An upload never sent is deleted after a day. No Idempotency-Key: a retry starts another upload. Only a platform API key: another key returns 403 forbidden. The consult must be one your key reads with GET /v1/consults/{consultId}, else 404 not_found; a consult filed without patientContact platform returns 409 patient_contact_affinity.","summary":"Start uploading the patient's file"}},"/v1/feedback":{"post":{"tags":["Feedback"],"operationId":"feedback.create","parameters":[{"name":"Idempotency-Key","in":"header","schema":{"type":"string","pattern":"^[\\x21-\\x7e]{1,255}$","description":"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."},"required":true,"description":"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."},{"description":"The dated API version this request is written against. Required when the request sends an API key; without one, the current version applies.","in":"header","name":"Affinity-Version","required":false,"schema":{"default":"2026-11-01","enum":["2026-11-01"],"type":"string"}}],"security":[{},{"apiKey":[]}],"responses":{"202":{"description":"Accepted","content":{"application/json":{"schema":{"title":"FeedbackCreateResponse","type":"object","properties":{"id":{"type":"string","pattern":"^fbk_[0-7][0-9a-hjkmnp-tv-z]{25}$","examples":["fbk_01j2y8m6jcc9tt24af5pw9x1bc"]}},"required":["id"],"examples":[{"id":"fbk_01j2y8m6jcc9tt24af5pw9x1bc"}],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"400":{"description":"Bad Request","content":{"application/problem+json":{"schema":{"title":"FeedbackCreate400Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"401":{"description":"Unauthorized","content":{"application/problem+json":{"schema":{"title":"FeedbackCreate401Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"409":{"description":"Conflict","content":{"application/problem+json":{"schema":{"title":"FeedbackCreate409Response","$ref":"#/components/schemas/Problem409"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"413":{"description":"Content Too Large","content":{"application/problem+json":{"schema":{"title":"FeedbackCreate413Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"415":{"description":"Unsupported Media Type","content":{"application/problem+json":{"schema":{"properties":{"code":{"description":"A stable code for the problem. Branch on it, not on detail.","const":"unsupported_media_type","type":"string"},"detail":{"description":"What went wrong and what to do, for a person to read.","type":"string"},"title":{"description":"A short summary of the problem's type.","type":"string"},"type":{"description":"A URI that names the problem's type.","type":"string"},"instance":{"description":"The path of the request.","type":"string"},"requestId":{"description":"Identifies the request, as its X-Request-Id header does. Send it when you report a problem.","type":"string"},"status":{"description":"The HTTP status code of the response.","type":"integer"},"traceId":{"description":"The request trace ID.","type":"string"}},"required":["code","detail","instance","requestId","status","title","type"],"type":"object","additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"429":{"description":"Too Many Requests","content":{"application/problem+json":{"schema":{"title":"FeedbackCreate429Response","$ref":"#/components/schemas/Problem429"}}},"headers":{"Retry-After":{"$ref":"#/components/headers/Retry-After"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"500":{"description":"Internal Server Error","content":{"application/problem+json":{"schema":{"title":"FeedbackCreate500Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"503":{"description":"Service Unavailable","content":{"application/problem+json":{"schema":{"title":"FeedbackCreate503Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","maxLength":5000,"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*$","description":"Text with at least one visible character."},"pageUrl":{"type":"string","maxLength":2000},"requestId":{"type":"string","pattern":"^(?:([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|[fF]{8}-[fF]{4}-[fF]{4}-[fF]{4}-[fF]{12})|req_[0-7][0-9a-hjkmnp-tv-z]{25})$","examples":["6e562761-eff3-4626-a8b9-25ce7c670ccd"],"description":"The `requestId` of the response, as the API returned it: a UUID or its `req_` form."}},"required":["message"],"additionalProperties":false,"examples":[{"message":"The error does not explain which field is invalid.","pageUrl":"https://docs.affinityrx.com/errors/","requestId":"6e562761-eff3-4626-a8b9-25ce7c670ccd"}]}}},"required":true,"description":"Send the JSON body with Content-Type: application/json."},"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.","summary":"Send feedback"}},"/v1/medications/{medicationId}":{"get":{"tags":["Medications"],"operationId":"medications.get","parameters":[{"name":"medicationId","in":"path","schema":{"type":"string","pattern":"^med_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The medication ID.","examples":["med_01j2y8m6jcc9tt24af5pw9x1bc"]},"required":true,"description":"The medication ID."},{"name":"practiceId","in":"query","schema":{"type":"string","pattern":"^prac_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"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.","examples":["prac_01j2y8m6jcc9tt24af5pw9x1bc"]},"required":false,"description":"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."},{"name":"expand","in":"query","schema":{"type":"array","items":{"type":"string","enum":["variants"]},"description":"Add related records to the response. `variants` adds the medication's other strengths, forms and pharmacies."},"required":false,"description":"Add related records to the response. `variants` adds the medication's other strengths, forms and pharmacies.","style":"form","explode":true},{"description":"The dated API version this request is written against.","in":"header","name":"Affinity-Version","required":true,"schema":{"default":"2026-11-01","enum":["2026-11-01"],"type":"string"}}],"security":[{"apiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"title":"MedicationsGetResponse","type":"object","properties":{"category":{"type":"string","description":"What the medication is prescribed for. Every strength, form and pharmacy of one medication has the same category.","x-extensible-enum":["weight_loss","hormones","sexual_health","hair","skin","wellness","peptides","pain","other","supplies"]},"coldChainRequired":{"type":"boolean","description":"Whether the medication requires refrigerated shipping."},"compoundingReasons":{"type":"array","items":{"type":"string"},"description":"The accepted compounding reasons. A compoundingReason must be one of them; an empty list means the medication takes no reason, so omit compoundingReason."},"defaultDirections":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The catalog's default directions, or null when none are supplied."},"fill":{"anyOf":[{"$ref":"#/components/schemas/Fill"},{"type":"null"}],"description":"What the pharmacy dispenses for one price, or null when the complete fill is unknown."},"form":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The dosage form, or null when it is unknown."},"fullName":{"type":"string","description":"The name with each ingredient: its salt where the catalog records one, such as Enclomiphene Citrate, or the ingredients of a blend named for what prescribers call it, such as Myers' Cocktail. Equals name otherwise."},"id":{"type":"string","pattern":"^med_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The public record identifier.","examples":["med_01j2y8m6jcc9tt24af5pw9x1bc"]},"kit":{"anyOf":[{"$ref":"#/components/schemas/Kit"},{"type":"null"}],"description":"The vials or bottles a kit holds, in the order they are used; null for anything that is not a kit."},"name":{"type":"string","description":"The name."},"pharmacy":{"$ref":"#/components/schemas/PharmacyReference"},"pharmacyRank":{"type":"integer","minimum":0,"maximum":9007199254740991,"description":"Affinity's preference for the dispensing pharmacy, from 0 for the most preferred. When two pharmacies have the same item at the same price, choose the lower rank. Absent when Affinity has no preference for the pharmacy."},"price":{"type":"integer","minimum":0,"maximum":9007199254740991,"description":"The price in integer cents."},"researchUseOnly":{"type":"boolean","description":"Whether the medication is for research use only (RUO). Only an organization with RUO access sees one."},"maxRefills":{"type":["integer","null"],"minimum":0,"maximum":9007199254740991,"description":"The most refills a prescription of this medication takes, or null when any count within the request limits is accepted. 0 means the pharmacy takes no refills: send a new order for each fill."},"quantities":{"type":"array","items":{"type":"integer","minimum":1,"maximum":9007199254740991},"description":"The accepted quantities, counted in quantityUnit; an empty list permits any quantity within the request limits."},"quantityUnit":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The unit used to count the prescribed quantity, or null when it is unknown."},"receivesAllergies":{"type":"boolean","description":"Whether this medication's pharmacy receives the patient's allergies. When false, the pharmacy's API has no field for them, so they never reach it; Affinity still accepts and sends the order. Tell the prescriber before they sign."},"requirements":{"type":"array","items":{"type":"string"},"description":"The optional prescription field paths that this medication requires."},"restrictedStates":{"type":"array","items":{"type":"string"},"description":"Every state where this medication cannot ship, including states the pharmacy does not cover. It can ship to every other state."},"shippingOptions":{"type":"array","items":{"$ref":"#/components/schemas/ShippingOption"},"description":"The shipping options available for this medication."},"shippingSuppliesPrice":{"type":"integer","minimum":0,"maximum":9007199254740991,"description":"Always 0. Each shipping option price is the complete shipping price."},"strength":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The pharmacy's strength text, or null when it is unknown."},"fieldLimits":{"type":"object","properties":{"directions":{"type":"integer","minimum":1,"maximum":9007199254740991,"description":"The maximum character count for directions."},"notes":{"type":"integer","minimum":1,"maximum":9007199254740991,"description":"The maximum character count for notes, including allergies when notesIncludeAllergies is true."},"notesIncludeAllergies":{"type":"boolean","description":"Whether the patient's allergies share the notes field and its character limit."}},"required":["directions","notes"],"description":"Pharmacy-specific character limits for directions and notes. When notesIncludeAllergies is true, notes share their limit with the patient's allergies, composed as the pharmacy receives them. Absent when the ordinary prescription limits apply.","additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"unsupportedFields":{"type":"array","items":{"type":"string","x-extensible-enum":["notes","substitutionPermitted"]},"description":"The prescription fields this medication's pharmacy cannot receive: notes (send none) and substitutionPermitted (send true). An order that sets one is still accepted; in Live mode Affinity staff handle it, and in Test mode it fails when sent. Absent when the pharmacy receives them all."},"variants":{"type":"array","items":{"$ref":"#/components/schemas/Medication"},"description":"With expand=variants: every other available strength, form and pharmacy of the same medication, for the current organization and mode."}},"required":["category","coldChainRequired","compoundingReasons","defaultDirections","fill","form","fullName","id","kit","name","pharmacy","price","researchUseOnly","maxRefills","quantities","quantityUnit","receivesAllergies","requirements","restrictedStates","shippingOptions","shippingSuppliesPrice","strength"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"400":{"description":"Bad Request","content":{"application/problem+json":{"schema":{"title":"MedicationsGet400Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"401":{"description":"Unauthorized","content":{"application/problem+json":{"schema":{"title":"MedicationsGet401Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"403":{"description":"Forbidden","content":{"application/problem+json":{"schema":{"title":"MedicationsGet403Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"404":{"description":"Not Found","content":{"application/problem+json":{"schema":{"title":"MedicationsGet404Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"429":{"description":"Too Many Requests","content":{"application/problem+json":{"schema":{"title":"MedicationsGet429Response","$ref":"#/components/schemas/Problem429"}}},"headers":{"Retry-After":{"$ref":"#/components/headers/Retry-After"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"500":{"description":"Internal Server Error","content":{"application/problem+json":{"schema":{"title":"MedicationsGet500Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"503":{"description":"Service Unavailable","content":{"application/problem+json":{"schema":{"title":"MedicationsGet503Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}}}},"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.","summary":"Read a medication"}},"/v1/medications":{"get":{"tags":["Medications"],"operationId":"medications.list","parameters":[{"name":"practiceId","in":"query","schema":{"type":"string","pattern":"^prac_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"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.","examples":["prac_01j2y8m6jcc9tt24af5pw9x1bc"]},"required":false,"description":"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."},{"name":"limit","in":"query","schema":{"description":"Maximum records per page, from 1 to 100. Defaults to 25.","type":"integer","minimum":1,"maximum":100},"required":false,"description":"Maximum records per page, from 1 to 100. Defaults to 25."},{"name":"startingAfter","in":"query","schema":{"type":"string","maxLength":2048,"description":"Page forward using the previous response's nextCursor. Keep the same filters, sort, organization and mode."},"required":false,"description":"Page forward using the previous response's nextCursor. Keep the same filters, sort, organization and mode."},{"name":"query","in":"query","schema":{"type":"string","maxLength":120,"description":"Find medications that match every word of this text, in any order. Case and accents are ignored. The search reads the name, ingredients, strength, form, route, brands, category and pharmacy name. A word matches the start of a word in this text. A word of letters also matches a part of the name. A word of letters only that matches no word start can have typos: 1 from 4 letters, 2 from 6 letters. A word with a digit takes no typos. Thousands commas are optional: 1000 IU finds 1,000 IU/mL. A word of punctuation alone, such as %, matches only a name that contains it. A medication ID finds that medication. Results stay A to Z by name. An empty query lists every medication. Restart pagination after changing query."},"required":false,"description":"Find medications that match every word of this text, in any order. Case and accents are ignored. The search reads the name, ingredients, strength, form, route, brands, category and pharmacy name. A word matches the start of a word in this text. A word of letters also matches a part of the name. A word of letters only that matches no word start can have typos: 1 from 4 letters, 2 from 6 letters. A word with a digit takes no typos. Thousands commas are optional: 1000 IU finds 1,000 IU/mL. A word of punctuation alone, such as %, matches only a name that contains it. A medication ID finds that medication. Results stay A to Z by name. An empty query lists every medication. Restart pagination after changing query."},{"description":"The dated API version this request is written against.","in":"header","name":"Affinity-Version","required":true,"schema":{"default":"2026-11-01","enum":["2026-11-01"],"type":"string"}}],"security":[{"apiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"title":"MedicationsListResponse","$ref":"#/components/schemas/MedicationList"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"400":{"description":"Bad Request","content":{"application/problem+json":{"schema":{"title":"MedicationsList400Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"401":{"description":"Unauthorized","content":{"application/problem+json":{"schema":{"title":"MedicationsList401Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"403":{"description":"Forbidden","content":{"application/problem+json":{"schema":{"title":"MedicationsList403Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"404":{"description":"Not Found","content":{"application/problem+json":{"schema":{"title":"MedicationsList404Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"429":{"description":"Too Many Requests","content":{"application/problem+json":{"schema":{"title":"MedicationsList429Response","$ref":"#/components/schemas/Problem429"}}},"headers":{"Retry-After":{"$ref":"#/components/headers/Retry-After"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"500":{"description":"Internal Server Error","content":{"application/problem+json":{"schema":{"title":"MedicationsList500Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"503":{"description":"Service Unavailable","content":{"application/problem+json":{"schema":{"title":"MedicationsList503Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}}}},"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, ingredient, strength, form or pharmacy. 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` lists the accepted reasons; when it is empty, send no reason. `quantities` lists 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.","summary":"List medications","x-pier-pagination":{"backward":false,"cursorField":"id","kind":"cursor"}}},"/v1/orders/{orderId}/cancel":{"post":{"tags":["Orders"],"operationId":"orders.cancel","parameters":[{"name":"orderId","in":"path","schema":{"type":"string","pattern":"^ord_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The order ID.","examples":["ord_01j2y8m6jcc9tt24af5pw9x1bc"]},"required":true,"description":"The order ID."},{"name":"Idempotency-Key","in":"header","schema":{"type":"string","pattern":"^[\\x21-\\x7e]{1,255}$","description":"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."},"required":true,"description":"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."},{"description":"The dated API version this request is written against.","in":"header","name":"Affinity-Version","required":true,"schema":{"default":"2026-11-01","enum":["2026-11-01"],"type":"string"}}],"security":[{"apiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"title":"OrdersCancelResponse","$ref":"#/components/schemas/Order"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"202":{"description":"Accepted","content":{"application/json":{"schema":{"title":"OrdersCancelResponse","$ref":"#/components/schemas/Order"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"400":{"description":"Bad Request","content":{"application/problem+json":{"schema":{"title":"OrdersCancel400Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"401":{"description":"Unauthorized","content":{"application/problem+json":{"schema":{"title":"OrdersCancel401Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"403":{"description":"Forbidden","content":{"application/problem+json":{"schema":{"title":"OrdersCancel403Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"404":{"description":"Not Found","content":{"application/problem+json":{"schema":{"title":"OrdersCancel404Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"409":{"description":"Conflict","content":{"application/problem+json":{"schema":{"title":"OrdersCancel409Response","$ref":"#/components/schemas/Problem409"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"413":{"description":"Content Too Large","content":{"application/problem+json":{"schema":{"title":"OrdersCancel413Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"415":{"description":"Unsupported Media Type","content":{"application/problem+json":{"schema":{"title":"OrdersCancel415Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"429":{"description":"Too Many Requests","content":{"application/problem+json":{"schema":{"title":"OrdersCancel429Response","$ref":"#/components/schemas/Problem429"}}},"headers":{"Retry-After":{"$ref":"#/components/headers/Retry-After"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"500":{"description":"Internal Server Error","content":{"application/problem+json":{"schema":{"title":"OrdersCancel500Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"503":{"description":"Service Unavailable","content":{"application/problem+json":{"schema":{"title":"OrdersCancel503Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}}}},"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.","summary":"Cancel an order"}},"/v1/orders":{"post":{"tags":["Orders"],"operationId":"orders.create","parameters":[{"name":"Idempotency-Key","in":"header","schema":{"type":"string","pattern":"^[\\x21-\\x7e]{1,255}$","description":"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."},"required":true,"description":"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."},{"description":"The dated API version this request is written against.","in":"header","name":"Affinity-Version","required":true,"schema":{"default":"2026-11-01","enum":["2026-11-01"],"type":"string"}}],"security":[{"apiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"title":"OrdersCreateResponse","$ref":"#/components/schemas/Order"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"400":{"description":"Bad Request","content":{"application/problem+json":{"schema":{"title":"OrdersCreate400Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"401":{"description":"Unauthorized","content":{"application/problem+json":{"schema":{"title":"OrdersCreate401Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"403":{"description":"Forbidden","content":{"application/problem+json":{"schema":{"title":"OrdersCreate403Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"404":{"description":"Not Found","content":{"application/problem+json":{"schema":{"title":"OrdersCreate404Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"409":{"description":"Conflict","content":{"application/problem+json":{"schema":{"title":"OrdersCreate409Response","$ref":"#/components/schemas/Problem409"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"413":{"description":"Content Too Large","content":{"application/problem+json":{"schema":{"title":"OrdersCreate413Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"415":{"description":"Unsupported Media Type","content":{"application/problem+json":{"schema":{"properties":{"code":{"description":"A stable code for the problem. Branch on it, not on detail.","const":"unsupported_media_type","type":"string"},"detail":{"description":"What went wrong and what to do, for a person to read.","type":"string"},"title":{"description":"A short summary of the problem's type.","type":"string"},"type":{"description":"A URI that names the problem's type.","type":"string"},"instance":{"description":"The path of the request.","type":"string"},"requestId":{"description":"Identifies the request, as its X-Request-Id header does. Send it when you report a problem.","type":"string"},"status":{"description":"The HTTP status code of the response.","type":"integer"},"traceId":{"description":"The request trace ID.","type":"string"}},"required":["code","detail","instance","requestId","status","title","type"],"type":"object","additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"422":{"description":"Unprocessable Content","content":{"application/problem+json":{"schema":{"title":"OrdersCreate422Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"429":{"description":"Too Many Requests","content":{"application/problem+json":{"schema":{"title":"OrdersCreate429Response","$ref":"#/components/schemas/Problem429"}}},"headers":{"Retry-After":{"$ref":"#/components/headers/Retry-After"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"500":{"description":"Internal Server Error","content":{"application/problem+json":{"schema":{"title":"OrdersCreate500Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"503":{"description":"Service Unavailable","content":{"application/problem+json":{"schema":{"title":"OrdersCreate503Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}}}},"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderInput"}}},"required":true,"description":"Send the JSON body with Content-Type: application/json."},"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. A medication that the practice's catalog does not list in the caller's mode returns 422 medication_not_visible, with an issue at prescriptions[n].medicationId; read GET /v1/medications with the same key and practiceId. Other broken order rules return 422 invalid_order, with one issue for each problem. 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.","summary":"Create, sign and submit an order"},"get":{"tags":["Orders"],"operationId":"orders.list","parameters":[{"name":"limit","in":"query","schema":{"description":"Maximum records per page, from 1 to 100. Defaults to 25.","type":"integer","minimum":1,"maximum":100},"required":false,"description":"Maximum records per page, from 1 to 100. Defaults to 25."},{"name":"startingAfter","in":"query","schema":{"type":"string","maxLength":2048,"description":"Page forward using the previous response's nextCursor. Keep the same filters, sort, organization and mode."},"required":false,"description":"Page forward using the previous response's nextCursor. Keep the same filters, sort, organization and mode."},{"name":"externalOrderId","in":"query","schema":{"type":"string","minLength":1,"maxLength":128,"description":"Match the external order ID exactly, including case. Combine with practiceId when your platform reuses IDs across practices."},"required":false,"description":"Match the external order ID exactly, including case. Combine with practiceId when your platform reuses IDs across practices."},{"name":"updatedAfter","in":"query","schema":{"type":"string","format":"date-time","description":"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."},"required":false,"description":"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."},{"name":"patientId","in":"query","schema":{"type":"string","pattern":"^pat_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"Limit results to the patient with this pat_ ID.","examples":["pat_01j2y8m6jcc9tt24af5pw9x1bc"]},"required":false,"description":"Limit results to the patient with this pat_ ID."},{"name":"practiceId","in":"query","schema":{"type":"string","pattern":"^prac_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"Limit results to the practice with this prac_ ID, within your authorized practices.","examples":["prac_01j2y8m6jcc9tt24af5pw9x1bc"]},"required":false,"description":"Limit results to the practice with this prac_ ID, within your authorized practices."},{"name":"query","in":"query","schema":{"type":"string","maxLength":120,"description":"Search saved order snapshots and tracking numbers: patient names, email, phone, date of birth (1985-03-02, 03/02/1985, 3/2/1985 or 03021985) and external ID; order external ID; prescriber name and NPI; medication names and brands; pharmacy name; each shipment's tracking number. 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 word containing letters or numbers must match, so each word narrows the list; punctuation-only words are ignored. An empty or punctuation-only query leaves the list unfiltered. Separate strength fields, practice names, prac_ IDs and rx_ IDs are not searched. Restart pagination when filters change."},"required":false,"description":"Search saved order snapshots and tracking numbers: patient names, email, phone, date of birth (1985-03-02, 03/02/1985, 3/2/1985 or 03021985) and external ID; order external ID; prescriber name and NPI; medication names and brands; pharmacy name; each shipment's tracking number. 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 word containing letters or numbers must match, so each word narrows the list; punctuation-only words are ignored. An empty or punctuation-only query leaves the list unfiltered. Separate strength fields, practice names, prac_ IDs and rx_ IDs are not searched. Restart pagination when filters change."},{"name":"status","in":"query","schema":{"type":"string","enum":["awaiting_approval","submitted","processing","shipped","delivered","cancelled","failed"],"description":"Return only orders with this status. Omit to include all statuses."},"required":false,"description":"Return only orders with this status. Omit to include all statuses."},{"name":"cancelRequested","in":"query","schema":{"type":"string","enum":["true","false"],"description":"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."},"required":false,"description":"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."},{"name":"recentlyShipped","in":"query","schema":{"type":"string","enum":["true","false"],"description":"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."},"required":false,"description":"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."},{"name":"sort","in":"query","schema":{"type":"string","enum":["patient","patient_desc","created","created_desc"],"description":"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."},"required":false,"description":"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."},{"description":"The dated API version this request is written against.","in":"header","name":"Affinity-Version","required":true,"schema":{"default":"2026-11-01","enum":["2026-11-01"],"type":"string"}}],"security":[{"apiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"title":"OrdersListResponse","$ref":"#/components/schemas/OrderList"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"400":{"description":"Bad Request","content":{"application/problem+json":{"schema":{"title":"OrdersList400Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"401":{"description":"Unauthorized","content":{"application/problem+json":{"schema":{"title":"OrdersList401Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"403":{"description":"Forbidden","content":{"application/problem+json":{"schema":{"title":"OrdersList403Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"404":{"description":"Not Found","content":{"application/problem+json":{"schema":{"title":"OrdersList404Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"429":{"description":"Too Many Requests","content":{"application/problem+json":{"schema":{"title":"OrdersList429Response","$ref":"#/components/schemas/Problem429"}}},"headers":{"Retry-After":{"$ref":"#/components/headers/Retry-After"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"500":{"description":"Internal Server Error","content":{"application/problem+json":{"schema":{"title":"OrdersList500Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"503":{"description":"Service Unavailable","content":{"application/problem+json":{"schema":{"title":"OrdersList503Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}}}},"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.","summary":"List orders","x-pier-pagination":{"backward":false,"cursorField":"id","kind":"cursor"}}},"/v1/orders/{orderId}":{"get":{"tags":["Orders"],"operationId":"orders.get","parameters":[{"name":"orderId","in":"path","schema":{"type":"string","pattern":"^ord_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The order ID.","examples":["ord_01j2y8m6jcc9tt24af5pw9x1bc"]},"required":true,"description":"The order ID."},{"description":"The dated API version this request is written against.","in":"header","name":"Affinity-Version","required":true,"schema":{"default":"2026-11-01","enum":["2026-11-01"],"type":"string"}}],"security":[{"apiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"title":"OrdersGetResponse","$ref":"#/components/schemas/Order"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"400":{"description":"Bad Request","content":{"application/problem+json":{"schema":{"title":"OrdersGet400Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"401":{"description":"Unauthorized","content":{"application/problem+json":{"schema":{"title":"OrdersGet401Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"403":{"description":"Forbidden","content":{"application/problem+json":{"schema":{"title":"OrdersGet403Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"404":{"description":"Not Found","content":{"application/problem+json":{"schema":{"title":"OrdersGet404Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"429":{"description":"Too Many Requests","content":{"application/problem+json":{"schema":{"title":"OrdersGet429Response","$ref":"#/components/schemas/Problem429"}}},"headers":{"Retry-After":{"$ref":"#/components/headers/Retry-After"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"500":{"description":"Internal Server Error","content":{"application/problem+json":{"schema":{"title":"OrdersGet500Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"503":{"description":"Service Unavailable","content":{"application/problem+json":{"schema":{"title":"OrdersGet503Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}}}},"description":"Read one order and its prescriptions in the API key's organization and mode.","summary":"Read an order"}},"/v1/orders/search":{"post":{"tags":["Orders"],"operationId":"orders.search","parameters":[{"description":"The dated API version this request is written against.","in":"header","name":"Affinity-Version","required":true,"schema":{"default":"2026-11-01","enum":["2026-11-01"],"type":"string"}}],"security":[{"apiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"title":"OrdersSearchResponse","$ref":"#/components/schemas/OrderList"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"400":{"description":"Bad Request","content":{"application/problem+json":{"schema":{"title":"OrdersSearch400Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"401":{"description":"Unauthorized","content":{"application/problem+json":{"schema":{"title":"OrdersSearch401Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"403":{"description":"Forbidden","content":{"application/problem+json":{"schema":{"title":"OrdersSearch403Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"404":{"description":"Not Found","content":{"application/problem+json":{"schema":{"title":"OrdersSearch404Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"413":{"description":"Content Too Large","content":{"application/problem+json":{"schema":{"title":"OrdersSearch413Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"415":{"description":"Unsupported Media Type","content":{"application/problem+json":{"schema":{"title":"OrdersSearch415Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"429":{"description":"Too Many Requests","content":{"application/problem+json":{"schema":{"title":"OrdersSearch429Response","$ref":"#/components/schemas/Problem429"}}},"headers":{"Retry-After":{"$ref":"#/components/headers/Retry-After"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"500":{"description":"Internal Server Error","content":{"application/problem+json":{"schema":{"title":"OrdersSearch500Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"503":{"description":"Service Unavailable","content":{"application/problem+json":{"schema":{"title":"OrdersSearch503Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}}}},"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderSearch"}}},"required":true,"description":"Send the JSON body with Content-Type: application/json."},"description":"Takes the same filters as List orders (GET /v1/orders) in a JSON body, so patient details stay out of URLs and logs. Matches similar spellings as List orders does. Returns the same list, newest first unless sort is supplied. For the next page, send the same body with startingAfter set to nextCursor. limit is a number, and cancelRequested and recentlyShipped are booleans.","summary":"Search orders"}},"/v1/practices":{"post":{"tags":["Practices"],"operationId":"practices.create","parameters":[{"name":"Idempotency-Key","in":"header","schema":{"type":"string","pattern":"^[\\x21-\\x7e]{1,255}$","description":"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."},"required":true,"description":"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."},{"description":"The dated API version this request is written against.","in":"header","name":"Affinity-Version","required":true,"schema":{"default":"2026-11-01","enum":["2026-11-01"],"type":"string"}}],"security":[{"apiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"title":"PracticesCreateResponse","$ref":"#/components/schemas/Practice"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"400":{"description":"Bad Request","content":{"application/problem+json":{"schema":{"title":"PracticesCreate400Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"401":{"description":"Unauthorized","content":{"application/problem+json":{"schema":{"title":"PracticesCreate401Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"403":{"description":"Forbidden","content":{"application/problem+json":{"schema":{"title":"PracticesCreate403Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"404":{"description":"Not Found","content":{"application/problem+json":{"schema":{"title":"PracticesCreate404Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"409":{"description":"Conflict","content":{"application/problem+json":{"schema":{"title":"PracticesCreate409Response","$ref":"#/components/schemas/Problem409"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"413":{"description":"Content Too Large","content":{"application/problem+json":{"schema":{"title":"PracticesCreate413Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"415":{"description":"Unsupported Media Type","content":{"application/problem+json":{"schema":{"properties":{"code":{"description":"A stable code for the problem. Branch on it, not on detail.","const":"unsupported_media_type","type":"string"},"detail":{"description":"What went wrong and what to do, for a person to read.","type":"string"},"title":{"description":"A short summary of the problem's type.","type":"string"},"type":{"description":"A URI that names the problem's type.","type":"string"},"instance":{"description":"The path of the request.","type":"string"},"requestId":{"description":"Identifies the request, as its X-Request-Id header does. Send it when you report a problem.","type":"string"},"status":{"description":"The HTTP status code of the response.","type":"integer"},"traceId":{"description":"The request trace ID.","type":"string"}},"required":["code","detail","instance","requestId","status","title","type"],"type":"object","additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"422":{"description":"Unprocessable Content","content":{"application/problem+json":{"schema":{"title":"PracticesCreate422Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"429":{"description":"Too Many Requests","content":{"application/problem+json":{"schema":{"title":"PracticesCreate429Response","$ref":"#/components/schemas/Problem429"}}},"headers":{"Retry-After":{"$ref":"#/components/headers/Retry-After"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"500":{"description":"Internal Server Error","content":{"application/problem+json":{"schema":{"title":"PracticesCreate500Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"503":{"description":"Service Unavailable","content":{"application/problem+json":{"schema":{"title":"PracticesCreate503Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"externalId":{"anyOf":[{"type":"string","maxLength":128,"pattern":"^\\s*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f](?:[^\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f]*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f])?\\s*$","description":"Text with at least one visible character."},{"type":"null"}],"description":"Your practice identifier, unique among your platform's active practices."},"address":{"$ref":"#/components/schemas/PracticeAddressInput"},"liveEnabled":{"type":"boolean","default":false},"name":{"type":"string","maxLength":100,"pattern":"^\\s*[\\x21-\\x3b\\x3d\\x3f-\\x7e\\xa1-\\xac\\xae-ĥĨ-ķĹ-ľŁ-ňŌ-ťŨ-ſƒƠơƯưǄ-ǜǞ-ǣǦ-ǭǰ-ǵǸ-țȞȟȦ-ȳʰʲʳʷʸˆ˜ˡ-ˣ̀-ͯ;·᪰-᫝᫠-᫫ᴬ-ᴮᴰᴱᴳ-ᴺᴼᴾ-ᵃᵇ-ᵉᵍᵏᵐᵒᵖ-ᵘᵛᵢ-ᵥᶜᶞᶠᶻ᷀-ẙẛẞẠ-ỹ`´–—‘-‚“-„†-•…‰‹›ⁱⁿₐ-ₓₕ-ₜ€⃐-⃰ℂℊ-ℎℐ-ℓℕℙ-ℝ™ℤℨK-ℭℯ-ℱℳℴℹⅅ-ⅉⱼⱽ꟱-ꟴꟹﬀ-ﬆ︠-︯Ａ-Ｚａ-ｚ](?:[\\x09\\x20-\\x3b\\x3d\\x3f-\\x7e\\xa0-\\xac\\xae-ĥĨ-ķĹ-ľŁ-ňŌ-ťŨ-ſƒƠơƯưǄ-ǜǞ-ǣǦ-ǭǰ-ǵǸ-țȞȟȦ-ȳʰʲʳʷʸˆ˜ˡ-ˣ̀-ͯ;·᪰-᫝᫠-᫫ᴬ-ᴮᴰᴱᴳ-ᴺᴼᴾ-ᵃᵇ-ᵉᵍᵏᵐᵒᵖ-ᵘᵛᵢ-ᵥᶜᶞᶠᶻ᷀-ẙẛẞẠ-ỹ`´–—‘-‚“-„†-•…‰‹›ⁱⁿₐ-ₓₕ-ₜ€⃐-⃰ℂℊ-ℎℐ-ℓℕℙ-ℝ™ℤℨK-ℭℯ-ℱℳℴℹⅅ-ⅉⱼⱽ꟱-ꟴꟹﬀ-ﬆ︠-︯Ａ-Ｚａ-ｚ]*[\\x21-\\x3b\\x3d\\x3f-\\x7e\\xa1-\\xac\\xae-ĥĨ-ķĹ-ľŁ-ňŌ-ťŨ-ſƒƠơƯưǄ-ǜǞ-ǣǦ-ǭǰ-ǵǸ-țȞȟȦ-ȳʰʲʳʷʸˆ˜ˡ-ˣ̀-ͯ;·᪰-᫝᫠-᫫ᴬ-ᴮᴰᴱᴳ-ᴺᴼᴾ-ᵃᵇ-ᵉᵍᵏᵐᵒᵖ-ᵘᵛᵢ-ᵥᶜᶞᶠᶻ᷀-ẙẛẞẠ-ỹ`´–—‘-‚“-„†-•…‰‹›ⁱⁿₐ-ₓₕ-ₜ€⃐-⃰ℂℊ-ℎℐ-ℓℕℙ-ℝ™ℤℨK-ℭℯ-ℱℳℴℹⅅ-ⅉⱼⱽ꟱-ꟴꟹﬀ-ﬆ︠-︯Ａ-Ｚａ-ｚ])?\\s*$","description":"The practice name. PerfectRx prints it: use Windows-1252 characters, without < or >. PerfectRx receives another letter as its base letter, such as l for ł."},"phone":{"type":"string","maxLength":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}$","description":"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. The area code and the 3 digits after it start with 2 to 9; a number with 0 or 1 there returns 422 with the field in issues.","examples":["+15125550100"]}},"required":["address","name","phone"],"additionalProperties":false}}},"required":true,"description":"Send the JSON body with Content-Type: application/json."},"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.","summary":"Create a practice"},"get":{"tags":["Practices"],"operationId":"practices.list","parameters":[{"name":"limit","in":"query","schema":{"description":"Maximum records per page, from 1 to 100. Defaults to 25.","type":"integer","minimum":1,"maximum":100},"required":false,"description":"Maximum records per page, from 1 to 100. Defaults to 25."},{"name":"startingAfter","in":"query","schema":{"type":"string","maxLength":2048,"description":"Page forward using the previous response's nextCursor. Keep the same filters, sort, organization and mode."},"required":false,"description":"Page forward using the previous response's nextCursor. Keep the same filters, sort, organization and mode."},{"name":"externalId","in":"query","schema":{"type":"string","minLength":1,"maxLength":128,"description":"Match the external practice ID exactly, including case. Keep this filter unchanged while paging."},"required":false,"description":"Match the external practice ID exactly, including case. Keep this filter unchanged while paging."},{"name":"query","in":"query","schema":{"type":"string","maxLength":120,"description":"Find practices that match every word of this text, in any order. Case is ignored. The search reads the practice's name, external ID, city and state, and your platform's name. A word matches the start of a word in this text, or a part of the practice's name. A word of letters only that matches no word start can have typos: 1 from 4 letters, 2 from 6 letters. A word with a digit, such as a code, matches only as typed. A word of punctuation alone, such as &, matches only a name that contains it. A practice ID finds that practice. Results keep the order of sort. Restart pagination after changing query."},"required":false,"description":"Find practices that match every word of this text, in any order. Case is ignored. The search reads the practice's name, external ID, city and state, and your platform's name. A word matches the start of a word in this text, or a part of the practice's name. A word of letters only that matches no word start can have typos: 1 from 4 letters, 2 from 6 letters. A word with a digit, such as a code, matches only as typed. A word of punctuation alone, such as &, matches only a name that contains it. A practice ID finds that practice. Results keep the order of sort. Restart pagination after changing query."},{"name":"sort","in":"query","schema":{"type":"string","enum":["name","name_desc","location","location_desc","mode","mode_desc","created","created_desc"],"description":"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."},"required":false,"description":"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."},{"description":"The dated API version this request is written against.","in":"header","name":"Affinity-Version","required":true,"schema":{"default":"2026-11-01","enum":["2026-11-01"],"type":"string"}}],"security":[{"apiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"title":"PracticesListResponse","$ref":"#/components/schemas/PracticeList"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"400":{"description":"Bad Request","content":{"application/problem+json":{"schema":{"title":"PracticesList400Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"401":{"description":"Unauthorized","content":{"application/problem+json":{"schema":{"title":"PracticesList401Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"403":{"description":"Forbidden","content":{"application/problem+json":{"schema":{"title":"PracticesList403Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"404":{"description":"Not Found","content":{"application/problem+json":{"schema":{"title":"PracticesList404Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"429":{"description":"Too Many Requests","content":{"application/problem+json":{"schema":{"title":"PracticesList429Response","$ref":"#/components/schemas/Problem429"}}},"headers":{"Retry-After":{"$ref":"#/components/headers/Retry-After"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"500":{"description":"Internal Server Error","content":{"application/problem+json":{"schema":{"title":"PracticesList500Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"503":{"description":"Service Unavailable","content":{"application/problem+json":{"schema":{"title":"PracticesList503Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}}}},"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.","summary":"List practices","x-pier-pagination":{"backward":false,"cursorField":"id","kind":"cursor"}}},"/v1/practices/{practiceId}":{"get":{"tags":["Practices"],"operationId":"practices.get","parameters":[{"name":"practiceId","in":"path","schema":{"type":"string","pattern":"^prac_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The practice ID.","examples":["prac_01j2y8m6jcc9tt24af5pw9x1bc"]},"required":true,"description":"The practice ID."},{"description":"The dated API version this request is written against.","in":"header","name":"Affinity-Version","required":true,"schema":{"default":"2026-11-01","enum":["2026-11-01"],"type":"string"}}],"security":[{"apiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"title":"PracticesGetResponse","$ref":"#/components/schemas/Practice"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"400":{"description":"Bad Request","content":{"application/problem+json":{"schema":{"title":"PracticesGet400Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"401":{"description":"Unauthorized","content":{"application/problem+json":{"schema":{"title":"PracticesGet401Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"403":{"description":"Forbidden","content":{"application/problem+json":{"schema":{"title":"PracticesGet403Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"404":{"description":"Not Found","content":{"application/problem+json":{"schema":{"title":"PracticesGet404Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"429":{"description":"Too Many Requests","content":{"application/problem+json":{"schema":{"title":"PracticesGet429Response","$ref":"#/components/schemas/Problem429"}}},"headers":{"Retry-After":{"$ref":"#/components/headers/Retry-After"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"500":{"description":"Internal Server Error","content":{"application/problem+json":{"schema":{"title":"PracticesGet500Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"503":{"description":"Service Unavailable","content":{"application/problem+json":{"schema":{"title":"PracticesGet503Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}}}},"description":"Read one practice accessible to the API key. A platform can read its own practices.","summary":"Read a practice"},"patch":{"tags":["Practices"],"operationId":"practices.update","parameters":[{"name":"practiceId","in":"path","schema":{"type":"string","pattern":"^prac_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The practice ID.","examples":["prac_01j2y8m6jcc9tt24af5pw9x1bc"]},"required":true,"description":"The practice ID."},{"name":"Idempotency-Key","in":"header","schema":{"type":"string","pattern":"^[\\x21-\\x7e]{1,255}$","description":"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."},"required":true,"description":"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."},{"description":"The dated API version this request is written against.","in":"header","name":"Affinity-Version","required":true,"schema":{"default":"2026-11-01","enum":["2026-11-01"],"type":"string"}}],"security":[{"apiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"title":"PracticesUpdateResponse","$ref":"#/components/schemas/Practice"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"400":{"description":"Bad Request","content":{"application/problem+json":{"schema":{"title":"PracticesUpdate400Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"401":{"description":"Unauthorized","content":{"application/problem+json":{"schema":{"title":"PracticesUpdate401Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"403":{"description":"Forbidden","content":{"application/problem+json":{"schema":{"title":"PracticesUpdate403Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"404":{"description":"Not Found","content":{"application/problem+json":{"schema":{"title":"PracticesUpdate404Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"409":{"description":"Conflict","content":{"application/problem+json":{"schema":{"title":"PracticesUpdate409Response","$ref":"#/components/schemas/Problem409"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"413":{"description":"Content Too Large","content":{"application/problem+json":{"schema":{"title":"PracticesUpdate413Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"415":{"description":"Unsupported Media Type","content":{"application/problem+json":{"schema":{"properties":{"code":{"description":"A stable code for the problem. Branch on it, not on detail.","const":"unsupported_media_type","type":"string"},"detail":{"description":"What went wrong and what to do, for a person to read.","type":"string"},"title":{"description":"A short summary of the problem's type.","type":"string"},"type":{"description":"A URI that names the problem's type.","type":"string"},"instance":{"description":"The path of the request.","type":"string"},"requestId":{"description":"Identifies the request, as its X-Request-Id header does. Send it when you report a problem.","type":"string"},"status":{"description":"The HTTP status code of the response.","type":"integer"},"traceId":{"description":"The request trace ID.","type":"string"}},"required":["code","detail","instance","requestId","status","title","type"],"type":"object","additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"422":{"description":"Unprocessable Content","content":{"application/problem+json":{"schema":{"title":"PracticesUpdate422Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"429":{"description":"Too Many Requests","content":{"application/problem+json":{"schema":{"title":"PracticesUpdate429Response","$ref":"#/components/schemas/Problem429"}}},"headers":{"Retry-After":{"$ref":"#/components/headers/Retry-After"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"500":{"description":"Internal Server Error","content":{"application/problem+json":{"schema":{"title":"PracticesUpdate500Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"503":{"description":"Service Unavailable","content":{"application/problem+json":{"schema":{"title":"PracticesUpdate503Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"externalId":{"anyOf":[{"type":"string","maxLength":128,"pattern":"^\\s*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f](?:[^\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f]*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f])?\\s*$","description":"Text with at least one visible character."},{"type":"null"}],"description":"Your practice identifier, unique among your platform's active practices. Send null to clear it. Only the platform sets it for a practice it manages; the practice gets 403 platform_only."},"address":{"anyOf":[{"type":"object","properties":{"line1":{"type":"string","maxLength":70,"pattern":"^\\s*[\\x21-\\x3b\\x3d\\x3f-\\x7e\\xa1-\\xac\\xae-ĥĨ-ķĹ-ľŁ-ňŌ-ťŨ-ſƒƠơƯưǄ-ǜǞ-ǣǦ-ǭǰ-ǵǸ-țȞȟȦ-ȳʰʲʳʷʸˆ˜ˡ-ˣ̀-ͯ;·᪰-᫝᫠-᫫ᴬ-ᴮᴰᴱᴳ-ᴺᴼᴾ-ᵃᵇ-ᵉᵍᵏᵐᵒᵖ-ᵘᵛᵢ-ᵥᶜᶞᶠᶻ᷀-ẙẛẞẠ-ỹ`´–—‘-‚“-„†-•…‰‹›ⁱⁿₐ-ₓₕ-ₜ€⃐-⃰ℂℊ-ℎℐ-ℓℕℙ-ℝ™ℤℨK-ℭℯ-ℱℳℴℹⅅ-ⅉⱼⱽ꟱-ꟴꟹﬀ-ﬆ︠-︯Ａ-Ｚａ-ｚ](?:[\\x09\\x20-\\x3b\\x3d\\x3f-\\x7e\\xa0-\\xac\\xae-ĥĨ-ķĹ-ľŁ-ňŌ-ťŨ-ſƒƠơƯưǄ-ǜǞ-ǣǦ-ǭǰ-ǵǸ-țȞȟȦ-ȳʰʲʳʷʸˆ˜ˡ-ˣ̀-ͯ;·᪰-᫝᫠-᫫ᴬ-ᴮᴰᴱᴳ-ᴺᴼᴾ-ᵃᵇ-ᵉᵍᵏᵐᵒᵖ-ᵘᵛᵢ-ᵥᶜᶞᶠᶻ᷀-ẙẛẞẠ-ỹ`´–—‘-‚“-„†-•…‰‹›ⁱⁿₐ-ₓₕ-ₜ€⃐-⃰ℂℊ-ℎℐ-ℓℕℙ-ℝ™ℤℨK-ℭℯ-ℱℳℴℹⅅ-ⅉⱼⱽ꟱-ꟴꟹﬀ-ﬆ︠-︯Ａ-Ｚａ-ｚ]*[\\x21-\\x3b\\x3d\\x3f-\\x7e\\xa1-\\xac\\xae-ĥĨ-ķĹ-ľŁ-ňŌ-ťŨ-ſƒƠơƯưǄ-ǜǞ-ǣǦ-ǭǰ-ǵǸ-țȞȟȦ-ȳʰʲʳʷʸˆ˜ˡ-ˣ̀-ͯ;·᪰-᫝᫠-᫫ᴬ-ᴮᴰᴱᴳ-ᴺᴼᴾ-ᵃᵇ-ᵉᵍᵏᵐᵒᵖ-ᵘᵛᵢ-ᵥᶜᶞᶠᶻ᷀-ẙẛẞẠ-ỹ`´–—‘-‚“-„†-•…‰‹›ⁱⁿₐ-ₓₕ-ₜ€⃐-⃰ℂℊ-ℎℐ-ℓℕℙ-ℝ™ℤℨK-ℭℯ-ℱℳℴℹⅅ-ⅉⱼⱽ꟱-ꟴꟹﬀ-ﬆ︠-︯Ａ-Ｚａ-ｚ])?\\s*$","description":"The street address. Line 1 and line 2 together: 70 characters or fewer."},"line2":{"anyOf":[{"type":"string","pattern":"^\\s*(?:[\\x21-\\x3b\\x3d\\x3f-\\x7e\\xa1-\\xac\\xae-ĥĨ-ķĹ-ľŁ-ňŌ-ťŨ-ſƒƠơƯưǄ-ǜǞ-ǣǦ-ǭǰ-ǵǸ-țȞȟȦ-ȳʰʲʳʷʸˆ˜ˡ-ˣ̀-ͯ;·᪰-᫝᫠-᫫ᴬ-ᴮᴰᴱᴳ-ᴺᴼᴾ-ᵃᵇ-ᵉᵍᵏᵐᵒᵖ-ᵘᵛᵢ-ᵥᶜᶞᶠᶻ᷀-ẙẛẞẠ-ỹ`´–—‘-‚“-„†-•…‰‹›ⁱⁿₐ-ₓₕ-ₜ€⃐-⃰ℂℊ-ℎℐ-ℓℕℙ-ℝ™ℤℨK-ℭℯ-ℱℳℴℹⅅ-ⅉⱼⱽ꟱-ꟴꟹﬀ-ﬆ︠-︯Ａ-Ｚａ-ｚ](?:[\\x09\\x20-\\x3b\\x3d\\x3f-\\x7e\\xa0-\\xac\\xae-ĥĨ-ķĹ-ľŁ-ňŌ-ťŨ-ſƒƠơƯưǄ-ǜǞ-ǣǦ-ǭǰ-ǵǸ-țȞȟȦ-ȳʰʲʳʷʸˆ˜ˡ-ˣ̀-ͯ;·᪰-᫝᫠-᫫ᴬ-ᴮᴰᴱᴳ-ᴺᴼᴾ-ᵃᵇ-ᵉᵍᵏᵐᵒᵖ-ᵘᵛᵢ-ᵥᶜᶞᶠᶻ᷀-ẙẛẞẠ-ỹ`´–—‘-‚“-„†-•…‰‹›ⁱⁿₐ-ₓₕ-ₜ€⃐-⃰ℂℊ-ℎℐ-ℓℕℙ-ℝ™ℤℨK-ℭℯ-ℱℳℴℹⅅ-ⅉⱼⱽ꟱-ꟴꟹﬀ-ﬆ︠-︯Ａ-Ｚａ-ｚ]*[\\x21-\\x3b\\x3d\\x3f-\\x7e\\xa1-\\xac\\xae-ĥĨ-ķĹ-ľŁ-ňŌ-ťŨ-ſƒƠơƯưǄ-ǜǞ-ǣǦ-ǭǰ-ǵǸ-țȞȟȦ-ȳʰʲʳʷʸˆ˜ˡ-ˣ̀-ͯ;·᪰-᫝᫠-᫫ᴬ-ᴮᴰᴱᴳ-ᴺᴼᴾ-ᵃᵇ-ᵉᵍᵏᵐᵒᵖ-ᵘᵛᵢ-ᵥᶜᶞᶠᶻ᷀-ẙẛẞẠ-ỹ`´–—‘-‚“-„†-•…‰‹›ⁱⁿₐ-ₓₕ-ₜ€⃐-⃰ℂℊ-ℎℐ-ℓℕℙ-ℝ™ℤℨK-ℭℯ-ℱℳℴℹⅅ-ⅉⱼⱽ꟱-ꟴꟹﬀ-ﬆ︠-︯Ａ-Ｚａ-ｚ])?\\s*)?$","maxLength":70},{"type":"null"}],"description":"The apartment or suite. Send null, empty text, N/A, NA, none or - to remove it. See notes, TBD and unknown return 422. An omitted `line2` keeps the saved suite, also when `line1` changes."},"city":{"type":"string","maxLength":100,"pattern":"^\\s*[\\x21-\\x3b\\x3d\\x3f-\\x7e\\xa1-\\xac\\xae-ĥĨ-ķĹ-ľŁ-ňŌ-ťŨ-ſƒƠơƯưǄ-ǜǞ-ǣǦ-ǭǰ-ǵǸ-țȞȟȦ-ȳʰʲʳʷʸˆ˜ˡ-ˣ̀-ͯ;·᪰-᫝᫠-᫫ᴬ-ᴮᴰᴱᴳ-ᴺᴼᴾ-ᵃᵇ-ᵉᵍᵏᵐᵒᵖ-ᵘᵛᵢ-ᵥᶜᶞᶠᶻ᷀-ẙẛẞẠ-ỹ`´–—‘-‚“-„†-•…‰‹›ⁱⁿₐ-ₓₕ-ₜ€⃐-⃰ℂℊ-ℎℐ-ℓℕℙ-ℝ™ℤℨK-ℭℯ-ℱℳℴℹⅅ-ⅉⱼⱽ꟱-ꟴꟹﬀ-ﬆ︠-︯Ａ-Ｚａ-ｚ](?:[\\x09\\x20-\\x3b\\x3d\\x3f-\\x7e\\xa0-\\xac\\xae-ĥĨ-ķĹ-ľŁ-ňŌ-ťŨ-ſƒƠơƯưǄ-ǜǞ-ǣǦ-ǭǰ-ǵǸ-țȞȟȦ-ȳʰʲʳʷʸˆ˜ˡ-ˣ̀-ͯ;·᪰-᫝᫠-᫫ᴬ-ᴮᴰᴱᴳ-ᴺᴼᴾ-ᵃᵇ-ᵉᵍᵏᵐᵒᵖ-ᵘᵛᵢ-ᵥᶜᶞᶠᶻ᷀-ẙẛẞẠ-ỹ`´–—‘-‚“-„†-•…‰‹›ⁱⁿₐ-ₓₕ-ₜ€⃐-⃰ℂℊ-ℎℐ-ℓℕℙ-ℝ™ℤℨK-ℭℯ-ℱℳℴℹⅅ-ⅉⱼⱽ꟱-ꟴꟹﬀ-ﬆ︠-︯Ａ-Ｚａ-ｚ]*[\\x21-\\x3b\\x3d\\x3f-\\x7e\\xa1-\\xac\\xae-ĥĨ-ķĹ-ľŁ-ňŌ-ťŨ-ſƒƠơƯưǄ-ǜǞ-ǣǦ-ǭǰ-ǵǸ-țȞȟȦ-ȳʰʲʳʷʸˆ˜ˡ-ˣ̀-ͯ;·᪰-᫝᫠-᫫ᴬ-ᴮᴰᴱᴳ-ᴺᴼᴾ-ᵃᵇ-ᵉᵍᵏᵐᵒᵖ-ᵘᵛᵢ-ᵥᶜᶞᶠᶻ᷀-ẙẛẞẠ-ỹ`´–—‘-‚“-„†-•…‰‹›ⁱⁿₐ-ₓₕ-ₜ€⃐-⃰ℂℊ-ℎℐ-ℓℕℙ-ℝ™ℤℨK-ℭℯ-ℱℳℴℹⅅ-ⅉⱼⱽ꟱-ꟴꟹﬀ-ﬆ︠-︯Ａ-Ｚａ-ｚ])?\\s*$","description":"The city name."},"state":{"type":"string","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]|[Pp][Rr])\\s*$","description":"The two-letter code of a US state, DC or PR, in any letter case. Affinity stores and returns it in upper case."},"postalCode":{"type":"string","pattern":"^\\s*\\d{5}(?:[ -]?\\d{4})?\\s*$","description":"The US ZIP code: 78701, or ZIP+4 as 78701-1234, 78701 1234 or 787011234. Affinity stores and returns 78701 or 78701-1234."}},"additionalProperties":false},{"type":"null"}],"description":"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 >. PerfectRx receives another letter as its base letter, such as l for ł. Line 1 and line 2 together: 70 characters or fewer."},"liveEnabled":{"type":["boolean","null"],"description":"Omit it or send null to leave Live unchanged."},"name":{"type":"string","maxLength":100,"pattern":"^\\s*[\\x21-\\x3b\\x3d\\x3f-\\x7e\\xa1-\\xac\\xae-ĥĨ-ķĹ-ľŁ-ňŌ-ťŨ-ſƒƠơƯưǄ-ǜǞ-ǣǦ-ǭǰ-ǵǸ-țȞȟȦ-ȳʰʲʳʷʸˆ˜ˡ-ˣ̀-ͯ;·᪰-᫝᫠-᫫ᴬ-ᴮᴰᴱᴳ-ᴺᴼᴾ-ᵃᵇ-ᵉᵍᵏᵐᵒᵖ-ᵘᵛᵢ-ᵥᶜᶞᶠᶻ᷀-ẙẛẞẠ-ỹ`´–—‘-‚“-„†-•…‰‹›ⁱⁿₐ-ₓₕ-ₜ€⃐-⃰ℂℊ-ℎℐ-ℓℕℙ-ℝ™ℤℨK-ℭℯ-ℱℳℴℹⅅ-ⅉⱼⱽ꟱-ꟴꟹﬀ-ﬆ︠-︯Ａ-Ｚａ-ｚ](?:[\\x09\\x20-\\x3b\\x3d\\x3f-\\x7e\\xa0-\\xac\\xae-ĥĨ-ķĹ-ľŁ-ňŌ-ťŨ-ſƒƠơƯưǄ-ǜǞ-ǣǦ-ǭǰ-ǵǸ-țȞȟȦ-ȳʰʲʳʷʸˆ˜ˡ-ˣ̀-ͯ;·᪰-᫝᫠-᫫ᴬ-ᴮᴰᴱᴳ-ᴺᴼᴾ-ᵃᵇ-ᵉᵍᵏᵐᵒᵖ-ᵘᵛᵢ-ᵥᶜᶞᶠᶻ᷀-ẙẛẞẠ-ỹ`´–—‘-‚“-„†-•…‰‹›ⁱⁿₐ-ₓₕ-ₜ€⃐-⃰ℂℊ-ℎℐ-ℓℕℙ-ℝ™ℤℨK-ℭℯ-ℱℳℴℹⅅ-ⅉⱼⱽ꟱-ꟴꟹﬀ-ﬆ︠-︯Ａ-Ｚａ-ｚ]*[\\x21-\\x3b\\x3d\\x3f-\\x7e\\xa1-\\xac\\xae-ĥĨ-ķĹ-ľŁ-ňŌ-ťŨ-ſƒƠơƯưǄ-ǜǞ-ǣǦ-ǭǰ-ǵǸ-țȞȟȦ-ȳʰʲʳʷʸˆ˜ˡ-ˣ̀-ͯ;·᪰-᫝᫠-᫫ᴬ-ᴮᴰᴱᴳ-ᴺᴼᴾ-ᵃᵇ-ᵉᵍᵏᵐᵒᵖ-ᵘᵛᵢ-ᵥᶜᶞᶠᶻ᷀-ẙẛẞẠ-ỹ`´–—‘-‚“-„†-•…‰‹›ⁱⁿₐ-ₓₕ-ₜ€⃐-⃰ℂℊ-ℎℐ-ℓℕℙ-ℝ™ℤℨK-ℭℯ-ℱℳℴℹⅅ-ⅉⱼⱽ꟱-ꟴꟹﬀ-ﬆ︠-︯Ａ-Ｚａ-ｚ])?\\s*$","description":"The practice name. PerfectRx prints it: use Windows-1252 characters, without < or >. PerfectRx receives another letter as its base letter, such as l for ł."},"phone":{"anyOf":[{"type":"string","maxLength":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})$"},{"type":"null"}],"description":"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. The area code and the 3 digits after it start with 2 to 9; a number with 0 or 1 there returns 422 with the field in issues. Empty text counts as null.","examples":["+15125550100"]}},"additionalProperties":false}}},"required":true,"description":"Send the JSON body with Content-Type: application/json."},"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.","summary":"Update a practice"}},"/v1/webhook-endpoints":{"post":{"tags":["Webhooks"],"operationId":"webhooks.create","parameters":[{"name":"Idempotency-Key","in":"header","schema":{"type":"string","pattern":"^[\\x21-\\x7e]{1,255}$","description":"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."},"required":true,"description":"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."},{"description":"The dated API version this request is written against.","in":"header","name":"Affinity-Version","required":true,"schema":{"default":"2026-11-01","enum":["2026-11-01"],"type":"string"}}],"security":[{"apiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"title":"WebhooksCreateResponse","type":"object","properties":{"createdAt":{"type":"string","description":"When the record was created.","format":"date-time"},"updatedAt":{"type":"string","description":"When the record was last updated.","format":"date-time"},"mode":{"type":"string","description":"The Test or Live mode of this record.","x-extensible-enum":["test","live"]},"id":{"type":"string","pattern":"^whe_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The public record identifier.","examples":["whe_01j2y8m6jcc9tt24af5pw9x1bc"]},"url":{"type":"string","description":"The public HTTPS URL that receives webhook events.","format":"uri"},"secret":{"type":"string","description":"The signing secret, returned on creation and its idempotent replay for 24 hours."}},"required":["createdAt","updatedAt","mode","id","url","secret"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"400":{"description":"Bad Request","content":{"application/problem+json":{"schema":{"title":"WebhooksCreate400Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"401":{"description":"Unauthorized","content":{"application/problem+json":{"schema":{"title":"WebhooksCreate401Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"403":{"description":"Forbidden","content":{"application/problem+json":{"schema":{"title":"WebhooksCreate403Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"404":{"description":"Not Found","content":{"application/problem+json":{"schema":{"title":"WebhooksCreate404Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"409":{"description":"Conflict","content":{"application/problem+json":{"schema":{"title":"WebhooksCreate409Response","$ref":"#/components/schemas/Problem409"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"413":{"description":"Content Too Large","content":{"application/problem+json":{"schema":{"title":"WebhooksCreate413Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"415":{"description":"Unsupported Media Type","content":{"application/problem+json":{"schema":{"properties":{"code":{"description":"A stable code for the problem. Branch on it, not on detail.","const":"unsupported_media_type","type":"string"},"detail":{"description":"What went wrong and what to do, for a person to read.","type":"string"},"title":{"description":"A short summary of the problem's type.","type":"string"},"type":{"description":"A URI that names the problem's type.","type":"string"},"instance":{"description":"The path of the request.","type":"string"},"requestId":{"description":"Identifies the request, as its X-Request-Id header does. Send it when you report a problem.","type":"string"},"status":{"description":"The HTTP status code of the response.","type":"integer"},"traceId":{"description":"The request trace ID.","type":"string"}},"required":["code","detail","instance","requestId","status","title","type"],"type":"object","additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"422":{"description":"Unprocessable Content","content":{"application/problem+json":{"schema":{"title":"WebhooksCreate422Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"429":{"description":"Too Many Requests","content":{"application/problem+json":{"schema":{"title":"WebhooksCreate429Response","$ref":"#/components/schemas/Problem429"}}},"headers":{"Retry-After":{"$ref":"#/components/headers/Retry-After"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"500":{"description":"Internal Server Error","content":{"application/problem+json":{"schema":{"title":"WebhooksCreate500Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"503":{"description":"Service Unavailable","content":{"application/problem+json":{"schema":{"title":"WebhooksCreate503Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string","format":"uri","minLength":8,"maxLength":2048,"description":"The public HTTPS URL that receives webhook events."}},"required":["url"],"additionalProperties":false}}},"required":true,"description":"Send the JSON body with Content-Type: application/json."},"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.","summary":"Add a webhook endpoint","callbacks":{"orderEvent":{"{$request.body#/url}":{"post":{"tags":["Webhooks"],"summary":"Receive an Affinity event","description":"Affinity POSTs each event as JSON to your registered endpoint URL, with an `Affinity-Signature: t=<Unix time in seconds>,v1=<signature>` header and an `Affinity-Event-Id` header that holds the event `id`. The signature is the lowercase hex HMAC-SHA256 of `t`, a period (`.`) and the raw request body bytes, keyed with the endpoint's whole signing secret (`whsec_…`). Verify each request before you use it: calculate the signature from the raw body, compare it with `v1` in constant time, and reject the request if they differ or if `t` is more than 300 seconds from your current time. Any 2xx response within 10 seconds acknowledges the delivery. Affinity does not follow redirects. After any other status, a redirect or no response, Affinity retries an order, prescription or consult event, up to 12 tries in all, waiting 2, 4, 8 minutes and so on, at most 24 hours, between tries. A `webhook_endpoint.test` event is sent once and not retried.","externalDocs":{"description":"Receive order updates: verify the signature","url":"https://docs.affinityrx.com/guides/receive-order-updates/#verify-the-signature"},"parameters":[{"name":"Affinity-Signature","in":"header","required":true,"description":"`t=<Unix time in seconds>,v1=<lowercase hex HMAC-SHA256 of t.rawBody>`, keyed with the endpoint's signing secret.","schema":{"type":"string","pattern":"^t=[0-9]+,v1=[0-9a-f]{64}$"}},{"name":"Affinity-Event-Id","in":"header","required":true,"description":"The event `id`. Every delivery attempt of one event sends the same value.","schema":{"type":"string","pattern":"^evt_[0-7][0-9a-hjkmnp-tv-z]{25}$"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookEvent"}}}},"responses":{"2XX":{"description":"Event acknowledged."},"default":{"description":"Not acknowledged: any other status, a redirect or no response within 10 seconds. Affinity retries every event except `webhook_endpoint.test`."}}}}}}},"get":{"tags":["Webhooks"],"operationId":"webhooks.list","parameters":[{"name":"limit","in":"query","schema":{"description":"Maximum records per page, from 1 to 100. Defaults to 25.","type":"integer","minimum":1,"maximum":100},"required":false,"description":"Maximum records per page, from 1 to 100. Defaults to 25."},{"name":"startingAfter","in":"query","schema":{"type":"string","maxLength":2048,"description":"Page forward using the previous response's nextCursor. Keep the same filters, sort, organization and mode."},"required":false,"description":"Page forward using the previous response's nextCursor. Keep the same filters, sort, organization and mode."},{"description":"The dated API version this request is written against.","in":"header","name":"Affinity-Version","required":true,"schema":{"default":"2026-11-01","enum":["2026-11-01"],"type":"string"}}],"security":[{"apiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"title":"WebhooksListResponse","$ref":"#/components/schemas/WebhookEndpointList"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"400":{"description":"Bad Request","content":{"application/problem+json":{"schema":{"title":"WebhooksList400Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"401":{"description":"Unauthorized","content":{"application/problem+json":{"schema":{"title":"WebhooksList401Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"403":{"description":"Forbidden","content":{"application/problem+json":{"schema":{"title":"WebhooksList403Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"404":{"description":"Not Found","content":{"application/problem+json":{"schema":{"title":"WebhooksList404Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"429":{"description":"Too Many Requests","content":{"application/problem+json":{"schema":{"title":"WebhooksList429Response","$ref":"#/components/schemas/Problem429"}}},"headers":{"Retry-After":{"$ref":"#/components/headers/Retry-After"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"500":{"description":"Internal Server Error","content":{"application/problem+json":{"schema":{"title":"WebhooksList500Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"503":{"description":"Service Unavailable","content":{"application/problem+json":{"schema":{"title":"WebhooksList503Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}}}},"description":"List webhook endpoints owned by the API key's organization in its current mode. Signing secrets are not returned.","summary":"List webhook endpoints of the current mode","x-pier-pagination":{"backward":false,"cursorField":"id","kind":"cursor"}}},"/v1/webhook-endpoints/{webhookEndpointId}":{"delete":{"tags":["Webhooks"],"operationId":"webhooks.remove","parameters":[{"name":"webhookEndpointId","in":"path","schema":{"type":"string","pattern":"^whe_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The webhook endpoint ID.","examples":["whe_01j2y8m6jcc9tt24af5pw9x1bc"]},"required":true,"description":"The webhook endpoint ID."},{"description":"The dated API version this request is written against.","in":"header","name":"Affinity-Version","required":true,"schema":{"default":"2026-11-01","enum":["2026-11-01"],"type":"string"}}],"security":[{"apiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"title":"WebhooksRemoveResponse","type":"object","properties":{"deleted":{"type":"boolean","description":"Always true.","examples":[true]},"id":{"type":"string","pattern":"^whe_[0-7][0-9a-hjkmnp-tv-z]{25}$","examples":["whe_01j2y8m6jcc9tt24af5pw9x1bc"]}},"required":["deleted","id"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"400":{"description":"Bad Request","content":{"application/problem+json":{"schema":{"title":"WebhooksRemove400Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"401":{"description":"Unauthorized","content":{"application/problem+json":{"schema":{"title":"WebhooksRemove401Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"403":{"description":"Forbidden","content":{"application/problem+json":{"schema":{"title":"WebhooksRemove403Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"404":{"description":"Not Found","content":{"application/problem+json":{"schema":{"title":"WebhooksRemove404Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"413":{"description":"Content Too Large","content":{"application/problem+json":{"schema":{"title":"WebhooksRemove413Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"429":{"description":"Too Many Requests","content":{"application/problem+json":{"schema":{"title":"WebhooksRemove429Response","$ref":"#/components/schemas/Problem429"}}},"headers":{"Retry-After":{"$ref":"#/components/headers/Retry-After"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"500":{"description":"Internal Server Error","content":{"application/problem+json":{"schema":{"title":"WebhooksRemove500Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"503":{"description":"Service Unavailable","content":{"application/problem+json":{"schema":{"title":"WebhooksRemove503Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}}}},"description":"Events not delivered to it yet are dropped.","summary":"Delete a webhook endpoint"},"patch":{"tags":["Webhooks"],"operationId":"webhooks.update","parameters":[{"name":"webhookEndpointId","in":"path","schema":{"type":"string","pattern":"^whe_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The webhook endpoint ID.","examples":["whe_01j2y8m6jcc9tt24af5pw9x1bc"]},"required":true,"description":"The webhook endpoint ID."},{"name":"Idempotency-Key","in":"header","schema":{"type":"string","pattern":"^[\\x21-\\x7e]{1,255}$","description":"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."},"required":true,"description":"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."},{"description":"The dated API version this request is written against.","in":"header","name":"Affinity-Version","required":true,"schema":{"default":"2026-11-01","enum":["2026-11-01"],"type":"string"}}],"security":[{"apiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"title":"WebhooksUpdateResponse","$ref":"#/components/schemas/WebhookEndpoint"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"400":{"description":"Bad Request","content":{"application/problem+json":{"schema":{"title":"WebhooksUpdate400Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"401":{"description":"Unauthorized","content":{"application/problem+json":{"schema":{"title":"WebhooksUpdate401Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"403":{"description":"Forbidden","content":{"application/problem+json":{"schema":{"title":"WebhooksUpdate403Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"404":{"description":"Not Found","content":{"application/problem+json":{"schema":{"title":"WebhooksUpdate404Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"409":{"description":"Conflict","content":{"application/problem+json":{"schema":{"title":"WebhooksUpdate409Response","$ref":"#/components/schemas/Problem409"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"413":{"description":"Content Too Large","content":{"application/problem+json":{"schema":{"title":"WebhooksUpdate413Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"415":{"description":"Unsupported Media Type","content":{"application/problem+json":{"schema":{"properties":{"code":{"description":"A stable code for the problem. Branch on it, not on detail.","const":"unsupported_media_type","type":"string"},"detail":{"description":"What went wrong and what to do, for a person to read.","type":"string"},"title":{"description":"A short summary of the problem's type.","type":"string"},"type":{"description":"A URI that names the problem's type.","type":"string"},"instance":{"description":"The path of the request.","type":"string"},"requestId":{"description":"Identifies the request, as its X-Request-Id header does. Send it when you report a problem.","type":"string"},"status":{"description":"The HTTP status code of the response.","type":"integer"},"traceId":{"description":"The request trace ID.","type":"string"}},"required":["code","detail","instance","requestId","status","title","type"],"type":"object","additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"422":{"description":"Unprocessable Content","content":{"application/problem+json":{"schema":{"title":"WebhooksUpdate422Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"429":{"description":"Too Many Requests","content":{"application/problem+json":{"schema":{"title":"WebhooksUpdate429Response","$ref":"#/components/schemas/Problem429"}}},"headers":{"Retry-After":{"$ref":"#/components/headers/Retry-After"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"500":{"description":"Internal Server Error","content":{"application/problem+json":{"schema":{"title":"WebhooksUpdate500Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"503":{"description":"Service Unavailable","content":{"application/problem+json":{"schema":{"title":"WebhooksUpdate503Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string","format":"uri","minLength":8,"maxLength":2048}},"required":["url"],"additionalProperties":false}}},"required":true,"description":"Send the JSON body with Content-Type: application/json."},"description":"The signing secret stays the same.","summary":"Change a webhook endpoint's URL"}},"/v1/webhook-endpoints/{webhookEndpointId}/resend-failed":{"post":{"tags":["Webhooks"],"operationId":"webhooks.resendFailed","parameters":[{"name":"webhookEndpointId","in":"path","schema":{"type":"string","pattern":"^whe_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The webhook endpoint ID.","examples":["whe_01j2y8m6jcc9tt24af5pw9x1bc"]},"required":true,"description":"The webhook endpoint ID."},{"name":"Idempotency-Key","in":"header","schema":{"type":"string","pattern":"^[\\x21-\\x7e]{1,255}$","description":"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."},"required":true,"description":"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."},{"description":"The dated API version this request is written against.","in":"header","name":"Affinity-Version","required":true,"schema":{"default":"2026-11-01","enum":["2026-11-01"],"type":"string"}}],"security":[{"apiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"title":"WebhooksResendFailedResponse","type":"object","properties":{"queued":{"type":"integer","minimum":0,"maximum":9007199254740991,"description":"The number of failed deliveries queued for retry plus pending deliveries made due now."}},"required":["queued"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"400":{"description":"Bad Request","content":{"application/problem+json":{"schema":{"title":"WebhooksResendFailed400Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"401":{"description":"Unauthorized","content":{"application/problem+json":{"schema":{"title":"WebhooksResendFailed401Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"403":{"description":"Forbidden","content":{"application/problem+json":{"schema":{"title":"WebhooksResendFailed403Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"404":{"description":"Not Found","content":{"application/problem+json":{"schema":{"title":"WebhooksResendFailed404Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"409":{"description":"Conflict","content":{"application/problem+json":{"schema":{"title":"WebhooksResendFailed409Response","$ref":"#/components/schemas/Problem409"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"413":{"description":"Content Too Large","content":{"application/problem+json":{"schema":{"title":"WebhooksResendFailed413Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"415":{"description":"Unsupported Media Type","content":{"application/problem+json":{"schema":{"title":"WebhooksResendFailed415Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"429":{"description":"Too Many Requests","content":{"application/problem+json":{"schema":{"title":"WebhooksResendFailed429Response","$ref":"#/components/schemas/Problem429"}}},"headers":{"Retry-After":{"$ref":"#/components/headers/Retry-After"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"500":{"description":"Internal Server Error","content":{"application/problem+json":{"schema":{"title":"WebhooksResendFailed500Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"}}},"503":{"description":"Service Unavailable","content":{"application/problem+json":{"schema":{"title":"WebhooksResendFailed503Response","$ref":"#/components/schemas/Problem"}}},"headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Affinity-Trace-Id":{"$ref":"#/components/headers/X-Affinity-Trace-Id"},"X-Api-Version":{"$ref":"#/components/headers/X-Api-Version"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}}}},"description":"Queue failed 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.","summary":"Resend failed webhook deliveries"}}},"components":{"schemas":{"PracticeAddressInput":{"type":"object","properties":{"line1":{"type":"string","maxLength":70,"pattern":"^\\s*[\\x21-\\x3b\\x3d\\x3f-\\x7e\\xa1-\\xac\\xae-ĥĨ-ķĹ-ľŁ-ňŌ-ťŨ-ſƒƠơƯưǄ-ǜǞ-ǣǦ-ǭǰ-ǵǸ-țȞȟȦ-ȳʰʲʳʷʸˆ˜ˡ-ˣ̀-ͯ;·᪰-᫝᫠-᫫ᴬ-ᴮᴰᴱᴳ-ᴺᴼᴾ-ᵃᵇ-ᵉᵍᵏᵐᵒᵖ-ᵘᵛᵢ-ᵥᶜᶞᶠᶻ᷀-ẙẛẞẠ-ỹ`´–—‘-‚“-„†-•…‰‹›ⁱⁿₐ-ₓₕ-ₜ€⃐-⃰ℂℊ-ℎℐ-ℓℕℙ-ℝ™ℤℨK-ℭℯ-ℱℳℴℹⅅ-ⅉⱼⱽ꟱-ꟴꟹﬀ-ﬆ︠-︯Ａ-Ｚａ-ｚ](?:[\\x09\\x20-\\x3b\\x3d\\x3f-\\x7e\\xa0-\\xac\\xae-ĥĨ-ķĹ-ľŁ-ňŌ-ťŨ-ſƒƠơƯưǄ-ǜǞ-ǣǦ-ǭǰ-ǵǸ-țȞȟȦ-ȳʰʲʳʷʸˆ˜ˡ-ˣ̀-ͯ;·᪰-᫝᫠-᫫ᴬ-ᴮᴰᴱᴳ-ᴺᴼᴾ-ᵃᵇ-ᵉᵍᵏᵐᵒᵖ-ᵘᵛᵢ-ᵥᶜᶞᶠᶻ᷀-ẙẛẞẠ-ỹ`´–—‘-‚“-„†-•…‰‹›ⁱⁿₐ-ₓₕ-ₜ€⃐-⃰ℂℊ-ℎℐ-ℓℕℙ-ℝ™ℤℨK-ℭℯ-ℱℳℴℹⅅ-ⅉⱼⱽ꟱-ꟴꟹﬀ-ﬆ︠-︯Ａ-Ｚａ-ｚ]*[\\x21-\\x3b\\x3d\\x3f-\\x7e\\xa1-\\xac\\xae-ĥĨ-ķĹ-ľŁ-ňŌ-ťŨ-ſƒƠơƯưǄ-ǜǞ-ǣǦ-ǭǰ-ǵǸ-țȞȟȦ-ȳʰʲʳʷʸˆ˜ˡ-ˣ̀-ͯ;·᪰-᫝᫠-᫫ᴬ-ᴮᴰᴱᴳ-ᴺᴼᴾ-ᵃᵇ-ᵉᵍᵏᵐᵒᵖ-ᵘᵛᵢ-ᵥᶜᶞᶠᶻ᷀-ẙẛẞẠ-ỹ`´–—‘-‚“-„†-•…‰‹›ⁱⁿₐ-ₓₕ-ₜ€⃐-⃰ℂℊ-ℎℐ-ℓℕℙ-ℝ™ℤℨK-ℭℯ-ℱℳℴℹⅅ-ⅉⱼⱽ꟱-ꟴꟹﬀ-ﬆ︠-︯Ａ-Ｚａ-ｚ])?\\s*$","description":"The street address. Line 1 and line 2 together: 70 characters or fewer."},"line2":{"anyOf":[{"type":"string","pattern":"^\\s*(?:[\\x21-\\x3b\\x3d\\x3f-\\x7e\\xa1-\\xac\\xae-ĥĨ-ķĹ-ľŁ-ňŌ-ťŨ-ſƒƠơƯưǄ-ǜǞ-ǣǦ-ǭǰ-ǵǸ-țȞȟȦ-ȳʰʲʳʷʸˆ˜ˡ-ˣ̀-ͯ;·᪰-᫝᫠-᫫ᴬ-ᴮᴰᴱᴳ-ᴺᴼᴾ-ᵃᵇ-ᵉᵍᵏᵐᵒᵖ-ᵘᵛᵢ-ᵥᶜᶞᶠᶻ᷀-ẙẛẞẠ-ỹ`´–—‘-‚“-„†-•…‰‹›ⁱⁿₐ-ₓₕ-ₜ€⃐-⃰ℂℊ-ℎℐ-ℓℕℙ-ℝ™ℤℨK-ℭℯ-ℱℳℴℹⅅ-ⅉⱼⱽ꟱-ꟴꟹﬀ-ﬆ︠-︯Ａ-Ｚａ-ｚ](?:[\\x09\\x20-\\x3b\\x3d\\x3f-\\x7e\\xa0-\\xac\\xae-ĥĨ-ķĹ-ľŁ-ňŌ-ťŨ-ſƒƠơƯưǄ-ǜǞ-ǣǦ-ǭǰ-ǵǸ-țȞȟȦ-ȳʰʲʳʷʸˆ˜ˡ-ˣ̀-ͯ;·᪰-᫝᫠-᫫ᴬ-ᴮᴰᴱᴳ-ᴺᴼᴾ-ᵃᵇ-ᵉᵍᵏᵐᵒᵖ-ᵘᵛᵢ-ᵥᶜᶞᶠᶻ᷀-ẙẛẞẠ-ỹ`´–—‘-‚“-„†-•…‰‹›ⁱⁿₐ-ₓₕ-ₜ€⃐-⃰ℂℊ-ℎℐ-ℓℕℙ-ℝ™ℤℨK-ℭℯ-ℱℳℴℹⅅ-ⅉⱼⱽ꟱-ꟴꟹﬀ-ﬆ︠-︯Ａ-Ｚａ-ｚ]*[\\x21-\\x3b\\x3d\\x3f-\\x7e\\xa1-\\xac\\xae-ĥĨ-ķĹ-ľŁ-ňŌ-ťŨ-ſƒƠơƯưǄ-ǜǞ-ǣǦ-ǭǰ-ǵǸ-țȞȟȦ-ȳʰʲʳʷʸˆ˜ˡ-ˣ̀-ͯ;·᪰-᫝᫠-᫫ᴬ-ᴮᴰᴱᴳ-ᴺᴼᴾ-ᵃᵇ-ᵉᵍᵏᵐᵒᵖ-ᵘᵛᵢ-ᵥᶜᶞᶠᶻ᷀-ẙẛẞẠ-ỹ`´–—‘-‚“-„†-•…‰‹›ⁱⁿₐ-ₓₕ-ₜ€⃐-⃰ℂℊ-ℎℐ-ℓℕℙ-ℝ™ℤℨK-ℭℯ-ℱℳℴℹⅅ-ⅉⱼⱽ꟱-ꟴꟹﬀ-ﬆ︠-︯Ａ-Ｚａ-ｚ])?\\s*)?$","maxLength":70},{"type":"null"}],"description":"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. Line 1 and line 2 together: 70 characters or fewer."},"city":{"type":"string","maxLength":100,"pattern":"^\\s*[\\x21-\\x3b\\x3d\\x3f-\\x7e\\xa1-\\xac\\xae-ĥĨ-ķĹ-ľŁ-ňŌ-ťŨ-ſƒƠơƯưǄ-ǜǞ-ǣǦ-ǭǰ-ǵǸ-țȞȟȦ-ȳʰʲʳʷʸˆ˜ˡ-ˣ̀-ͯ;·᪰-᫝᫠-᫫ᴬ-ᴮᴰᴱᴳ-ᴺᴼᴾ-ᵃᵇ-ᵉᵍᵏᵐᵒᵖ-ᵘᵛᵢ-ᵥᶜᶞᶠᶻ᷀-ẙẛẞẠ-ỹ`´–—‘-‚“-„†-•…‰‹›ⁱⁿₐ-ₓₕ-ₜ€⃐-⃰ℂℊ-ℎℐ-ℓℕℙ-ℝ™ℤℨK-ℭℯ-ℱℳℴℹⅅ-ⅉⱼⱽ꟱-ꟴꟹﬀ-ﬆ︠-︯Ａ-Ｚａ-ｚ](?:[\\x09\\x20-\\x3b\\x3d\\x3f-\\x7e\\xa0-\\xac\\xae-ĥĨ-ķĹ-ľŁ-ňŌ-ťŨ-ſƒƠơƯưǄ-ǜǞ-ǣǦ-ǭǰ-ǵǸ-țȞȟȦ-ȳʰʲʳʷʸˆ˜ˡ-ˣ̀-ͯ;·᪰-᫝᫠-᫫ᴬ-ᴮᴰᴱᴳ-ᴺᴼᴾ-ᵃᵇ-ᵉᵍᵏᵐᵒᵖ-ᵘᵛᵢ-ᵥᶜᶞᶠᶻ᷀-ẙẛẞẠ-ỹ`´–—‘-‚“-„†-•…‰‹›ⁱⁿₐ-ₓₕ-ₜ€⃐-⃰ℂℊ-ℎℐ-ℓℕℙ-ℝ™ℤℨK-ℭℯ-ℱℳℴℹⅅ-ⅉⱼⱽ꟱-ꟴꟹﬀ-ﬆ︠-︯Ａ-Ｚａ-ｚ]*[\\x21-\\x3b\\x3d\\x3f-\\x7e\\xa1-\\xac\\xae-ĥĨ-ķĹ-ľŁ-ňŌ-ťŨ-ſƒƠơƯưǄ-ǜǞ-ǣǦ-ǭǰ-ǵǸ-țȞȟȦ-ȳʰʲʳʷʸˆ˜ˡ-ˣ̀-ͯ;·᪰-᫝᫠-᫫ᴬ-ᴮᴰᴱᴳ-ᴺᴼᴾ-ᵃᵇ-ᵉᵍᵏᵐᵒᵖ-ᵘᵛᵢ-ᵥᶜᶞᶠᶻ᷀-ẙẛẞẠ-ỹ`´–—‘-‚“-„†-•…‰‹›ⁱⁿₐ-ₓₕ-ₜ€⃐-⃰ℂℊ-ℎℐ-ℓℕℙ-ℝ™ℤℨK-ℭℯ-ℱℳℴℹⅅ-ⅉⱼⱽ꟱-ꟴꟹﬀ-ﬆ︠-︯Ａ-Ｚａ-ｚ])?\\s*$","description":"The city name."},"state":{"type":"string","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]|[Pp][Rr])\\s*$","description":"The two-letter code of a US state, DC or PR, in any letter case. Affinity stores and returns it in upper case."},"postalCode":{"type":"string","pattern":"^\\s*\\d{5}(?:[ -]?\\d{4})?\\s*$","description":"The US ZIP code: 78701, or ZIP+4 as 78701-1234, 78701 1234 or 787011234. Affinity stores and returns 78701 or 78701-1234."}},"required":["line1","city","state","postalCode"],"additionalProperties":false,"description":"The practice's US mailing address. PerfectRx prints it: use Windows-1252 characters, without < or >. PerfectRx receives another letter as its base letter, such as l for ł. Line 1 and line 2 together: 70 characters or fewer."},"ShippingDestinationAddressType":{"type":"string","enum":["address"],"description":"Use patient, practice or address to select the shipping destination."},"ShippingDestinationPracticeType":{"type":"string","enum":["practice"],"description":"Use patient, practice or address to select the shipping destination."},"ShippingDestinationPatientType":{"type":"string","enum":["patient"],"description":"Use patient, practice or address to select the shipping destination."},"OrderSearch":{"type":"object","properties":{"limit":{"type":"integer","minimum":1,"maximum":100,"description":"Maximum records per page, from 1 to 100. Defaults to 25.","default":25},"startingAfter":{"type":"string","maxLength":2048,"description":"Page forward using the previous response's nextCursor. Keep the same filters, sort, organization and mode."},"externalOrderId":{"type":"string","minLength":1,"maxLength":128,"description":"Match the external order ID exactly, including case. Combine with practiceId when your platform reuses IDs across practices."},"updatedAfter":{"type":"string","format":"date-time","description":"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":{"type":"string","pattern":"^pat_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"Limit results to the patient with this pat_ ID.","examples":["pat_01j2y8m6jcc9tt24af5pw9x1bc"]},"practiceId":{"type":"string","pattern":"^prac_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"Limit results to the practice with this prac_ ID, within your authorized practices.","examples":["prac_01j2y8m6jcc9tt24af5pw9x1bc"]},"query":{"type":"string","maxLength":120,"description":"Search saved order snapshots and tracking numbers: patient names, email, phone, date of birth (1985-03-02, 03/02/1985, 3/2/1985 or 03021985) and external ID; order external ID; prescriber name and NPI; medication names and brands; pharmacy name; each shipment's tracking number. 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 word containing letters or numbers must match, so each word narrows the list; punctuation-only words are ignored. An empty or punctuation-only query leaves the list unfiltered. Separate strength fields, practice names, prac_ IDs and rx_ IDs are not searched. Restart pagination when filters change."},"status":{"type":"string","enum":["awaiting_approval","submitted","processing","shipped","delivered","cancelled","failed"],"description":"Return only orders with this status. Omit to include all statuses."},"cancelRequested":{"type":["boolean","null"],"description":"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. Null counts as omitted."},"recentlyShipped":{"type":["boolean","null"],"description":"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. Null counts as omitted."},"sort":{"type":"string","enum":["patient","patient_desc","created","created_desc"],"description":"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."}},"additionalProperties":false},"OrderInput":{"type":"object","properties":{"externalOrderId":{"anyOf":[{"type":"string","maxLength":128,"pattern":"^\\s*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f](?:[^\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f]*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f])?\\s*$","description":"Text with at least one visible character."},{"type":"null"}],"description":"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":{"$ref":"#/components/schemas/PatientInput"},"practiceId":{"type":"string","pattern":"^prac_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"Required with a platform API key. Send a child practice ID. Independent practice keys can omit this field to use their own practice.","examples":["prac_01j2y8m6jcc9tt24af5pw9x1bc"]},"prescriber":{"$ref":"#/components/schemas/PrescriberInput"},"prescriptions":{"type":"array","items":{"$ref":"#/components/schemas/PrescriptionInput"},"description":"The 1 to 20 prescriptions approved for this patient.","minItems":1,"maxItems":20},"shipping":{"type":"object","properties":{"optionId":{"type":"string","pattern":"^shp_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The shipping option identifier from the medication's shippingOptions.","examples":["shp_01j2y8m6jcc9tt24af5pw9x1bc"]},"destination":{"$ref":"#/components/schemas/ShippingDestinationInput"}},"required":["optionId"],"additionalProperties":false,"description":"The shipping option and destination."},"signatureAttestation":{"type":"boolean","description":"Must be true to attest that the named prescriber approved and signed these prescriptions.","examples":[true]}},"required":["patient","prescriptions","shipping","signatureAttestation"],"additionalProperties":false},"ShippingDestinationPracticeInput":{"type":"object","properties":{"type":{"$ref":"#/components/schemas/ShippingDestinationPracticeType"}},"required":["type"],"additionalProperties":false},"ShippingDestinationPatientInput":{"type":"object","properties":{"type":{"$ref":"#/components/schemas/ShippingDestinationPatientType"}},"required":["type"],"additionalProperties":false},"PrescriptionInput":{"type":"object","properties":{"compoundingReason":{"anyOf":[{"type":"string","pattern":"^\\s*(?:[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f](?:[^\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f]*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f])?\\s*)?$","maxLength":200},{"type":"null"}],"description":"One of the medication's compoundingReasons values, required when the medication's requirements include it. Another value returns 422. Empty text counts as null."},"daysSupply":{"type":["integer","null"],"minimum":1,"maximum":365,"description":"The number of days the prescribed quantity lasts, required when the medication's requirements include it. Null counts as not sent."},"directions":{"type":"string","maxLength":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*$","description":"The prescriber's directions for use, as the clinician wrote them. None, N/A, NA, TBD, unknown and see notes return 422."},"medicationId":{"type":"string","pattern":"^med_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The medication's public identifier from the current catalog.","examples":["med_01j2y8m6jcc9tt24af5pw9x1bc"]},"notes":{"anyOf":[{"type":"string","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*)?$","maxLength":1000},{"type":"null"}],"description":"The prescriber's additional notes to the pharmacy. Empty text counts as null."},"quantity":{"type":"integer","minimum":1,"maximum":10000,"description":"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."},"refills":{"type":"integer","minimum":0,"maximum":99,"description":"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."},"substitutionPermitted":{"type":"boolean","description":"Whether the prescriber permits substitution; defaults to true when omitted.","default":true}},"required":["directions","medicationId","quantity","refills"],"additionalProperties":false},"PrescriberInput":{"type":"object","properties":{"phone":{"anyOf":[{"type":"string","maxLength":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})$"},{"type":"null"}],"description":"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. The area code and the 3 digits after it start with 2 to 9; a number with 0 or 1 there returns 422 with the field in issues. Empty text counts as null. When the phone is omitted, null or blank, the order uses the practice phone.","examples":["+15125550100"]},"address":{"$ref":"#/components/schemas/AddressInput"},"firstName":{"type":"string","maxLength":60,"pattern":"^\\s*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f](?:[^\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f]*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f])?\\s*$","description":"The first name."},"lastName":{"type":"string","maxLength":60,"pattern":"^\\s*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f](?:[^\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f]*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f])?\\s*$","description":"The last name."},"npi":{"type":"string","pattern":"^\\s*(?:\\d{10})\\s*$","description":"The prescribing clinician's 10-digit National Provider Identifier (NPI). Surrounding spaces are removed."}},"required":["firstName","lastName","npi"],"additionalProperties":false,"description":"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."},"PatientInput":{"type":"object","properties":{"address":{"$ref":"#/components/schemas/AddressInput"},"allergies":{"type":"array","items":{"type":"object","properties":{"category":{"type":"string","enum":["drug","food","insect","latex","mold","pet","pollen"],"description":"The allergy category."},"display":{"type":"string","maxLength":200,"pattern":"^\\s*[^\\s\\x00-\\x1f\\x7f-\\x9f](?:[^\\x00-\\x1f\\x7f-\\x9f]*[^\\s\\x00-\\x1f\\x7f-\\x9f])?\\s*$","minLength":1,"description":"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."}},"required":["category","display"],"additionalProperties":false},"description":"The reported allergies. Send `[]` when the patient reports no new allergies.","maxItems":50},"dateOfBirth":{"type":"string","pattern":"^\\s*(?:(19|20)\\d\\d-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01]))\\s*$","description":"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."},"email":{"type":"string","maxLength":254,"pattern":"^\\s*[^\\s@\\x00-\\x1f\\x7f-\\x9f]+@[^\\s@\\x00-\\x1f\\x7f-\\x9f]+\\.[^\\s@\\x00-\\x1f\\x7f-\\x9f]+\\s*$","description":"The patient's email address."},"firstName":{"type":"string","maxLength":60,"pattern":"^\\s*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f](?:[^\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f]*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f])?\\s*$","description":"The first name. N/A, TBD, unknown and none return 422."},"sex":{"type":"string","enum":["female","male","unknown"],"description":"The patient's sex as sent to the pharmacy."},"lastName":{"type":"string","maxLength":60,"pattern":"^\\s*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f](?:[^\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f]*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f])?\\s*$","description":"The last name. N/A, TBD, unknown and none return 422."},"middleName":{"anyOf":[{"type":"string","pattern":"^\\s*(?:[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f](?:[^\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f]*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f])?\\s*)?$","maxLength":60},{"type":"null"}],"description":"The patient's middle name, or null when there is none. Empty text counts as null."},"phone":{"type":"string","maxLength":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}$","description":"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. The area code and the 3 digits after it start with 2 to 9; a number with 0 or 1 there returns 422 with the field in issues.","examples":["+15125550100"]},"shippingUpdates":{"type":["boolean","null"],"description":"Send this patient shipping updates: on its way, out for delivery, delivered, and a delivery problem. Send false to turn them off. Omit it, or send null, to keep the patient's current setting; a new patient starts with it off. If your organization turns on Shipping updates for new orders in the dashboard's Settings, an order that omits it turns the updates on: for a consult, the order its approval creates. Each email has a link that lets the patient stop the updates. After a stop, Affinity keeps this setting but sends no update until the patient starts them again from that link."},"smsConsentAt":{"anyOf":[{"type":"string","format":"date-time","description":"An ISO 8601 timestamp with a timezone of Z, +hh:mm or +hhmm, for example 2026-10-21T12:34:56.789Z."},{"type":"null"}],"description":"When the patient agreed to get text messages. Send null when the patient has not agreed, or withdrew. Omit it to keep the patient's current setting. A new patient starts with null."},"externalId":{"anyOf":[{"type":"string","maxLength":128,"pattern":"^\\s*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f](?:[^\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f]*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f])?\\s*$","description":"Text with at least one visible character."},{"type":"null"}],"description":"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."},"id":{"type":"string","pattern":"^pat_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"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.","examples":["pat_01j2y8m6jcc9tt24af5pw9x1bc"]}},"required":["address","allergies","dateOfBirth","email","firstName","sex","lastName","phone"],"additionalProperties":false,"description":"The patient details that the pharmacy receives."},"ConsultAttachmentInput":{"type":"object","properties":{"fileName":{"type":"string","minLength":1,"maxLength":500,"description":"The file's name, 1 to 500 characters."},"contentType":{"type":"string","enum":["image/jpeg","image/png","image/gif","application/pdf"],"description":"The file's type. Convert a HEIC photo to JPEG first, and send a JPEG at most 3000 pixels on its long side."},"byteSize":{"type":"integer","maximum":26214400,"exclusiveMinimum":0,"description":"The file's size in bytes: at most 10 MB (10485760) for a JPEG, PNG or GIF, and 25 MB (26214400) for a PDF."}},"required":["fileName","contentType","byteSize"],"additionalProperties":false},"ConsultMessageInput":{"type":"object","properties":{"body":{"type":"string","maxLength":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*$","description":"What the patient wrote, 1 to 2000 characters. Omit it for a message of files only, which reads back with body \"\"."},"attachments":{"type":"array","items":{"type":"string","pattern":"^att_[0-7][0-9a-hjkmnp-tv-z]{25}$","examples":["att_01j2y8m6jcc9tt24af5pw9x1bc"]},"description":"1 to 5 att_ IDs of the patient's checked uploads in this consult, in order, each not sent before.","minItems":1,"maxItems":5}},"additionalProperties":false},"ConsultInput":{"type":"object","properties":{"externalConsultId":{"anyOf":[{"type":"string","maxLength":128,"pattern":"^\\s*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f](?:[^\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f]*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f])?\\s*$","description":"Text with at least one visible character."},{"type":"null"}],"description":"Your consult identifier, unique within the practice and mode. A declined consult keeps it, so send a new one when you file again. A used value returns 409 consult_already_exists with data.consultId."},"practiceId":{"type":"string","pattern":"^prac_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The prac_ ID of a practice your platform manages. The consult's order is that practice's order.","examples":["prac_01j2y8m6jcc9tt24af5pw9x1bc"]},"patient":{"$ref":"#/components/schemas/ConsultPatientInput"},"prescriptions":{"type":"array","items":{"$ref":"#/components/schemas/ConsultPrescriptionInput"},"description":"The 1 to 20 proposed prescriptions, checked as a signed order with the same lines would be now.","minItems":1,"maxItems":20},"shipping":{"type":"object","properties":{"optionId":{"type":"string","pattern":"^shp_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The shipping option identifier from the medication's shippingOptions.","examples":["shp_01j2y8m6jcc9tt24af5pw9x1bc"]},"destination":{"$ref":"#/components/schemas/ShippingDestinationInput"}},"required":["optionId"],"additionalProperties":false,"description":"The shipping option and destination."},"intake":{"type":"array","items":{"$ref":"#/components/schemas/ConsultIntakeAnswerInput"},"description":"The patient's intake answers, 1 to 150, each with its own id. Each missing required answer returns 422 invalid_order with one issue at intake, code required, that names the id.","minItems":1,"maxItems":150},"patientQuestion":{"anyOf":[{"type":"string","maxLength":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*$","description":"Text with at least one visible character."},{"type":"null"}],"description":"The patient's question for the clinician. Null or omitted: none."},"patientContact":{"type":"string","enum":["affinity","platform"],"description":"Who talks to the patient about the clinician's messages. affinity (the default): Affinity emails and texts the patient a link to its own messages page. platform: your app shows the conversation to the patient through the consult's messages routes and webhooks, and Affinity never contacts the patient about it: no email, text or link. Set it on every consult; it cannot change after filing. Either way, shipping emails for the approved order follow patient.shippingUpdates and your platform's Shipping updates for new orders setting.","default":"affinity"}},"required":["practiceId","patient","prescriptions","shipping","intake"],"additionalProperties":false,"examples":[{"practiceId":"prac_01j9z3k4m5n6p7q8r9s0t1v2w3","externalConsultId":"intake-1042","patient":{"externalId":"patient-1042","firstName":"Dana","middleName":null,"lastName":"Example","dateOfBirth":"1985-06-14","sex":"female","phone":"+15125550100","email":"dana.example@example.com","allergies":[],"address":{"line1":"200 Example Ave","line2":null,"city":"Austin","state":"TX","postalCode":"78701"},"heightInches":65,"weightPounds":204},"prescriptions":[{"medicationId":"med_3v9r73nmfs8bmbjb960yd2pggg","quantity":1,"refills":0,"directions":"Inject 0.25 mL (7.5 mg tirzepatide) under the skin once weekly.","compoundingReason":"concentration_adjustment","notes":null,"substitutionPermitted":true,"schedule":{"step":3,"steps":[{"dose":{"amount":2.5,"unit":"mg"},"weeks":4},{"dose":{"amount":5,"unit":"mg"},"weeks":4},{"dose":{"amount":7.5,"unit":"mg"},"weeks":4},{"dose":{"amount":10,"unit":"mg"},"weeks":4},{"dose":{"amount":12.5,"unit":"mg"},"weeks":4},{"dose":{"amount":15,"unit":"mg"},"weeks":null}]}}],"shipping":{"optionId":"shp_7yna882w139zfbmwzeyb16y24e"},"intake":[{"id":"pregnancy_breastfeeding","question":"Are you pregnant, planning pregnancy or breastfeeding?","answer":"No","critical":false},{"id":"allergies","question":"Do you have any allergies?","answer":"No","critical":false},{"id":"current_medications","question":"What medications do you take now?","answer":"Metformin 500 mg twice daily","critical":false},{"id":"bariatric_surgery","question":"Have you had weight-loss surgery?","answer":"No","critical":false},{"id":"medullary_thyroid_cancer_men2","question":"Have you or a relative had medullary thyroid cancer or MEN2?","answer":"No","critical":false},{"id":"pancreatic_disease","question":"Have you had pancreatitis?","answer":"No","critical":false},{"id":"diabetes_history","question":"Do you have diabetes?","answer":"Type 2, A1c 7.1","critical":true},{"id":"gastroparesis","question":"Do you have gastroparesis?","answer":"No","critical":false},{"id":"severe_hypertriglyceridemia","question":"Have you had very high triglycerides?","answer":"No","critical":false},{"id":"hypoglycemia_history","question":"Have you had low blood sugar episodes?","answer":"No","critical":false},{"id":"glucose_lowering_medications","question":"Do you take medicine to lower blood sugar?","answer":"Metformin 500 mg twice daily","critical":true},{"id":"glp1_hypersensitivity","question":"Have you reacted to a GLP-1 medicine before?","answer":"No","critical":false}],"patientQuestion":"Can I keep taking metformin?"}]},"ConsultIntakeAnswerInput":{"type":"object","properties":{"id":{"type":"string","maxLength":100,"pattern":"^\\s*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f](?:[^\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f]*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f])?\\s*$","description":"Your question ID, unique within the consult. The required answers use fixed IDs: pregnancy_breastfeeding for a female patient, and allergies, current_medications, bariatric_surgery, medullary_thyroid_cancer_men2, pancreatic_disease, diabetes_history, gastroparesis, severe_hypertriglyceridemia, hypoglycemia_history, glucose_lowering_medications and glp1_hypersensitivity for a GLP-1 medication."},"question":{"type":"string","maxLength":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*$","description":"The question exactly as the patient saw it."},"answer":{"type":"string","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*)?$","maxLength":5000,"description":"The patient's answer, word for word. Surrounding spaces are removed. An empty answer returns 422 invalid_order at intake[n].answer."},"critical":{"type":"boolean","description":"Whether you flag the answer for the clinician. The clinician acknowledges each flagged answer before approving."}},"required":["id","question","answer","critical"],"additionalProperties":false},"ShippingDestinationInput":{"description":"Defaults to the patient's address. State restrictions and pharmacy coverage use the destination's state.","oneOf":[{"$ref":"#/components/schemas/ShippingDestinationPatientInput"},{"$ref":"#/components/schemas/ShippingDestinationPracticeInput"},{"$ref":"#/components/schemas/ShippingDestinationAddressInput"}],"discriminator":{"propertyName":"type","mapping":{"patient":"#/components/schemas/ShippingDestinationPatientInput","practice":"#/components/schemas/ShippingDestinationPracticeInput","address":"#/components/schemas/ShippingDestinationAddressInput"}}},"ShippingDestinationAddressInput":{"type":"object","properties":{"type":{"$ref":"#/components/schemas/ShippingDestinationAddressType"},"address":{"$ref":"#/components/schemas/AddressInput"}},"required":["type","address"],"additionalProperties":false},"AddressInput":{"type":"object","properties":{"line1":{"type":"string","maxLength":200,"pattern":"^\\s*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f](?:[^\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f]*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f])?\\s*$","description":"The street address."},"line2":{"anyOf":[{"type":"string","pattern":"^\\s*(?:[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f](?:[^\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f]*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f])?\\s*)?$","maxLength":200},{"type":"null"}],"description":"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."},"city":{"type":"string","maxLength":100,"pattern":"^\\s*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f](?:[^\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f]*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f])?\\s*$","description":"The city name."},"state":{"type":"string","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*$","description":"The two-letter US state or territory code, such as TX, in any letter case. Affinity stores and returns it in upper case."},"postalCode":{"type":"string","pattern":"^\\s*\\d{5}(?:[ -]?\\d{4})?\\s*$","description":"The US ZIP code: 78701, or ZIP+4 as 78701-1234, 78701 1234 or 787011234. Affinity stores and returns 78701 or 78701-1234."}},"required":["line1","city","state","postalCode"],"additionalProperties":false,"description":"The US mailing address."},"ConsultPrescriptionInput":{"type":"object","properties":{"compoundingReason":{"anyOf":[{"type":"string","pattern":"^\\s*(?:[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f](?:[^\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f]*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f])?\\s*)?$","maxLength":200},{"type":"null"}],"description":"One of the medication's compoundingReasons values, required when the medication's requirements include it. Another value returns 422. Empty text counts as null."},"daysSupply":{"type":["integer","null"],"minimum":1,"maximum":365,"description":"The number of days the prescribed quantity lasts, required when the medication's requirements include it. Null counts as not sent."},"directions":{"type":"string","maxLength":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*$","description":"The prescriber's directions for use, as the clinician wrote them. None, N/A, NA, TBD, unknown and see notes return 422."},"medicationId":{"type":"string","pattern":"^med_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The medication's public identifier from the current catalog.","examples":["med_01j2y8m6jcc9tt24af5pw9x1bc"]},"notes":{"anyOf":[{"type":"string","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*)?$","maxLength":1000},{"type":"null"}],"description":"The prescriber's additional notes to the pharmacy. Empty text counts as null."},"quantity":{"type":"integer","minimum":1,"maximum":10000,"description":"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."},"refills":{"type":"integer","minimum":0,"maximum":99,"description":"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."},"substitutionPermitted":{"type":"boolean","description":"Whether the prescriber permits substitution; defaults to true when omitted.","default":true},"schedule":{"anyOf":[{"$ref":"#/components/schemas/TitrationScheduleInput"},{"type":"null"}],"description":"The titration schedule for this prescription, for the clinician to read. Null or omitted: none. The order is the prescription alone: file a new consult before each increase."}},"required":["directions","medicationId","quantity","refills"],"additionalProperties":false},"TitrationScheduleInput":{"type":"object","properties":{"step":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991,"description":"The step this consult decides, from 1 to the number of steps.","examples":[1]},"steps":{"type":"array","items":{"$ref":"#/components/schemas/TitrationStepInput"},"description":"Every step of the schedule, in order: 1 to 12."}},"required":["step","steps"],"additionalProperties":false},"TitrationStepInput":{"type":"object","properties":{"dose":{"type":"object","properties":{"amount":{"type":"number","description":"The weekly dose, above 0 and at most 10,000, with at most 3 decimal places.","examples":[2.5]},"unit":{"type":"string","description":"The unit: mg.","examples":["mg"]}},"required":["amount","unit"],"additionalProperties":false,"description":"The weekly dose of this step."},"weeks":{"type":["integer","null"],"minimum":-9007199254740991,"maximum":9007199254740991,"description":"How many weeks the step lasts, at least 1. Null or omitted only on the last step, which lasts until the clinician changes it (maintenance).","default":null}},"required":["dose"],"additionalProperties":false},"ConsultPatientInput":{"type":"object","properties":{"address":{"$ref":"#/components/schemas/AddressInput"},"allergies":{"type":"array","items":{"type":"object","properties":{"category":{"type":"string","enum":["drug","food","insect","latex","mold","pet","pollen"],"description":"The allergy category."},"display":{"type":"string","maxLength":200,"pattern":"^\\s*[^\\s\\x00-\\x1f\\x7f-\\x9f](?:[^\\x00-\\x1f\\x7f-\\x9f]*[^\\s\\x00-\\x1f\\x7f-\\x9f])?\\s*$","minLength":1,"description":"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."}},"required":["category","display"],"additionalProperties":false},"description":"The reported allergies. Send `[]` when the patient reports no new allergies.","maxItems":50},"dateOfBirth":{"type":"string","pattern":"^\\s*(?:(19|20)\\d\\d-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01]))\\s*$","description":"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."},"email":{"type":"string","maxLength":254,"pattern":"^\\s*[^\\s@\\x00-\\x1f\\x7f-\\x9f]+@[^\\s@\\x00-\\x1f\\x7f-\\x9f]+\\.[^\\s@\\x00-\\x1f\\x7f-\\x9f]+\\s*$","description":"The patient's email address."},"firstName":{"type":"string","maxLength":60,"pattern":"^\\s*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f](?:[^\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f]*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f])?\\s*$","description":"The first name. N/A, TBD, unknown and none return 422."},"sex":{"type":"string","enum":["female","male","unknown"],"description":"The patient's sex as sent to the pharmacy."},"lastName":{"type":"string","maxLength":60,"pattern":"^\\s*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f](?:[^\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f]*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f])?\\s*$","description":"The last name. N/A, TBD, unknown and none return 422."},"middleName":{"anyOf":[{"type":"string","pattern":"^\\s*(?:[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f](?:[^\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f]*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f])?\\s*)?$","maxLength":60},{"type":"null"}],"description":"The patient's middle name, or null when there is none. Empty text counts as null."},"phone":{"type":"string","maxLength":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}$","description":"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. The area code and the 3 digits after it start with 2 to 9; a number with 0 or 1 there returns 422 with the field in issues.","examples":["+15125550100"]},"shippingUpdates":{"type":["boolean","null"],"description":"Send this patient shipping updates: on its way, out for delivery, delivered, and a delivery problem. Send false to turn them off. Omit it, or send null, to keep the patient's current setting; a new patient starts with it off. If your organization turns on Shipping updates for new orders in the dashboard's Settings, an order that omits it turns the updates on: for a consult, the order its approval creates. Each email has a link that lets the patient stop the updates. After a stop, Affinity keeps this setting but sends no update until the patient starts them again from that link."},"smsConsentAt":{"anyOf":[{"type":"string","format":"date-time","description":"An ISO 8601 timestamp with a timezone of Z, +hh:mm or +hhmm, for example 2026-10-21T12:34:56.789Z."},{"type":"null"}],"description":"When the patient agreed to get text messages. Send null when the patient has not agreed, or withdrew. Omit it to keep the patient's current setting. A new patient starts with null."},"externalId":{"anyOf":[{"type":"string","maxLength":128,"pattern":"^\\s*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f](?:[^\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f]*[^\\s\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f])?\\s*$","description":"Text with at least one visible character."},{"type":"null"}],"description":"Your patient identifier within the practice and mode. The order an approval creates reuses the saved patient with this externalId, as POST /v1/orders does."},"heightInches":{"type":"number","minimum":12,"maximum":108,"description":"The patient's height in inches, 12 to 108."},"weightPounds":{"type":"number","minimum":20,"maximum":1500,"description":"The patient's weight in pounds, 20 to 1500."}},"required":["address","allergies","dateOfBirth","email","firstName","sex","lastName","phone","heightInches","weightPounds"],"additionalProperties":false,"description":"The patient, as for POST /v1/orders, with height and weight. The patient's address state decides the clinician's license and the live-visit refusal."},"OrderEventType":{"type":"string","enum":["order.cancelled","order.delivered","order.failed","order.processing","order.shipped","order.submitted","order.updated"],"description":"The event type; ignore event types that you do not recognize.","x-enum-varnames":["ORDER_CANCELLED","ORDER_DELIVERED","ORDER_FAILED","ORDER_PROCESSING","ORDER_SHIPPED","ORDER_SUBMITTED","ORDER_UPDATED"],"x-fern-enum":{"order.cancelled":{"name":"OrderCancelled"},"order.delivered":{"name":"OrderDelivered"},"order.failed":{"name":"OrderFailed"},"order.processing":{"name":"OrderProcessing"},"order.shipped":{"name":"OrderShipped"},"order.submitted":{"name":"OrderSubmitted"},"order.updated":{"name":"OrderUpdated"}}},"PrescriptionEventType":{"type":"string","enum":["prescription.failed","prescription.cancelled"],"description":"The event type; ignore event types that you do not recognize.","x-enum-varnames":["PRESCRIPTION_FAILED","PRESCRIPTION_CANCELLED"],"x-fern-enum":{"prescription.failed":{"name":"PrescriptionFailed"},"prescription.cancelled":{"name":"PrescriptionCancelled"}}},"ConsultEventType":{"type":"string","enum":["consult.approved","consult.declined"],"description":"The event type; ignore event types that you do not recognize.","x-enum-varnames":["CONSULT_APPROVED","CONSULT_DECLINED"],"x-fern-enum":{"consult.approved":{"name":"ConsultApproved"},"consult.declined":{"name":"ConsultDeclined"}}},"ConsultMessageEventType":{"type":"string","enum":["consult.message.created","consult.message.updated"],"description":"The event type; ignore event types that you do not recognize.","x-enum-varnames":["CONSULT_MESSAGE_CREATED","CONSULT_MESSAGE_UPDATED"],"x-fern-enum":{"consult.message.created":{"name":"ConsultMessageCreated"},"consult.message.updated":{"name":"ConsultMessageUpdated"}}},"WebhookEndpointTestEventType":{"type":"string","enum":["webhook_endpoint.test"],"description":"The event type; ignore event types that you do not recognize.","x-enum-varnames":["WEBHOOK_ENDPOINT_TEST"],"x-fern-enum":{"webhook_endpoint.test":{"name":"WebhookEndpointTest"}}},"Account":{"type":"object","properties":{"id":{"type":"string","pattern":"^(plat|prac|pharm)_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The public record identifier.","examples":["prac_01j2y8m6jcc9tt24af5pw9x1bc"]},"name":{"type":"string","description":"The name."},"phone":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The contact phone number."},"address":{"anyOf":[{"$ref":"#/components/schemas/Address"},{"type":"null"}],"description":"The US mailing address."},"liveEnabled":{"type":"boolean","description":"Effective Live access. A managed practice requires both its own Live setting and its platform's Live access."},"createdAt":{"type":"string","description":"When the record was created.","format":"date-time"},"mode":{"type":"string","description":"The Test or Live mode selected by the API key.","x-extensible-enum":["test","live"]},"type":{"type":"string","description":"The organization type.","x-extensible-enum":["platform","practice","pharmacy"]}},"required":["id","name","phone","address","liveEnabled","createdAt","mode","type"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"Address":{"type":"object","properties":{"line1":{"type":"string","description":"The street address."},"line2":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The apartment or suite, or null when there is none."},"city":{"type":"string","description":"The city name."},"state":{"type":"string","description":"The two-letter US state code."},"postalCode":{"type":"string","description":"The US ZIP code."}},"required":["line1","line2","city","state","postalCode"],"description":"The US mailing address.","additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"Consult":{"type":"object","properties":{"id":{"type":"string","pattern":"^cns_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The public record identifier.","examples":["cns_01j2y8m6jcc9tt24af5pw9x1bc"]},"status":{"type":"string","description":"waiting until a clinician decides; then approved, with orderId, or declined, with declineReason. Both are final.","x-extensible-enum":["waiting","approved","declined"]},"externalConsultId":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Your consult identifier as filed, or null when none was sent."},"practiceId":{"type":"string","pattern":"^prac_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The practice's public identifier.","examples":["prac_01j2y8m6jcc9tt24af5pw9x1bc"]},"network":{"type":"object","properties":{"name":{"type":"string","description":"The name."}},"required":["name"],"description":"The clinician network that reviews the consult.","additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"patient":{"$ref":"#/components/schemas/ConsultPatient"},"prescriptions":{"type":"array","items":{"$ref":"#/components/schemas/ConsultPrescription"},"description":"The proposed prescriptions, in the order filed."},"patientQuestion":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The patient's question for the clinician, or null when none was sent."},"estimatedTotal":{"type":"integer","minimum":0,"maximum":9007199254740991,"description":"The price in integer cents when the consult was filed. The order an approval creates is what is charged: read its total."},"orderId":{"anyOf":[{"type":"string","pattern":"^ord_[0-7][0-9a-hjkmnp-tv-z]{25}$","examples":["ord_01j2y8m6jcc9tt24af5pw9x1bc"]},{"type":"null"}],"description":"The signed order the approval created, or null until a clinician approves."},"declineReason":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The clinician's reason for declining, or null unless declined."},"changes":{"type":"array","items":{"$ref":"#/components/schemas/ConsultChange"},"description":"What the clinician changed when approving; empty when approved as proposed or not approved."},"patientContact":{"type":"string","description":"Who talks to the patient about the clinician's messages, as filed: affinity (Affinity emails and texts the patient) or platform (your app shows the conversation; Affinity never contacts the patient).","x-extensible-enum":["affinity","platform"]},"patientMessages":{"anyOf":[{"$ref":"#/components/schemas/ConsultPatientMessages"},{"type":"null"}],"description":"That the network has messaged the patient and whose reply it waits on, or null before the first message."},"createdAt":{"type":"string","description":"When the consult was filed.","format":"date-time"},"updatedAt":{"type":"string","description":"When the network last changed the consult: filing, each step of its review (a clinician taking, releasing or handing it off, or waiting on the patient's reply) and the decision. A new message alone does not change it: read patientMessages.","format":"date-time"},"decidedAt":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"description":"When the clinician decided, or null until then."},"intake":{"type":"array","items":{"$ref":"#/components/schemas/ConsultIntakeAnswer"},"description":"The patient's intake answers, word for word. Present when you file or read one consult; absent on list rows."}},"required":["id","status","externalConsultId","practiceId","network","patient","prescriptions","patientQuestion","estimatedTotal","orderId","declineReason","changes","patientContact","patientMessages","createdAt","updatedAt","decidedAt"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"ConsultPatient":{"type":"object","properties":{"address":{"$ref":"#/components/schemas/Address"},"allergies":{"type":"array","items":{"$ref":"#/components/schemas/Allergy"},"description":"The reported allergies; an empty list means no new allergies reported."},"dateOfBirth":{"type":"string","description":"The patient's birth date in YYYY-MM-DD format.","format":"date"},"email":{"type":"string","description":"The patient's email address."},"firstName":{"type":"string","description":"The first name."},"sex":{"type":"string","description":"The patient's sex as sent to the pharmacy.","x-extensible-enum":["female","male","unknown"]},"lastName":{"type":"string","description":"The last name."},"middleName":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The patient's middle name, or null when there is none."},"phone":{"type":"string","description":"The contact phone number."},"externalId":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Your patient identifier as filed, or null when none was sent."},"heightInches":{"type":"number","description":"The patient's height in inches."},"weightPounds":{"type":"number","description":"The patient's weight in pounds."},"smsConsentAt":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"description":"When the patient agreed to receive texts, as filed: null when the consult sent that they have not agreed or withdrew. Absent when the consult did not send it."},"shippingUpdates":{"type":"boolean","description":"Whether to email the patient shipping updates, as filed. Absent when the consult did not send it."}},"required":["address","allergies","dateOfBirth","email","firstName","sex","lastName","middleName","phone","externalId","heightInches","weightPounds"],"description":"The patient as the consult was filed.","additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"Allergy":{"type":"object","properties":{"category":{"type":"string","description":"The allergy category.","x-extensible-enum":["drug","food","insect","latex","mold","pet","pollen"]},"display":{"type":"string","description":"The reported allergy name."}},"required":["category","display"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"ConsultPrescription":{"type":"object","properties":{"medication":{"$ref":"#/components/schemas/ConsultMedication"},"quantity":{"type":"integer","minimum":1,"maximum":9007199254740991,"description":"The proposed quantity in quantityUnit."},"refills":{"type":"integer","minimum":0,"maximum":9007199254740991,"description":"The proposed number of refills after the first fill."},"directions":{"type":"string","description":"The proposed directions for use."},"schedule":{"$ref":"#/components/schemas/TitrationSchedule"}},"required":["medication","quantity","refills","directions"],"description":"A prescription as proposed; changes says what the clinician changed.","additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"ConsultMedication":{"type":"object","properties":{"id":{"type":"string","pattern":"^med_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The medication's public identifier.","examples":["med_01j2y8m6jcc9tt24af5pw9x1bc"]},"name":{"type":"string","description":"The name."},"strength":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The pharmacy's strength text, or null when it is unknown."},"form":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The dosage form, or null when it is unknown."},"quantityUnit":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The unit used to count the prescribed quantity, or null when it is unknown."},"fill":{"anyOf":[{"$ref":"#/components/schemas/Fill"},{"type":"null"}],"description":"What the pharmacy dispenses for one price, or null when the complete fill is unknown."}},"required":["id","name","strength","form","quantityUnit","fill"],"description":"The medication as the catalog described it when the consult was filed.","additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"Fill":{"type":"object","properties":{"amount":{"type":"integer","minimum":1,"maximum":9007199254740991,"description":"How much one fill holds, in `unit`."},"container":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"What holds one fill, such as `vial`. Null when the pharmacy does not say."},"ingredients":{"type":"array","items":{"type":"object","properties":{"amount":{"type":"number","description":"The amount in the specified unit."},"name":{"type":"string","description":"The name."},"unit":{"type":"string","description":"The unit used to measure the amount."}},"required":["amount","name","unit"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"description":"Each active ingredient's total in one fill: a 2 mL vial of 30 mg/mL is 60 mg."},"unit":{"type":"string","description":"The unit of `amount`, the same as `quantityUnit`: `vial` for a vial product."},"volume":{"anyOf":[{"type":"object","properties":{"amount":{"type":"number","description":"The amount in the specified unit."},"unit":{"type":"string","description":"The unit used to measure the amount."}},"required":["amount","unit"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},{"type":"null"}],"description":"What one vial holds, such as 2 mL. Null for a product that is not a vial."}},"required":["amount","container","ingredients","unit","volume"],"description":"What the pharmacy dispenses for one price. A quantity counts `unit`, not fills, and is a whole number of fills: for a fill of 30 tablets, quantity 60 is two fills and costs twice the price. For a vial product, one fill is one vial and quantity counts vials.","additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"TitrationSchedule":{"type":"object","properties":{"step":{"type":"integer","minimum":1,"maximum":9007199254740991,"description":"The step this consult decides, from 1."},"steps":{"type":"array","items":{"$ref":"#/components/schemas/TitrationStep"},"description":"Every step of the schedule, in order."}},"required":["step","steps"],"description":"The titration schedule filed with it. Absent when none was sent.","additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"TitrationStep":{"type":"object","properties":{"dose":{"type":"object","properties":{"amount":{"type":"number","description":"The weekly dose."},"unit":{"type":"string","description":"The dose's unit: mg."}},"required":["amount","unit"],"description":"The weekly dose of this step.","additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"weeks":{"type":"integer","minimum":1,"maximum":9007199254740991,"description":"How many weeks the step lasts. Absent on the last step, which lasts until the clinician changes it (maintenance)."}},"required":["dose"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"ConsultChange":{"type":"object","properties":{"prescription":{"type":"integer","minimum":0,"maximum":9007199254740991,"description":"The prescription's index in prescriptions, from 0."},"field":{"type":"string","description":"The field the clinician changed.","x-extensible-enum":["quantity","refills","directions","compoundingReason"]},"from":{"type":"string","description":"The proposed value, as text: 30 for a quantity. Empty for a compounding reason when none was sent."},"to":{"type":"string","description":"The value the clinician approved, as text. Empty for a compounding reason when the clinician removed it."}},"required":["prescription","field","from","to"],"description":"A change the clinician made when approving; the order holds what was signed.","additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"ConsultPatientMessages":{"type":"object","properties":{"lastMessageAt":{"type":"string","description":"When the newest message was written.","format":"date-time"},"awaiting":{"type":"string","description":"Whose reply the conversation waits on: patient when the network wrote last, network when the patient did.","x-extensible-enum":["patient","network"]}},"required":["lastMessageAt","awaiting"],"description":"That the network has messaged the patient, never what was said or by whom. Null before the first message.","additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"ConsultIntakeAnswer":{"type":"object","properties":{"id":{"type":"string","description":"Your question ID."},"question":{"type":"string","description":"The question exactly as the patient saw it."},"answer":{"type":"string","description":"The patient's answer, word for word."},"critical":{"type":"boolean","description":"Whether you flagged the answer for the clinician."}},"required":["id","question","answer","critical"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"ConsultList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Consult"}},"hasMore":{"type":"boolean"},"nextCursor":{"anyOf":[{"type":"string"},{"type":"null"}]},"object":{"type":"string","enum":["list"]},"url":{"type":"string"}},"required":["data","hasMore","nextCursor","object","url"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"ConsultAttachment":{"type":"object","properties":{"id":{"type":"string","pattern":"^att_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The file's ID.","examples":["att_01j2y8m6jcc9tt24af5pw9x1bc"]},"fileName":{"type":"string","description":"The file's name, as it was uploaded, cleaned."},"contentType":{"type":"string","description":"The file's type.","x-extensible-enum":["image/jpeg","image/png","image/gif","application/pdf"]},"byteSize":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991,"description":"The file's size in bytes."}},"required":["id","fileName","contentType","byteSize"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"ConsultMessage":{"type":"object","properties":{"id":{"type":"string","pattern":"^msg_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The message ID.","examples":["msg_01j2y8m6jcc9tt24af5pw9x1bc"]},"consultId":{"type":"string","pattern":"^cns_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The consult the message is in.","examples":["cns_01j2y8m6jcc9tt24af5pw9x1bc"]},"author":{"type":"string","description":"Who wrote it: clinician (the consult's clinician), care_team (another member of the clinician network) or patient (the messages you post).","x-extensible-enum":["clinician","care_team","patient"]},"authorName":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The writer's name, for the clinician or the care team. Null for the patient, and for a member without a name."},"body":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The text. Empty (\"\") for a message of files only; null once the message was removed."},"attachments":{"type":"array","items":{"$ref":"#/components/schemas/ConsultMessageAttachment"},"description":"The files, in the writer's order. Empty once the message was removed."},"removed":{"type":"boolean","description":"A member of the care team removed the message, which can be the patient's own. Show that it was removed instead of the text you kept."},"createdAt":{"type":"string","description":"When the message was written.","format":"date-time"},"editedAt":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"description":"When its writer last edited it, or null."},"updatedAt":{"type":"string","description":"When the message last changed: written, edited or removed. Of two copies of a message, keep the one with the later updatedAt.","format":"date-time"}},"required":["id","consultId","author","authorName","body","attachments","removed","createdAt","editedAt","updatedAt"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"ConsultMessageAttachment":{"type":"object","properties":{"id":{"type":"string","pattern":"^att_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The file's ID.","examples":["att_01j2y8m6jcc9tt24af5pw9x1bc"]},"fileName":{"type":"string","description":"The file's name, as it was uploaded, cleaned."},"contentType":{"type":"string","description":"The file's type.","x-extensible-enum":["image/jpeg","image/png","image/gif","application/pdf"]},"byteSize":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991,"description":"The file's size in bytes."},"url":{"type":"string","description":"A signed link to the file, without an API key, until urlExpiresAt (5 minutes). Download the file and keep it in your own storage; read the message again for a new link."},"urlExpiresAt":{"type":"string","description":"When url stops working.","format":"date-time"}},"required":["id","fileName","contentType","byteSize","url","urlExpiresAt"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"ConsultMessageList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ConsultMessage"}},"hasMore":{"type":"boolean"},"nextCursor":{"anyOf":[{"type":"string"},{"type":"null"}]},"object":{"type":"string","enum":["list"]},"url":{"type":"string"}},"required":["data","hasMore","nextCursor","object","url"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"ConsultAttachmentUpload":{"type":"object","properties":{"attachment":{"$ref":"#/components/schemas/ConsultAttachment"},"upload":{"$ref":"#/components/schemas/ConsultAttachmentUploadTarget"}},"required":["attachment","upload"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"ConsultAttachmentUploadTarget":{"type":"object","properties":{"method":{"type":"string","enum":["PUT"],"description":"The HTTP method to send the bytes with."},"url":{"type":"string","description":"A signed link that takes the file's bytes, without an API key."},"headers":{"type":"object","additionalProperties":{"type":"string"},"description":"Send exactly these headers with the bytes: Content-Type and Content-Length. The link signs both, so storage refuses a body of another type or length, and a chunked body."},"expiresAt":{"type":"string","description":"When url stops taking the bytes (10 minutes).","format":"date-time"}},"required":["method","url","headers","expiresAt"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"Kit":{"type":"object","properties":{"days":{"type":"integer","minimum":1,"maximum":9007199254740991,"description":"How many days the kit lasts."},"vials":{"type":"array","items":{"type":"object","properties":{"ingredients":{"type":"array","items":{"type":"object","properties":{"amount":{"type":"number","description":"The amount in the specified unit."},"name":{"type":"string","description":"The name."},"unit":{"type":"string","description":"The unit used to measure the amount."}},"required":["amount","name","unit"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"description":"Each active ingredient's total in this vial."},"strength":{"type":"string","description":"This vial's strength, such as 5 mg/mL."}},"required":["ingredients","strength"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"description":"Each vial or bottle in the order it is used. `fill.volume` is what one holds."}},"required":["days","vials"],"description":"Vials or bottles shipped together as one product and used in order.","additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"PharmacyReference":{"type":"object","properties":{"id":{"type":"string","pattern":"^pharm_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The public record identifier.","examples":["pharm_01j2y8m6jcc9tt24af5pw9x1bc"]},"name":{"type":"string","description":"The name."}},"required":["id","name"],"description":"The dispensing pharmacy.","additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"ShippingOption":{"type":"object","properties":{"id":{"type":"string","pattern":"^shp_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"Shared across Test and Live. Old Test shipping IDs remain valid in Test.","examples":["shp_01j2y8m6jcc9tt24af5pw9x1bc"]},"name":{"type":"string","description":"The name."},"price":{"type":"integer","minimum":0,"maximum":9007199254740991,"description":"The price in integer cents."}},"required":["id","name","price"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"Medication":{"type":"object","properties":{"category":{"type":"string","description":"What the medication is prescribed for. Every strength, form and pharmacy of one medication has the same category.","x-extensible-enum":["weight_loss","hormones","sexual_health","hair","skin","wellness","peptides","pain","other","supplies"]},"coldChainRequired":{"type":"boolean","description":"Whether the medication requires refrigerated shipping."},"compoundingReasons":{"type":"array","items":{"type":"string"},"description":"The accepted compounding reasons. A compoundingReason must be one of them; an empty list means the medication takes no reason, so omit compoundingReason."},"defaultDirections":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The catalog's default directions, or null when none are supplied."},"fill":{"anyOf":[{"$ref":"#/components/schemas/Fill"},{"type":"null"}],"description":"What the pharmacy dispenses for one price, or null when the complete fill is unknown."},"form":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The dosage form, or null when it is unknown."},"fullName":{"type":"string","description":"The name with each ingredient: its salt where the catalog records one, such as Enclomiphene Citrate, or the ingredients of a blend named for what prescribers call it, such as Myers' Cocktail. Equals name otherwise."},"id":{"type":"string","pattern":"^med_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The public record identifier.","examples":["med_01j2y8m6jcc9tt24af5pw9x1bc"]},"kit":{"anyOf":[{"$ref":"#/components/schemas/Kit"},{"type":"null"}],"description":"The vials or bottles a kit holds, in the order they are used; null for anything that is not a kit."},"name":{"type":"string","description":"The name."},"pharmacy":{"$ref":"#/components/schemas/PharmacyReference"},"pharmacyRank":{"type":"integer","minimum":0,"maximum":9007199254740991,"description":"Affinity's preference for the dispensing pharmacy, from 0 for the most preferred. When two pharmacies have the same item at the same price, choose the lower rank. Absent when Affinity has no preference for the pharmacy."},"price":{"type":"integer","minimum":0,"maximum":9007199254740991,"description":"The price in integer cents."},"researchUseOnly":{"type":"boolean","description":"Whether the medication is for research use only (RUO). Only an organization with RUO access sees one."},"maxRefills":{"type":["integer","null"],"minimum":0,"maximum":9007199254740991,"description":"The most refills a prescription of this medication takes, or null when any count within the request limits is accepted. 0 means the pharmacy takes no refills: send a new order for each fill."},"quantities":{"type":"array","items":{"type":"integer","minimum":1,"maximum":9007199254740991},"description":"The accepted quantities, counted in quantityUnit; an empty list permits any quantity within the request limits."},"quantityUnit":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The unit used to count the prescribed quantity, or null when it is unknown."},"receivesAllergies":{"type":"boolean","description":"Whether this medication's pharmacy receives the patient's allergies. When false, the pharmacy's API has no field for them, so they never reach it; Affinity still accepts and sends the order. Tell the prescriber before they sign."},"requirements":{"type":"array","items":{"type":"string"},"description":"The optional prescription field paths that this medication requires."},"restrictedStates":{"type":"array","items":{"type":"string"},"description":"Every state where this medication cannot ship, including states the pharmacy does not cover. It can ship to every other state."},"shippingOptions":{"type":"array","items":{"$ref":"#/components/schemas/ShippingOption"},"description":"The shipping options available for this medication."},"shippingSuppliesPrice":{"type":"integer","minimum":0,"maximum":9007199254740991,"description":"Always 0. Each shipping option price is the complete shipping price."},"strength":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The pharmacy's strength text, or null when it is unknown."},"fieldLimits":{"type":"object","properties":{"directions":{"type":"integer","minimum":1,"maximum":9007199254740991,"description":"The maximum character count for directions."},"notes":{"type":"integer","minimum":1,"maximum":9007199254740991,"description":"The maximum character count for notes, including allergies when notesIncludeAllergies is true."},"notesIncludeAllergies":{"type":"boolean","description":"Whether the patient's allergies share the notes field and its character limit."}},"required":["directions","notes"],"description":"Pharmacy-specific character limits for directions and notes. When notesIncludeAllergies is true, notes share their limit with the patient's allergies, composed as the pharmacy receives them. Absent when the ordinary prescription limits apply.","additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"unsupportedFields":{"type":"array","items":{"type":"string","x-extensible-enum":["notes","substitutionPermitted"]},"description":"The prescription fields this medication's pharmacy cannot receive: notes (send none) and substitutionPermitted (send true). An order that sets one is still accepted; in Live mode Affinity staff handle it, and in Test mode it fails when sent. Absent when the pharmacy receives them all."}},"required":["category","coldChainRequired","compoundingReasons","defaultDirections","fill","form","fullName","id","kit","name","pharmacy","price","researchUseOnly","maxRefills","quantities","quantityUnit","receivesAllergies","requirements","restrictedStates","shippingOptions","shippingSuppliesPrice","strength"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"MedicationList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Medication"}},"hasMore":{"type":"boolean"},"nextCursor":{"anyOf":[{"type":"string"},{"type":"null"}]},"object":{"type":"string","enum":["list"]},"url":{"type":"string"}},"required":["data","hasMore","nextCursor","object","url"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"Order":{"type":"object","properties":{"cancelRequestedAt":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"description":"When cancellation was requested, or null when no cancellation is waiting."},"consultId":{"anyOf":[{"type":"string","pattern":"^cns_[0-7][0-9a-hjkmnp-tv-z]{25}$","examples":["cns_01j2y8m6jcc9tt24af5pw9x1bc"]},{"type":"null"}],"description":"The consult whose approval created this order, or null."},"createdAt":{"type":"string","description":"When the record was created.","format":"date-time"},"externalOrderId":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Your order identifier, unique within the practice and mode. A failed or cancelled order keeps it."},"failureReason":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Why the order failed, for a person to read. Null unless the order failed; a refused cancel leaves it null."},"id":{"type":"string","pattern":"^ord_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The public record identifier.","examples":["ord_01j2y8m6jcc9tt24af5pw9x1bc"]},"mode":{"type":"string","description":"The Test or Live mode of this record.","x-extensible-enum":["test","live"]},"patient":{"$ref":"#/components/schemas/Patient"},"patientId":{"type":"string","pattern":"^pat_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The patient's public identifier.","examples":["pat_01j2y8m6jcc9tt24af5pw9x1bc"]},"practice":{"anyOf":[{"type":"object","properties":{"address":{"$ref":"#/components/schemas/Address"},"name":{"type":"string","description":"The name."},"phone":{"type":"string","description":"The contact phone number."},"archivedAt":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"description":"When the practice was archived, or null while it is active."}},"required":["address","name","phone","archivedAt"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},{"type":"null"}],"description":"The practice contact details saved when the order was signed, or null for historical orders without a snapshot."},"practiceId":{"type":"string","pattern":"^prac_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The practice's public identifier.","examples":["prac_01j2y8m6jcc9tt24af5pw9x1bc"]},"prescriber":{"anyOf":[{"type":"object","properties":{"firstName":{"type":"string","description":"The first name."},"lastName":{"type":"string","description":"The last name."},"npi":{"type":"string","description":"The prescribing clinician's 10-digit National Provider Identifier (NPI)."},"phone":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The contact phone number."},"address":{"anyOf":[{"$ref":"#/components/schemas/Address"},{"type":"null"}],"description":"The US mailing address."}},"required":["firstName","lastName","npi","phone","address"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},{"type":"null"}],"description":"The prescribing clinician's details saved when the order was signed."},"prescriptions":{"type":"array","items":{"$ref":"#/components/schemas/Prescription"},"description":"The prescriptions for this order's patient."},"shipping":{"type":"object","properties":{"option":{"anyOf":[{"type":"object","properties":{"id":{"type":"string","pattern":"^shp_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The public record identifier.","examples":["shp_01j2y8m6jcc9tt24af5pw9x1bc"]},"name":{"type":"string","description":"The name."},"price":{"type":"integer","minimum":0,"maximum":9007199254740991,"description":"The shipping price charged, in integer cents."}},"required":["id","name","price"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},{"type":"null"}],"description":"The shipping option saved at signing, or null for historical orders without an option."},"destination":{"$ref":"#/components/schemas/ShippingDestination"}},"required":["option","destination"],"description":"The shipping option and destination.","additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"shipments":{"type":"array","items":{"$ref":"#/components/schemas/Shipment"},"description":"The shipped packages, oldest first; a split shipment or reshipment adds a package."},"status":{"type":"string","description":"The current fulfillment status.","x-extensible-enum":["awaiting_approval","submitted","processing","shipped","delivered","cancelled","failed"]},"trackingUrl":{"anyOf":[{"type":"string","format":"uri"},{"type":"null"}],"description":"The carrier's tracking page for the newest package. Null when there is no package yet or the carrier has no tracking page."},"statusHistory":{"type":"array","items":{"$ref":"#/components/schemas/StatusHistoryEntry"},"description":"The order's status changes, oldest first."},"total":{"type":"integer","minimum":0,"maximum":9007199254740991,"description":"The total order price in integer cents, including medication and shipping."},"updatedAt":{"type":"string","description":"When the record was last updated.","format":"date-time"}},"required":["cancelRequestedAt","consultId","createdAt","externalOrderId","failureReason","id","mode","patient","patientId","practice","practiceId","prescriber","prescriptions","shipping","shipments","status","trackingUrl","statusHistory","total","updatedAt"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"Patient":{"type":"object","properties":{"address":{"$ref":"#/components/schemas/Address"},"allergies":{"type":"array","items":{"$ref":"#/components/schemas/Allergy"},"description":"The reported allergies; an empty list means no new allergies reported."},"dateOfBirth":{"type":"string","description":"The patient's birth date in YYYY-MM-DD format.","format":"date"},"email":{"type":"string","description":"The patient's email address."},"firstName":{"type":"string","description":"The first name."},"sex":{"type":"string","description":"The patient's sex as sent to the pharmacy.","x-extensible-enum":["female","male","unknown"]},"lastName":{"type":"string","description":"The last name."},"middleName":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The patient's middle name, or null when there is none."},"phone":{"type":"string","description":"The contact phone number."}},"required":["address","allergies","dateOfBirth","email","firstName","sex","lastName","middleName","phone"],"description":"The patient details saved when the order was signed.","additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"Prescription":{"type":"object","properties":{"compoundingReason":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The reason for compounding, required when the medication's requirements include it."},"daysSupply":{"type":"integer","minimum":1,"maximum":365,"description":"The number of days the prescribed quantity lasts. Absent when the order sent none."},"directions":{"type":"string","description":"The prescriber's directions for use."},"id":{"type":"string","pattern":"^rx_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The public record identifier.","examples":["rx_01j2y8m6jcc9tt24af5pw9x1bc"]},"pharmacy":{"$ref":"#/components/schemas/PharmacyReference"},"status":{"type":"string","description":"This prescription's status, with the order's values; the order's status sums up its prescriptions'. A pharmacy that accepts or rejects an order as a whole gives every prescription the order's status. One that reports each prescription can ship one and reject another.","x-extensible-enum":["awaiting_approval","submitted","processing","shipped","delivered","cancelled","failed"]},"failureReason":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Why this prescription failed, for a person to read: the order's failureReason when it has the order's status, Affinity's generic rejection text when it alone failed, and null otherwise. A refused cancel leaves it null."},"medication":{"type":"object","properties":{"fill":{"anyOf":[{"$ref":"#/components/schemas/Fill"},{"type":"null"}],"description":"What the pharmacy dispenses for one price, or null when the complete fill is unknown."},"form":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The dosage form, or null when it is unknown."},"id":{"type":"string","pattern":"^med_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The public record identifier.","examples":["med_01j2y8m6jcc9tt24af5pw9x1bc"]},"kit":{"anyOf":[{"$ref":"#/components/schemas/Kit"},{"type":"null"}],"description":"The vials or bottles a kit holds, in the order they are used; null for anything that is not a kit."},"name":{"type":"string","description":"The name."},"quantityUnit":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The unit used to count the prescribed quantity, or null when it is unknown."},"strength":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The pharmacy's strength text, or null when it is unknown."}},"required":["fill","form","id","kit","name","quantityUnit","strength"],"description":"The medication details saved when the order was signed.","additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"notes":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The prescriber's additional notes to the pharmacy."},"price":{"type":"integer","minimum":0,"maximum":9007199254740991,"description":"The prescription's price in integer cents: with a fill, the price per fill times the number of fills."},"quantity":{"type":"integer","minimum":1,"maximum":9007199254740991,"description":"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."},"refills":{"type":"integer","minimum":0,"maximum":9007199254740991,"description":"The number of authorized refills in addition to the first fill."},"substitutionPermitted":{"type":"boolean","description":"Whether the prescriber permits substitution; defaults to true when omitted."}},"required":["compoundingReason","directions","id","pharmacy","status","failureReason","medication","notes","price","quantity","refills","substitutionPermitted"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"ShippingDestination":{"oneOf":[{"$ref":"#/components/schemas/ShippingDestinationPatient"},{"$ref":"#/components/schemas/ShippingDestinationPractice"},{"$ref":"#/components/schemas/ShippingDestinationAddress"}],"description":"The shipping destination; defaults to the patient's address when omitted.","discriminator":{"propertyName":"type","mapping":{"patient":"#/components/schemas/ShippingDestinationPatient","practice":"#/components/schemas/ShippingDestinationPractice","address":"#/components/schemas/ShippingDestinationAddress"}}},"ShippingDestinationPatient":{"type":"object","properties":{"type":{"$ref":"#/components/schemas/ShippingDestinationPatientType"}},"required":["type"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"ShippingDestinationPractice":{"type":"object","properties":{"type":{"$ref":"#/components/schemas/ShippingDestinationPracticeType"}},"required":["type"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"ShippingDestinationAddress":{"type":"object","properties":{"type":{"$ref":"#/components/schemas/ShippingDestinationAddressType"},"address":{"$ref":"#/components/schemas/Address"}},"required":["type","address"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"Shipment":{"type":"object","properties":{"carrier":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The carrier name, or null when it is unknown."},"trackingNumber":{"type":"string","description":"The package tracking number."},"trackingUrl":{"anyOf":[{"type":"string","format":"uri"},{"type":"null"}],"description":"The carrier's tracking page for this package, or null when the carrier has none."}},"required":["carrier","trackingNumber","trackingUrl"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"StatusHistoryEntry":{"type":"object","properties":{"createdAt":{"type":"string","description":"When the record was created.","format":"date-time"},"status":{"type":"string","description":"The current fulfillment status.","x-extensible-enum":["awaiting_approval","submitted","processing","shipped","delivered","cancelled","failed"]}},"required":["createdAt","status"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"OrderList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Order"}},"hasMore":{"type":"boolean"},"nextCursor":{"anyOf":[{"type":"string"},{"type":"null"}]},"object":{"type":"string","enum":["list"]},"url":{"type":"string"}},"required":["data","hasMore","nextCursor","object","url"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"Practice":{"type":"object","properties":{"id":{"type":"string","pattern":"^prac_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The public record identifier.","examples":["prac_01j2y8m6jcc9tt24af5pw9x1bc"]},"name":{"type":"string","description":"The name."},"phone":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"The contact phone number."},"address":{"anyOf":[{"$ref":"#/components/schemas/Address"},{"type":"null"}],"description":"The US mailing address."},"liveEnabled":{"type":"boolean","description":"Effective Live access. A managed practice requires both its own Live setting and its platform's Live access."},"createdAt":{"type":"string","description":"When the record was created.","format":"date-time"},"externalId":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Your practice identifier, unique among your platform's active practices, or null when unset."}},"required":["id","name","phone","address","liveEnabled","createdAt","externalId"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"PracticeList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Practice"}},"hasMore":{"type":"boolean"},"nextCursor":{"anyOf":[{"type":"string"},{"type":"null"}]},"object":{"type":"string","enum":["list"]},"url":{"type":"string"}},"required":["data","hasMore","nextCursor","object","url"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"WebhookEndpointList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/WebhookEndpoint"}},"hasMore":{"type":"boolean"},"nextCursor":{"anyOf":[{"type":"string"},{"type":"null"}]},"object":{"type":"string","enum":["list"]},"url":{"type":"string"}},"required":["data","hasMore","nextCursor","object","url"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"WebhookEndpoint":{"type":"object","properties":{"createdAt":{"type":"string","description":"When the record was created.","format":"date-time"},"updatedAt":{"type":"string","description":"When the record was last updated.","format":"date-time"},"mode":{"type":"string","description":"The Test or Live mode of this record.","x-extensible-enum":["test","live"]},"id":{"type":"string","pattern":"^whe_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The public record identifier.","examples":["whe_01j2y8m6jcc9tt24af5pw9x1bc"]},"url":{"type":"string","description":"The public HTTPS URL that receives webhook events.","format":"uri"}},"required":["createdAt","updatedAt","mode","id","url"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"WebhookEvent":{"oneOf":[{"$ref":"#/components/schemas/OrderEvent"},{"$ref":"#/components/schemas/PrescriptionEvent"},{"$ref":"#/components/schemas/ConsultEvent"},{"$ref":"#/components/schemas/ConsultMessageEvent"},{"$ref":"#/components/schemas/WebhookEndpointTestEvent"}],"discriminator":{"propertyName":"type","mapping":{"order.cancelled":"#/components/schemas/OrderEvent","order.delivered":"#/components/schemas/OrderEvent","order.failed":"#/components/schemas/OrderEvent","order.processing":"#/components/schemas/OrderEvent","order.shipped":"#/components/schemas/OrderEvent","order.submitted":"#/components/schemas/OrderEvent","order.updated":"#/components/schemas/OrderEvent","prescription.failed":"#/components/schemas/PrescriptionEvent","prescription.cancelled":"#/components/schemas/PrescriptionEvent","consult.approved":"#/components/schemas/ConsultEvent","consult.declined":"#/components/schemas/ConsultEvent","consult.message.created":"#/components/schemas/ConsultMessageEvent","consult.message.updated":"#/components/schemas/ConsultMessageEvent","webhook_endpoint.test":"#/components/schemas/WebhookEndpointTestEvent"}}},"OrderEvent":{"type":"object","properties":{"id":{"type":"string","pattern":"^evt_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The event identifier; retries and resends keep the same identifier.","examples":["evt_01j2y8m6jcc9tt24af5pw9x1bc"]},"type":{"$ref":"#/components/schemas/OrderEventType"},"createdAt":{"type":"string","description":"When the event was created.","format":"date-time"},"data":{"type":"object","properties":{"order":{"$ref":"#/components/schemas/WebhookOrder"}},"required":["order"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."},"description":"The event payload."}},"required":["id","type","createdAt","data"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"WebhookOrder":{"type":"object","properties":{"cancelRequestedAt":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"description":"When cancellation was requested, or null when no cancellation is waiting."},"consultId":{"anyOf":[{"type":"string","pattern":"^cns_[0-7][0-9a-hjkmnp-tv-z]{25}$","examples":["cns_01j2y8m6jcc9tt24af5pw9x1bc"]},{"type":"null"}],"description":"The consult whose approval created this order, or null. Absent on an event created before 2026-11-26, including a resend of one."},"externalOrderId":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Your order identifier, unique within the practice and mode. A failed or cancelled order keeps it."},"failureReason":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Why the order failed, for a person to read. Null unless the order failed; a refused cancel leaves it null."},"id":{"type":"string","pattern":"^ord_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The public record identifier.","examples":["ord_01j2y8m6jcc9tt24af5pw9x1bc"]},"shipments":{"type":"array","items":{"$ref":"#/components/schemas/Shipment"},"description":"The shipped packages, oldest first; a split shipment or reshipment adds a package."},"prescriptions":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","pattern":"^rx_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The prescription's public identifier.","examples":["rx_01j2y8m6jcc9tt24af5pw9x1bc"]},"status":{"type":"string","description":"The current fulfillment status.","x-extensible-enum":["awaiting_approval","submitted","processing","shipped","delivered","cancelled","failed"]},"failureReason":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Why the order failed, for a person to read. Null unless the order failed; a refused cancel leaves it null."}},"required":["id","status","failureReason"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"description":"The prescriptions for this order's patient."},"status":{"type":"string","description":"The current fulfillment status.","x-extensible-enum":["awaiting_approval","submitted","processing","shipped","delivered","cancelled","failed"]},"trackingUrl":{"anyOf":[{"type":"string","format":"uri"},{"type":"null"}],"description":"The carrier's tracking page for the newest package. Null when there is no package yet or the carrier has no tracking page."},"updatedAt":{"type":"string","description":"When the record was last updated.","format":"date-time"}},"required":["cancelRequestedAt","externalOrderId","failureReason","id","shipments","prescriptions","status","trackingUrl","updatedAt"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."},"description":"The order's operational details without patient data or prescription clinical details. `failureReason` is always Affinity's own summary; a reason written by Affinity staff is in the order that `GET /v1/orders/{orderId}` returns."},"PrescriptionEvent":{"type":"object","properties":{"id":{"type":"string","pattern":"^evt_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The event identifier; retries and resends keep the same identifier.","examples":["evt_01j2y8m6jcc9tt24af5pw9x1bc"]},"type":{"$ref":"#/components/schemas/PrescriptionEventType"},"createdAt":{"type":"string","description":"When the event was created.","format":"date-time"},"data":{"type":"object","properties":{"order":{"$ref":"#/components/schemas/WebhookOrder"},"prescriptionId":{"type":"string","pattern":"^rx_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The public identifier of the prescription that changed.","examples":["rx_01j2y8m6jcc9tt24af5pw9x1bc"]}},"required":["order","prescriptionId"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."},"description":"The event payload."}},"required":["id","type","createdAt","data"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."},"description":"An event about one prescription of an order. Affinity does not send these yet: no released pharmacy reports a prescription apart from its order. Handle them so that a later release does not break your receiver."},"ConsultEvent":{"type":"object","properties":{"id":{"type":"string","pattern":"^evt_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The event identifier; retries and resends keep the same identifier.","examples":["evt_01j2y8m6jcc9tt24af5pw9x1bc"]},"type":{"$ref":"#/components/schemas/ConsultEventType"},"createdAt":{"type":"string","description":"When the event was created.","format":"date-time"},"data":{"type":"object","properties":{"consult":{"$ref":"#/components/schemas/WebhookConsult"}},"required":["consult"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."},"description":"The event payload."}},"required":["id","type","createdAt","data"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."},"description":"A clinician decided a consult. Each consult sends one of these, once. An approval's order then sends its own order events, which can arrive before this one."},"WebhookConsult":{"type":"object","properties":{"decidedAt":{"type":"string","description":"When the clinician approved or declined the consult.","format":"date-time"},"externalConsultId":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Your consult identifier as filed, or null when none was sent."},"id":{"type":"string","pattern":"^cns_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The consult's public identifier.","examples":["cns_01j2y8m6jcc9tt24af5pw9x1bc"]},"orderId":{"anyOf":[{"type":"string","pattern":"^ord_[0-7][0-9a-hjkmnp-tv-z]{25}$","examples":["ord_01j2y8m6jcc9tt24af5pw9x1bc"]},{"type":"null"}],"description":"The signed order that the approval created, or null when the consult was declined."},"practiceId":{"type":"string","pattern":"^prac_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The practice's public identifier.","examples":["prac_01j2y8m6jcc9tt24af5pw9x1bc"]},"status":{"type":"string","description":"The clinician's decision.","x-extensible-enum":["approved","declined"]}},"required":["decidedAt","externalConsultId","id","orderId","practiceId","status"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."},"description":"The consult's decision without patient data or clinical details. The decline reason and the clinician's changes are in the consult that `GET /v1/consults/{consultId}` returns."},"ConsultMessageEvent":{"type":"object","properties":{"id":{"type":"string","pattern":"^evt_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The event identifier; retries and resends keep the same identifier.","examples":["evt_01j2y8m6jcc9tt24af5pw9x1bc"]},"type":{"$ref":"#/components/schemas/ConsultMessageEventType"},"createdAt":{"type":"string","description":"When the event was created.","format":"date-time"},"data":{"type":"object","properties":{"message":{"$ref":"#/components/schemas/WebhookConsultMessage"}},"required":["message"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."},"description":"The event payload."}},"required":["id","type","createdAt","data"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."},"description":"The care team wrote a message in a consult filed with patientContact platform (consult.message.created), or edited a message or removed one, the patient's too (consult.message.updated). Never sent for the patient's own messages, nor for a consult filed with patientContact affinity."},"WebhookConsultMessage":{"type":"object","properties":{"id":{"type":"string","pattern":"^msg_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The message's public identifier.","examples":["msg_01j2y8m6jcc9tt24af5pw9x1bc"]},"consultId":{"type":"string","pattern":"^cns_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The consult's public identifier.","examples":["cns_01j2y8m6jcc9tt24af5pw9x1bc"]},"externalConsultId":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Your consult identifier as filed, or null when none was sent."},"practiceId":{"type":"string","pattern":"^prac_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The practice's public identifier.","examples":["prac_01j2y8m6jcc9tt24af5pw9x1bc"]}},"required":["id","consultId","externalConsultId","practiceId"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."},"description":"Which message changed, without its text or files. Read the message with `GET /v1/consults/{consultId}/messages/{messageId}`."},"WebhookEndpointTestEvent":{"type":"object","properties":{"id":{"type":"string","pattern":"^evt_[0-7][0-9a-hjkmnp-tv-z]{25}$","description":"The event identifier; retries and resends keep the same identifier.","examples":["evt_01j2y8m6jcc9tt24af5pw9x1bc"]},"type":{"$ref":"#/components/schemas/WebhookEndpointTestEventType"},"createdAt":{"type":"string","description":"When the event was created.","format":"date-time"},"data":{"type":"object","description":"The event payload.","additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}}},"required":["id","type","createdAt","data"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"Problem":{"properties":{"code":{"description":"A stable code for the problem. Branch on it, not on detail.","type":"string"},"detail":{"description":"What went wrong and what to do, for a person to read.","type":"string"},"title":{"description":"A short summary of the problem's type.","type":"string"},"type":{"description":"A URI that names the problem's type.","type":"string"},"issues":{"type":"array","items":{"type":"object","properties":{"code":{"type":"string","description":"A stable code for this field's problem."},"field":{"type":"string","description":"The field as one string, such as `patient.address.state` or `prescriptions[0].quantity`."},"message":{"type":"string","description":"What is wrong with the field and what to send, for a person to read."},"path":{"type":"array","items":{"anyOf":[{"type":"string"},{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}]},"description":"The field as a list of property names and array indexes."}},"required":["code","field","message","path"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"description":"One entry for each field that the request got wrong, when the problem is about fields."},"instance":{"description":"The path of the request.","type":"string"},"requestId":{"description":"Identifies the request, as its X-Request-Id header does. Send it when you report a problem.","type":"string"},"status":{"description":"The HTTP status code of the response.","type":"integer"},"traceId":{"description":"The request trace ID.","type":"string"}},"required":["code","detail","instance","requestId","status","title","type"],"type":"object","additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}},"Problem429":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"data":{"type":"object","properties":{"retryAfterSeconds":{"type":"integer","minimum":1,"maximum":9007199254740991}},"required":["retryAfterSeconds"],"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}}},"type":"object"}]},"Problem409":{"allOf":[{"$ref":"#/components/schemas/Problem"},{"properties":{"data":{"type":"object","properties":{"consultId":{"type":"string","pattern":"^cns_[0-7][0-9a-hjkmnp-tv-z]{25}$","examples":["cns_01j2y8m6jcc9tt24af5pw9x1bc"]},"orderId":{"type":"string","pattern":"^ord_[0-7][0-9a-hjkmnp-tv-z]{25}$","examples":["ord_01j2y8m6jcc9tt24af5pw9x1bc"]},"practiceId":{"type":"string","pattern":"^prac_[0-7][0-9a-hjkmnp-tv-z]{25}$","examples":["prac_01j2y8m6jcc9tt24af5pw9x1bc"]}},"additionalProperties":{"description":"A field that this API version can add. Ignore fields that you do not know."}}},"type":"object"}]}},"securitySchemes":{"apiKey":{"bearerFormat":"sk_test_… or sk_live_…","description":"Send Authorization: Bearer <key> with an active API key from the Affinity dashboard. Test and Live keys act in their mode.","scheme":"bearer","type":"http"}},"headers":{"X-Request-Id":{"description":"Identifies this request. A problem response also returns it as `requestId`.","schema":{"type":"string"}},"X-Affinity-Trace-Id":{"description":"The request trace ID, also returned as traceId in problems.","schema":{"pattern":"^[0-9a-f]{32}$","type":"string"}},"X-Api-Version":{"description":"The resolved API version. Absent when no version resolved.","schema":{"type":"string"}},"Retry-After":{"description":"Seconds to wait before retrying.","schema":{"minimum":1,"type":"integer"}}}},"security":[],"tags":[{"name":"Account","description":"The organization and mode that the API key acts for."},{"name":"Consults","description":"File consults for a network clinician to review, and read their decisions and signed prescriptions."},{"name":"Feedback","description":"Tell Affinity about a wrong or unclear response or page."},{"name":"Medications","description":"The medications a practice can order, with prices and shipping options."},{"name":"Orders","description":"Create, find and cancel orders."},{"name":"Practices","description":"Create, find and update practices."},{"name":"Webhooks","description":"Endpoints that receive signed order and consult events."}],"servers":[{"url":"https://api-staging.affinityrx.com"}]}