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

# Create order from cart

> Create an order from items in the authenticated shopper's cart.

## Request

```http theme={null}
POST /orders/from-cart
Authorization: Bearer {{token}}
x-shop-id: {{shopId}}
Content-Type: application/json

{}
```

## Headers

| Header          | Type   | Description                                   |
| --------------- | ------ | --------------------------------------------- |
| `Authorization` | string | Provide the customer token as `Bearer <jwt>`. |
| `x-shop-id`     | string | Identify the shop that owns the order.        |
| `Content-Type`  | string | Always set to `application/json`.             |

## Body parameters

You can create an order using one of the following methods:

| Field            | Type  | Required | Description                                                        |
| ---------------- | ----- | -------- | ------------------------------------------------------------------ |
| `productIds`     | array | No       | Array of product IDs to include (any variants of these products).  |
| `items`          | array | No       | Array of explicit items with `productId` and optional `variantId`. |
| `indices`        | array | No       | Array of 0-based cart item positions to include.                   |
| `additionalInfo` | array | No       | Custom labelled key/value info to attach to the order — see below. |

### `additionalInfo` entries

Attach custom fields to the order (e.g. a gift message or delivery
instructions). Each entry has a required `label` and an optional `value`. Entries
without a label are dropped, and the list is capped at 50 entries.

| Field   | Type   | Required | Description                            |
| ------- | ------ | -------- | -------------------------------------- |
| `label` | string | Yes      | The field name (max 100 characters).   |
| `value` | string | No       | The field value (max 2000 characters). |

<Note>
  If no body parameters are provided, the entire cart will be converted into an order.
</Note>

<Note>
  Food and service cart items have no `productId`, so select them with `indices`
  (0-based cart positions) or send an empty body to include the whole cart. The
  resulting order items carry an `itemType` of `product`, `food`, or `service`;
  service items reference `service` and include any `selectedAddons`. Service
  (business) orders are non-shippable, so `shippingCost` is `0` and no shipment is
  created.
</Note>

## Request examples

### Create order from entire cart

```json theme={null}
{}
```

### Create order from selected products

```json theme={null}
{
  "productIds": [
    "68e5bb463a1fc56a8ac150bf",
    "68e5bb463a1fc56a8ac150c0"
  ]
}
```

### Create order from explicit items

```json theme={null}
{
  "items": [
    { "productId": "68e5bb463a1fc56a8ac150bf" },
    { "productId": "68e5bb463a1fc56a8ac150bf", "variantId": "68e5c1303a1fc56a8ac151e2" }
  ]
}
```

### Create order from cart indices

```json theme={null}
{
  "indices": [0, 2]
}
```

### Create order with additional info

```json theme={null}
{
  "additionalInfo": [
    { "label": "Gift message", "value": "Happy birthday!" },
    { "label": "Delivery instructions", "value": "Leave at the front desk" }
  ]
}
```

## Successful response

```json theme={null}
{
    "status": 200,
    "success": true,
    "message": "Order created from cart",
    "data": {
        "_id": "6a27d632289b87893fcbde35",
        "user": "69360693a7a8f7dc8ae32d6d",
        "shop": "68b8f52575da81b332af29f1",
        "items": [
            {
                "product": "69fb494e51280f9f65d059ae",
                "variant": null,
                "name": "Wristwatch",
                "price": 45000,
                "quantity": 1,
                "imageUrl": "https://cdn.salesive.com/products/wristwatch.webp",
                "_id": "6a27d632289b87893fcbde36"
            }
        ],
        "status": "pending",
        "source": "online",
        "paymentMethod": "other",
        "payment": null,
        "discount": 0,
        "coupon": null,
        "subtotal": 45000,
        "shippingCost": 0,
        "tax": 0,
        "fee": 675,
        "additionalInfo": [
            { "label": "Gift message", "value": "Happy birthday!" }
        ],
        "posCustomerName": null,
        "posCustomerEmail": null,
        "posCustomerPhone": null,
        "shipment": null,
        "deleted": false,
        "deletedAt": null,
        "orderId": 17,
        "createdAt": "2026-06-09T09:00:34.748Z",
        "updatedAt": "2026-06-09T09:00:34.748Z",
        "__v": 0,
        "total": 45675,
        "amount": 45000,
        "id": "6a27d632289b87893fcbde35"
    }
}
```

## Error response

```json theme={null}
{
    "status": 400,
    "success": false,
    "message": "Cart is empty",
    "data": {}
}
```


## OpenAPI

````yaml POST /orders/from-cart
openapi: 3.1.0
info:
  title: Salesive Store API
  description: >-
    REST interface for querying products, categories, and merchandising banners
    exposed by Salesive storefronts.
  version: 1.0.0
servers:
  - description: Production
    url: https://store.salesive.com/api/v1
