Subscription Invoices

Throughout the lifecycle of a subscription, numerous invoices are generated. Typically, there is one at the time of purchase, and then one for each renewal.

A subscription invoice belongs to a Subscription and a Store.


The subscription invoice object

Attributes


store_id

The ID of the Store this subscription invoice belongs to.


subscription_id

The ID of the Subscription associated with this subscription invoice.


customer_id

The ID of the customer this subscription invoice belongs to.


user_name

The full name of the customer.


user_email

The email address of the customer.


billing_reason

The reason for the invoice being generated.

  • initial - The initial invoice generated when the subscription is created.
  • renewal - A renewal invoice generated when the subscription is renewed.
  • updated - An invoice generated when the subscription is updated.

card_brand

Lowercase brand of the card used to pay for the invoice. One of

  • visa
  • mastercard
  • amex
  • discover
  • jcb
  • diners
  • unionpay

Will be empty for non-card payments.


card_last_four

The last 4 digits of the card used to pay for the invoice. Will be empty for non-card payments.


currency

The ISO 4217 currency code for the invoice (e.g. USD, GBP, etc).


currency_rate

If the invoice currency is USD, this will always be 1.0. Otherwise, this is the currency conversion rate used to determine the cost of the invoice in USD at the time of payment.


status

The status of the invoice. One of

  • pending - The invoice is waiting for payment.
  • paid - The invoice has been paid.
  • void - The invoice was cancelled or cannot be paid.
  • refunded - The invoice was paid but has since been fully refunded.

status_formatted

The formatted status of the invoice.


refunded

A boolean value indicating whether the invoice has been refunded.


refunded_at

If the invoice has been refunded, this will be an ISO 8601 formatted date-time string indicating when the invoice was refunded. Otherwise, it will be null.


subtotal

A positive integer in cents representing the subtotal of the invoice in the invoice currency.


discount_total

A positive integer in cents representing the total discount value applied to the invoice in the invoice currency.


tax

A positive integer in cents representing the tax applied to the invoice in the invoice currency.


tax_inclusive

A boolean indicating if the order was created with tax inclusive or exclusive pricing.


total

A positive integer in cents representing the total cost of the invoice in the invoice currency.


subtotal_usd

A positive integer in cents representing the subtotal of the invoice in USD.


discount_total_usd

A positive integer in cents representing the total discount value applied to the invoice in USD.


tax_usd

A positive integer in cents representing the tax applied to the invoice in USD.


total_usd

A positive integer in cents representing the total cost of the invoice in USD.


subtotal_formatted

A human-readable string representing the subtotal of the invoice in the invoice currency (e.g. $9.99).


discount_total_formatted

A human-readable string representing the total discount value applied to the invoice in the invoice currency (e.g. $9.99).


tax_formatted

A human-readable string representing the tax applied to the invoice in the invoice currency (e.g. $9.99).


total_formatted

A human-readable string representing the total cost of the invoice in the invoice currency (e.g. $9.99).


urls

An object of customer-facing URLs for the invoice. It contains:

  • invoice_url - The unique URL to download a PDF of the invoice. Note: for security reasons, download URLs are signed (but do not expire). Will be null if status is pending.

created_at

An ISO 8601 formatted date-time string indicating when the invoice was created.


updated_at

An ISO 8601 formatted date-time string indicating when the invoice was last updated.


test_mode

A boolean indicating if the object was created within test mode.

Subscription invoice object

