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

# Create Order

> 
### Overview

This API places a **medicine order** for an IPD admission of your workspace. The order is sent to a pharmacy provider: `evital` (an external pharmacy on eVital) or `dawakhana` (your in-house pharmacy).

**Choosing the provider:** pass `provider` to pick one. When it is omitted, the order goes to eVital if eVital is set up for your workspace, otherwise to Dawakhana; if neither is set up the request fails with `400`.

**eVital orders** require `pharmacyId` (the `id` of a pharmacy from the pharmacies list). Each item's `quantity` must already be in that pharmacy's order unit (loose or strip), and items are matched by `medicine_id`.

**Dawakhana orders** get a server-generated `orderNumber`. An item's `name` is used as the line name (falling back to `medicine_id`).

The order starts in status `CREATED`. The user making the request is recorded in `createdBy` and `createdByName`. Fields not listed in the request body are rejected.



## OpenAPI

````yaml post /ipd/v1/service/orders
openapi: 3.0.0
info:
  title: Ekacare API & Webhook Documentation
  contact: {}
  version: '1.0'
servers:
  - description: Production
    url: https://api.eka.care
  - description: Stage/Sandbox
    url: https://api.dev.eka.care
security: []
paths:
  /ipd/v1/service/orders:
    post:
      tags:
        - IPD API
      summary: Create Order
      description: >-

        ### Overview


        This API places a **medicine order** for an IPD admission of your
        workspace. The order is sent to a pharmacy provider: `evital` (an
        external pharmacy on eVital) or `dawakhana` (your in-house pharmacy).


        **Choosing the provider:** pass `provider` to pick one. When it is
        omitted, the order goes to eVital if eVital is set up for your
        workspace, otherwise to Dawakhana; if neither is set up the request
        fails with `400`.


        **eVital orders** require `pharmacyId` (the `id` of a pharmacy from the
        pharmacies list). Each item's `quantity` must already be in that
        pharmacy's order unit (loose or strip), and items are matched by
        `medicine_id`.


        **Dawakhana orders** get a server-generated `orderNumber`. An item's
        `name` is used as the line name (falling back to `medicine_id`).


        The order starts in status `CREATED`. The user making the request is
        recorded in `createdBy` and `createdByName`. Fields not listed in the
        request body are rejected.
      operationId: CreateIpdOrder
      parameters:
        - name: auth
          in: header
          required: true
          schema:
            type: string
          example: >-
            eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJiX2lkIjoiMTIzNDU2IiwiY2xpZW50X2lkIjoiNzg5MCIsImV4dHJhX2ZpZWxkIjoiZXh0cmFfZmllbGRfZGF0YSJ9.q9KzBI6f4l3OyM_EkB5Quq0l9EEMFh5JS-fx3F_PHUM
      requestBody:
        description: The order to place.
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required:
                - admissionId
                - items
              properties:
                admissionId:
                  type: string
                  description: >-
                    Id of the IPD admission the order is for (a UUID or a
                    24-character hex id).
                ipd_id:
                  type: string
                  description: Patient IPD case number.
                rxId:
                  type: string
                  description: Id of the prescription the order is based on.
                rxPdfUrl:
                  type: string
                  description: URL of the prescription PDF.
                provider:
                  type: string
                  enum:
                    - evital
                    - dawakhana
                  description: >-
                    Pharmacy provider to send the order to. See the overview for
                    the default.
                pharmacyId:
                  type: string
                  description: >-
                    Id of the pharmacy to fulfil the order. Required for
                    `evital` orders.
                patient_id:
                  type: string
                  description: Id of the patient.
                patient_name:
                  type: string
                  description: Name of the patient.
                mobile:
                  type: string
                  description: Mobile number of the patient.
                doctor_name:
                  type: string
                  description: Name of the prescribing doctor.
                delivery_type:
                  type: string
                  enum:
                    - pickup
                    - delivery
                  description: How the medicines reach the patient.
                notes:
                  type: string
                  description: Order-level remarks.
                custom_fields:
                  type: object
                  additionalProperties:
                    type: string
                  description: >-
                    Extra key-value fields passed to the provider (used by
                    eVital).
                items:
                  type: array
                  description: Medicines to order.
                  items:
                    $ref: '#/components/schemas/IpdOrderItemInput'
            example:
              admissionId: a1b2c3d4-5678-90ab-cdef-1234567890ab
              ipd_id: IPD-2026-0042
              provider: dawakhana
              patient_id: pid-321
              patient_name: Ravi Kumar
              mobile: '9876543210'
              doctor_name: Dr. Vivek Sharma
              delivery_type: pickup
              items:
                - medicine_id: med-paracetamol-500
                  name: Paracetamol 500mg Tablet
                  generic_name: Paracetamol
                  quantity: 10
                  directions: 1 tablet every 6 hours
      responses:
        '200':
          description: OK — the created order.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IpdOrderResponse'
              example:
                success: true
                data:
                  id: 66f1cd07e4b0a1b2c3d4ef0a
                  admissionId: a1b2c3d4-5678-90ab-cdef-1234567890ab
                  kind: order
                  orderNumber: DW-7Q2K9F3M
                  ipdId: IPD-2026-0042
                  status: CREATED
                  createdBy: '161467756044203'
                  createdByName: Vivek Sharma
                  isCollected: false
                  provider: dawakhana
                  patientName: Ravi Kumar
                  mobile: '9876543210'
                  patientId: pid-321
                  doctorName: Dr. Vivek Sharma
                  deliveryType: pickup
                  createdAt: '2026-10-07T12:10:00.000Z'
                  updatedAt: '2026-10-07T12:10:00.000Z'
        '400':
          description: >-
            Bad Request. Returns `{ success: false, error }` when the order
            could not be placed (for example no pharmacy provider is set up,
            `pharmacyId` is missing for an eVital order, eVital rejected the
            order, or `admissionId` is not a valid id), or `{ message }` when
            the request body failed schema validation (for example `admissionId`
            or `items` is missing, an item has no `quantity`, or an unknown
            field was sent; the `message` is currently empty).
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/IpdServiceFailure'
                  - $ref: '#/components/schemas/IpdServiceError'
              example:
                success: false
                error: pharmacyId is required for eVital orders
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IpdServiceError'
      deprecated: false
