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

# Create a new electronic prescription

> Deliver an electronic prescription to Blend either in SCRIPT XML or JSON.



## OpenAPI

````yaml /openapi-public.yml post /api/v1/prescriptions/electronic_prescriptions
openapi: 3.0.3
info:
  title: Blend API
  version: 1.0.0
  description: API for Blend
servers:
  - url: https://api.byblend.com
    description: Blend production server
security:
  - bearerAuth: []
tags:
  - name: Orders
    description: Order management endpoints
  - name: Patients
    description: Patient management endpoints
  - name: Reports
    description: Reporting endpoints
  - name: Products and Materials
    description: Product catalog and inventory endpoints
  - name: Electronic Prescriptions
    description: Electronic prescription management endpoints
  - name: Authentication
    description: Authentication endpoints
  - name: Notifications
    description: User management endpoints
  - name: Prescribers
paths:
  /api/v1/prescriptions/electronic_prescriptions:
    post:
      tags:
        - Electronic Prescriptions
      summary: Create a new electronic prescription
      description: >-
        Deliver an electronic prescription to Blend either in SCRIPT XML or
        JSON.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ElectronicPrescriptionCreate'
          application/xml:
            schema:
              type: string
              format: xml
              description: >-
                NCPDP SCRIPT standard XML format for electronic prescriptions.
                For complete specification, see NCPDP SCRIPT Implementation
                Guide.
                https://www.ncpdp.org/NCPDP/media/pdf/SCRIPT-Implementation-Guide.pdf
          text/xml:
            schema:
              type: string
              format: xml
              description: >-
                NCPDP SCRIPT standard XML format for electronic prescriptions.
                For complete specification, see NCPDP SCRIPT Implementation
                Guide.
                https://www.ncpdp.org/NCPDP/media/pdf/SCRIPT-Implementation-Guide.pdf
      responses:
        '200':
          description: Successful response with electronic prescription
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ElectronicPrescription'
      externalDocs:
        description: NCPDP SCRIPT Implementation Guide
        url: https://www.ncpdp.org/NCPDP/media/pdf/SCRIPT-Implementation-Guide.pdf
