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

# Create New Order

> Create a new order manually through the system, typically for in-store purchases, phone orders, or direct customer orders.

This endpoint allows stores to create new orders directly in the system, bypassing delivery platforms. This is useful for in-store purchases, phone orders, catering orders, or any direct customer transactions.

<Info>
  This endpoint creates orders that are immediately available for fulfillment and can be integrated with your existing POS system or used for direct customer service.
</Info>

### Request Body

<ParamField body="store_id" type="string" required>
  The unique identifier of the store creating the order
</ParamField>

<ParamField body="customer" type="object" required>
  Customer information for the order

  <Expandable title="Customer Object">
    <ParamField body="customer_name" type="string" required>
      Customer's full name
    </ParamField>

    <ParamField body="contact_phone" type="string" required>
      Customer's contact phone number
    </ParamField>

    <ParamField body="email" type="string" optional>
      Customer's email address
    </ParamField>

    <ParamField body="delivery_address" type="object" optional>
      Delivery address (required if order\_type is "delivery")

      <Expandable title="Address Object">
        <ParamField body="street" type="string" required>Street address</ParamField>
        <ParamField body="city" type="string" required>City</ParamField>
        <ParamField body="state" type="string" required>State or province</ParamField>
        <ParamField body="zip_code" type="string" required>ZIP or postal code</ParamField>
        <ParamField body="apartment" type="string" optional>Apartment or unit number</ParamField>
        <ParamField body="delivery_instructions" type="string" optional>Special delivery instructions</ParamField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="order_items" type="array" required>
  Array of items to include in the order

  <Expandable title="Order Item Object">
    <ParamField body="item_id" type="string" required>
      Unique identifier of the product/item
    </ParamField>

    <ParamField body="quantity" type="integer" required>
      Quantity of this item to order
    </ParamField>

    <ParamField body="special_instructions" type="string" optional>
      Special preparation instructions for this item
    </ParamField>

    <ParamField body="modifiers" type="array" optional>
      Array of modifier IDs and values (e.g., size, extras, customizations)
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="order_type" type="string" required>
  Type of order: "pickup", "delivery", "dine\_in"
</ParamField>

<ParamField body="partner" type="string" optional default="LulaDirect">
  Source platform (defaults to "LulaDirect" for manual orders)
</ParamField>

<ParamField body="payment_method" type="string" required>
  Payment method: "cash", "card", "online", "corporate\_account"
</ParamField>

<ParamField body="special_instructions" type="string" optional>
  General order-level special instructions
</ParamField>

<ParamField body="scheduled_time" type="string" optional>
  Scheduled pickup/delivery time (ISO 8601 format). If not provided, order is for immediate fulfillment
</ParamField>

<ParamField body="created_by" type="string" required>
  Employee ID who created the order
</ParamField>

### Response

<ResponseField name="success" type="boolean">
  Indicates whether the order was successfully created
</ResponseField>

<ResponseField name="message" type="string">
  Confirmation message or error details
</ResponseField>

<ResponseField name="order" type="object">
  Complete order object with all calculated values

  <Expandable title="Created Order Object">
    <ResponseField name="id" type="string">
      Unique order identifier
    </ResponseField>

    <ResponseField name="order_number" type="string">
      Human-readable order number for customer reference
    </ResponseField>

    <ResponseField name="subtotal" type="string">
      Order subtotal before taxes and fees
    </ResponseField>

    <ResponseField name="tax_amount" type="string">
      Calculated tax amount
    </ResponseField>

    <ResponseField name="total_price" type="string">
      Final total price including all fees and taxes
    </ResponseField>

    <ResponseField name="status" type="string">
      Initial order status (typically "pending" or "confirmed")
    </ResponseField>

    <ResponseField name="estimated_ready_time" type="string">
      Estimated time when order will be ready
    </ResponseField>

    <ResponseField name="createdAt" type="string">
      Order creation timestamp
    </ResponseField>

    <ResponseField name="fulfillment_id" type="string">
      Unique identifier for fulfillment tracking
    </ResponseField>
  </Expandable>
</ResponseField>

### Request Example

