Skip to main content

Version: v1

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

HeaderValueDescription
Content-Typeapplication/jsonSpecifies that the request body is in JSON format
AuthorizationBearer {token}Authentication token (replace {token} with your actual token)
x-store-id{storeId}StoreId (replace {storeId} with your actual storeId)

Request Body Parameters

ParameterTypeRequiredDescription
cartIdStringYesUnique identifier for the cart
customerIdStringYesUnique identifier for the customer
channelTypeenum(DEFAULT,ONDC)YesChannel through which the order is placed
paymentMethodenum(COD,CVS)YesMethod of payment (e.g., "COD" for Cash on Delivery)
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)

BuyerInfo Object

ParameterTypeRequiredDescription
firstNameStringYesCustomer's first name
lastNameStringYesCustomer's last name
addressStringYesCustomer's street address
cityStringYesCustomer's city
pincodeNumberYesCustomer's postal/ZIP code
stateStringYesCustomer's state/province
countryStringYesCustomer's country
emailStringYesCustomer's email address
phoneStringYesCustomer's phone number
isShippingSameBooleanYesWhether shipping address is the same as billing address

ShippingDetail Object

ParameterTypeRequiredDescription
firstNameStringYesRecipient's first name
lastNameStringYesRecipient's last name
addressStringYesShipping street address
cityStringYesShipping city
pincodeNumberYesShipping postal/ZIP code
stateStringYesShipping state/province
countryStringYesShipping country
emailStringYesRecipient's email address
phoneStringYesRecipient's phone number

Address Object

ParameterTypeRequiredDescription
nameStringYesFull name
addressStringYesStreet address
cityStringYesCity
pincodeNumberYesPostal/ZIP code
stateStringYesState/province
countryStringYesCountry
emailStringYesEmail address
phoneStringYesPhone 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)

FieldTypeDescription
messageStringStatus message indicating the result of the order creation
dataDataContains all details about the order
sourceStringSource of the order data (e.g., "db")

Data Object

FieldTypeDescription
idStringUnique identifier for the order
storeIdStringStore ID from where the order was placed
customerIdStringCustomer's unique identifier
channelTypeStringChannel through which the order was placed (e.g., DEFAULT)
statusStringCurrent status of the order (e.g., PENDING)
fulfillmentStatusStringStatus of order fulfillment (e.g., PENDING)
purchaseDateStringDate and time when the purchase was made (ISO format)
paymentMethodStringPayment method used for the order (e.g., COD)
paymentDetailObjectAdditional payment-related details
buyerInfoBuyerInfoInformation about the buyer
shippingDetailShippingDetailShipping address details
addressAddressPickup address details
packageMeasurementObjectPackage measurement details
totalAmountNumberTotal amount for the order (in minor units, e.g., paise)
externalOrderIdStringExternal platform order ID (if applicable)
razorpayOrderIdStringRazorpay order ID (only applicable if user doesn't use COD)
externalOrderStatusStringStatus of the order on the external platform
extraDataObjectAny additional data
createdAtStringTimestamp when the order was created (ISO format)
updatedAtStringTimestamp 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 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