Create Order
Creates a new order based on a cart and customer information, including shipping and payment details.
HTTP Method & Endpoint
POST | /order
Request Format
Request Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
cartId | String | Yes | Unique identifier for the cart |
customerId | String | Yes | Unique identifier for the customer |
channelType | enum(DEFAULT) | Yes | Channel through which the order is placed |
paymentMethod | enum(CVS,COD) | Yes | Method of payment |
buyerInfo | BuyerInfo | Yes | Customer's personal and delivery information |
shippingDetail | ShippingDetail | Yes | Shipping information (can be different from buyer info) |
address | Address | Yes | Pickup address information |
extraData | Object | No | Additional data for the order (can be empty) |
Response Format
Success Response (200 OK)
| Field | Type | Description |
|---|---|---|
message | String | Status message indicating the result of the order creation |
data | Order | Contains all details about the order |
source | String | Source of the order data (e.g., "db") |
Example Request
Click to view Request
{
"cartId": "33863324215067648",
"customerId": "33864324216707648",
"channelType": "DEFAULT",
"paymentMethod": "CVS",
"buyerInfo": {
"firstName": "Priya",
"lastName": "Patel",
"address": "78 Ghandhi Road",
"city": "ahemdabad",
"pincode": 380001,
"state": "gujarat",
"country": "india",
"email": "abc@gmail.com",
"phone": "9876543210",
"building":"123",
"isShippingSame": false,
},
"shippingDetail": {
"firstName": "Priya",
"lastName": "Patel",
"address": "78 Ghandhi Road",
"city": "ahemdabad",
"pincode": 380001,
"state": "gujarat",
"country": "india",
"email": "abc@gmail.com",
"building":"123",
"phone": "9876543210",
},
"address": {
"name": "Piya",
"address": "78 Ghandhi Road",
"city": "ahemdabad",
"pincode": 380001,
"state": "gujarat",
"country": "india",
"email": "abc@gmail.com",
"building":"123",
"phone": "9876543210",
},
"extraData": {}
}
Example Response
Click to view JSON Response
{
"message": "Order created successfully",
"data": {
"id": "53766957931612160",
"storeId": "49006338654987264",
"customerId": "49019401470865408",
"channelType": "DEFAULT",
"status": "CONFIRMED",
"fulfillmentStatus": "PENDING",
"purchaseDate": "2025-05-29T08:50:41.714Z",
"paymentMethod": "CVS",
"paymentDetail": {
"totalAmount": 500000,
"subTotalAmount": 500000
},
"buyerInfo": {
"city": "ahemdabad",
"email": "abc@gmail.com",
"phone": "9876543210",
"state": "gujarat",
"address": "78 Ghandhi Road",
"country": "india",
"pincode": 380001,
"building": "gujarat",
"lastName": "Patel",
"firstName": "Priya",
"isShippingSame": false
},
"shippingDetail": {
"city": "ahemdabad",
"email": "abc@gmail.com",
"phone": "9876543210",
"state": "gujarat",
"address": "78 Ghandhi Road",
"country": "india",
"pincode": 380001,
"building": "gujarat",
"lastName": "Patel",
"firstName": "Priya"
},
"address": {
"city": "ahemdabad",
"name": "Piya",
"email": "abc@gmail.com",
"phone": "9876543210",
"state": "gujarat",
"address": "78 Ghandhi Road",
"country": "india",
"pincode": 380001,
"building": "gujarat"
},
"packageMeasurement": {},
"totalAmount": 5000,
"externalOrderId": "53766957931612160",
"externalOrderStatus": "CONFIRMED",
"extraData": {},
"createdAt": "2025-05-29T08:50:41.716Z",
"updatedAt": "2025-05-29T08:50:42.823Z",
"razorpayOrderId": "order_QagWPRAfb5MqFN"
},
"source": "db"
}
warning
You must pass CVS in paymentMethod in the request params in order to get razorpayOrderId
Examples
JavaScript (React)
import axios from "axios";
import { api } from "../constant";
const createOrder = async () => {
const cartId = localStorage.getItem("cartId");
const cartId = localStorage.getItem("customerId");
try {
const res = await api.post("/order", {
cartId: cartId,
customerId: customerId,
channelType: "DEFAULT",
paymentMethod: "CVS",
// The following is dummy data. Please replace each field with actual user information as needed.
buyerInfo: {
firstName: "Priya",
lastName: "Patel",
address: "78 Ghandhi Road",
city: "ahemdabad",
pincode: 380001,
state: "gujarat",
country: "india",
email: "abc@gmail.com",
phone: "9876543210",
building: "123",
isShippingSame: false,
},
shippingDetail: {
firstName: "Priya",
lastName: "Patel",
address: "78 Ghandhi Road",
city: "ahemdabad",
pincode: 380001,
state: "gujarat",
country: "india",
email: "abc@gmail.com",
building: "123",
phone: "9876543210",
},
address: {
name: "Piya",
address: "78 Ghandhi Road",
city: "ahemdabad",
pincode: 380001,
state: "gujarat",
country: "india",
email: "abc@gmail.com",
building: "123",
phone: "9876543210",
},
extraData: {},
});
console.log(res.data.data);
} catch (error) {
console.error("Error fetching products:", error);
}
};
Error Responses
| Status Code | Description |
|---|---|
| 400 | Bad Request - Invalid input parameters |
| 401 | Unauthorized - Authentication failed or token missing |
| 404 | Not Found - Cart or customer not found |
| 500 | Internal Server Error - Server-side issue |
Notes
- The Cash on Delivery (COD) payment method requires a valid phone number
- All address fields must be properly formatted
- The
isShippingSameflag determines whether the system should use buyer information for shipping