Skip to main content

Create New Sales Order

1. API Information

  • Endpoint: /api/v6.1/sale_order
  • Method: POST
  • Authentication: Requires X-API-KEY
  • Header:
    • Content-Type: application/json
    • X-API-KEY: <your_api_key>

2. Request Body

{
"account": {
"account_code": "CUSTOMER_001",
"account_name": "Customer ABC",
"contact_name": "Contact Person XYZ",
"account_phone": "0900000000",
"account_email": "[email protected]",
"account_address": "Customer Address"
},
"order_code": "ORDER_001",
"order_date": "2025-03-12",
"assigned_username": "employee01",
"order_source_name": "Sales Source A",
"store_name": "Central Warehouse",
"lading_code": "LD_001",
"campaign_code": "CMP_001",
"opportunity_code": "OPP_001",
"saved_order_details": [
{
"product_code": "PROD_001",
"product_name": "Product A",
"unit_name": "Piece",
"quantity": 1,
"price": 65000,
"product_sale_off": 1,
"cash_discount": 10000,
"note": "Fragile product"
}
],
"order_terms": [
{"term_content": "1. Allow co-inspection"},
{"term_content": "2. No returns allowed"}
],
"custom_fields": {
"warehouse_entry_date": "2025-02-03",
"warehouse_storage": "Secret Warehouse",
"tags": [
"Bulky goods",
"Fragile goods",
"High-tech goods",
"Biochemicals",
"High-grade pharmaceuticals"
]
},
"discount": 10,
"discount_amount": 11000,
"vat": 10,
"vat_amount": 4400,
"transport_amount": 10000,
"installation_amount": 10000,
"payment_method_name":"Bank Transfer",
"saved_sale_order_payments": [
{
"method_name": "Bank Transfer",
"amount": 50000,
"description": "Advance payment 50k",
"pay_date": "2025-02-03"
}
],
"is_auto_approve": 0
}

3. Field Descriptions

3.1. Customer Information (account)

FieldTypeDescription
account_codestringCustomer code
account_namestringCustomer name
contact_namestringContact person
account_phonestringCustomer phone number
account_emailstringCustomer email
account_addressstringCustomer address

3.2. Order Information

FieldTypeDescription
order_codestringOrder code
order_datestringOrder date (YYYY-MM-DD)
assigned_usernamestringAssigned employee
order_source_namestringOrder source
store_namestringExport warehouse name
lading_codestringBill of lading code
campaign_codestringCampaign code
opportunity_codestringOpportunity code

3.3. Product Details (saved_order_details)

FieldTypeDescription
product_codestringProduct code
product_namestringProduct name
unit_namestringUnit of measurement
quantityintQuantity
priceintProduct price
product_sale_offintProduct discount (0: no discount, 1: discounted)
cash_discountintDiscount amount
notestringProduct note

3.4. Order Terms (order_terms)

FieldTypeDescription
term_contentstringTerm content

3.5. Payment

FieldTypeDescription
discountintDiscount percentage
discount_amountintDiscount amount
vatintTax percentage
vat_amountintTax amount
transport_amountintShipping fee
installation_amountintInstallation fee
payment_method_namestringPayment method
saved_sale_order_paymentsarrayList of direct payments
is_auto_approveintWhether to auto-approve the order

4. Response

{
"message": "Successfully added",
"data": {
"order_id": 189,
"order_code": "ORDER_001"
}
}

5. Notes

  • order_code must be unique in the system.\
  • Some fields like lading_code, campaign_code can be left empty if not applicable.\
  • order_terms helps set specific terms for the order.\
  • saved_sale_order_payments will automatically pay for the order when the order is created.\
  • custom_fields contain various custom fields depending on business requirements.\
  • Các giá trị của custom_fields có kiểu datetime có thể truyền dang string theo định dạng YYYY-MM-DD , Y-m-d H:i:s hoặc timestamp.\
  • Các giá trị của custom_fields có kiểu select có thể truyền id hoặc tên lựa chọn (nếu lựa chọn không có sẵn sẽ tự tạo mới).