{ "type": "subscription-invoices", "id": "1", "attributes": { "store_id": 1, "subscription_id": 1, "customer_id": 1, "user_name": "Darlene Daugherty", "user_email": "[email protected]", "billing_reason": "initial", "card_brand": "visa", "card_last_four": "4242", "currency": "USD", "currency_rate": "1.00000000", "status": "paid", "status_formatted": "Paid", "refunded": false, "refunded_at": null, "subtotal": 999, "discount_total": 0, "tax": 0, "tax_inclusive": false, "total": 999, "subtotal_usd": 999, "discount_total_usd": 0, "tax_usd": 0, "total_usd": 999, "subtotal_formatted": "$9.99", "discount_total_formatted": "$0.00", "tax_formatted": "$0.00", "total_formatted": "$9.99", "urls": { "invoice_url": "https://app.lemonsqueezy.com/my-orders/.../subscription-invoice/..." }, "created_at": "2023-01-18T12:16:24.000000Z", "updated_at": "2023-01-18T12:16:24.000000Z", "test_mode": false }, "relationships": { "store": { "links": { "related": "https://api.lemonsqueezy.com/v1/subscription-invoices/1/store", "self": "https://api.lemonsqueezy.com/v1/subscription-invoices/1/relationships/store" } }, "subscription": { "links": { "related": "https://api.lemonsqueezy.com/v1/subscription-invoices/1/subscription", "self": "https://api.lemonsqueezy.com/v1/subscription-invoices/1/relationships/subscription" } }, "customer": { "links": { "related": "https://api.lemonsqueezy.com/v1/subscription-invoices/1/customer", "self": "https://api.lemonsqueezy.com/v1/subscription-invoices/1/relationships/customer" } } } }, "links": { "self": "https://api.lemonsqueezy.com/v1/subscription-invoices/1" } }

Retrieve a subscription invoice

Retrieves the subscription invoice with the given ID.

GET /v1/subscription-invoices/:id

curl "https://api.lemonsqueezy.com/v1/subscription-invoices/1" -H 'Accept: application/vnd.api+json' -H 'Content-Type: application/vnd.api+json' -H 'Authorization: Bearer {api_key}'

Returns

Returns a subscription invoice object.

Response

{ "jsonapi": { "version": "1.0" }, "links": { "self": "https://api.lemonsqueezy.com/v1/subscription-invoices/1" }, "data": { "type": "subscription-invoices", "id": "1", "attributes": { "store_id": 1, "subscription_id": 1, "customer_id": 1, "user_name": "Darlene Daugherty", "user_email": "[email protected]", "billing_reason": "initial", "card_brand": "visa", "card_last_four": "4242", "currency": "USD", "currency_rate": "1.00000000", "status": "paid", "status_formatted": "Paid", "refunded": false, "refunded_at": null, "subtotal": 999, "discount_total": 0, "tax": 0, "tax_inclusive": false, "total": 999, "subtotal_usd": 999, "discount_total_usd": 0, "tax_usd": 0, "total_usd": 999, "subtotal_formatted": "$9.99", "discount_total_formatted": "$0.00", "tax_formatted": "$0.00", "total_formatted": "$9.99", "urls": { "invoice_url": "https://app.lemonsqueezy.com/my-orders/.../subscription-invoice/..." }, "created_at": "2023-01-18T12:16:24.000000Z", "updated_at": "2023-01-18T12:16:24.000000Z", "test_mode": false }, "relationships": { "store": { "links": { "related": "https://api.lemonsqueezy.com/v1/subscription-invoices/1/store", "self": "https://api.lemonsqueezy.com/v1/subscription-invoices/1/relationships/store" } }, "subscription": { "links": { "related": "https://api.lemonsqueezy.com/v1/subscription-invoices/1/subscription", "self": "https://api.lemonsqueezy.com/v1/subscription-invoices/1/relationships/subscription" } }, "customer": { "links": { "related": "https://api.lemonsqueezy.com/v1/subscription-invoices/1/customer", "self": "https://api.lemonsqueezy.com/v1/subscription-invoices/1/relationships/customer" } } }, "links": { "self": "https://api.lemonsqueezy.com/v1/subscription-invoices/1" } } }

List all subscription invoices

Returns a paginated list of subscription invoices.

Tip: to retrieve subscription invoices for a certain subscription, you can include related resources or use a nested query.

Parameters


store_id

Only return subscription invoices belonging to the store with this ID.


status

Only return subscription invoices with this status.


refunded

Only return subscription invoices that are refunded (the value should be true or false).


subscription_id

Only return subscription invoices belonging to a subscription with this ID.

GET /v1/subscription-invoices

curl "https://api.lemonsqueezy.com/v1/subscription-invoices" -H 'Accept: application/vnd.api+json' -H 'Content-Type: application/vnd.api+json' -H 'Authorization: Bearer {api_key}'
curl "https://api.lemonsqueezy.com/v1/subscription-invoices?filter[status]=past_due" -H 'Accept: application/vnd.api+json' -H 'Content-Type: application/vnd.api+json' -H 'Authorization: Bearer {api_key}'
curl "https://api.lemonsqueezy.com/v1/subscription-invoices?filter[subscription_id]=6" -H 'Accept: application/vnd.api+json' -H 'Content-Type: application/vnd.api+json' -H 'Authorization: Bearer {api_key}'

