Skip to main content

Prescriptions & Treatments

Create checkout sessions for prescriptions or treatments. These endpoints handle prescription validation, checkout creation, and return a checkout URL or draft order for the patient to complete their purchase.

Create Prescription Checkout

Upload one or more signed prescriptions (as base64 PDFs) along with line items and patient data to create a checkout.
POST /v2/public-api/prescriptions/{shop_identifier}
shop_identifier
string
required
Unique identifier for the shop
Required permission: create_prescription_checkout

Request Body

{
  "reserved_draft_order_id": "123",
  "prescriptions": [
    {
      "id": "my-prescription-001",
      "pdf_base64": "JVBERi0xLjQK..."
    }
  ],
  "lines": [
    {
      "sku_uid": "sku-456",
      "quantity": 1,
      "prescription_id": "my-prescription-001"
    }
  ],
  "patient_data": {
    "first_name": "Max",
    "last_name": "Mustermann",
    "date_of_birth": 631152000,
    "gender": "male"
  },
  "buyerIdentity": {
    "email": "max.mustermann@example.com",
    "phone": "+4917612345678",
    "countryCode": "DE",
    "customerAccessToken": "shopify-customer-access-token"
  },
  "checkout_type": "draft_order",
  "prepaid": false,
  "external_order_id": "order-123",
  "delivery": {
    "delivery_type": "pickup",
    "delivery_price": 499
  },
  "transaction": {
    "transaction_id": "txn-123",
    "transaction_amount": 4299
  },
  "billing_address": {
    "first_name": "Max",
    "last_name": "Mustermann",
    "address1": "Hauptstraße 42",
    "city": "Berlin",
    "province": "",
    "country_code": "DE",
    "zip": "10115"
  },
  "shipping_address": {
    "first_name": "Max",
    "last_name": "Mustermann",
    "address1": "Hauptstraße 42",
    "city": "Berlin",
    "province": "",
    "country_code": "DE",
    "zip": "10115"
  }
}
FieldTypeRequiredDescription
reserved_draft_order_idstringNoShopify legacy DraftOrder ID returned by the product reservation endpoint. When present, RxScale updates that draft order instead of creating a new checkout
prescriptionsarrayNoList of prescription objects with id and pdf_base64
prescriptions[].idstringYesYour internal ID for this prescription (used to link line items)
prescriptions[].pdf_base64stringYesBase64-encoded PDF of the signed prescription
linesarrayNoLine items for the checkout
lines[].sku_uidstringYesSKU UID from the product catalog
lines[].quantityintegerYesQuantity to order
lines[].prescription_idstringNoLinks the line item to a prescription by its id
patient_dataobjectYesPatient demographic data
patient_data.first_namestringYesPatient first name
patient_data.last_namestringYesPatient last name
patient_data.date_of_birthintegerYesDate of birth as Unix timestamp
patient_data.genderstringYesPatient gender (male, female, divers)
buyerIdentityobjectConditionalShopify cart buyer identity. Required when checkout_type is draft_order_without_checkout_request; used for checkout_link carts and draft-order checkout requests
buyerIdentity.emailstringNoBuyer email address
buyerIdentity.phonestringNoBuyer phone number
buyerIdentity.countryCodestringNoShopify country code for the buyer
buyerIdentity.customerAccessTokenstringNoShopify Storefront customer access token. When provided with checkout_type: "checkout_link", Shopify associates the cart with the customer’s account
checkout_typestringNoCheckout type: checkout_link, draft_order (default), or draft_order_without_checkout_request
prepaidbooleanNoWhether the order has already been paid externally. Defaults to false and is attached to Shopify order attributes as prepaid=true or prepaid=false. It does not change checkout_type behavior
external_order_idstringNoYour external order identifier. When present, RxScale attaches it to Shopify order attributes as external_order_id
deliveryobjectNoDelivery metadata to attach to the Shopify order attributes
delivery.delivery_typestringNoDelivery type. The store owner maps this value to their own shipping methods
delivery.delivery_priceintegerNoDelivery price to attach to the Shopify order attributes
transactionobjectNoTransaction metadata to attach to the Shopify order attributes
transaction.transaction_idstringNoTransaction identifier to attach to the Shopify order attributes
transaction.transaction_amountintegerNoTransaction amount to attach to the Shopify order attributes
billing_addressobjectNoBilling address attached to the Shopify draft order. Ignored when checkout_type is checkout_link
billing_address.first_namestringNoRecipient first name
billing_address.last_namestringNoRecipient last name
billing_address.address1stringNoSingle-line street address including house number
billing_address.citystringNoCity
billing_address.provincestringNoState, province, or region. Populated for countries like IE; sent as an empty string for countries like DE
billing_address.country_codestringNoISO country code
billing_address.zipstringNoPostal code
shipping_addressobjectNoShipping address attached to the Shopify draft order. Ignored when checkout_type is checkout_link
shipping_address.first_namestringNoRecipient first name
shipping_address.last_namestringNoRecipient last name
shipping_address.address1stringNoSingle-line street address including house number
shipping_address.citystringNoCity
shipping_address.provincestringNoState, province, or region. Populated for countries like IE; sent as an empty string for countries like DE
shipping_address.country_codestringNoISO country code
shipping_address.zipstringNoPostal code
buyerIdentity.customerAccessToken only applies when checkout_type is checkout_link, because Shopify uses it on Storefront carts. It does not attach a customer account to Shopify draft orders.
Send buyerIdentity when using checkout_type: "draft_order_without_checkout_request". RxScale rejects the request without it because no Shopify checkout request is sent to collect customer details later.

