Create a Recurring Invoices

Copperx allows you to create recurring invoices for subscriptions, memberships, and services that require periodic payments.

๐Ÿ”ง How It Works

  1. Create a Recurring Invoice: Provide the relevant customer, amount, and recurrence details.

  2. Invoice Generation & Automation: Copperxโ€™s system automatically generates new invoices at the defined interval.

  3. Notifications & Webhooks: Stay updated with webhooks for successful payments, failures, or other events.

โœ… Step 1: Create a Customer

Before creating an invoice, youโ€™ll need to create a customer:

curl --request POST \
  --url https://api.copperx.dev/api/v1/customers \
  --header 'Authorization: Bearer {API_KEY}' \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "email": "[email protected]",
    "name": "John Doe",
    "metadata": {
      "customerType": "SaaS"
    }
  }'

โœ… Save the customerId from the response.


โœ… Step 2: Create a Product

Next, create the product to be billed:

โœ… Save the productId from the response.

โœ… Save the defaultPrice.id as a priceId from the response.


โœ… Step 3: Create a Recurring Invoice

Use the customerId and productId and priceId in the invoice creation request:

โœ… Save the invoiceId from the response.


โœ… Step 4: Finalize the Invoice

Finalize the invoice to make it active and ready for payment collection:

๐Ÿ› ๏ธ Best Practices

โœ… Validate Customer Details: Make sure the customer information is accurate before generating invoices. โœ… Use Webhooks: Listen for events like invoice.paid, customer.subscription.started, and invoice.marked_as_paid to keep your system up to date. โœ… Secure API Calls: Always use HTTPS and a valid API key. โœ… Clear Terms: Clearly communicate the subscription and billing terms to customers.

Last updated