Skip to main content

Overview

The invoice.created webhook is triggered when a new invoice is created in your Metrifox account. Invoices are generated for subscriptions, orders, and other billable events.

When It’s Triggered

This event is sent immediately after an invoice is successfully created, which can happen when:
  • A subscription billing cycle starts (recurring invoice)
  • An order is completed and invoiced
  • An invoice is created manually
  • An invoice is generated through the API

Payload Structure

{
  "id": "550e8400-e29b-41d4-a716-446655440007",
  "type": "invoice.created",
  "created_at": 1704067620000,
  "data": {
    "invoice": {
      "id": "301",
      "invoice_number": "INV-2024-001",
      "customer_id": "123",
      "customer_key": "cust_abc123",
      "subscription_id": "101",
      "order_id": "789",
      "status": "open",
      "total_amount": 99.99,
      "subtotal": 99.99,
      "tax_amount": 0.00,
      "currency": "USD",
      "due_date": "2024-01-15T00:00:00Z",
      "issued_at": "2024-01-01T00:07:00Z",
      "tenant_id": "456",
      "line_items": [
        {
          "description": "Pro Plan - Monthly",
          "quantity": 1,
          "unit_price": 99.99,
          "total": 99.99
        }
      ],
      "created_at": "2024-01-01T00:07:00Z",
      "updated_at": "2024-01-01T00:07:00Z"
      // ... other invoice fields
    }
  }
}

Data Fields

The data.invoice object contains the complete invoice record, including:
  • id: Internal invoice ID
  • invoice_number: Human-readable invoice number
  • customer_id: ID of the customer this invoice is for
  • customer_key: Customer key
  • subscription_id: ID of the subscription (if applicable)
  • order_id: ID of the order (if applicable)
  • status: Invoice status (e.g., “open”, “paid”, “void”, “draft”)
  • total_amount: Total invoice amount including taxes
  • subtotal: Subtotal before taxes
  • tax_amount: Total tax amount
  • currency: Currency code (e.g., “USD”, “NGN”)
  • due_date: Date when the invoice is due
  • issued_at: Timestamp when the invoice was issued
  • tenant_id: The tenant ID this invoice belongs to
  • line_items: Array of invoice line items with descriptions, quantities, and prices
  • created_at: Timestamp when the invoice was created
  • updated_at: Timestamp when the invoice was last updated
  • Additional invoice-specific fields

Example Use Cases

  • Send invoice emails to customers
  • Sync invoices to your accounting system
  • Update financial records
  • Trigger payment processing workflows
  • Track revenue and billing analytics
  • Generate invoice PDFs