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

type

Contact

Invoice

ACCOUNTS_RECEIVABLE

Customer

Bill

ACCOUNTS_PAYABLE

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_RECEIVABLE to create a customer invoice, or

  • ACCOUNTS_PAYABLE to 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 = true if your amounts already include tax.

  • inclusive_of_tax = false if 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_categories array to include the id values 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_RECEIVABLE for a customer invoice

  • contact — the Merge Contact ID of the customer

  • issue_date — Issue date of the invoice

  • due_date — Due date of the invoice

  • currency — ISO 4217 currency code

  • memo — Private note about the invoice

  • line_items — Array of line items, each with description, quantity, unit_price, total_amount, and item

  • tracking_categories — Array of Tracking Category id values. Set it at the transaction level, on each line item, or both.

  • sub_total — Total amount before taxes

  • total_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_PAYABLE for a vendor bill

  • contact — Merge ID of the vendor or supplier

  • issue_date — Issue date of the bill

  • due_date — Due date of the bill

  • currency — ISO 4217 currency code

  • line_items — Array of line items, each with description, quantity, unit_price, total_amount, and account

  • sub_total — Total amount before taxes

  • total_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 required remote_field_class ID and a value

Integration nuances

NetSuite

Required fields

Field

Customer invoice

Vendor bill

type

ACCOUNTS_RECEIVABLE

ACCOUNTS_PAYABLE

company

✓

✓

contact

✓ Customer

✓ Vendor

currency

✓

✓

line_items

Each line needs an item

Each line needs an item or an account, or send purchase_orders instead

Key nuances

  • Contact and project — Always set contact at the top level. On each line item, set contact or project, but not both.

  • Purchase orders — Send line_items or purchase_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_orders must belong to the same vendor as contact. 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 as suitetax.

  • netsuite_tax_details_override — Boolean. If true, enables the tax details override. Use it with netsuite_tax_override_mode.

  • netsuite_line_tax_overrides — Array. Sets line-level tax overrides for advanced tax scenarios. Provide it when netsuite_tax_details_override is true and netsuite_tax_override_mode is suitetax.

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 company

  • contact — Merge ID of the customer

  • number — Invoice number

  • currency — ISO 4217 currency code

  • inclusive_of_tax — Whether the amounts include tax

  • line_items — Array of line items, each with description, quantity, unit_price, total_amount, item, and tax_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 company

  • contact — Merge ID of the vendor. It must match the vendor on every purchase order.

  • number — Bill number

  • currency — ISO 4217 currency code

  • purchase_orders — Array of Purchase Order Merge IDs. Send it instead of line_items.

  • integration_params.bill_reference_number — Vendor bill reference number

QuickBooks Online

Required fields

Field

Customer invoice

Vendor bill

type

ACCOUNTS_RECEIVABLE

ACCOUNTS_PAYABLE

contact

✓ Customer or project

✓ Vendor

issue_date

✓

✓

due_date

✓

✓

line_items

Each line needs description, quantity, unit_price, total_amount, and an item

Each line needs description, quantity, unit_price, total_amount, and an item or an account

number

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 contact to 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, set contact to a vendor. Projects aren’t supported on vendor bills. If contact is 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 — number is 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_tax sets 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), or TAX if 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. Send tax_rate on every line to avoid errors.

  • Discounts — Set total_discount at 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_RECEIVABLE for a customer invoice

  • contact — Merge ID of the customer

  • number — Invoice number

  • issue_date — Issue date of the invoice

  • due_date — Due date of the invoice

  • currency — ISO 4217 currency code

  • line_items — Array of line items, each with description, quantity, unit_price, total_amount, item, and tax_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_PAYABLE for a vendor bill

  • contact — Merge ID of the vendor

  • number — Bill number

  • issue_date — Issue date of the bill

  • due_date — Due date of the bill

  • currency — ISO 4217 currency code

  • line_items — Array of line items, each with description, quantity, unit_price, total_amount, account, and tax_rate

Sage Intacct

Required fields

Field

Customer invoice

Vendor bill

contact

✓ Customer

✓ Vendor

issue_date

✓

✓

due_date

✓

✓

line_items

Each line needs total_amount, account, and item

Each line needs account. item is optional. Not sent with purchase_orders.

status

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 either purchase_orders or line_items, not both.

  • Currency — Set currency if your company uses multiple currencies. Set exchange_rate only 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_fields at the transaction level or on a line item. See Custom fields with remote_fields above.

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_id or vendor_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 customer

  • number — Invoice number

  • issue_date — Issue date of the invoice

  • due_date — Due date of the invoice

  • memo — Private note about the invoice

  • line_items — Array of line items, each with description, quantity, unit_price, total_amount, account, and item

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_PAYABLE for a vendor bill

  • contact — Merge ID of the vendor

  • number — Bill number

  • issue_date — Issue date of the bill

  • due_date — Due date of the bill

  • memo — Private note about the bill

  • line_items — Array of line items, each with description, quantity, unit_price, total_amount, account, and item

Xero

Required fields

Field

Customer invoice

Vendor bill

type

ACCOUNTS_RECEIVABLE

ACCOUNTS_PAYABLE

contact

✓ Customer

✓ Supplier

line_items

✓ 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_rate is 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 customer

  • number — Invoice number

  • status — Status of the invoice, such as OPEN

  • line_items — Array of line items, each with unit_price, quantity, total_amount, account, and tracking_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 supplier

  • number — Bill number

  • status — Status of the bill, such as OPEN

  • line_items — Array of line items, each with unit_price, quantity, total_amount, account, and tracking_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].