Docs

The Invoice Item object

Invoice Items represent the component lines of an invoice. When you create an invoice item with an invoice field, it is attached to the specified invoice and included as an invoice line item within invoice.lines. Invoice items can be created before you are ready to send the invoice, which is useful with subscriptions when you want to add a charge or credit that settles with the customer's wallet at the end of a billing cycle.

Attributes

id string

Unique identifier for the object. Zoneless invoice item IDs are prefixed with ii_z_.

object string

String representing the object's type. Objects of the same type share the same value.

amount integer

Amount (in the currency specified) of the invoice item. This should always be equal to unit_amount * quantity. For USDC, this is cents (e.g., 100 = $1 USDC).

currency enum

Three-letter currency code, in lowercase. For Zoneless, this is usdc.

Difference from Stripe: Uses usdc instead of fiat currency codes like usd.

customernullable string Expandable This can be expanded into an object with the expand request parameter.

The ID of the customer to bill for this invoice item. null when using customer_account.

customer_accountnullable string

The ID of the account to bill for this invoice item.

date timestamp

Time at which the object was created. Measured in seconds since the Unix epoch.

descriptionnullable string

An arbitrary string attached to the object. Often useful for displaying to users.

discountable boolean

If true, discounts will apply to this invoice item. Always false for prorations.

discountsnullable array of strings Expandable This can be expanded into an object with the expand request parameter.

The discounts which apply to the invoice item. Item discounts are applied before invoice discounts. Use expand[]=discounts to expand each discount.

invoicenullable string Expandable This can be expanded into an object with the expand request parameter.

The ID of the invoice this invoice item belongs to.

livemode boolean

Has the value true if the object exists in live mode or the value false if the object exists in test mode.

metadatanullable object

Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.

period object

The period associated with this invoice item. When set to different values, the period will be rendered on the invoice.

pricingnullable object

The pricing information of the invoice item.

proration boolean

Whether the invoice item was created automatically as a proration adjustment when the customer switched plans.

quantity integer

Quantity of units for the invoice item in integer format, with any decimal precision truncated. For the item's full-precision decimal quantity, use quantity_decimal. This field will be deprecated in favor of quantity_decimal in a future version. If the invoice item is a proration, the quantity of the subscription that the proration was computed for.

quantity_decimal decimal string

Non-negative decimal with at most 12 decimal places. The quantity of units for the invoice item.

More attributes

THE INVOICE ITEM OBJECT
{
  "id": "ii_z_1QfGHtLkdIwHu7ixBYwjAM42",
  "object": "invoiceitem",
  "amount": 2500,
  "currency": "usdc",
  "customer": "cus_z_KmR4eUfNV2Hib",
  "customer_account": null,
  "date": 1721415600,
  "created": 1721415600,
  "description": "Studio license",
  "discountable": true,
  "discounts": [],
  "invoice": null,
  "livemode": false,
  "metadata": {},
  "net_amount": null,
  "parent": null,
  "period": {
    "end": 1721415600,
    "start": 1721415600
  },
  "pricing": {
    "price_details": {
      "price": "price_z_1QfGHsLkdIwHu7ix1be5Ljaj",
      "product": "prod_z_KmR47xbBdJT8EN"
    },
    "type": "price_details",
    "unit_amount_decimal": "2500"
  },
  "proration": false,
  "proration_details": null,
  "quantity": 1,
  "quantity_decimal": "1",
  "tax_rates": [],
  "test_clock": null,
  "platform_account": "acct_z_Platform123abc"
}

Create an invoice item

Creates an item to be added to a draft invoice (up to 250 items per invoice). If no invoice is specified, the item will be on the next invoice created for the customer specified.

ENDPOINTS
POST /v1/invoiceitems

Parameters

customer string Required unless customer_account is provided

The ID of the customer to bill for this invoice item.

customer_account string Required unless customer is provided

The ID of the account representing the customer to bill for this invoice item.

amount integer

The integer amount in the smallest currency unit of the charge to be applied to the upcoming invoice. Passing in a negative amount will reduce the amount_due on the invoice. For USDC, this is cents (e.g., 100 = $1 USDC).

currency enum

Three-letter currency code, in lowercase. For Zoneless, use usdc.

Difference from Stripe: Use usdc instead of fiat currency codes like usd.

description string

An arbitrary string which you can attach to the invoice item. The description is displayed in the invoice for easy tracking.

pricing object

The pricing information for the invoice item.

quantity integer

