Skip to main content
POST
/
invoices
JavaScript
import Whop from '@whop/sdk';

const client = new Whop({
  apiKey: process.env['WHOP_API_KEY'], // This is the default and can be omitted
});

const invoice = await client.invoices.create({
  collection_method: 'send_invoice',
  company_id: 'biz_xxxxxxxxxxxxxx',
  due_date: '2023-12-01T05:00:00.401Z',
  member_id: 'mber_xxxxxxxxxxxxx',
  plan: {},
  product: { title: 'title' },
});

console.log(invoice.id);
{
  "id": "inv_xxxxxxxxxxxxxx",
  "created_at": "2023-12-01T05:00:00.401Z",
  "status": "draft",
  "number": "#0001",
  "due_date": "2023-12-01T05:00:00.401Z",
  "email_address": "customer@example.com",
  "fetch_invoice_token": "eyJhbGciOiJIUzI1NiJ9...",
  "current_plan": {
    "id": "plan_xxxxxxxxxxxxx",
    "formatted_price": "$10.00",
    "currency": "usd"
  },
  "user": {
    "id": "user_xxxxxxxxxxxxx",
    "name": "John Doe",
    "username": "johndoe42"
  }
}

Authorizations

Authorization
string
header
required

A company API key, company scoped JWT, app API key, or user OAuth token. You must prepend your key/token with the word 'Bearer', which will look like Bearer ***************************

Body

application/json

Autogenerated input type of CreateInvoice

company_id
string
required

The unique identifier of the company to create this invoice for.

Example:

"biz_xxxxxxxxxxxxxx"

product
object
required

The properties of the product to create for this invoice. Provide this to create a new product inline.

member_id
string
required

The unique identifier of an existing member to create this invoice for. If not provided, you must supply an email_address and customer_name.

Example:

"mber_xxxxxxxxxxxxx"

plan
object
required

The plan attributes defining the price, currency, and billing interval for this invoice.

collection_method
enum<string>
required

How the invoice should be collected. Use charge_automatically to charge a stored payment method, or send_invoice to email the customer.

Available options:
send_invoice,
charge_automatically
due_date
string<date-time>
required

The date by which the invoice must be paid.

Example:

"2023-12-01T05:00:00.401Z"

customer_name
string | null

The name of the customer. Required when creating an invoice for a customer who is not yet a member of the company.

automatically_finalizes_at
string<date-time> | null

The date and time when the invoice will be automatically finalized and charged. Only valid when collection_method is charge_automatically. If not provided, the charge will be processed immediately.

Example:

"2023-12-01T05:00:00.401Z"

charge_buyer_fee
boolean | null

Whether to charge the customer a buyer fee on this invoice.

payment_method_id
string | null

The unique identifier of the payment method to charge. Required when collection_method is charge_automatically.

Example:

"pmt_xxxxxxxxxxxxxx"

payment_token_id
string | null

The payment token ID to use for this invoice. If using charge_automatically, you must provide a payment_token.

Example:

"payt_xxxxxxxxxxxxx"

Response

A successful response

An invoice represents an itemized bill sent by a company to a customer for a specific product and plan, tracking the amount owed, due date, and payment status.

id
string
required

The unique identifier for the invoice.

Example:

"inv_xxxxxxxxxxxxxx"

created_at
string<date-time>
required

The datetime the invoice was created.

Example:

"2023-12-01T05:00:00.401Z"

status
enum<string>
required

The current payment status of the invoice, such as draft, open, paid, or void.

Available options:
draft,
open,
paid,
past_due,
void
number
string
required

The sequential invoice number for display purposes.

Example:

"#0001"

due_date
string<date-time> | null
required

The deadline by which payment is expected. Null if the invoice is collected automatically.

Example:

"2023-12-01T05:00:00.401Z"

email_address
string | null
required

The email address of the customer this invoice is addressed to. Null if no email is on file.

Example:

"customer@example.com"

fetch_invoice_token
string
required

A signed token that allows fetching invoice data publicly without authentication.

Example:

"eyJhbGciOiJIUzI1NiJ9..."

current_plan
object
required

The plan that this invoice charges for.

user
object
required

The user this invoice is addressed to. Null if the user account has been removed.