Skip to main content

Create New Purchase Order

Endpoint: POST /api/v6.1/purchase_order

Description: This API is used to create a new purchase order, including order information, customer, terms, payment method, and product list.


Request

Method: POST

Headers:

Content-Type: application/json
X-API-KEY: <your-api-key>
Cookie: <your-session-cookie>

Body (JSON):

{
"order_code": "DHM001",
"order_date": "2025-04-25",
"contract_code": "HD0003",
"campaign_code": "CD0024",
"account": {
"account_code": "KH001",
"account_phone": "0123456789",
"account_email": "[email protected]",
"account_address": "Hanoi",
"account_name": "Customer A",
"contact_name": "Contact Person"
},
"discount": 5,
"discount_amount": 4042.5,
"vat": 5,
"vat_amount": 3840.375,
"transport": 5,
"transport_amount": 4042.5,
"installation": 10,
"installation_amount": 8085,
"order_source_name": "FB Source",
"store_name": "Branch A",
"payment_method_name": "Cash",
"assigned_username": "responsible_person",
"order_terms": [
{ "term_content": "Delivery time: 2 days" },
{ "term_content": "Delivery location: Hanoi" }
],
"custom_fields": {
"sub_order_code": "1234",
"warehouse_storage": "Warehouse A",
"tags": ["Fast Delivery"]
},
"saved_order_details": [
{
"product_code": "SP001",
"product_name": "Product A",
"quantity": 2,
"price": 20000,
"amount": 40000,
"unit_name": "Piece"
},
{
"product_code": "SP002",
"product_name": "Product B",
"quantity": 1,
"price": 25000,
"amount": 25000,
"unit_name": "Box"
},
{
"product_code": "SP003",
"product_name": "Product C",
"quantity": 1,
"price": 35000,
"amount": 34650,
"unit_name": "Pack",
"variants": [
{
"quantity": 1,
"variant_attributes": [
{ "attribute_name": "Color", "value_name": "Red" },
{ "attribute_name": "Size", "value_name": "L" }
]
}
]
}
]
}

Response

Status: 200 OK

{
"message": "Successfully added",
"data": {
"identity": 367,
"order_code": "DHM001"
}
}