Create invoice

Create a new invoice.

Recent Requests
Log in to see full request history
TimeStatusUser Agent
Retrieving recent requests…
LoadingLoading…

Overview

Create a new invoice for a customer. Invoices can be created manually for one-time charges or custom billing scenarios outside of the normal subscription cycle.

Example: Create a manual invoice for a customer who requested additional services not covered by their subscription.


Conditional Requirements

ConditionRequired Fields
Alwayscustomer_id OR customer_old_provider_id (at least one)
Alwayscurrency
No line_items providedtotal
line_items providedline_items.*.unit_price, line_items.*.quantity
line_items.*.tax_name is setline_items.*.tax_rate
line_items.*.tax_rate is setline_items.*.tax_name
line_items.*.tax_amount is setline_items.*.tax_name, line_items.*.tax_rate
line_items.*.tax_name_N / tax_rate_N / tax_amount_N is setSame rules as above, for the same N
Top-level tax_name, tax_rate or tax_amount is setThe other two top-level tax fields (for the same suffix)
Both customer_id AND customer_old_provider_id are setMust reference the same customer
Both subscription_id AND subscription_old_provider_id are setMust reference the same subscription

Taxes

A tax is a set of three fields: tax_name, tax_rate (percentage, 0–100) and tax_amount (minor units, e.g. cents). When tax_amount is sent it is stored exactly as provided instead of being calculated from the rate, which is useful when importing invoices from another system.

Multiple taxes. Add more taxes by repeating the set with a numeric suffix, _1 to _5, or the same number without the underscore:

  • tax_name_1, tax_rate_1, tax_amount_1
  • tax_name2, tax_rate2, tax_amount2

Each tax is attached to the same line item. The account's tax setting still applies: with exclusive tax the tax is added to the total, with inclusive tax the total is treated as already including it.

Several taxes on the subscription line

When subscription_id is provided without line_items, one line item is created from the subscription and every complete top-level tax set (name, rate and amount) is attached to it.

{
  "customer_id": 1234,
  "subscription_id": 5678,
  "currency": "cad",
  "total": 10000,
  "tax_name": "GST",   "tax_rate": 5,    "tax_amount": 500,
  "tax_name_1": "QST", "tax_rate_1": 10, "tax_amount_1": 1000,
  "tax_name2": "PST",  "tax_rate2": 7,   "tax_amount2": 700
}

Result: one line item, subtotal 10000, tax 2200, total 12200.

Several taxes per line item

Each entry in line_items can carry its own taxes. On a line item, tax_amount is optional; when omitted it is calculated from the rate.

{
  "customer_id": 1234,
  "currency": "cad",
  "line_items": [
    {
      "description": "Print subscription",
      "unit_price": 10000,
      "quantity": 1,
      "tax_name": "GST",   "tax_rate": 5,    "tax_amount": 500,
      "tax_name_1": "QST", "tax_rate_1": 10, "tax_amount_1": 1000
    },
    {
      "description": "Digital add-on",
      "unit_price": 4000,
      "quantity": 1,
      "tax_name_1": "GST", "tax_rate_1": 5, "tax_amount_1": 200
    }
  ]
}

Flat line item keys (CSV imports)

Line items can also be sent as flat keys named line_N_<field>, so one CSV row can describe a whole invoice. Each N becomes one line item, ordered by N, with all of its taxes. A group whose values are all empty is ignored, so a CSV can keep unused columns. Flat line items are added after any line_items in the same request.

line_1_description, line_1_unit_price, line_1_quantity,
line_1_tax_name, line_1_tax_rate, line_1_tax_amount,
line_1_tax_name_1, line_1_tax_rate_1, line_1_tax_amount_1,
line_2_description, line_2_unit_price, line_2_quantity
{
  "customer_id": 1234,
  "currency": "cad",
  "line_1_description": "Print subscription",
  "line_1_unit_price": 10000,
  "line_1_quantity": 1,
  "line_1_tax_name": "GST",
  "line_1_tax_rate": 5,
  "line_1_tax_amount": 500,
  "line_1_tax_name_1": "QST",
  "line_1_tax_rate_1": 10,
  "line_1_tax_amount_1": 1000,
  "line_2_description": "Digital add-on",
  "line_2_unit_price": 4000,
  "line_2_quantity": 1
}
Query Params
int32
required

