> ## Documentation Index
> Fetch the complete documentation index at: https://docs.metrifox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Invoice Created

## 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

```json theme={null}
{
  "id": "550e8400-e29b-41d4-a716-446655440007",
  "type": "invoice.created",
  "created_at": 1704067620000,
  "data": {
    "invoice": {
      "id": "e0240d63-d025-4e26-ab3c-75a846fd8b88",
      "title": "Order - OE3Y4",
      "due_at": "2026-02-09T23:59:59.999Z",
      "status": "open",
      "comment": "Invoice created for order OE3Y4",
      "sent_at": "2026-02-09T11:10:05.000Z",
      "metadata": {},
      "is_manual": false,
      "issued_at": "2026-02-09T11:08:31.902Z",
      "source_id": "a4966ab2-e2fb-47d3-b562-c470312a082c",
      "tenant_id": "b1b7b362-5c5c-48a5-9454-94c3c4d3e5b3",
      "created_at": "2026-02-09T11:08:32.051Z",
      "deleted_at": null,
      "updated_at": "2026-02-09T11:08:32.362Z",
      "customer_id": "96a271f5-480d-4d53-b23f-46888da09311",
      "customer_key": "cust_ext_67890",
      "source_type": "Orders::Order",
      "completed_at": "2026-02-09T11:08:45.000Z",
      "currency_code": "USD",
      "overdue_until": "2026-02-12T23:59:59.999Z",
      "invoice_number": "INV042",
      "payment_term_val": 0,
      "payment_term_type": "on_receipt",
      "payment_link_status": "non_applicable",
      "failed_payment_count": 0,
      "payment_intent_result": "requires_action",
      "stripe_payment_link_id": "plink_1Q2w3E4r5T6y7U8i",
      "last_payment_failure_at": "2026-02-09T11:09:30.000Z",
      "payment_link_created_at": "2026-02-09T11:08:50.000Z",
      "stripe_payment_link_url": "https://pay.example.com/plink_1Q2w3E4r5T6y7U8i",
      "last_payment_failure_reason": "insufficient_funds"
    },
    "summary": {
      "id": "1795ffd9-02b5-4db4-9280-47ff2342853e",
      "created_at": "2026-02-09T11:08:32.242Z",
      "invoice_id": "e0240d63-d025-4e26-ab3c-75a846fd8b88",
      "updated_at": "2026-02-09T11:08:32.242Z",
      "total_amount": "1458.0",
      "items_subtotal": "1458.0",
      "total_after_tax": "1458.0",
      "total_discounts": "0.0",
      "total_before_tax": "1458.0",
      "total_extra_fees": "0.0",
      "total_tax_amount": "0.0",
      "total_amount_paid": "0.0",
      "total_adjustment_amount": "0.0",
      "total_outstanding_amount": "1458.0"
    }
  }
}
```

## Data Fields

The payload includes invoice details and a summary:

### `data.invoice`

* `id`: Internal invoice ID
* `title`: Invoice title or label
* `due_at`: Timestamp when the invoice is due
* `status`: Invoice status (e.g., "open", "paid", "void", "draft")
* `comment`: Optional invoice comment or note
* `sent_at`: Timestamp when the invoice was sent
* `metadata`: Custom metadata object
* `is_manual`: Whether the invoice was created manually
* `issued_at`: Timestamp when the invoice was issued
* `source_id`: Source record ID (e.g., order ID)
* `tenant_id`: The tenant ID this invoice belongs to
* `created_at`: Timestamp when the invoice was created
* `deleted_at`: Deletion timestamp (if deleted)
* `updated_at`: Timestamp when the invoice was last updated
* `customer_id`: ID of the customer this invoice is for
* `customer_key`: Your external customer identifier
* `source_type`: Source record type
* `completed_at`: Completion timestamp (if completed)
* `currency_code`: Currency code (e.g., "USD", "NGN")
* `overdue_until`: Timestamp until which the invoice is overdue (if applicable)
* `invoice_number`: Human-readable invoice number
* `payment_term_val`: Payment term value
* `payment_term_type`: Payment term type (e.g., "on\_receipt")
* `payment_link_status`: Payment link status
* `failed_payment_count`: Number of failed payment attempts
* `payment_intent_result`: Payment intent result (if any)
* `stripe_payment_link_id`: Stripe payment link ID (if any)
* `last_payment_failure_at`: Timestamp of the last payment failure (if any)
* `payment_link_created_at`: Timestamp when payment link was created (if any)
* `stripe_payment_link_url`: Stripe payment link URL (if any)
* `last_payment_failure_reason`: Reason for last payment failure (if any)

### `data.summary`

* `id`: Summary ID
* `created_at`: Timestamp when the summary was created
* `invoice_id`: Invoice ID the summary belongs to
* `updated_at`: Timestamp when the summary was last updated
* `total_amount`: Total invoice amount
* `items_subtotal`: Subtotal of line items
* `total_after_tax`: Total after tax
* `total_discounts`: Total discounts
* `total_before_tax`: Total before tax
* `total_extra_fees`: Total extra fees
* `total_tax_amount`: Total tax amount
* `total_amount_paid`: Total amount paid
* `total_adjustment_amount`: Total adjustments
* `total_outstanding_amount`: Total outstanding amount

## 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
