POSTing Invoices with Merge's Accounting Unified API
Last updated: November 23, 2026
Overview
The Invoices common model contains both customer invoices and vendor bills, and you create either one with POST /invoices. In this article, you'll learn how to create either an invoice or a bill.
Transaction type |
| Contact |
|---|---|---|
Invoice |
| Customer |
Bill |
| Vendor or supplier |
To jump to a specific integration, see NetSuite, QuickBooks Online, Sage Intacct, or Xero under Integration nuances.
Requirements
The key things to get right upfront are listed below. We also recommend reviewing the integration nuances section to understand ERP-specific behavior.
To see the required fields for the Linked Account you’re targeting, call GET /invoices/meta/post before writing your integration.
Non-negotiables
The three topics below apply to nearly every POST /invoices use case.
Accounts payable vs accounts receivable
Set type to:
ACCOUNTS_RECEIVABLEto create a customer invoice, orACCOUNTS_PAYABLEto create a vendor bill.
Contact
Set contact to the Merge ID of a customer for an invoice, or of a vendor or supplier for a bill. Use Merge IDs, not names or third-party IDs. Retrieve the contact with GET /contacts, or create it first.
See POSTing contacts with Merge’s Accounting Unified API if you're looking to create the Contact record first.
Line items
Include line_items in every request. Each entry describes one line with a description, quantity, unit_price, and total_amount, plus fields that classify it, such as an item, an account, or Tracking Categories.
If you provide totals, make sure they agree with the line items, discounts, and taxes. Some integrations, such as NetSuite and Sage Intacct, calculate totals from the line items. Others, such as Xero, use the totals you send. Currency uses ISO 4217 codes, such as USD, GBP, and EUR.
Use case-dependent concepts
Generating accounts payable bills from purchase orders
For a supported integration, you can include a Purchase Order ID in the purchase_orders array to generate an Accounts Payable invoice from a purchase order. See the invoice creation reference for details.
Tax
Set inclusive_of_tax at the transaction level to identify whether the amounts are inclusive or exclusive of tax.
inclusive_of_tax=trueif your amounts already include tax.inclusive_of_tax=falseif your amounts are pre-tax.
To associate a line item with a specific tax rate, populate tax_rate on the line with the Merge ID of a Tax Rate.
Tracking categories
Tracking Categories are supported at both the transaction level and the line-item level. Use top-level tracking_categories when the same classification applies to the whole invoice, and line-level tracking_categories when different lines need different classifications.
To include Tracking Categories, set the
tracking_categoriesarray to include theidvalues of the Tracking Category records.
Tracking category behavior varies by integration and by the end user’s ERP configuration. Some platforms may only support a limited number of tracking categories, or end users may have validation rules based on which dimensions are enabled, required, or restricted for an invoice or bill. See the integration nuances below for details.
Integration parameters
Merge normalizes invoice and bill creation across ERPs, but some integrations accept integration-specific values for certain scenarios. Pass them in the integration_params object inside model, where each key is the parameter name and the value is the target value. To see which parameters your target integration supports, query GET /invoices/meta/post. If you don’t want to branch per integration, you can always send integration_params, because Merge ignores parameters that don’t apply to an integration. See NetSuite and Sage Intacct in the integration nuances below.
Custom fields with remote_fields
Use remote_fields to set integration- or customer-specific fields. Each entry pairs a remote_field_class ID with a value. The example below shows text, boolean, number, URL, and object values.
Idempotency
Send a unique Idempotency-Key header for each invoice or bill. If you retry the same request after a timeout, rate limit, or network error, reuse the key and the identical request body. Use a new key for a different transaction. Merge treats requests with the same key as the same operation for 24 hours. See Idempotency for Accounting POST requests to learn more.
Request samples
Send each request with your Merge API key as a bearer token in the Authorization header and the Linked Account token in X-Account-Token.
These samples show the general shape of a request. See Integration nuances for an example for each integration.
Create a customer invoice
Sample POST /invoices request body:
{
"model": {
"type": "ACCOUNTS_RECEIVABLE",
"contact": "{customer_merge_id}",
"issue_date": "2026-09-21T00:00:00Z",
"due_date": "2026-10-21T00:00:00Z",
"currency": "USD",
"memo": "September implementation services",
"line_items": [
{
"description": "Implementation services",
"quantity": 1,
"unit_price": 1500,
"total_amount": 1500,
"item": "{item_merge_id}",
"tracking_categories": [
"{tracking_category_merge_id_2}"
]
}
],
"tracking_categories": [
"{tracking_category_merge_id_1}"
],
"sub_total": 1500,
"total_amount": 1500
}
}type—ACCOUNTS_RECEIVABLEfor a customer invoicecontact— the Merge Contact ID of the customerissue_date— Issue date of the invoicedue_date— Due date of the invoicecurrency— ISO 4217 currency codememo— Private note about the invoiceline_items— Array of line items, each withdescription,quantity,unit_price,total_amount, anditemtracking_categories— Array of Tracking Categoryidvalues. Set it at the transaction level, on each line item, or both.sub_total— Total amount before taxestotal_amount— Total amount of the invoice
Create a vendor bill
Use the same endpoint and headers, but set type to ACCOUNTS_PAYABLE and provide a vendor contact.
{
"model": {
"type": "ACCOUNTS_PAYABLE",
"contact": "{vendor_merge_id}",
"issue_date": "2026-09-21T00:00:00Z",
"due_date": "2026-10-21T00:00:00Z",
"currency": "USD",
"line_items": [
{
"description": "Software subscription",
"quantity": 1,
"unit_price": 500,
"total_amount": 500,
"account": "{expense_account_merge_id}"
}
],
"sub_total": 500,
"total_amount": 500
}
}type—ACCOUNTS_PAYABLEfor a vendor billcontact— Merge ID of the vendor or supplierissue_date— Issue date of the billdue_date— Due date of the billcurrency— ISO 4217 currency codeline_items— Array of line items, each withdescription,quantity,unit_price,total_amount, andaccountsub_total— Total amount before taxestotal_amount— Total amount of the bill
Create a vendor bill with remote_fields
The following example shows how to include remote_fields when POSTing a vendor bill. To create a customer invoice instead, set type to ACCOUNTS_RECEIVABLE. This example is illustrative, and which fields apply depends on your integration.
{
"model": {
"type": "ACCOUNTS_PAYABLE",
"contact": "{vendor_merge_id}",
"issue_date": "2026-09-19T00:00:00",
"due_date": "2026-09-30T00:00:00",
"memo": "Sample Invoice - Accounts Payable",
"company": "{company_merge_id}",
"currency": "USD",
"exchange_rate": "1",
"line_items": [
{
"description": "Sample test",
"unit_price": 30,
"quantity": 3,
"total_amount": 90,
"item": "{item_merge_id}",
"tracking_categories": [
"{tracking_category_merge_id_3}"
]
}
],
"tracking_categories": [
"{tracking_category_merge_id_1}",
"{tracking_category_merge_id_2}"
],
"remote_fields": [
{
"remote_field_class": "{remote_field_class_merge_id}",
"value": "Test Free Form Text"
},
{
"remote_field_class": "{remote_field_class_merge_id}",
"value": true
},
{
"remote_field_class": "{remote_field_class_merge_id}",
"value": 1
},
{
"remote_field_class": "{remote_field_class_merge_id}",
"value": "https://example.com"
},
{
"remote_field_class": "{remote_field_class_merge_id}",
"value": {
"remote_id": "17"
}
}
]
}
}remote_fields— Array of entries, each with a requiredremote_field_classID and avalue
Integration nuances
NetSuite
Required fields
Field | Customer invoice | Vendor bill |
|---|---|---|
|
|
|
| ✓ | ✓ |
| ✓ Customer | ✓ Vendor |
| ✓ | ✓ |
| Each line needs an | Each line needs an |
Key nuances
Contact and project — Always set
contactat the top level. On each line item, setcontactorproject, but not both.Purchase orders — Send
line_itemsorpurchase_orders, but not both.Tax rate — On a customer invoice, every line item must use the same
tax_rate, or the request is rejected. To bill items with different tax rates, create a separate invoice for each rate.Purchase order vendor — On a vendor bill, every purchase order in
purchase_ordersmust belong to the same vendor ascontact. To bill purchase orders from different vendors, create a separate bill for each vendor.
NetSuite integration parameters
NetSuite accepts these values in integration_params at the transaction level.
bill_reference_number— String. Sets the vendor bill reference number on an accounts payable invoice.netsuite_tax_override_mode— String. Sets the tax override mode, such assuitetax.netsuite_tax_details_override— Boolean. Iftrue, enables the tax details override. Use it withnetsuite_tax_override_mode.netsuite_line_tax_overrides— Array. Sets line-level tax overrides for advanced tax scenarios. Provide it whennetsuite_tax_details_overrideistrueandnetsuite_tax_override_modeissuitetax.
The tax parameters are typically for advanced tax scenarios or for accounts that use SuiteTax.
Customer invoice example
Create a customer invoice with two lines, each with an item and a tax rate:
{
"model": {
"type": "ACCOUNTS_RECEIVABLE",
"company": "{company_merge_id}",
"contact": "{customer_merge_id}",
"number": "INV-1001",
"issue_date": "2026-09-18T00:00:00Z",
"due_date": "2026-10-18T00:00:00Z",
"currency": "USD",
"inclusive_of_tax": false,
"line_items": [
{
"description": "Implementation services",
"quantity": 1,
"unit_price": 1500,
"total_amount": 1500,
"item": "{item_merge_id}",
"tax_rate": "{tax_rate_merge_id}"
},
{
"description": "Admin training",
"quantity": 2,
"unit_price": 400,
"total_amount": 800,
"item": "{item_merge_id}",
"tax_rate": "{tax_rate_merge_id}"
}
]
}
}company— Merge ID of the companycontact— Merge ID of the customernumber— Invoice numbercurrency— ISO 4217 currency codeinclusive_of_tax— Whether the amounts include taxline_items— Array of line items, each withdescription,quantity,unit_price,total_amount,item, andtax_rate
Vendor bill example
Create a vendor bill from a purchase order, with a bill reference number:
{
"model": {
"type": "ACCOUNTS_PAYABLE",
"company": "{company_merge_id}",
"contact": "{vendor_merge_id}",
"number": "BILL-1001",
"issue_date": "2026-09-18T00:00:00Z",
"due_date": "2026-10-18T00:00:00Z",
"currency": "USD",
"purchase_orders": [
"{purchase_order_merge_id}"
],
"integration_params": {
"bill_reference_number": "VND-INV-00123"
}
}
}company— Merge ID of the companycontact— Merge ID of the vendor. It must match the vendor on every purchase order.number— Bill numbercurrency— ISO 4217 currency codepurchase_orders— Array of Purchase Order Merge IDs. Send it instead ofline_items.integration_params.bill_reference_number— Vendor bill reference number
QuickBooks Online
Required fields
Field | Customer invoice | Vendor bill |
|---|---|---|
|
|
|
| ✓ Customer or project | ✓ Vendor |
| ✓ | ✓ |
| ✓ | ✓ |
| Each line needs | Each line needs |
| Only if Custom Transaction Numbers is on in QuickBooks Online | Only if Custom Transaction Numbers is on in QuickBooks Online |
Key nuances
Contact and project — On a customer invoice, set
contactto a customer or a project, because QuickBooks Online treats a project as a customer, and every line item must reference the same project. On a vendor bill, setcontactto a vendor. Projects aren’t supported on vendor bills. Ifcontactis a project on a bill, the request fails with this error:Quickbooks Online requires a Contact of type 'Vendor' for ACCOUNTS_PAYABLE Invoices. Please enter a Contact where is_supplier = true.Document number —
numberis optional. If the company has Custom Transaction Numbers turned on in QuickBooks Online, the request fails without it. If not, QuickBooks Online assigns the next invoice or bill number.Tracking categories — Merge maps tracking categories to QuickBooks Online classes and departments.
Payment term — Set the payment term with
payment_term. Merge maps it to the QuickBooks Online sales term.Tax — If the invoice has taxes, Merge builds the tax details.
inclusive_of_taxsets whether the amounts include tax. If automatic sales tax is on, QuickBooks Online allows only one tax rate per invoice.Tax rate — Merge doesn’t require
tax_rate. If you leave it out, Merge assigns a default tax code to each line:NON(non-taxable), orTAXif the line or invoice is taxable. QuickBooks Online may accept or reject that default depending on the company’s tax settings, such as automatic sales tax. Sendtax_rateon every line to avoid errors.Discounts — Set
total_discountat the transaction level. Merge adds it as its own discount line on a customer invoice. Vendor bills and line-level discounts aren’t supported.Currency — The invoice currency must match the contact’s currency, or the request fails with this error:
Currency of {x1} must match the Contact's currency of {x2}
Customer invoice example
Create a customer invoice with one line, an item, and a tax rate:
{
"model": {
"type": "ACCOUNTS_RECEIVABLE",
"contact": "{customer_merge_id}",
"number": "INV-1001",
"issue_date": "2026-09-18T00:00:00Z",
"due_date": "2026-10-18T00:00:00Z",
"currency": "USD",
"line_items": [
{
"description": "Consulting services",
"quantity": 1,
"unit_price": 1000,
"total_amount": 1000,
"item": "{item_merge_id}",
"tax_rate": "{tax_rate_merge_id}"
}
]
}
}type—ACCOUNTS_RECEIVABLEfor a customer invoicecontact— Merge ID of the customernumber— Invoice numberissue_date— Issue date of the invoicedue_date— Due date of the invoicecurrency— ISO 4217 currency codeline_items— Array of line items, each withdescription,quantity,unit_price,total_amount,item, andtax_rate
Vendor bill example
Create a vendor bill with one line, an expense account, and a tax rate:
{
"model": {
"type": "ACCOUNTS_PAYABLE",
"contact": "{vendor_merge_id}",
"number": "BILL-1001",
"issue_date": "2026-09-18T00:00:00Z",
"due_date": "2026-10-18T00:00:00Z",
"currency": "USD",
"line_items": [
{
"description": "Software subscription",
"quantity": 1,
"unit_price": 500,
"total_amount": 500,
"account": "{expense_account_merge_id}",
"tax_rate": "{tax_rate_merge_id}"
}
]
}
}type—ACCOUNTS_PAYABLEfor a vendor billcontact— Merge ID of the vendornumber— Bill numberissue_date— Issue date of the billdue_date— Due date of the billcurrency— ISO 4217 currency codeline_items— Array of line items, each withdescription,quantity,unit_price,total_amount,account, andtax_rate
Sage Intacct
Required fields
Field | Customer invoice | Vendor bill |
|---|---|---|
| ✓ Customer | ✓ Vendor |
| ✓ | ✓ |
| ✓ | ✓ |
| Each line needs | Each line needs |
| Do not send | Do not send |
Key nuances
Existing records — The customer, accounts, and items must already exist in Sage Intacct. Reference them by Merge ID.
Purchase orders — Include at most one Purchase Order ID in
purchase_orders. Purchase orders apply to vendor bills, not customer invoices. Send eitherpurchase_ordersorline_items, not both.Currency — Set
currencyif your company uses multiple currencies. Setexchange_rateonly when the invoice currency differs from the base currency.Custom fields — To fill custom fields on your Sage Intacct invoice form, pass them in
remote_fieldsat the transaction level or on a line item. See Custom fields withremote_fieldsabove.
Sage Intacct integration parameters
Sage Intacct accepts optional values in integration_params. You only need them in specific cases.
tax_solution_id— Set it if your Sage Intacct instance uses custom tax solutions. Most invoices don’t need it.customer_idorvendor_id— At the line-item level, set only one of them, not both, to override the default customer or vendor for that line. This is for advanced scenarios.
Customer invoice example
Create a customer invoice with two lines, each with an account and an item:
{
"model": {
"type": "ACCOUNTS_RECEIVABLE",
"contact": "{customer_merge_id}",
"number": "INV-1001",
"issue_date": "2026-09-18T00:00:00Z",
"due_date": "2026-10-18T00:00:00Z",
"memo": "September implementation services",
"currency": "USD",
"line_items": [
{
"description": "Implementation services",
"quantity": 1,
"unit_price": 1500,
"total_amount": 1500,
"account": "{account_merge_id}",
"item": "{item_merge_id}"
},
{
"description": "Admin training",
"quantity": 2,
"unit_price": 400,
"total_amount": 800,
"account": "{account_merge_id}",
"item": "{item_merge_id}"
}
]
}
}contact— Merge ID of the customernumber— Invoice numberissue_date— Issue date of the invoicedue_date— Due date of the invoicememo— Private note about the invoiceline_items— Array of line items, each withdescription,quantity,unit_price,total_amount,account, anditem
Vendor bill example
Create a vendor bill with one line, an account, and an item:
{
"model": {
"type": "ACCOUNTS_PAYABLE",
"contact": "{vendor_merge_id}",
"number": "BILL-1001",
"issue_date": "2026-09-18T00:00:00Z",
"due_date": "2026-10-18T00:00:00Z",
"memo": "September software subscription",
"currency": "USD",
"line_items": [
{
"description": "Software subscription",
"quantity": 1,
"unit_price": 500,
"total_amount": 500,
"account": "{account_merge_id}",
"item": "{item_merge_id}"
}
]
}
}type—ACCOUNTS_PAYABLEfor a vendor billcontact— Merge ID of the vendornumber— Bill numberissue_date— Issue date of the billdue_date— Due date of the billmemo— Private note about the billline_items— Array of line items, each withdescription,quantity,unit_price,total_amount,account, anditem
Xero
Required fields
Field | Customer invoice | Vendor bill |
|---|---|---|
|
|
|
| ✓ Customer | ✓ Supplier |
| ✓ At least one entry | ✓ At least one entry |
Key nuances
Accounts and tax rates — Each line needs an account, an item, or both. A line with neither usually fails.
tax_rateis optional. If you omit it, Xero uses the default tax rate of the line’s account.Customer and supplier designation — Xero sets a contact’s customer or supplier designation based on the transactions associated with it. It does not let you set it through the API. If you want the designation set shortly after you create a contact, create an accounts receivable (AR) invoice or an accounts payable (AP) bill for that contact soon after.
Tracking categories — Each line item can include up to two Tracking Categories. Use at most one per
category_type. If you send two of the same type, Merge sends both to Xero, which may reject the request or keep only one.
Customer invoice example
Create a customer invoice with one line, an account, and tracking categories:
{
"model": {
"type": "ACCOUNTS_RECEIVABLE",
"contact": "{customer_merge_id}",
"number": "INV-1001",
"issue_date": "2026-09-18T00:00:00Z",
"due_date": "2026-10-18T00:00:00Z",
"memo": "September implementation services",
"currency": "AUD",
"status": "OPEN",
"line_items": [
{
"description": "Implementation services",
"unit_price": 1500,
"quantity": 1,
"total_amount": 1500,
"account": "{account_merge_id}",
"tracking_categories": [
"{tracking_category_merge_id_1}",
"{tracking_category_merge_id_2}"
]
}
]
}
}contact— Merge ID of the customernumber— Invoice numberstatus— Status of the invoice, such asOPENline_items— Array of line items, each withunit_price,quantity,total_amount,account, andtracking_categories
Vendor bill example
Create a vendor bill with two lines, each with an account and tracking categories:
{
"model": {
"type": "ACCOUNTS_PAYABLE",
"contact": "{vendor_merge_id}",
"number": "BILL-1001",
"issue_date": "2026-09-18T00:00:00Z",
"due_date": "2026-10-18T00:00:00Z",
"memo": "Sales planning workshop travel",
"currency": "AUD",
"status": "OPEN",
"line_items": [
{
"description": "Return airfare - Sydney to Melbourne",
"unit_price": 850.0,
"quantity": 2.0,
"total_amount": 1700.0,
"account": "{account_merge_id}",
"tracking_categories": [
"{tracking_category_merge_id_1}",
"{tracking_category_merge_id_2}"
]
},
{
"description": "Client dinner - Melbourne",
"unit_price": 42.5,
"quantity": 2.0,
"total_amount": 85.0,
"account": "{account_merge_id}",
"tracking_categories": [
"{tracking_category_merge_id_3}",
"{tracking_category_merge_id_2}"
]
}
]
}
}contact— Merge ID of the vendor or suppliernumber— Bill numberstatus— Status of the bill, such asOPENline_items— Array of line items, each withunit_price,quantity,total_amount,account, andtracking_categories
Questions
Have questions about a specific integration or running into integration-specific issues? Reach out to your Customer Success Manager, or contact [email protected].