> ## Documentation Index
> Fetch the complete documentation index at: https://api.vitarelay.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Place an order for your own patient

> Creates an order for any mix of R&D, 503B, and 503A products. For each 503A (patient-specific)
line, VitaRelay records an external-source **signed** prescription whose prescriber
identity is resolved from your roster by `prescriber_npi`.

A controlled substance requires the prescriber to have a DEA on file for the
patient's state; otherwise 422 `controlled_requires_dea`. Prescriber identity
(name/DEA/license) is derived from your roster by NPI, never from the body.

The patient must belong to your practice; any other patient returns 404.
`external_order_id` is an idempotency key — replaying a request with the same key
returns the original order with `idempotent_replay: true` (HTTP 200).

Test keys return a simulated sandbox response and create no real rows.

**Scope required:** `orders:write`.




## OpenAPI

````yaml /practice-api/openapi.yaml post /orders
openapi: 3.0.3
info:
  title: VitaRelay Practice API
  version: 1.0.0
  description: >
    The Practice API is for provider practices that prescribe with their OWN
    licensed

    prescribers (NPI/DEA/license on file with VitaRelay). VitaRelay is logistics
    and

    fulfillment only — your own provider is the prescriber of record.


    No cost, pharmacy, margin, or price data is ever exposed through this API.
servers:
  - url: https://vitarelay.com/api/public/practice/v1
security:
  - bearerAuth: []
tags:
  - name: Catalog
    description: Unified 503A / 503B / R&D catalog (no pricing).
  - name: Orders
    description: Place and track orders for your own patients.
  - name: Prescribers
    description: >-
      Manage your practice's prescriber roster. NPI and DEA are validated by
      format and checksum only — this is not a NPPES or DEA registry lookup. DEA
      numbers are always masked in responses.
paths:
  /orders:
    post:
      tags:
        - Orders
      summary: Place an order for your own patient
      description: >
        Creates an order for any mix of R&D, 503B, and 503A products. For each
        503A (patient-specific)

        line, VitaRelay records an external-source **signed** prescription whose
        prescriber

        identity is resolved from your roster by `prescriber_npi`.


        A controlled substance requires the prescriber to have a DEA on file for
        the

        patient's state; otherwise 422 `controlled_requires_dea`. Prescriber
        identity

        (name/DEA/license) is derived from your roster by NPI, never from the
        body.


        The patient must belong to your practice; any other patient returns 404.

        `external_order_id` is an idempotency key — replaying a request with the
        same key

        returns the original order with `idempotent_replay: true` (HTTP 200).


        Test keys return a simulated sandbox response and create no real rows.


        **Scope required:** `orders:write`.
      operationId: createOrder
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateOrderRequest'
            examples:
              office_stock_503b:
                summary: 503B office-stock order (no prescriber, no prescriptions)
                description: >-
                  Bulk office-use compounded product shipped to the practice. No
                  prescriber_npi and no prescriptions[] are required for 503B.
                value:
                  patient_id: b3f1c2a4-0000-0000-0000-000000000001
                  items:
                    - platform_product_id: 8a1e6b90-503b-4b00-9000-000000000abc
                      quantity: 2
                  shipping_destination_type: practice_office
                  shipping_address:
                    name: Vital Glow — Men's and Women's Health
                    line1: 1494 Lake Murray Boulevard STE A
                    city: Columbia
                    state: SC
                    postal_code: '29212'
                    country: US
                  external_order_id: po-2026-0042
              rx_503a:
                summary: >-
                  503A patient-specific Rx order (prescriber + prescription
                  line)
                description: >-
                  Patient-specific compounded prescription. Requires
                  prescriber_npi (resolved against your roster) and one
                  prescriptions[] line per 503A product. Controlled substances
                  additionally require the prescriber to have a DEA on file for
                  the patient's state.
                value:
                  patient_id: b3f1c2a4-0000-0000-0000-000000000002
                  prescriber_npi: '1629850987'
                  items:
                    - platform_product_id: 7c2d5e10-503a-4a00-9000-000000000def
                      quantity: 1
                  prescriptions:
                    - platform_product_id: 7c2d5e10-503a-4a00-9000-000000000def
                      drug_name: Testosterone Cypionate
                      strength: 200mg/mL
                      dosage_form: injectable
                      sig: Inject 0.5 mL IM weekly
                      quantity: 10
                      quantity_unit: mL
                      days_supply: 140
                      refills_authorized: 3
                      diagnosis_code: E29.1
                  shipping_destination_type: patient_direct
                  shipping_address:
                    name: John Patient
                    line1: 22 Elm St
                    city: Columbia
                    state: SC
                    postal_code: '29201'
                    country: US
                  external_order_id: rx-2026-0043
      responses:
        '200':
          description: Idempotent replay — the original order returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateOrderResponse'
        '201':
          description: Order created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateOrderResponse'
        '400':
          $ref: '#/components/responses/Error'
        '401':
          $ref: '#/components/responses/Error'
        '403':
          $ref: '#/components/responses/Error'
        '404':
          $ref: '#/components/responses/Error'
        '422':
          description: >
            Validation or prescriber failure. Possible `error.code` values:


            - `validation_failed` — body failed schema validation.

            - `prescriber_required` — `prescriber_npi` missing while the cart
            contains a 503A (patient-specific) product. 503B office-stock and
            R&D do not require it.

            - `prescriber_not_found` — NPI is not a registered prescriber on
            your roster.

            - `controlled_requires_dea` — a controlled-substance line lacks a
            resolved DEA.

            - `prescriptions_required` — a `prescriptions` line is missing for a
            503A (patient-specific) product. 503B office-stock does not use
            prescription lines.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          $ref: '#/components/responses/Error'