The unique identifier of the site associated with your account.

Body Params
string
required

The currency code. Must be valid for the account and customer and is.

line_items
array of objects

Encapsulates details about a good or service being invoiced, including its description, price, quantity, and optional taxes. Each line item can carry several taxes (tax_name/tax_rate/tax_amount plus suffixed sets).

Line items can also be sent as flat line_N_<field> keys (e.g. line_1_unit_price, line_1_tax_name_1), one line item per N.

Required if total is not provided.

line_items
int32

The total amount of the invoice in minor units e.g. cents.

Required if line_items are not provided.

string

Name of the tax applied to the line item generated from the subscription when line_items is not provided. Required with tax_rate.

double
0 to 100

Percentage (0-100) of the tax applied to the line item generated from the subscription when line_items is not provided. Required with tax_name.

int32
0 to 2147483647

Tax amount in minor units (e.g. cents), stored exactly as sent instead of being calculated from tax_rate. Requires tax_name and tax_rate. At the top level tax_name, tax_rate and tax_amount are all required for the tax to apply.

string

Name of an additional tax applied to the line item generated from the subscription when line_items is not provided. Required with tax_rate_1. Up to 5 additional taxes are supported with suffixes _1 … _5, or the same suffix without the underscore (e.g. tax_name2, tax_rate2, tax_amount2).

double
0 to 100

Percentage (0-100) of the additional tax applied to the line item generated from the subscription when line_items is not provided. Required with tax_name_1. Up to 5 additional taxes are supported with suffixes _1 … _5, or the same suffix without the underscore (e.g. tax_name2, tax_rate2, tax_amount2).

int32
0 to 2147483647

Amount in minor units of the additional tax applied to the line item generated from the subscription when line_items is not provided, stored exactly as sent. Requires tax_name_1 and tax_rate_1. At the top level tax_name, tax_rate and tax_amount are all required for the tax to apply. Up to 5 additional taxes are supported with suffixes _1 … _5, or the same suffix without the underscore (e.g. tax_name2, tax_rate2, tax_amount2).

int32

The unique identifier of the customer.

Required if customer_old_provider_id is not provided.

string

The unique identifier which was add to the customer who owns this invoice.

If provided, customer_id can be omitted.

date-time

Represents the start of the line item's billing period. Measured in seconds since the Unix epoch.

If provided, must be a timestamp before or equal to period_end.

date-time

Represents the end of the line item's billing period. Measured in seconds since the Unix epoch. Represents the start of the line item's billing period. Measured in seconds since the Unix epoch.

If provided, must be a timestamp after or equal to period_start.

date-time

Represents the date at which the invoice will be due.

If provided, must be a timestamp after or equal to period_start.

string
enum

The status of the invoice, one of: draft, open, paid, uncollectible, or void

Allowed:
string
enum

Indicates the reason why the invoice was created.

manual: For an invoice unrelated to a subscription or e-commerce order.
subscription_create: For a newly created subscription.
subscription_cycle: For a subscription which advanced into a new period.
subscription_update: For a subscription which was updated.
order_create: For an e-commerce order.

Allowed:
int32

The unique identifier of the subscription to assign to this invoice.

Can be omitted if subscription_old_provider_id is provided.

string

The unique identifier of a previously created subscription for which old_provider_id was specified.

Can be omitted if subscription_id is provided.

customer_address
object

An address object representing the customer's billing address, which will be saved under this invoice. If omitted, the default behavior will be to use the customer's current default billing address.

Can be omitted if billing_address_id is provided.

int32

Specifies the associated billing address for a customer or invoice.

Can be omitted if customer_addressis provided.

customer_shipping
object

An address object representing the customer's shipping address, which will be saved under this invoice.

Can be omitted if shipping_address_id is provided.

int32

Specifies the associated shipping address for a customer or invoice.

Can be omitted if customer_shipping is provided.

boolean
Defaults to false

A flag determining whether this invoice was imported.

metadata
object
int32

If this field is populated, the revenue recognition calculation will use its value instead of the plan_shipments_per_interval value from the plan. This allows for custom shipment-based recognition logic on a per-subscription basis

string

Specifies the purchase order value of the invoice

Responses

Language
Credentials
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json