Non-negative integer. The quantity of units for the invoice item. Use quantity_decimal instead to provide decimal precision. This field will be deprecated in favor of quantity_decimal in a future version.

More attributes

Returns

The created invoice item object is returned if successful. Otherwise, this call raises an error.

POST/v1/invoiceitems
import { Zoneless } from '@zoneless/node';
const zoneless = new Zoneless('sk_live_z_YOUR_API_KEY', 'https://api.zoneless.com');

const invoiceItem = await zoneless.invoiceItems.create({
  customer: 'cus_z_KmR4eUfNV2Hib',
  pricing: {
    price: 'price_z_1QfGHsLkdIwHu7ix1be5Ljaj',
  },
});
RESPONSE
{
  "id": "ii_z_1QfGHtLkdIwHu7ixBYwjAM42",
  "object": "invoiceitem",
  "amount": 2500,
  "currency": "usdc",
  "customer": "cus_z_KmR4eUfNV2Hib",
  "customer_account": null,
  "date": 1721415600,
  "created": 1721415600,
  "description": "Studio license",
  "discountable": true,
  "discounts": [],
  "invoice": null,
  "livemode": false,
  "metadata": {},
  "net_amount": null,
  "parent": null,
  "period": {
    "end": 1721415600,
    "start": 1721415600
  },
  "pricing": {
    "price_details": {
      "price": "price_z_1QfGHsLkdIwHu7ix1be5Ljaj",
      "product": "prod_z_KmR47xbBdJT8EN"
    },
    "type": "price_details",
    "unit_amount_decimal": "2500"
  },
  "proration": false,
  "proration_details": null,
  "quantity": 1,
  "quantity_decimal": "1",
  "tax_rates": [],
  "test_clock": null,
  "platform_account": "acct_z_Platform123abc"
}

Update an invoice item

Updates the amount or description of an invoice item on an upcoming invoice. Updating an invoice item is only possible before the invoice it's attached to is closed.

ENDPOINTS
POST /v1/invoiceitems/:id

Parameters

amount integer

The integer amount in the smallest currency unit of the charge to be applied to the upcoming invoice. If you want to apply a credit to the customer's account, pass a negative amount.

description string

An arbitrary string which you can attach to the invoice item. The description is displayed in the invoice for easy tracking.

metadata object

Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata.

pricing object

The pricing information for the invoice item.

quantity integer

Non-negative integer. The quantity of units for the invoice item. Use quantity_decimal instead to provide decimal precision. This field will be deprecated in favor of quantity_decimal in a future version.

More attributes

Returns

The updated invoice item object is returned upon success. Otherwise, this call raises an error.

POST/v1/invoiceitems/:id
import { Zoneless } from '@zoneless/node';
const zoneless = new Zoneless('sk_live_z_YOUR_API_KEY', 'https://api.zoneless.com');

const invoiceItem = await zoneless.invoiceItems.update(
  'ii_z_1QfGHtLkdIwHu7ixBYwjAM42',
  {
    metadata: {
      order_id: '9284',
    },
  }
);
RESPONSE
{
  "id": "ii_z_1QfGHtLkdIwHu7ixBYwjAM42",
  "object": "invoiceitem",
  "amount": 2500,
  "currency": "usdc",
  "customer": "cus_z_KmR4eUfNV2Hib",
  "customer_account": null,
  "date": 1721415600,
  "created": 1721415600,
  "description": "Studio license",
  "discountable": true,
  "discounts": [],
  "invoice": null,
  "livemode": false,
  "metadata": {
    "order_id": "9284"
  },
  "net_amount": null,
  "parent": null,
  "period": {
    "end": 1721415600,
    "start": 1721415600
  },
  "pricing": {
    "price_details": {
      "price": "price_z_1QfGHsLkdIwHu7ix1be5Ljaj",
      "product": "prod_z_KmR47xbBdJT8EN"
    },
    "type": "price_details",
    "unit_amount_decimal": "2500"
  },
  "proration": false,
  "proration_details": null,
  "quantity": 1,
  "quantity_decimal": "1",
  "tax_rates": [],
  "test_clock": null,
  "platform_account": "acct_z_Platform123abc"
}

Retrieve an invoice item

Retrieves the invoice item with the given ID.

ENDPOINTS
GET /v1/invoiceitems/:id

Parameters

No parameters.

Returns

Returns an invoice item if a valid invoice item ID was provided. Raises an error otherwise.

GET/v1/invoiceitems/:id
import { Zoneless } from '@zoneless/node';
const zoneless = new Zoneless('sk_live_z_YOUR_API_KEY', 'https://api.zoneless.com');