components:
  schemas:
    CreateOrderRequest:
      type: object
      additionalProperties: false
      properties:
        patient_id:
          type: string
          format: uuid
          description: Your own patient. Either this or external_patient_id is required.
        external_patient_id:
          type: string
          description: >-
            Your system's patient identifier (used when the patient was created
            via API).
        prescriber_npi:
          type: string
          pattern: ^[0-9]{10}$
          description: >-
            Required only when the cart contains a 503A (patient-specific)
            product. Not needed for 503B office-stock or R&D orders.
        items:
          type: array
          minItems: 1
          maxItems: 50
          items:
            $ref: '#/components/schemas/OrderItem'
        prescriptions:
          type: array
          items:
            $ref: '#/components/schemas/PrescriptionLine'
          description: >-
            One line per 503A (patient-specific) product ordered. Not used for
            503B office-stock or R&D.
        shipping_destination_type:
          type: string
          enum:
            - practice_office
            - patient_direct
            - distributor_office
        shipping_address:
          $ref: '#/components/schemas/ShippingAddress'
        external_order_id:
          type: string
          description: Idempotency key. Replays return the original order.
      required:
        - items
        - shipping_destination_type
        - shipping_address
    CreateOrderResponse:
      type: object
      properties:
        data:
          type: object
          properties:
            order_id:
              type: string
            order_number:
              type: string
            status:
              type: string
            escripts_created:
              type: integer
            sandbox:
              type: boolean
            idempotent_replay:
              type: boolean
              description: Present and true on idempotent replays (HTTP 200).
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
            message:
              type: string
    OrderItem:
      type: object
      properties:
        platform_product_id:
          type: string
          format: uuid
        quantity:
          type: integer
          minimum: 1
          maximum: 999
      required:
        - platform_product_id
        - quantity
    PrescriptionLine:
      type: object
      description: >-
        One line per 503A (patient-specific) product in the order — your own
        script, written in your EMR. 503B office-stock does not use prescription
        lines.
      properties:
        platform_product_id:
          type: string
          format: uuid
        drug_name:
          type: string
        strength:
          type: string
        dosage_form:
          type: string
        sig:
          type: string
        quantity:
          type: number
        quantity_unit:
          type: string
        days_supply:
          type: integer
        refills_authorized:
          type: integer
        diagnosis_code:
          type: string
        notes:
          type: string
      required:
        - platform_product_id
        - drug_name
    ShippingAddress:
      type: object
      properties:
        name:
          type: string
        line1:
          type: string
        line2:
          type: string
        city:
          type: string
        state:
          type: string
        postal_code:
          type: string
        country:
          type: string
          description: 2-letter country code
          minLength: 2
          maxLength: 2
      required:
        - name
        - line1
        - city
        - state
        - postal_code
        - country
  responses:
    Error:
      description: Error envelope.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Practice API key (`vr_live_...` or `vr_test_...`).

````