Returns

Returns a paginated list of subscription invoice objects ordered by created_at (descending).

Response

{ "meta": { "page": { "currentPage": 1, "from": 1, "lastPage": 1, "perPage": 10, "to": 10, "total": 10 } }, "jsonapi": { "version": "1.0" }, "links": { "first": "https://api.lemonsqueezy.com/v1/subscription-invoices?page%5Bnumber%5D=1&page%5Bsize%5D=10&sort=-createdAt", "last": "https://api.lemonsqueezy.com/v1/subscription-invoices?page%5Bnumber%5D=1&page%5Bsize%5D=10&sort=-createdAt" }, "data": [ { "type": "subscription-invoices", "id": "1", "attributes": { "store_id": 1, "subscription_id": 1, "customer_id": 1, "user_name": "Darlene Daugherty", "user_email": "[email protected]", "billing_reason": "initial", "card_brand": "visa", "card_last_four": "4242", "currency": "USD", "currency_rate": "1.00000000", "status": "paid", "status_formatted": "Paid", "refunded": false, "refunded_at": null, "subtotal": 999, "discount_total": 0, "tax": 0, "tax_inclusive": false, "total": 999, "subtotal_usd": 999, "discount_total_usd": 0, "tax_usd": 0, "total_usd": 999, "subtotal_formatted": "$9.99", "discount_total_formatted": "$0.00", "tax_formatted": "$0.00", "total_formatted": "$9.99", "urls": { "invoice_url": "https://app.lemonsqueezy.com/my-orders/.../subscription-invoice/..." }, "created_at": "2023-01-18T12:16:24.000000Z", "updated_at": "2023-01-18T12:16:24.000000Z", "test_mode": false }, "relationships": { "store": { "links": { "related": "https://api.lemonsqueezy.com/v1/subscription-invoices/1/store", "self": "https://api.lemonsqueezy.com/v1/subscription-invoices/1/relationships/store" } }, "subscription": { "links": { "related": "https://api.lemonsqueezy.com/v1/subscription-invoices/1/subscription", "self": "https://api.lemonsqueezy.com/v1/subscription-invoices/1/relationships/subscription" } }, "customer": { "links": { "related": "https://api.lemonsqueezy.com/v1/subscription-invoices/1/customer", "self": "https://api.lemonsqueezy.com/v1/subscription-invoices/1/relationships/customer" } } }, "links": { "self": "https://api.lemonsqueezy.com/v1/subscription-invoices/1" } }, {...}, {...}, ] }

Generate subscription invoice

Generates a new invoice for the given subscription with given parameters.

Attributes


name

Optional. The full name of the customer.


address

Optional. The street address of the customer.


city

Optional. The city of the customer.


state

Optional. The state of the customer.


zip_code

Optional. The ZIP code of the customer.


country

Optional. The country of the customer.


notes

Optional. Any additional notes to include on the invoice.


POST /v1/subscription-invoices/:id/generate-invoice

curl -X "POST" "https://api.lemonsqueezy.com/v1/subscription-invoices/1/generate-invoice?name=John%20Doe&address=123%20Main%20St&city=Anytown&state=CA&zip_code=12345&country=US¬es=Thank%20you%20for%20your%20business" -H 'Accept: application/vnd.api+json' -H 'Content-Type: application/vnd.api+json' -H 'Authorization: Bearer {api_key}'

Returns

Returns a link to download the generated invoice.

Response

{ "jsonapi": { "version": "1.0" }, "meta": { "urls": { "download_invoice": "https://app.lemonsqueezy.com/my-orders/c1e4de31-b4cf-4668-a6fe-019d071d41ab/subscription-invoice/75/download?address=123%20Main%20St&city=Anytown&country=US&name=John%20Doe¬es=Thank%20you%20for%20your%20business&state=CA&zip_code=12345&signature=c21a17a13d9deeacc99ff52144a06b49df141af37dd668cc70a76bcc8022888e" } } }