Checkout Types

The checkout_type field controls how the order is created in Shopify:
ValueDescription
draft_orderCreates a Shopify draft order and sends a checkout request to the customer (default)
checkout_linkReturns a Shopify checkout link for the customer to complete payment directly
draft_order_without_checkout_requestCreates a Shopify draft order without sending a checkout request to the customer. Requires buyerIdentity because customer details are not collected through a Shopify checkout request
If reserved_draft_order_id is present, checkout_type is ignored. RxScale stores the signed prescriptions and adds _prescription_uid metadata to the matching reserved draft-order line items. Matching is based on the Shopify variant resolved from sku_uid; duplicate sku_uid values are rejected because they are ambiguous. The reserved draft order must belong to the telemedicine provider linked to the API key.

Example Request

curl -X POST "https://api.rxscale.com/v2/public-api/prescriptions/my-shop" \
  -H "X-API-Key: your-api-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "reserved_draft_order_id": "123",
    "prescriptions": [
      {
        "id": "rx-001",
        "pdf_base64": "JVBERi0xLjQK..."
      }
    ],
    "lines": [
      {
        "sku_uid": "sku-456",
        "quantity": 1,
        "prescription_id": "rx-001"
      }
    ],
    "patient_data": {
      "first_name": "Max",
      "last_name": "Mustermann",
      "date_of_birth": 631152000,
      "gender": "male"
    },
    "buyerIdentity": {
      "email": "max.mustermann@example.com",
      "phone": "+4917612345678",
      "countryCode": "DE",
      "customerAccessToken": "shopify-customer-access-token"
    },
    "prepaid": false,
    "external_order_id": "order-123",
    "delivery": {
      "delivery_type": "pickup",
      "delivery_price": 499
    },
    "transaction": {
      "transaction_id": "txn-123",
      "transaction_amount": 4299
    },
    "billing_address": {
      "first_name": "Max",
      "last_name": "Mustermann",
      "address1": "Hauptstraße 42",
      "city": "Berlin",
      "province": "",
      "country_code": "DE",
      "zip": "10115"
    },
    "shipping_address": {
      "first_name": "Max",
      "last_name": "Mustermann",
      "address1": "Hauptstraße 42",
      "city": "Berlin",
      "province": "",
      "country_code": "DE",
      "zip": "10115"
    }
  }'

Response

{
  "status": "success",
  "prescriptions": [
    {
      "id": "rx-001",
      "prescription_uid": "px-abc123"
    }
  ]
}
The response maps your prescription IDs to the RxScale prescription UIDs. Use these UIDs to query order status via the Orders endpoint. When reserved_draft_order_id is used, no new checkout or draft order is created. The existing reserved draft order is updated and can continue through the normal Shopify order and fulfillment process after payment.

Create Treatment Checkout

Create a checkout for treatment-based orders (no prescription required).
POST /v2/public-api/treatments/{shop_identifier}
shop_identifier
string
required
Unique identifier for the shop
Required permission: create_treatment_checkout

Request Body

{
  "lines": [
    {
      "sku_uid": "sku-789",
      "quantity": 1,
      "anamnesis_id": "anam-001"
    }
  ],
  "buyerIdentity": {
    "email": "max.mustermann@example.com",
    "phone": "+4917612345678",
    "countryCode": "DE",
    "customerAccessToken": "shopify-customer-access-token"
  },
  "checkout_type": "draft_order"
}
FieldTypeRequiredDescription
linesarrayYesLine items for the checkout
lines[].sku_uidstringYesSKU UID from the product catalog
lines[].quantityintegerYesQuantity to order
lines[].anamnesis_idstringNoAnamnesis ID for linking to a patient questionnaire
buyerIdentityobjectConditionalShopify cart buyer identity. Required when checkout_type is draft_order_without_checkout_request; used for checkout_link carts and draft-order checkout requests
buyerIdentity.emailstringNoBuyer email address
buyerIdentity.phonestringNoBuyer phone number
buyerIdentity.countryCodestringNoShopify country code for the buyer
buyerIdentity.customerAccessTokenstringNoShopify Storefront customer access token. When provided with checkout_type: "checkout_link", Shopify associates the cart with the customer’s account
checkout_typestringNoCheckout type: checkout_link, draft_order (default), or draft_order_without_checkout_request
buyerIdentity.customerAccessToken only applies when checkout_type is checkout_link, because Shopify uses it on Storefront carts. It does not attach a customer account to Shopify draft orders.
Send buyerIdentity when using checkout_type: "draft_order_without_checkout_request". RxScale rejects the request without it because no Shopify checkout request is sent to collect customer details later.
See Checkout Types above for details on each option.

Example Request

curl -X POST "https://api.rxscale.com/v2/public-api/treatments/my-shop" \
  -H "X-API-Key: your-api-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "lines": [
      {
        "sku_uid": "sku-789",
        "quantity": 1
      }
    ],
    "buyerIdentity": {
      "email": "max.mustermann@example.com",
      "phone": "+4917612345678",
      "countryCode": "DE",
      "customerAccessToken": "shopify-customer-access-token"
    }
  }'

Response

{
  "status": "success",
  "checkout_url": "https://shop.example.com/checkout/abc123"
}