components:
  schemas:
    ElectronicPrescriptionCreate:
      type: object
      description: By default, electronic prescriptions reference existing Blend patients.
      properties:
        medication:
          $ref: '#/components/schemas/ElectronicPrescriptionProduct'
          type: object
          description: >-
            A single medication prescribed. If you need to prescribe multiple
            medications, use the `medications` array instead. One of
            `medication` or `medications` is required.
        medications:
          type: array
          description: >-
            An array of medications prescribed. One of `medication` or
            `medications` is required.
          items:
            $ref: '#/components/schemas/ElectronicPrescriptionProduct'
        order:
          type: object
          description: >-
            An order can be created before or after a prescription is submitted.
            If created in advance, you may supply the order ID in your
            prescription.
          properties:
            id:
              type: string
              description: Blend ID of the created order
            order_number:
              type: string
              description: >-
                Alternatively you can provide the Blend order number to identify
                an existing order.
        patient:
          oneOf:
            - $ref: '#/components/schemas/PatientCreate'
            - $ref: '#/components/schemas/OrderPatientReferenceID'
            - $ref: '#/components/schemas/OrderPatientReferenceExternalID'
          description: >-
            A patient object. If you pass new patient data, a new patient will
            be created. Or you may reference an existing patient by `id` or
            `external_id`.
        prescriber:
          $ref: '#/components/schemas/ElectronicPrescriptionPrescriberCreate'
          type: object
          description: Reference to an already-created Blend prescriber.
      required:
        - patient
        - prescriber
        - medication
        - medications
    ElectronicPrescription:
      allOf:
        - $ref: '#/components/schemas/ID'
        - $ref: '#/components/schemas/Timestamps'
        - type: object
          properties:
            customer_id:
              type: string
              example: b658f16f-819c-4503-aede-bd555fc4ebfb
              description: >-
                Once identified, Blend ID of the customer associated with the
                patient
            patient_id:
              type: string
              description: Once identified, Blend ID of the patient
            prescriber_id:
              type: string
              description: Once identified, Blend ID of the prescriber
            source:
              type: string
              example: api_json
              description: Source of the prescription, e.g. `api_json`
            type:
              type: string
              example: NewRx
              description: Type of electronic prescription, e.g. `NewRx`
            medications:
              type: array
              description: Individual medication details from the electronic prescription
              items:
                $ref: '#/components/schemas/Prescription'
            reference_number:
              type: string
              description: As imported directly from electronic prescription XML
    ElectronicPrescriptionProduct:
      type: object
      properties:
        days_supply:
          type: integer
          example: 30
        description:
          type: string
          description: Equivalent to the SCRIPT `DrugDescription` field.
        drug_name:
          type: string
          example: Levothyroxine
        ndc:
          type: string
          example: '12345678901'
          description: If you wish to supply it, NDC code of a commercial medication.
        notes:
          type: string
          description: Any prescriber notes regarding the patient
        prescription_product_id:
          type: string
          example: 0227d1e5-ba9a-42b5-8fe2-38882aa65708
          description: >-
            Blend prescription product UUID for the prescribed product. One of
            `prescription_product_id` or `product_code` is required.
        product_code:
          type: string
          example: HC-RAPA31
          description: >-
            If you have provided a product code in your prescription products
            wihtin Blend, you may reference it in lieu of the Blend UUID.
        quantity:
          type: integer
          example: 30
        refills:
          type: integer
          example: 4
          description: Number of refills allowed
        sig:
          type: string
        substitution_allowed:
          type: boolean
        units:
          type: string
          example: C48480
          description: >-
            ID of the allowed quantity unit of measure. Please see the
            `/prescriptions/quantity_units` endpoint for allowed values.
        written_at:
          format: date-time
          description: Date the prescription was written
          example: '2025-04-25T00:00:00'
      required:
        - days_supply
        - drug_name
        - prescription_product_id
        - product_code
        - refills
        - quantity
        - written_at
        - sig
        - units
    PatientCreate:
      title: New Patient
      allOf:
        - $ref: '#/components/schemas/PatientCreateUpdateBase'
      required:
        - first_name
        - last_name
        - email
        - phone
        - date_of_birth
        - address
    OrderPatientReferenceID:
      type: object
      title: ID
      properties:
        id:
          type: string
          format: uuid
          example: 0227d1e5-ba9a-42b5-8fe2-38882aa65708
          description: Blend ID of an existing patient to associate.
    OrderPatientReferenceExternalID:
      type: object
      title: External ID
      properties:
        external_id:
          type: string
          example: '1234567890'
          description: External (your own) ID for an existing patient.
    ElectronicPrescriptionPrescriberCreate:
      type: object
      properties:
        id:
          type: string
          example: 0227d1e5-ba9a-42b5-8fe2-38882aa65708
          description: Blend UUID of the prescriber
      required:
        - id
    ID:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier
          example: 0227d1e5-ba9a-42b5-8fe2-38882aa65708
    Timestamps:
      type: object
      properties:
        created_at:
          type: string
          format: date-time
          description: Date and time of creation
          example: '2025-03-15T12:00:00Z'
        updated_at:
          type: string
          format: date-time
          description: Date and time of last update
          example: '2025-03-15T12:00:00Z'
    Prescription:
      allOf:
        - $ref: '#/components/schemas/ID'
        - type: object
          properties:
            customer_id:
              type: string
              description: >-
                Once identified, Blend ID of the customer associated with the
                patient
              format: uuid
              example: b658f16f-819c-4503-aede-bd555fc4ebfb
            electronic_prescription_id:
              type: string
              format: uuid
              example: b658f16f-819c-4503-aede-bd555fc4ebfb
              description: Blend ID of the containing electronic prescription
        - $ref: '#/components/schemas/PrescriptionCreateUpdate'
    PatientCreateUpdateBase:
      type: object
      allOf:
        - $ref: '#/components/schemas/PatientBase'
        - type: object
          properties:
            risk_factors:
              type: object
              description: >-
                Raw text risk factors for the patient. These will be parsed and
                automatically matched to standardized risk factors. Please
                delimit with commas, semi-colons, or slashes. Discrete risk
                factors can be added using the dedicated endpoints.
              properties:
                allergies:
                  type: string
                  example: peanuts, tree nuts, shellfish
                conditions:
                  type: string
                  example: asthma, hypertension
                medications:
                  type: string
                  example: albuterol, levothyroxine
    PrescriptionCreateUpdate:
      allOf:
        - $ref: '#/components/schemas/ID'
        - type: object
          properties:
            patient_id:
              type: string
              description: Once identified, Blend ID of the patient
            prescriber_id:
              type: string
              description: Once identified, Blend ID of the prescriber
            prescription_product_id:
              type: string
              description: Once identified, Blend ID of the prescription product
            days_supply:
              type: number
              description: Days supply of the prescription product
              example: 30
            description:
              type: string
              description: >-
                Description of the prescription product as imported directly
                from electronic prescription XML
            directions:
              type: string
              description: Parsed sig
            drug_name:
              type: string
              description: Name of the drug as provided in the electronic prescription XML
            expires_at:
              type: string
              format: date
              description: Date the prescription expires
              example: '2026-04-25T00:00:00'
            fills_remaining:
              type: number
              description: >-
                Total number of fills remaining. Upon initial receipt, this will
                include initial fill quantity plus any refills.
              example: 3
            transfer_fills:
              type: number
              description: Number of fills completed before transfer
              example: 0
            name:
              type: string
              description: >-
                Name of the Blend prescription product as imported from the
                assciated prescription_product
              example: Topical Rapamycin
            notes:
              type: string
              description: Notes as imported directly from electronic prescription XML
              example: Please dispense 30 days supply
            product_code:
              type: string
              description: >-
                Product code of the prescription product as imported directly
                from electronic prescription XML
            product_code_type:
              type: string
              description: >-
                Type of product code as imported directly from electronic
                prescription XML
            quantity:
              type: number
              description: Quantity of the prescription product to dispense
              example: 30
            refills:
              type: number
              description: Number of refills as ordered by the prescriber
              example: 2
            serial_number:
              type: string
              description: Blend-generated serial number of the prescription product
              example: '100721'
            sig:
              type: string
              description: >-
                Original sig as imported directly from electronic prescription
                XML
            status:
              type: string
              description: Status of the prescription in Blend workflow
              example: new
            strength:
              type: string
              description: >-
                Strength of the prescription product as imported directly from
                electronic prescription XML
            substitution_allowed:
              type: boolean
              description: Whether the prescription product can be substituted
              example: true
            units:
              type: string
              description: >-
                Units of measure; adheres to NCPDP QuantityUnitOfMeasure
                terminology code
              example: C48480
            written_at:
              type: string
              format: date-time
              description: Date and time the prescription was written
              example: '2025-04-25T00:00:00'
    PatientBase:
      type: object
      properties:
        first_name:
          type: string
          example: Willard
        middle_name:
          type: string
          example: Moises
        last_name:
          type: string
          example: Donnelly
        gender:
          type: string
          enum:
            - male
            - female
          example: male
          description: Gender of the patient
        email:
          type: string
          example: Harmon43@gmail.com
        phone:
          type: string
          description: 10-digit phone number without formatting, e.g. 6417383445
          example: '6417383445'
        date_of_birth:
          type: string
          format: date
          example: '1990-01-01'
        driver_license_number:
          type: string
          example: B49188319
        driver_license_state:
          type: string
          example: CA
        ssn:
          type: string
          example: '123456789'
          description: Social Security number. Can be provided with or without hyphens.
        primary_language:
          type: string
          description: ISO 639-1 language code
          example: en
        guardian_name:
          type: string
          description: Name of the patient's guardian. Required if patient is a minor.
          example: John Guardian
        guardian_phone:
          type: string
          example: '6417383445'
        guardian_email:
          type: string
          example: parent@example.com
        guardian_relationship:
          type: string
          description: >-
            Relationship of the guardian to the patient. See relationship types
            lookup for available values; most common are `parent` and
            `legal_guardian`; and `other` can be used.
          example: parent
        height_inches:
          type: integer
          example: 72
          description: Height of the patient in inches
        weight_pounds:
          type: integer
          example: 180
          description: Weight of the patient in pounds
        external_id:
          type: string
          example: '1234567890'
          description: >-
            External (your own) ID for the patient, to be used for prescription
            matching
        is_smoker:
          type: boolean
          example: false
          description: Whether the patient is a smoker
        is_diabetic:
          type: boolean
          example: false
          description: Whether the patient is diabetic
        is_pregnant:
          type: boolean
          example: false
          description: Whether the patient is pregnant
        receive_sms:
          type: boolean
          example: true
          description: >-
            Whether the patient should receive SMS notifications for shipments.
            This is only applicable if you have authorized Blend to send patient
            communications on your behalf.
        receive_email:
          type: boolean
          example: true
          description: >-
            Whether the patient should receive email notifications for
            shipments. This is only applicable if you have authorized Blend to
            send patient communications on your behalf.
        address:
          $ref: '#/components/schemas/AddressCreate'
    AddressCreate:
      type: object
      required:
        - address_1
        - city
        - state
        - zip_code
      properties:
        address_1:
          type: string
          example: 140 Lindgren Streets
        address_2:
          type: string
          example: Apt 227
        city:
          type: string
          example: North Consueloburgh
        state:
          type: string
          description: Two-letter state abbreviation
          example: CA
        country:
          type: string
          description: Two-letter country code, defaults to US
          example: US
        zip_code:
          type: string
          description: 5-digit ZIP code or 9-digit ZIP+4 code, e.g. 02108 or 02108-1234.
          example: '02108'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````