Skip to main content

Version: v1

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

ParameterTypeRequiredDescription
cartIdStringYesUnique identifier for the cart
customerIdStringYesUnique identifier for the customer
channelTypeenum(DEFAULT)YesChannel through which the order is placed
paymentMethodenum(CVS,COD)YesMethod of payment
buyerInfoBuyerInfoYesCustomer's personal and delivery information
shippingDetailShippingDetailYesShipping information (can be different from buyer info)
addressAddressYesPickup address information
extraDataObjectNoAdditional data for the order (can be empty)

Response Format

Success Response (200 OK)

FieldTypeDescription
messageStringStatus message indicating the result of the order creation
dataOrderContains all details about the order
sourceStringSource 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 CodeDescription
400Bad Request - Invalid input parameters
401Unauthorized - Authentication failed or token missing
404Not Found - Cart or customer not found
500Internal 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 isShippingSame flag determines whether the system should use buyer information for shipping