Skip to main content

Create Invoice

Creates an invoice in one of two ways:

  • From an order: send orderId. The line items, addresses, amounts, payment term, amount paid, status and due date are taken from the order.
  • Standalone: send "standalone": true with the full invoice details, for invoices that do not come from a store order (for example, invoices from your ERP).

Each order can have one active (not voided) invoice.

HTTP Request​

  • URL: /invoices
  • Method: POST
  • Headers:
    • accessToken: Required. Your API access token.
    • Content-Type: application/json
  • Required scope: READ_WRITE_INVOICE

Request Body​

The request body is a JSON object. Use the first table to create an invoice from an order, or the second table for a standalone invoice.

Invoice From an Order​

FieldTypeRequiredDescription
orderIdStringYesID of the order to invoice. The order must have items and must not be cancelled.
notesStringNoNotes shown on the invoice.
termsAndConditionsStringNoTerms shown on the invoice. Default is the store's default terms.
metaFieldsArrayNoCustom field values, each with code and value. Default is the order's metafields.
sendEmailBooleanNotrue to email the invoice to the customer. Default is false.

Standalone Invoice​

Include at least one of companyId, customerId or customerDetails.email.

FieldTypeRequiredDescription
standaloneBooleanYesSet to true.
lineItemsArrayYesInvoiced items, at least one. See Line Item Object.
totalNumberYesInvoice total.
companyIdStringNoID of the company to bill. Its details are filled in if companyDetails is not sent.
customerIdStringNoID of the customer to bill. Their details are filled in if customerDetails is not sent.
customerDetailsObjectNoCustomer firstName, lastName, email and phoneNumber.
companyDetailsObjectNoCompany name, email and phoneNumber.
orderIdStringNoID of a related order.
billingAddressObjectNoBilling address. See Address Object.
shippingAddressObjectNoShipping address. See Address Object.
currencyObjectNoCurrency currency (code) and symbol. Default is the store currency.
selectedCurrencyObjectNoCustomer's currency currency and exchange rate. The currency must be set up in the store.
selectedCurrencyAmountObjectNoAmounts in the selected currency. Calculated from rate if not sent.
subTotalNumberNoSubtotal. Default is the sum of the line totals.
lineDiscountAmountNumberNoLine discounts. Default is the sum of the line discounts.
discountAmountNumberNoOrder-level discount.
shippingCostNumberNoShipping charge.
shippingDiscountAmountNumberNoDiscount on shipping.
taxAmountNumberNoTax.
storeCreditAmountNumberNoStore credit used.
additionalCostsArrayNoExtra charges, each with name and amount.
shipmentDetailsObjectNoShipping method, as shippingMethod with name and label.
statusStringNodraft, open, partially_paid, paid or void. Default is based on paidAmount and total.
paidAmountNumberNoAmount already paid. Default is 0.
issuedDateStringNoIssue date. Default is today.
dueDateStringNoDue date. Default is based on the payment term.
paymentTermObjectNoPayment term name, paymentDueDays and dueType (net or fulfillment). Default is the store's default invoice payment term.
voidReasonStringNoReason, when creating a void invoice.
termsAndConditionsStringNoTerms shown on the invoice.
notesStringNoNotes shown on the invoice.
metaFieldsArrayNoCustom field values, each with code and value.
sendEmailBooleanNotrue to email the invoice to the customer. Default is false.

Line Item Object​

FieldTypeRequiredDescription
nameStringYesItem name.
skuStringYesItem SKU.
quantityNumberYesQuantity, greater than 0.
priceNumberYesUnit price.
extendedPriceNumberYesLine total.
discountAmountNumberNoLine discount.
productIdStringNoID of the matching store product.
variantIdStringNoID of the matching variant.
optionsArrayNoVariant options, each with optionName, optionValueLabel and optionValue.

Address Object​

FieldTypeRequiredDescription
address1StringYesStreet address.
cityStringYesCity.
stateObjectYesState name and code.
countryObjectYesCountry name and code.
firstName, lastNameStringNoName.
companyNameStringNoCompany name.
address2StringNoAdditional address line.
zipcodeStringNoPostal code.
phoneNumberStringNoPhone number.

cURL Example​

Create an invoice from an order:

curl --location '<BASE_URL>/invoices' \
--header 'accessToken: <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"orderId": "664f2310d5775459152d6dd8",
"notes": "Invoiced per customer PO #4521",
"metaFields": [{ "code": "erpInvoiceId", "value": "ERP-INV-88213" }],
"sendEmail": true
}'

Create a standalone invoice:

curl --location '<BASE_URL>/invoices' \
--header 'accessToken: <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"standalone": true,
"customerId": "664dec6cd5775459152d4926",
"billingAddress": {
"firstName": "Maria",
"lastName": "Lopez",
"address1": "4100 Industrial Blvd",
"city": "Austin",
"state": { "name": "Texas", "code": "TX" },
"country": { "name": "United States", "code": "US" },
"zipcode": "78744"
},
"lineItems": [
{ "name": "On-site safety training (July)", "sku": "SVC-TRAIN", "quantity": 10, "price": 150, "extendedPrice": 1500 }
],
"total": 1500
}'

Response​

  • 200 OK: The invoice was created.
  • 400 Bad Request: A required field is missing or invalid, the order, company or customer was not found, the order cannot be invoiced, or the order already has an invoice.
  • 401 Unauthorized: The access token is missing or invalid.
  • 403 Forbidden: The access token does not have the required scope.

Sample JSON Response​

{
"success": true,
"message": "Invoice created successfully",
"data": {
"id": "665f2310d5775459152d6dd8",
"entityId": "INV-1002",
"order": null,
"customer": "664dec6cd5775459152d4926",
"customerDetails": {
"firstName": "Maria",
"lastName": "Lopez",
"email": "maria.lopez@northwindsupply.com",
"phoneNumber": "512-555-0142"
},
"lineItems": [
{
"id": "665f2310d5775459152d6ddb",
"name": "On-site safety training (July)",
"sku": "SVC-TRAIN",
"quantity": 10,
"price": 150,
"extendedPrice": 1500,
"discountAmount": 0
}
],
"subTotal": 1500,
"total": 1500,
"status": "open",
"issuedDate": "2026-07-13T08:39:44.791Z",
"dueDate": "2026-08-12T08:39:44.791Z",
"paidAmount": 0,
"createdBy": { "id": "6489b2479467bbcf8c3d33aa", "name": "ERP Connector", "type": "api" },
"createdAt": "2026-07-13T08:39:44.816Z",
"updatedAt": "2026-07-13T08:39:44.816Z"
}
}

Response Details​

Invoice Data​

FieldTypeDescription
successBooleanWhether the invoice was created.
messageStringResult message.
dataObjectThe new invoice. See Get Invoice for all fields.

Notes​

  • The due date is the issue date plus the payment term's due days. For fulfillment payment terms, it is counted from the latest shipment date and is empty until the order ships. Without a payment term, the due date is the issue date.
  • An invoice created from an order can already be partially_paid or paid if the order has been paid.
  • A voided invoice does not stop you from creating a new invoice for the same order.
  • To invoice many orders at once, use Create Bulk Invoices.