security:
  - BearerAuth: []
    ShopIdHeader: []
paths:
  /orders/from-cart:
    post:
      summary: Create order from cart
      description: Create an order from items in the authenticated shopper's cart.
      parameters:
        - $ref: '#/components/parameters/XShopIdHeader'
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateOrderFromCartRequest'
      responses:
        '201':
          description: Order created successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderResponse'
        '400':
          description: Cart is empty or invalid request.
        '401':
          description: Unauthorized.
components:
  parameters:
    XShopIdHeader:
      name: x-shop-id
      in: header
      description: >-
        Optional identifier that scopes responses to a specific storefront when
        the referer cannot be inferred.
      required: false
      schema:
        type: string
  schemas:
    CreateOrderFromCartRequest:
      type: object
      properties:
        productIds:
          type: array
          items:
            type: string
          description: Array of product IDs to include (any variants of these products).
        items:
          type: array
          items:
            type: object
            required:
              - productId
            properties:
              productId:
                type: string
              variantId:
                type: string
          description: Array of explicit items with productId and optional variantId.
        indices:
          type: array
          items:
            type: integer
            minimum: 0
          description: Array of 0-based cart item positions to include.
        additionalInfo:
          type: array
          maxItems: 50
          items:
            $ref: '#/components/schemas/AdditionalInfoItem'
          description: >-
            Custom labelled key/value info to attach to the order (e.g. gift
            message, delivery instructions). Max 50 entries.
      description: If no parameters provided, entire cart will be converted to order.
    OrderResponse:
      type: object
      required:
        - status
        - success
        - message
        - data
      properties:
        status:
          type: integer
        success:
          type: boolean
        message:
          type: string
        data:
          $ref: '#/components/schemas/Order'
    AdditionalInfoItem:
      type: object
      required:
        - label
      properties:
        label:
          type: string
          maxLength: 100
          description: The name of the field (e.g. "Gift message").
        value:
          type: string
          maxLength: 2000
          description: The field value.
    Order:
      type: object
      required:
        - _id
        - orderId
        - user
        - shop
        - items
        - status
        - subtotal
        - shippingCost
        - total
      properties:
        _id:
          type: string
          description: Order identifier.
        orderId:
          type: integer
          description: Human-readable order number.
        user:
          type: string
          description: Identifier of the shopper who placed the order.
        shop:
          type: string
          description: Identifier of the shop associated with the order.
        items:
          type: array
          items:
            $ref: '#/components/schemas/OrderItem'
        status:
          type: string
          enum:
            - pending
            - processing
            - paid
            - cancelled
            - refunded
          description: Current status of the order.
        subtotal:
          type: number
          description: Subtotal before shipping costs.
        shippingCost:
          type: number
          description: Shipping cost for the order.
        total:
          type: number
          description: Total order amount (subtotal + shippingCost).
        shippingAddress:
          nullable: true
          deprecated: true
          description: >-
            Legacy embedded address; absent on current orders — use the
            shipment's shippingAddress instead.
          allOf:
            - $ref: '#/components/schemas/OrderAddress'
        payment:
          type: string
          description: Payment identifier.
        shipment:
          type: string
          description: Shipment identifier.
        notes:
          type: string
          description: Additional order notes.
        additionalInfo:
          type: array
          items:
            $ref: '#/components/schemas/AdditionalInfoItem'
          description: Custom labelled key/value info attached to the order.
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    OrderItem:
      type: object
      required:
        - product
        - name
        - price
        - quantity
      properties:
        product:
          type: string
          description: Product identifier.
        variant:
          type: string
          description: Variant identifier if applicable.
        name:
          type: string
          description: Product name.
        sku:
          type: string
          description: Product SKU.
        price:
          type: number
          description: Unit price at time of order.
        quantity:
          type: integer
          minimum: 1
          description: Quantity ordered.
        variantAttributes:
          type: object
          additionalProperties:
            type: string
        imageUrl:
          type: string
          format: uri
    OrderAddress:
      type: object
      properties:
        fullName:
          type: string
        addressLine1:
          type: string
        addressLine2:
          type: string
        city:
          type: string
        state:
          type: string
        zipCode:
          type: string
        country:
          type: string
        phoneNumber:
          type: string
      nullable: true
      deprecated: true
      description: >-
        Legacy embedded order address — not populated on current orders (no live
        order carries it). The delivery address lives on the order's shipment:
        see the shipment's shippingAddress, or GET /shipping/shipments.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: JWT issued by the Salesive Store API for authenticated shoppers.
    ShopIdHeader:
      type: apiKey
      in: header
      name: x-shop-id
      description: >-
        Optional storefront identifier sent as a header to scope responses to a
        specific shop. Try It requests remember this value once provided.

````