const invoiceItem = await zoneless.invoiceItems.retrieve(
  'ii_z_1QfGHtLkdIwHu7ixBYwjAM42'
);
RESPONSE
{
  "id": "ii_z_1QfGHtLkdIwHu7ixBYwjAM42",
  "object": "invoiceitem",
  "amount": 2500,
  "currency": "usdc",
  "customer": "cus_z_KmR4eUfNV2Hib",
  "customer_account": null,
  "date": 1721415600,
  "created": 1721415600,
  "description": "Studio license",
  "discountable": true,
  "discounts": [],
  "invoice": null,
  "livemode": false,
  "metadata": {},
  "net_amount": null,
  "parent": null,
  "period": {
    "end": 1721415600,
    "start": 1721415600
  },
  "pricing": {
    "price_details": {
      "price": "price_z_1QfGHsLkdIwHu7ix1be5Ljaj",
      "product": "prod_z_KmR47xbBdJT8EN"
    },
    "type": "price_details",
    "unit_amount_decimal": "2500"
  },
  "proration": false,
  "proration_details": null,
  "quantity": 1,
  "quantity_decimal": "1",
  "tax_rates": [],
  "test_clock": null,
  "platform_account": "acct_z_Platform123abc"
}

List all invoice items

Returns a list of your invoice items. Invoice items are returned sorted by creation date, with the most recently created invoice items appearing first.

ENDPOINTS
GET /v1/invoiceitems

Parameters

customer string

The identifier of the customer whose invoice items to return. If none is provided, returns all invoice items.

invoice string

Only return invoice items belonging to this invoice. If none is provided, all invoice items will be returned. If specifying an invoice, no customer identifier is needed.

limit integer

A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.

pending boolean

Set to true to only show pending invoice items, which are not yet attached to any invoices. Set to false to only show invoice items already attached to invoices. If unspecified, no filter is applied.

More attributes

Returns

A dictionary with a data property that contains an array of up to limit invoice items, starting after invoice item starting_after. Each entry in the array is a separate invoice item object. If no more invoice items are available, the resulting array will be empty.

GET/v1/invoiceitems
import { Zoneless } from '@zoneless/node';
const zoneless = new Zoneless('sk_live_z_YOUR_API_KEY', 'https://api.zoneless.com');

const invoiceItems = await zoneless.invoiceItems.list({
  limit: 3,
});
RESPONSE
{
  "object": "list",
  "url": "/v1/invoiceitems",
  "has_more": false,
  "data": [
    {
      "id": "ii_z_1QfGHtLkdIwHu7ixBYwjAM42",
      "object": "invoiceitem",
      "amount": 2500,
      "currency": "usdc",
      "customer": "cus_z_KmR4eUfNV2Hib",
      "customer_account": null,
      "date": 1721415600,
      "created": 1721415600,
      "description": "Studio license",
      "discountable": true,
      "discounts": [],
      "invoice": null,
      "livemode": false,
      "metadata": {},
      "net_amount": null,
      "parent": null,
      "period": {
        "end": 1721415600,
        "start": 1721415600
      },
      "pricing": {
        "price_details": {
          "price": "price_z_1QfGHsLkdIwHu7ix1be5Ljaj",
          "product": "prod_z_KmR47xbBdJT8EN"
        },
        "type": "price_details",
        "unit_amount_decimal": "2500"
      },
      "proration": false,
      "proration_details": null,
      "quantity": 1,
      "quantity_decimal": "1",
      "tax_rates": [],
      "test_clock": null,
      "platform_account": "acct_z_Platform123abc"
    }
  ]
}

Delete an invoice item

Deletes an invoice item, removing it from an invoice. Deleting invoice items is only possible when they're not attached to invoices, or if they're attached to a draft invoice.

ENDPOINTS
DELETE /v1/invoiceitems/:id

Parameters

No parameters.

Returns

An object with the deleted invoice item's ID and a deleted flag upon success. Otherwise, this call raises an error, such as if the invoice item has already been deleted.

DELETE/v1/invoiceitems/:id
import { Zoneless } from '@zoneless/node';
const zoneless = new Zoneless('sk_live_z_YOUR_API_KEY', 'https://api.zoneless.com');

const deleted = await zoneless.invoiceItems.del(
  'ii_z_1QfGHtLkdIwHu7ixBYwjAM42'
);
RESPONSE
{
  "id": "ii_z_1QfGHtLkdIwHu7ixBYwjAM42",
  "object": "invoiceitem",
  "deleted": true
}