Skip to main content

ERPNext Sales Cycle Integration via REST API

External systems can integrate with ERPNext using standard Frappe REST API endpoints to manage the full sales cycle including Sales Order, Delivery Note, Sales Invoice, and Payment Entry.

SUMMARY
ERPNext exposes all DocTypes as REST resources and provides whitelisted methods for workflow actions like converting Sales Orders into Delivery Notes, Invoices, and Payments.

1. Sales Order (Entry Point)

Frappe auto-generates REST APIs for all DocTypes. A Sales Order can be created directly using:

POST /api/resource/Sales Order

Example payload:

{
 "doctype": "Sales Order",
 "customer": "Test Customer",
 "company_address": "Test - Billing",
 "customer_address": "Test-Billing-3",
 "items": [{
   "item_code": "Mobile Display",
   "qty": 10,
   "rate": 2000,
   "delivery_date": "2022-11-06",
   "delivery_warehouse": "Stores - GTPL"
 }]
}
NOTE
Sales Order is typically the starting point of the ERPNext sales workflow in API-based integrations.

2. Delivery Note Creation

You can either create a Delivery Note directly or generate it from a Sales Order.

2.1 From Sales Order

POST /api/method/erpnext.selling.doctype.sales_order.sales_order.make_delivery_note
{
 "source_name": "SO-2022-00001"
}
Returns a Delivery Note JSON with pending items ready for shipment.

3. Sales Invoice Creation

Sales Invoice can be generated in multiple ways.

3.1 Direct Invoice

Use standard REST API:

POST /api/resource/Sales Invoice

3.2 From Sales Order

POST /api/method/erpnext.selling.doctype.sales_order.sales_order.make_sales_invoice
{
 "source_name": "SO-2022-00001"
}

3.3 From Delivery Note

POST /api/method/erpnext.stock.doctype.delivery_note.delivery_note.make_sales_invoice
NOTE
Both methods return a pre-filled Sales Invoice JSON with pending billable items.

4. Payment Entry (Against Invoice / Order)

Payments are created using a whitelisted method:

POST /api/method/erpnext.accounts.doctype.payment_entry.payment_entry.get_payment_entry

Example payload:

{
 "dt": "Sales Invoice",
 "dn": "SI-2022-0001",
 "party_amount": 2000,
 "bank_account": "Bank Name - CAB",
 "bank_amount": 2000,
 "party_type": "Customer",
 "payment_type": "Pay"
}

5. End-to-End API Flow

Typical Integration Flow

1. Create Sales Order → /api/resource/Sales Order
2. Generate Delivery Note → make_delivery_note
3. Create Sales Invoice → make_sales_invoice
4. Record Payment Entry → get_payment_entry

6. Key Advantages

  • Out-of-the-box REST APIs for all DocTypes
  • Whitelisted methods for business workflows
  • Supports full ERP sales cycle automation
  • Easy integration with external order management systems

7. Summary

ERPNext provides a complete API-driven sales lifecycle starting from Sales Order creation to Payment Entry processing. External systems can directly integrate using REST endpoints and whitelisted workflow methods.
Rating: 0 / 5 (0 votes)