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',
plan: {},
product: { title: 'title' },
});
console.log(invoice.id);curl --request POST \
--url https://api.whop.com/api/v1/invoices \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"company_id": "biz_xxxxxxxxxxxxxx",
"plan": {
"adaptive_pricing_enabled": true,
"billing_period": 42,
"custom_fields": [
{
"field_type": "<string>",
"name": "<string>",
"id": "<string>",
"order": 42,
"placeholder": "<string>",
"required": true
}
],
"description": "<string>",
"expiration_days": 42,
"initial_price": 6.9,
"internal_notes": "<string>",
"legacy_payment_method_controls": true,
"payment_method_configuration": {
"disabled": [],
"enabled": [],
"include_platform_defaults": true
},
"renewal_price": 6.9,
"stock": 42,
"trial_period_days": 42,
"unlimited_stock": true
},
"product": {
"title": "<string>",
"product_tax_code_id": "ptc_xxxxxxxxxxxxxx"
},
"automatically_finalizes_at": "2023-12-01T05:00:00.401Z",
"billing_address": {
"city": "<string>",
"country": "<string>",
"line1": "<string>",
"line2": "<string>",
"name": "<string>",
"phone": "<string>",
"postal_code": "<string>",
"state": "<string>",
"tax_id_value": "<string>"
},
"charge_buyer_fee": true,
"customer_name": "<string>",
"due_date": "2023-12-01T05:00:00.401Z",
"email_address": "<string>",
"line_items": [
{
"label": "<string>",
"unit_price": 6.9,
"quantity": 6.9
}
],
"mailing_address_id": "ma_xxxxxxxxxxxxxxx",
"member_id": "mber_xxxxxxxxxxxxx",
"payment_method_id": "pmt_xxxxxxxxxxxxxx",
"payment_token_id": "payt_xxxxxxxxxxxxx",
"save_as_draft": true,
"subscription_billing_anchor_at": "2023-12-01T05:00:00.401Z"
}
'import requests
url = "https://api.whop.com/api/v1/invoices"
payload = {
"company_id": "biz_xxxxxxxxxxxxxx",
"plan": {
"adaptive_pricing_enabled": True,
"billing_period": 42,
"custom_fields": [
{
"field_type": "<string>",
"name": "<string>",
"id": "<string>",
"order": 42,
"placeholder": "<string>",
"required": True
}
],
"description": "<string>",
"expiration_days": 42,
"initial_price": 6.9,
"internal_notes": "<string>",
"legacy_payment_method_controls": True,
"payment_method_configuration": {
"disabled": [],
"enabled": [],
"include_platform_defaults": True
},
"renewal_price": 6.9,
"stock": 42,
"trial_period_days": 42,
"unlimited_stock": True
},
"product": {
"title": "<string>",
"product_tax_code_id": "ptc_xxxxxxxxxxxxxx"
},
"automatically_finalizes_at": "2023-12-01T05:00:00.401Z",
"billing_address": {
"city": "<string>",
"country": "<string>",
"line1": "<string>",
"line2": "<string>",
"name": "<string>",
"phone": "<string>",
"postal_code": "<string>",
"state": "<string>",
"tax_id_value": "<string>"
},
"charge_buyer_fee": True,
"customer_name": "<string>",
"due_date": "2023-12-01T05:00:00.401Z",
"email_address": "<string>",
"line_items": [
{
"label": "<string>",
"unit_price": 6.9,
"quantity": 6.9
}
],
"mailing_address_id": "ma_xxxxxxxxxxxxxxx",
"member_id": "mber_xxxxxxxxxxxxx",
"payment_method_id": "pmt_xxxxxxxxxxxxxx",
"payment_token_id": "payt_xxxxxxxxxxxxx",
"save_as_draft": True,
"subscription_billing_anchor_at": "2023-12-01T05:00:00.401Z"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.whop.com/api/v1/invoices",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'company_id' => 'biz_xxxxxxxxxxxxxx',
'plan' => [
'adaptive_pricing_enabled' => true,
'billing_period' => 42,
'custom_fields' => [
[
'field_type' => '<string>',
'name' => '<string>',
'id' => '<string>',
'order' => 42,
'placeholder' => '<string>',
'required' => true
]
],
'description' => '<string>',
'expiration_days' => 42,
'initial_price' => 6.9,
'internal_notes' => '<string>',
'legacy_payment_method_controls' => true,
'payment_method_configuration' => [
'disabled' => [
],
'enabled' => [
],
'include_platform_defaults' => true
],
'renewal_price' => 6.9,
'stock' => 42,
'trial_period_days' => 42,
'unlimited_stock' => true
],
'product' => [
'title' => '<string>',
'product_tax_code_id' => 'ptc_xxxxxxxxxxxxxx'
],
'automatically_finalizes_at' => '2023-12-01T05:00:00.401Z',
'billing_address' => [
'city' => '<string>',
'country' => '<string>',
'line1' => '<string>',
'line2' => '<string>',
'name' => '<string>',
'phone' => '<string>',
'postal_code' => '<string>',
'state' => '<string>',
'tax_id_value' => '<string>'
],
'charge_buyer_fee' => true,
'customer_name' => '<string>',
'due_date' => '2023-12-01T05:00:00.401Z',
'email_address' => '<string>',
'line_items' => [
[
'label' => '<string>',
'unit_price' => 6.9,
'quantity' => 6.9
]
],
'mailing_address_id' => 'ma_xxxxxxxxxxxxxxx',
'member_id' => 'mber_xxxxxxxxxxxxx',
'payment_method_id' => 'pmt_xxxxxxxxxxxxxx',
'payment_token_id' => 'payt_xxxxxxxxxxxxx',
'save_as_draft' => true,
'subscription_billing_anchor_at' => '2023-12-01T05:00:00.401Z'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.whop.com/api/v1/invoices"
payload := strings.NewReader("{\n \"company_id\": \"biz_xxxxxxxxxxxxxx\",\n \"plan\": {\n \"adaptive_pricing_enabled\": true,\n \"billing_period\": 42,\n \"custom_fields\": [\n {\n \"field_type\": \"<string>\",\n \"name\": \"<string>\",\n \"id\": \"<string>\",\n \"order\": 42,\n \"placeholder\": \"<string>\",\n \"required\": true\n }\n ],\n \"description\": \"<string>\",\n \"expiration_days\": 42,\n \"initial_price\": 6.9,\n \"internal_notes\": \"<string>\",\n \"legacy_payment_method_controls\": true,\n \"payment_method_configuration\": {\n \"disabled\": [],\n \"enabled\": [],\n \"include_platform_defaults\": true\n },\n \"renewal_price\": 6.9,\n \"stock\": 42,\n \"trial_period_days\": 42,\n \"unlimited_stock\": true\n },\n \"product\": {\n \"title\": \"<string>\",\n \"product_tax_code_id\": \"ptc_xxxxxxxxxxxxxx\"\n },\n \"automatically_finalizes_at\": \"2023-12-01T05:00:00.401Z\",\n \"billing_address\": {\n \"city\": \"<string>\",\n \"country\": \"<string>\",\n \"line1\": \"<string>\",\n \"line2\": \"<string>\",\n \"name\": \"<string>\",\n \"phone\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"state\": \"<string>\",\n \"tax_id_value\": \"<string>\"\n },\n \"charge_buyer_fee\": true,\n \"customer_name\": \"<string>\",\n \"due_date\": \"2023-12-01T05:00:00.401Z\",\n \"email_address\": \"<string>\",\n \"line_items\": [\n {\n \"label\": \"<string>\",\n \"unit_price\": 6.9,\n \"quantity\": 6.9\n }\n ],\n \"mailing_address_id\": \"ma_xxxxxxxxxxxxxxx\",\n \"member_id\": \"mber_xxxxxxxxxxxxx\",\n \"payment_method_id\": \"pmt_xxxxxxxxxxxxxx\",\n \"payment_token_id\": \"payt_xxxxxxxxxxxxx\",\n \"save_as_draft\": true,\n \"subscription_billing_anchor_at\": \"2023-12-01T05:00:00.401Z\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.whop.com/api/v1/invoices")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"company_id\": \"biz_xxxxxxxxxxxxxx\",\n \"plan\": {\n \"adaptive_pricing_enabled\": true,\n \"billing_period\": 42,\n \"custom_fields\": [\n {\n \"field_type\": \"<string>\",\n \"name\": \"<string>\",\n \"id\": \"<string>\",\n \"order\": 42,\n \"placeholder\": \"<string>\",\n \"required\": true\n }\n ],\n \"description\": \"<string>\",\n \"expiration_days\": 42,\n \"initial_price\": 6.9,\n \"internal_notes\": \"<string>\",\n \"legacy_payment_method_controls\": true,\n \"payment_method_configuration\": {\n \"disabled\": [],\n \"enabled\": [],\n \"include_platform_defaults\": true\n },\n \"renewal_price\": 6.9,\n \"stock\": 42,\n \"trial_period_days\": 42,\n \"unlimited_stock\": true\n },\n \"product\": {\n \"title\": \"<string>\",\n \"product_tax_code_id\": \"ptc_xxxxxxxxxxxxxx\"\n },\n \"automatically_finalizes_at\": \"2023-12-01T05:00:00.401Z\",\n \"billing_address\": {\n \"city\": \"<string>\",\n \"country\": \"<string>\",\n \"line1\": \"<string>\",\n \"line2\": \"<string>\",\n \"name\": \"<string>\",\n \"phone\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"state\": \"<string>\",\n \"tax_id_value\": \"<string>\"\n },\n \"charge_buyer_fee\": true,\n \"customer_name\": \"<string>\",\n \"due_date\": \"2023-12-01T05:00:00.401Z\",\n \"email_address\": \"<string>\",\n \"line_items\": [\n {\n \"label\": \"<string>\",\n \"unit_price\": 6.9,\n \"quantity\": 6.9\n }\n ],\n \"mailing_address_id\": \"ma_xxxxxxxxxxxxxxx\",\n \"member_id\": \"mber_xxxxxxxxxxxxx\",\n \"payment_method_id\": \"pmt_xxxxxxxxxxxxxx\",\n \"payment_token_id\": \"payt_xxxxxxxxxxxxx\",\n \"save_as_draft\": true,\n \"subscription_billing_anchor_at\": \"2023-12-01T05:00:00.401Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.whop.com/api/v1/invoices")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"company_id\": \"biz_xxxxxxxxxxxxxx\",\n \"plan\": {\n \"adaptive_pricing_enabled\": true,\n \"billing_period\": 42,\n \"custom_fields\": [\n {\n \"field_type\": \"<string>\",\n \"name\": \"<string>\",\n \"id\": \"<string>\",\n \"order\": 42,\n \"placeholder\": \"<string>\",\n \"required\": true\n }\n ],\n \"description\": \"<string>\",\n \"expiration_days\": 42,\n \"initial_price\": 6.9,\n \"internal_notes\": \"<string>\",\n \"legacy_payment_method_controls\": true,\n \"payment_method_configuration\": {\n \"disabled\": [],\n \"enabled\": [],\n \"include_platform_defaults\": true\n },\n \"renewal_price\": 6.9,\n \"stock\": 42,\n \"trial_period_days\": 42,\n \"unlimited_stock\": true\n },\n \"product\": {\n \"title\": \"<string>\",\n \"product_tax_code_id\": \"ptc_xxxxxxxxxxxxxx\"\n },\n \"automatically_finalizes_at\": \"2023-12-01T05:00:00.401Z\",\n \"billing_address\": {\n \"city\": \"<string>\",\n \"country\": \"<string>\",\n \"line1\": \"<string>\",\n \"line2\": \"<string>\",\n \"name\": \"<string>\",\n \"phone\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"state\": \"<string>\",\n \"tax_id_value\": \"<string>\"\n },\n \"charge_buyer_fee\": true,\n \"customer_name\": \"<string>\",\n \"due_date\": \"2023-12-01T05:00:00.401Z\",\n \"email_address\": \"<string>\",\n \"line_items\": [\n {\n \"label\": \"<string>\",\n \"unit_price\": 6.9,\n \"quantity\": 6.9\n }\n ],\n \"mailing_address_id\": \"ma_xxxxxxxxxxxxxxx\",\n \"member_id\": \"mber_xxxxxxxxxxxxx\",\n \"payment_method_id\": \"pmt_xxxxxxxxxxxxxx\",\n \"payment_token_id\": \"payt_xxxxxxxxxxxxx\",\n \"save_as_draft\": true,\n \"subscription_billing_anchor_at\": \"2023-12-01T05:00:00.401Z\"\n}"
response = http.request(request)
puts response.read_body{
"created_at": "2023-12-01T05:00:00.401Z",
"current_plan": {
"formatted_price": "$10.00",
"id": "plan_xxxxxxxxxxxxx"
},
"due_date": "2023-12-01T05:00:00.401Z",
"email_address": "customer@example.com",
"fetch_invoice_token": "eyJhbGciOiJIUzI1NiJ9...",
"id": "inv_xxxxxxxxxxxxxx",
"line_items": [
{
"label": "Platform subscription",
"position": 42,
"quantity": 6.9,
"total": 6.9,
"unit_price": 6.9
}
],
"number": "#0001",
"user": {
"id": "user_xxxxxxxxxxxxx",
"name": "John Doe",
"username": "johndoe42"
}
}{
"error": {
"code": "parameter_missing",
"message": "Missing required parameter: amount.",
"param": "amount",
"type": "invalid_request_error"
}
}{
"error": {
"message": "Invalid or missing API key",
"type": "unauthorized"
}
}{
"error": {
"message": "You do not have permission to access this resource",
"type": "forbidden"
}
}{
"error": {
"message": "Resource not found",
"type": "not_found"
}
}{
"error": null
}{
"error": null
}{
"error": {
"message": "An unexpected error occurred",
"type": "internal_server_error"
}
}Create invoice
Create an invoice for a customer. The invoice can be charged automatically using a stored payment method, or sent to the customer for manual payment.
Required permissions:
invoice:create
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',
plan: {},
product: { title: 'title' },
});
console.log(invoice.id);curl --request POST \
--url https://api.whop.com/api/v1/invoices \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"company_id": "biz_xxxxxxxxxxxxxx",
"plan": {
"adaptive_pricing_enabled": true,
"billing_period": 42,
"custom_fields": [
{
"field_type": "<string>",
"name": "<string>",
"id": "<string>",
"order": 42,
"placeholder": "<string>",
"required": true
}
],
"description": "<string>",
"expiration_days": 42,
"initial_price": 6.9,
"internal_notes": "<string>",
"legacy_payment_method_controls": true,
"payment_method_configuration": {
"disabled": [],
"enabled": [],
"include_platform_defaults": true
},
"renewal_price": 6.9,
"stock": 42,
"trial_period_days": 42,
"unlimited_stock": true
},
"product": {
"title": "<string>",
"product_tax_code_id": "ptc_xxxxxxxxxxxxxx"
},
"automatically_finalizes_at": "2023-12-01T05:00:00.401Z",
"billing_address": {
"city": "<string>",
"country": "<string>",
"line1": "<string>",
"line2": "<string>",
"name": "<string>",
"phone": "<string>",
"postal_code": "<string>",
"state": "<string>",
"tax_id_value": "<string>"
},
"charge_buyer_fee": true,
"customer_name": "<string>",
"due_date": "2023-12-01T05:00:00.401Z",
"email_address": "<string>",
"line_items": [
{
"label": "<string>",
"unit_price": 6.9,
"quantity": 6.9
}
],
"mailing_address_id": "ma_xxxxxxxxxxxxxxx",
"member_id": "mber_xxxxxxxxxxxxx",
"payment_method_id": "pmt_xxxxxxxxxxxxxx",
"payment_token_id": "payt_xxxxxxxxxxxxx",
"save_as_draft": true,
"subscription_billing_anchor_at": "2023-12-01T05:00:00.401Z"
}
'import requests
url = "https://api.whop.com/api/v1/invoices"
payload = {
"company_id": "biz_xxxxxxxxxxxxxx",
"plan": {
"adaptive_pricing_enabled": True,
"billing_period": 42,
"custom_fields": [
{
"field_type": "<string>",
"name": "<string>",
"id": "<string>",
"order": 42,
"placeholder": "<string>",
"required": True
}
],
"description": "<string>",
"expiration_days": 42,
"initial_price": 6.9,
"internal_notes": "<string>",
"legacy_payment_method_controls": True,
"payment_method_configuration": {
"disabled": [],
"enabled": [],
"include_platform_defaults": True
},
"renewal_price": 6.9,
"stock": 42,
"trial_period_days": 42,
"unlimited_stock": True
},
"product": {
"title": "<string>",
"product_tax_code_id": "ptc_xxxxxxxxxxxxxx"
},
"automatically_finalizes_at": "2023-12-01T05:00:00.401Z",
"billing_address": {
"city": "<string>",
"country": "<string>",
"line1": "<string>",
"line2": "<string>",
"name": "<string>",
"phone": "<string>",
"postal_code": "<string>",
"state": "<string>",
"tax_id_value": "<string>"
},
"charge_buyer_fee": True,
"customer_name": "<string>",
"due_date": "2023-12-01T05:00:00.401Z",
"email_address": "<string>",
"line_items": [
{
"label": "<string>",
"unit_price": 6.9,
"quantity": 6.9
}
],
"mailing_address_id": "ma_xxxxxxxxxxxxxxx",
"member_id": "mber_xxxxxxxxxxxxx",
"payment_method_id": "pmt_xxxxxxxxxxxxxx",
"payment_token_id": "payt_xxxxxxxxxxxxx",
"save_as_draft": True,
"subscription_billing_anchor_at": "2023-12-01T05:00:00.401Z"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.whop.com/api/v1/invoices",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'company_id' => 'biz_xxxxxxxxxxxxxx',
'plan' => [
'adaptive_pricing_enabled' => true,
'billing_period' => 42,
'custom_fields' => [
[
'field_type' => '<string>',
'name' => '<string>',
'id' => '<string>',
'order' => 42,
'placeholder' => '<string>',
'required' => true
]
],
'description' => '<string>',
'expiration_days' => 42,
'initial_price' => 6.9,
'internal_notes' => '<string>',
'legacy_payment_method_controls' => true,
'payment_method_configuration' => [
'disabled' => [
],
'enabled' => [
],
'include_platform_defaults' => true
],
'renewal_price' => 6.9,
'stock' => 42,
'trial_period_days' => 42,
'unlimited_stock' => true
],
'product' => [
'title' => '<string>',
'product_tax_code_id' => 'ptc_xxxxxxxxxxxxxx'
],
'automatically_finalizes_at' => '2023-12-01T05:00:00.401Z',
'billing_address' => [
'city' => '<string>',
'country' => '<string>',
'line1' => '<string>',
'line2' => '<string>',
'name' => '<string>',
'phone' => '<string>',
'postal_code' => '<string>',
'state' => '<string>',
'tax_id_value' => '<string>'
],
'charge_buyer_fee' => true,
'customer_name' => '<string>',
'due_date' => '2023-12-01T05:00:00.401Z',
'email_address' => '<string>',
'line_items' => [
[
'label' => '<string>',
'unit_price' => 6.9,
'quantity' => 6.9
]
],
'mailing_address_id' => 'ma_xxxxxxxxxxxxxxx',
'member_id' => 'mber_xxxxxxxxxxxxx',
'payment_method_id' => 'pmt_xxxxxxxxxxxxxx',
'payment_token_id' => 'payt_xxxxxxxxxxxxx',
'save_as_draft' => true,
'subscription_billing_anchor_at' => '2023-12-01T05:00:00.401Z'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.whop.com/api/v1/invoices"
payload := strings.NewReader("{\n \"company_id\": \"biz_xxxxxxxxxxxxxx\",\n \"plan\": {\n \"adaptive_pricing_enabled\": true,\n \"billing_period\": 42,\n \"custom_fields\": [\n {\n \"field_type\": \"<string>\",\n \"name\": \"<string>\",\n \"id\": \"<string>\",\n \"order\": 42,\n \"placeholder\": \"<string>\",\n \"required\": true\n }\n ],\n \"description\": \"<string>\",\n \"expiration_days\": 42,\n \"initial_price\": 6.9,\n \"internal_notes\": \"<string>\",\n \"legacy_payment_method_controls\": true,\n \"payment_method_configuration\": {\n \"disabled\": [],\n \"enabled\": [],\n \"include_platform_defaults\": true\n },\n \"renewal_price\": 6.9,\n \"stock\": 42,\n \"trial_period_days\": 42,\n \"unlimited_stock\": true\n },\n \"product\": {\n \"title\": \"<string>\",\n \"product_tax_code_id\": \"ptc_xxxxxxxxxxxxxx\"\n },\n \"automatically_finalizes_at\": \"2023-12-01T05:00:00.401Z\",\n \"billing_address\": {\n \"city\": \"<string>\",\n \"country\": \"<string>\",\n \"line1\": \"<string>\",\n \"line2\": \"<string>\",\n \"name\": \"<string>\",\n \"phone\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"state\": \"<string>\",\n \"tax_id_value\": \"<string>\"\n },\n \"charge_buyer_fee\": true,\n \"customer_name\": \"<string>\",\n \"due_date\": \"2023-12-01T05:00:00.401Z\",\n \"email_address\": \"<string>\",\n \"line_items\": [\n {\n \"label\": \"<string>\",\n \"unit_price\": 6.9,\n \"quantity\": 6.9\n }\n ],\n \"mailing_address_id\": \"ma_xxxxxxxxxxxxxxx\",\n \"member_id\": \"mber_xxxxxxxxxxxxx\",\n \"payment_method_id\": \"pmt_xxxxxxxxxxxxxx\",\n \"payment_token_id\": \"payt_xxxxxxxxxxxxx\",\n \"save_as_draft\": true,\n \"subscription_billing_anchor_at\": \"2023-12-01T05:00:00.401Z\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.whop.com/api/v1/invoices")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"company_id\": \"biz_xxxxxxxxxxxxxx\",\n \"plan\": {\n \"adaptive_pricing_enabled\": true,\n \"billing_period\": 42,\n \"custom_fields\": [\n {\n \"field_type\": \"<string>\",\n \"name\": \"<string>\",\n \"id\": \"<string>\",\n \"order\": 42,\n \"placeholder\": \"<string>\",\n \"required\": true\n }\n ],\n \"description\": \"<string>\",\n \"expiration_days\": 42,\n \"initial_price\": 6.9,\n \"internal_notes\": \"<string>\",\n \"legacy_payment_method_controls\": true,\n \"payment_method_configuration\": {\n \"disabled\": [],\n \"enabled\": [],\n \"include_platform_defaults\": true\n },\n \"renewal_price\": 6.9,\n \"stock\": 42,\n \"trial_period_days\": 42,\n \"unlimited_stock\": true\n },\n \"product\": {\n \"title\": \"<string>\",\n \"product_tax_code_id\": \"ptc_xxxxxxxxxxxxxx\"\n },\n \"automatically_finalizes_at\": \"2023-12-01T05:00:00.401Z\",\n \"billing_address\": {\n \"city\": \"<string>\",\n \"country\": \"<string>\",\n \"line1\": \"<string>\",\n \"line2\": \"<string>\",\n \"name\": \"<string>\",\n \"phone\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"state\": \"<string>\",\n \"tax_id_value\": \"<string>\"\n },\n \"charge_buyer_fee\": true,\n \"customer_name\": \"<string>\",\n \"due_date\": \"2023-12-01T05:00:00.401Z\",\n \"email_address\": \"<string>\",\n \"line_items\": [\n {\n \"label\": \"<string>\",\n \"unit_price\": 6.9,\n \"quantity\": 6.9\n }\n ],\n \"mailing_address_id\": \"ma_xxxxxxxxxxxxxxx\",\n \"member_id\": \"mber_xxxxxxxxxxxxx\",\n \"payment_method_id\": \"pmt_xxxxxxxxxxxxxx\",\n \"payment_token_id\": \"payt_xxxxxxxxxxxxx\",\n \"save_as_draft\": true,\n \"subscription_billing_anchor_at\": \"2023-12-01T05:00:00.401Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.whop.com/api/v1/invoices")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"company_id\": \"biz_xxxxxxxxxxxxxx\",\n \"plan\": {\n \"adaptive_pricing_enabled\": true,\n \"billing_period\": 42,\n \"custom_fields\": [\n {\n \"field_type\": \"<string>\",\n \"name\": \"<string>\",\n \"id\": \"<string>\",\n \"order\": 42,\n \"placeholder\": \"<string>\",\n \"required\": true\n }\n ],\n \"description\": \"<string>\",\n \"expiration_days\": 42,\n \"initial_price\": 6.9,\n \"internal_notes\": \"<string>\",\n \"legacy_payment_method_controls\": true,\n \"payment_method_configuration\": {\n \"disabled\": [],\n \"enabled\": [],\n \"include_platform_defaults\": true\n },\n \"renewal_price\": 6.9,\n \"stock\": 42,\n \"trial_period_days\": 42,\n \"unlimited_stock\": true\n },\n \"product\": {\n \"title\": \"<string>\",\n \"product_tax_code_id\": \"ptc_xxxxxxxxxxxxxx\"\n },\n \"automatically_finalizes_at\": \"2023-12-01T05:00:00.401Z\",\n \"billing_address\": {\n \"city\": \"<string>\",\n \"country\": \"<string>\",\n \"line1\": \"<string>\",\n \"line2\": \"<string>\",\n \"name\": \"<string>\",\n \"phone\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"state\": \"<string>\",\n \"tax_id_value\": \"<string>\"\n },\n \"charge_buyer_fee\": true,\n \"customer_name\": \"<string>\",\n \"due_date\": \"2023-12-01T05:00:00.401Z\",\n \"email_address\": \"<string>\",\n \"line_items\": [\n {\n \"label\": \"<string>\",\n \"unit_price\": 6.9,\n \"quantity\": 6.9\n }\n ],\n \"mailing_address_id\": \"ma_xxxxxxxxxxxxxxx\",\n \"member_id\": \"mber_xxxxxxxxxxxxx\",\n \"payment_method_id\": \"pmt_xxxxxxxxxxxxxx\",\n \"payment_token_id\": \"payt_xxxxxxxxxxxxx\",\n \"save_as_draft\": true,\n \"subscription_billing_anchor_at\": \"2023-12-01T05:00:00.401Z\"\n}"
response = http.request(request)
puts response.read_body{
"created_at": "2023-12-01T05:00:00.401Z",
"current_plan": {
"formatted_price": "$10.00",
"id": "plan_xxxxxxxxxxxxx"
},
"due_date": "2023-12-01T05:00:00.401Z",
"email_address": "customer@example.com",
"fetch_invoice_token": "eyJhbGciOiJIUzI1NiJ9...",
"id": "inv_xxxxxxxxxxxxxx",
"line_items": [
{
"label": "Platform subscription",
"position": 42,
"quantity": 6.9,
"total": 6.9,
"unit_price": 6.9
}
],
"number": "#0001",
"user": {
"id": "user_xxxxxxxxxxxxx",
"name": "John Doe",
"username": "johndoe42"
}
}{
"error": {
"code": "parameter_missing",
"message": "Missing required parameter: amount.",
"param": "amount",
"type": "invalid_request_error"
}
}{
"error": {
"message": "Invalid or missing API key",
"type": "unauthorized"
}
}{
"error": {
"message": "You do not have permission to access this resource",
"type": "forbidden"
}
}{
"error": {
"message": "Resource not found",
"type": "not_found"
}
}{
"error": null
}{
"error": null
}{
"error": {
"message": "An unexpected error occurred",
"type": "internal_server_error"
}
}Authorizations
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
- CreateInvoiceInputWithProduct
- CreateInvoiceInputWithProductId
Autogenerated input type of CreateInvoice
How the invoice should be collected. Use charge_automatically to charge a stored payment method, or send_invoice to email the customer.
send_invoice, charge_automatically The unique identifier of the company to create this invoice for.
"biz_xxxxxxxxxxxxxx"
The plan attributes defining the price, currency, and billing interval for this invoice.
Show child attributes
Show child attributes
The properties of the product to create for this invoice. Provide this to create a new product inline.
Show child attributes
Show child attributes
The date and time when the invoice will be automatically finalized. For charge_automatically, triggers an automatic charge. For send_invoice, sends the invoice email to the customer at the specified time.
"2023-12-01T05:00:00.401Z"
Inline billing address to create a new mailing address for this invoice. Cannot be used together with mailing_address_id.
Show child attributes
Show child attributes
Whether to charge the customer a buyer fee on this invoice.
The name of the customer. Required when creating an invoice for a customer who is not yet a member of the company.
The date by which the invoice must be paid. Required unless save_as_draft is true.
"2023-12-01T05:00:00.401Z"
The email address of the customer. Required when creating an invoice for a customer who is not yet a member of the company.
Optional line items that break down the invoice total. When provided, the sum of (quantity * unit_price) for all items must equal the plan price.
Show child attributes
Show child attributes
The unique identifier of an existing mailing address to attach to this invoice. Cannot be used together with billing_address.
"ma_xxxxxxxxxxxxxxx"
The unique identifier of an existing member to create this invoice for. If not provided, you must supply an email_address and customer_name.
"mber_xxxxxxxxxxxxx"
The unique identifier of the payment method to charge. Required when collection_method is charge_automatically.
"pmt_xxxxxxxxxxxxxx"
The payment token ID to use for this invoice. If using charge_automatically, you must provide a payment_token.
"payt_xxxxxxxxxxxxx"
When true, creates the invoice as a draft without sending or charging. Relaxes customer and due date requirements.
The date that defines when the subscription billing cycle should start. When set on a renewal plan invoice, this anchors all future billing periods to this date.
"2023-12-01T05:00:00.401Z"
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.
The datetime the invoice was created.
"2023-12-01T05:00:00.401Z"
The plan that this invoice charges for.
Show child attributes
Show child attributes
The deadline by which payment is expected. Null if the invoice is collected automatically.
"2023-12-01T05:00:00.401Z"
The email address of the customer this invoice is addressed to. Null if no email is on file.
"customer@example.com"
A signed token that allows fetching invoice data publicly without authentication.
"eyJhbGciOiJIUzI1NiJ9..."
The unique identifier for the invoice.
"inv_xxxxxxxxxxxxxx"
Optional line items that break down the invoice total into individual charges.
Show child attributes
Show child attributes
The sequential invoice number for display purposes.
"#0001"
The current payment status of the invoice, such as draft, open, paid, or void.
draft, open, paid, past_due, uncollectible, void The user this invoice is addressed to. Null if the user account has been removed.
Show child attributes
Show child attributes