```json theme={null}
{
  "store_id": "449235c1-3d04-4519-998b-40d2a621e5e0",
  "customer": {
    "customer_name": "John Smith",
    "contact_phone": "+1 555-123-4567",
    "email": "john.smith@email.com",
    "delivery_address": {
      "street": "123 Main Street",
      "city": "Chicago",
      "state": "IL",
      "zip_code": "60601",
      "apartment": "Apt 4B",
      "delivery_instructions": "Ring doorbell twice"
    }
  },
  "order_items": [
    {
      "item_id": "prod_12345",
      "quantity": 2,
      "special_instructions": "Extra hot",
      "modifiers": [
        {
          "modifier_id": "size_large",
          "value": "Large"
        }
      ]
    },
    {
      "item_id": "prod_67890",
      "quantity": 1,
      "special_instructions": "No ice"
    }
  ],
  "order_type": "delivery",
  "partner": "LulaDirect",
  "payment_method": "card",
  "special_instructions": "Please call when arriving",
  "scheduled_time": "2024-01-15T18:30:00Z",
  "created_by": "emp_abc123"
}
```

### Response Example

```json theme={null}
{
  "success": true,
  "message": "Order successfully created and added to fulfillment queue",
  "order": {
    "id": "ord_new_123456",
    "order_number": "LD-2024-001234",
    "subtotal": "28.50",
    "tax_amount": "2.28",
    "total_price": "30.78",
    "status": "confirmed",
    "estimated_ready_time": "2024-01-15T18:30:00Z",
    "createdAt": "2024-01-15T17:45:00Z",
    "fulfillment_id": "ful_abc789",
    "customer": {
      "customer_name": "John Smith",
      "contact_phone": "+1 555-123-4567",
      "email": "john.smith@email.com"
    },
    "order_items": [
      {
        "id": "oi_item1",
        "item_name": "Large Coffee",
        "quantity": 2,
        "unit_price": "4.50",
        "total_price": "9.00",
        "special_instructions": "Extra hot"
      },
      {
        "id": "oi_item2",
        "item_name": "Iced Tea",
        "quantity": 1,
        "unit_price": "3.25",
        "total_price": "3.25",
        "special_instructions": "No ice"
      }
    ]
  }
}
```

<Accordion title="Order Creation Workflow">
  When an order is created, the following processes occur automatically:

  1. **Inventory Check**: Verify item availability
  2. **Price Calculation**: Calculate subtotal, taxes, and total
  3. **Order Number Generation**: Create unique customer-facing order number
  4. **Fulfillment Creation**: Initialize fulfillment tracking
  5. **Kitchen Notification**: Alert preparation staff (if applicable)
  6. **Customer Notification**: Send confirmation (if email provided)
  7. **Payment Hold**: Initiate payment processing (for card payments)
</Accordion>

<Note>
  **Order Numbers**: The system generates human-readable order numbers (e.g., "LD-2024-001234") for customer reference, separate from the internal UUID.
</Note>

<Tip>
  **Scheduled Orders**: Use the scheduled\_time parameter for advance orders. The order will automatically enter the fulfillment queue at the appropriate time.
</Tip>

### Error Responses

<Accordion title="Common Error Scenarios">
  **Item Not Available**

  ```json theme={null}
  {
    "success": false,
    "message": "One or more items are not available",
    "error_code": "ITEM_UNAVAILABLE",
    "unavailable_items": ["prod_12345"]
  }
  ```

  **Invalid Address (for delivery orders)**

  ```json theme={null}
  {
    "success": false,
    "message": "Delivery address is outside service area",
    "error_code": "INVALID_DELIVERY_ADDRESS"
  }
  ```

  **Payment Processing Error**

  ```json theme={null}
  {
    "success": false,
    "message": "Payment method could not be processed",
    "error_code": "PAYMENT_FAILED"
  }
  ```
</Accordion>

<Warning>
  **Payment Processing**: For card payments, ensure your payment processor is configured correctly. Failed payment processing will prevent order creation.
</Warning>

### Use Cases

<Accordion title="Common Use Cases">
  **Phone Orders**

  * Customer calls to place order
  * Staff member creates order in system
  * Customer pays on pickup/delivery

  **In-Store Purchases**

  * Walk-in customer orders
  * Immediate or scheduled preparation
  * Integration with POS system

  **Catering Orders**

  * Large scheduled orders
  * Corporate accounts
  * Advance preparation planning

  **Special Events**

  * Pre-orders for events
  * Bulk order management
  * Custom pricing arrangements
</Accordion>
