Orders
Create Order

Create Order

This endpoint allows you to create a new shipment order in the Gratero system. This page provides details on how to use this endpoint, including the request method, endpoint URLs for both test and production environments, and example request and response data.

As of now, QC feature is not available for reverse orders from API.

Parameters

To create a order, ensure all the required parameters are included. Additional parameters can be added based on your needs.

Note: Make sure to provide the correct calculated total_amount, as the API does not automatically compute the total.

ParamsTypeMandatoryDescription
order_idstringYesSpecify the order ID for your order
order_datestringYesDate of order purchase(format YYYY-MM-DD). Must be within the last 7 days
namestringYesFull name of customer
mobilestringYesCustomer mobile number
alt_mobilestringNoCustomer alternate mobile number
company_namestringNoCustomer company name
emailstringNoValid email address of customer
address_line_1stringYesAddress details of customer
address_line_2stringNoFurther address details of customer
citystringYesAddress city of customer
statestringYesAddress state of customer
pincodeintegerYesPincode of customer address. Must be 6 digits
productsarrayYesList of products in the form of Array. Maximum 10 products allowed
package_lengthintegerYesLength of shipment in cms. Must be more than 1
package_breadthintegerYesBreadth of shipment in cms. Must be more than 1
package_heightintegerYesHeight of shipment in cms. Must be more than 1
package_weightintegerYesWeight of shipment in kgs
payment_modestringYesPayment method of shipment (cod or prepaid). cod is default
discountintegerNoPayment method of shipment (cod or prepaid). cod is default
shipping_chargeintegerNoShipping charges in rupee
transaction_chargeintegerNoTransaction charges in rupee
giftwrap_chargeintegerNoGiftwrap charges in rupee
total_amountintegerYesTotal amount of order
warehouse_idintegerYesWarehouse ID (Pickup location) created in gratero system. If not given primary warehouse considered
logistic_idintegerYesThe logistic id of courier you want to select
ewaybill_nostringNoEway bill no of shipment. If shipment amount is greater than or equal to Rs. 50,000
delivery_remarksstringNoAny comments or remarks about shipment

New orders cannot be created using the same order IDs as cancelled orders.

JSON
"products": [
    {
        "product_name": "Books",
        "price": 240,
        "quantity": 2,
        "sku": "SKU0000225",
        "tax": 0,
        "discount": 80
    },
    {
        "product_name": "Another book",
        "price": 400,
        "quantity": 1,
        "sku": "SKU000028",
        "tax": 0,
        "discount": 40
    }
]

Find below logistics along with their IDs:

Logistic IDLogistic
1Delhivery
2Xpressbees
3Ecom Express
4DTDC

Example

Request

JSON
{
  "order_date": "2024-12-15",
  "order_id": "GTR-0010",
  "order_type": "forward",
  "name": "Raghav Bansal",
  "mobile": "9876543210",
  "alt_mobile": "",
  "email": "",
  "company_name": "Acme Corp",
  "gst_number": "GST123456789",
  "address_line_1": "123, 1st Floor",
  "address_line_2": "Main Road",
  "city": "Jaipur",
  "state": "Rajasthan",
  "pincode": "302020",
  "products": [
    {
      "product_name": "Books",
      "price": 240,
      "quantity": 2,
      "sku": "SKU0000225",
      "tax": 0,
      "discount": 80
    },
    {
      "product_name": "Another book",
      "price": 400,
      "quantity": 1,
      "sku": "SKU000028",
      "tax": 0,
      "discount": 40
    }
  ],
  "package_length": 10,
  "package_breadth": 5,
  "package_height": 2,
  "package_weight": 1.2,
  "payment_mode": "prepaid",
  "discount": 120,
  "total_price": 660,
  "warehouse_id": 26,
  "logistic_id": 2
}

Response

JSON
{
  "success": true,
  "id": 7326,
  "order_id": "GTR-0010",
  "awb": "89218773627",
  "logistic": "Delhivery",
  "additional_info": "LKO/JAI",
  "tracking_url": "https://gratero.com/track/89218773627",
  "message": "Order created in system"
}

Code

import { Instance } from "gratero";
 
const gratero = new Instance({
  api_key: "YOUR_API_KEY",
  secret_key: "YOUR_SECRET_KEY",
  environment: 'test'
});
 
gratero.order.create({
    order_id: "12345",
    // other parameters
}).then(data => console.log(data))
  .catch(error => console.log(error))