Create Order
Creates a new order based on a cart and customer information, including shipping and payment details.
warning
You must create a cart before creating an order.
HTTP Method & Endpoint
POST | /order
Request Format
Headers
| Header | Value | Description |
|---|---|---|
Content-Type | application/json | Specifies that the request body is in JSON format |
Authorization | Bearer {token} | Authentication token (replace {token} with your actual token) |
x-store-id | {storeId} | StoreId (replace {storeId} with your actual storeId) |
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,ONDC) | Yes | Channel through which the order is placed |
paymentMethod | enum(COD,CVS) | Yes | Method of payment (e.g., "COD" for Cash on Delivery) |
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) |
BuyerInfo Object
| Parameter | Type | Required | Description |
|---|---|---|---|
firstName | String | Yes | Customer's first name |
lastName | String | Yes | Customer's last name |
address | String | Yes | Customer's street address |
city | String | Yes | Customer's city |
pincode | Number | Yes | Customer's postal/ZIP code |
state | String | Yes | Customer's state/province |
country | String | Yes | Customer's country |
email | String | Yes | Customer's email address |
phone | String | Yes | Customer's phone number |
isShippingSame | Boolean | Yes | Whether shipping address is the same as billing address |
ShippingDetail Object
| Parameter | Type | Required | Description |
|---|---|---|---|
firstName | String | Yes | Recipient's first name |
lastName | String | Yes | Recipient's last name |
address | String | Yes | Shipping street address |
city | String | Yes | Shipping city |
pincode | Number | Yes | Shipping postal/ZIP code |
state | String | Yes | Shipping state/province |
country | String | Yes | Shipping country |
email | String | Yes | Recipient's email address |
phone | String | Yes | Recipient's phone number |
Address Object
| Parameter | Type | Required | Description |
|---|---|---|---|
name | String | Yes | Full name |
address | String | Yes | Street address |
city | String | Yes | City |
pincode | Number | Yes | Postal/ZIP code |
state | String | Yes | State/province |
country | String | Yes | Country |
email | String | Yes | Email address |
phone | String | Yes | Phone number |
Example Request
Click to view Request
{
"cartId": "33863324215067648",
"customerId": "33864324216707648",
"channelType": "DEFAULT",
"paymentMethod": "COD",
"buyerInfo": {
"firstName": "Priya",
"lastName": "Patel",
"address": "78 Ghandhi Road",
"city": "ahemdabad",
"pincode": 380001,
"state": "gujarat",
"country": "india",
"email": "abc@gmail.com",
"phone": "9876543210",
"isShippingSame": false
},
"shippingDetail": {
"firstName": "Priya",
"lastName": "Patel",
"address": "78 Ghandhi Road",
"city": "ahemdabad",
"pincode": 380001,
"state": "gujarat",
"country": "india",
"email": "abc@gmail.com",
"phone": "9876543210"
},
"address": {
"name": "Piya",
"address": "78 Ghandhi Road",
"city": "ahemdabad",
"pincode": 380001,
"state": "gujarat",
"country": "india",
"email": "abc@gmail.com",
"phone": "9876543210"
},
"extraData": {}
}
Response Format
Success Response (200 OK)
| Field | Type | Description |
|---|---|---|
message | String | Status message indicating the result of the order creation |
data | Data | Contains all details about the order |
source | String | Source of the order data (e.g., "db") |
Data Object
| Field | Type | Description |
|---|---|---|
id | String | Unique identifier for the order |
storeId | String | Store ID from where the order was placed |
customerId | String | Customer's unique identifier |
channelType | String | Channel through which the order was placed (e.g., DEFAULT) |
status | String | Current status of the order (e.g., PENDING) |
fulfillmentStatus | String | Status of order fulfillment (e.g., PENDING) |
purchaseDate | String | Date and time when the purchase was made (ISO format) |
paymentMethod | String | Payment method used for the order (e.g., COD) |
paymentDetail | Object | Additional payment-related details |
buyerInfo | BuyerInfo | Information about the buyer |
shippingDetail | ShippingDetail | Shipping address details |
address | Address | Pickup address details |
packageMeasurement | Object | Package measurement details |
totalAmount | Number | Total amount for the order (in minor units, e.g., paise) |
externalOrderId | String | External platform order ID (if applicable) |
razorpayOrderId | String | Razorpay order ID (only applicable if user doesn't use COD) |
externalOrderStatus | String | Status of the order on the external platform |
extraData | Object | Any additional data |
createdAt | String | Timestamp when the order was created (ISO format) |
updatedAt | String | Timestamp when the order was last updated (ISO format) |
Example Response
Click to view JSON Response
{
"message": "Order created successfully",
"data": {
"id": "30256970401565696",
"storeId": "30182834660443136",
"customerId": "30182834660443136",
"channelType": "DEFAULT",
"status": "PENDING",
"fulfillmentStatus": "PENDING",
"purchaseDate": "2025-03-25T11:50:23.888Z",
"paymentMethod": "COD",
"paymentDetail": {},
"buyerInfo": {
"firstName": "Priya",
"lastName": "Patel",
"address": "78 Ghandhi Road",
"city": "ahemdabad",
"pincode": 380001,
"state": "gujarat",
"country": "india",
"email": "abc@gmail.com",
"phone": "9876543210",
"isShippingSame": false
},
"shippingDetail": {
"firstName": "Priya",
"lastName": "Patel",
"address": "78 Ghandhi Road",
"city": "ahemdabad",
"pincode": 380001,
"state": "gujarat",
"country": "india",
"email": "abc@gmail.com",
"phone": "9876543210"
},
"address": {
"name": "Piya",
"address": "78 Ghandhi Road",
"city": "ahemdabad",
"pincode": 380001,
"state": "gujarat",
"country": "india",
"email": "abc@gmail.com",
"phone": "9876543210"
},
"packageMeasurement": {},
"totalAmount": 50000,
"externalOrderId": "",
"externalOrderStatus": "PENDING",
"extraData": {},
"createdAt": "2025-03-25T11:50:23.890Z",
"updatedAt": "2025-03-25T11:50:23.890Z"
},
"source": "db"
}
Examples
cURL
curl -X POST "https://dev-sfapi.unisouk.com/order" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <TOKEN>" \
-H "x-store-id: <STORE_ID>" \
-d '{
"cartId": "33863324215067648",
"customerId": "33864324216707648",
...
}'
JavaScript (React)
import axios from "axios";
const fetchProducts = async () => {
try {
const res = await axios.post(
"https://dev-sfapi.unisouk.com/order",
{
cartId: "33863324215067648",
customerId: "33864324216707648",
...
// copy from the request object above
},
{
headers: {
"Content-Type": "application/json",
Authorization: "Bearer <TOKEN>",
"x-store-id": "<STORE_ID>",
},
}
);
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