components:
  schemas:
    IpdOrderItemInput:
      title: IpdOrderItemInput
      type: object
      additionalProperties: false
      required:
        - quantity
      properties:
        medicine_id:
          type: string
          description: Id of the medicine. Used to match the medicine for eVital orders.
        name:
          type: string
          description: Name of the medicine.
        generic_name:
          type: string
          description: Generic (molecule) name of the medicine.
        quantity:
          type: number
          description: >-
            Quantity to order. For eVital orders, in the pharmacy's order unit
            (loose or strip).
        directions:
          type: string
          description: Dosage directions for the patient.
    IpdOrderResponse:
      title: IpdOrderResponse
      type: object
      properties:
        success:
          type: boolean
        data:
          $ref: '#/components/schemas/IpdOrder'
    IpdServiceFailure:
      title: IpdServiceFailure
      type: object
      properties:
        success:
          type: boolean
          description: Always `false`.
        error:
          type: string
          description: Human-readable error message.
    IpdServiceError:
      title: IpdServiceError
      type: object
      properties:
        message:
          type: string
          description: Human-readable error message.
    IpdOrder:
      title: IpdOrder
      type: object
      properties:
        id:
          type: string
          description: Order id.
        admissionId:
          type: string
          description: Id of the IPD admission the order is for.
        kind:
          type: string
          enum:
            - order
            - return
          description: '`order`, or `return` for a return order placed against an order.'
        parentOrderId:
          type: string
          description: For a return order, the id of the order it was placed against.
        externalReturnId:
          type: string
          description: For an eVital return order, eVital's return id.
        orderNumber:
          type: string
          description: >-
            Display order number (Dawakhana's own number, or eVital's order
            number).
        ipdId:
          type: string
          description: Patient IPD case number.
        status:
          type: string
          enum:
            - CREATED
            - DISPATCHED
            - CANCELLED
            - RETURNED
            - PARTIALLY_RETURNED
          description: Order status.
        createdBy:
          type: string
          description: Id of the user who placed the order.
        createdByName:
          type: string
          description: Name of the user who placed the order.
        rxId:
          type: string
          description: Id of the prescription the order is based on.
        isCollected:
          type: boolean
          description: '`true` when the patient has collected the medicines.'
        collectedBy:
          type: string
          description: Id of the user who marked the order collected.
        collectedByName:
          type: string
          description: Name of the user who marked the order collected.
        collectedAt:
          type: string
          description: Date-time the order was marked collected, as an ISO-8601 string.
        provider:
          type: string
          enum:
            - evital
            - dawakhana
          description: Pharmacy provider fulfilling the order.
        pharmacyId:
          type: string
          description: Id of the fulfilling pharmacy.
        patientName:
          type: string
          description: Name of the patient.
        mobile:
          type: string
          description: Mobile number of the patient.
        patientId:
          type: string
          description: Id of the patient.
        doctorName:
          type: string
          description: Name of the prescribing doctor.
        deliveryType:
          type: string
          enum:
            - pickup
            - delivery
          description: How the medicines reach the patient.
        rxPdfUrl:
          type: string
          description: URL of the prescription PDF.
        notes:
          type: string
          description: Order-level remarks.
        billedTotal:
          type: number
          description: Amount billed for the order, set when it is dispatched.
        fulfilmentType:
          type: string
          enum:
            - FULL
            - PARTIAL
          description: Whether the dispatched order was fulfilled fully or partially.
        dispatchNote:
          type: string
          description: Note added when the order was dispatched.
        dispatchedBy:
          type: string
          description: Id of the user who dispatched the order.
        dispatchedByName:
          type: string
          description: Name of the user who dispatched the order.
        dispatchedAt:
          type: string
          description: Date-time the order was dispatched, as an ISO-8601 string.
        cancelledBy:
          type: string
          description: Id of the user who cancelled the order.
        cancelledByName:
          type: string
          description: Name of the user who cancelled the order.
        cancelledAt:
          type: string
          description: Date-time the order was cancelled, as an ISO-8601 string.
        cancelReason:
          type: string
          description: Reason the order was cancelled.
        returnedBy:
          type: string
          description: Id of the user who returned the order.
        returnedByName:
          type: string
          description: Name of the user who returned the order.
        returnedAt:
          type: string
          description: Date-time the order was returned, as an ISO-8601 string.
        returnReason:
          type: string
          description: Reason the order was returned.
        returnedTotal:
          type: number
          description: Total amount returned against the order.
        createdAt:
          type: string
          description: Created date-time as an ISO-8601 string.
        updatedAt:
          type: string
          description: Last-updated date-time as an ISO-8601 string.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.