Skip to main content

Overview

The credit.purchased webhook is triggered when credits are purchased or provisioned for a customer in your Metrifox account. Credits can be used to pay for usage-based features or other charges.

When It’s Triggered

This event is sent immediately after credits are successfully purchased or provisioned, which can happen when:
  • A customer purchases credits through checkout
  • Credits are manually assigned to a customer
  • Credits are provisioned through the API
  • Credits are added as part of a plan or promotion

Payload Structure

{
  "id": "550e8400-e29b-41d4-a716-446655440008",
  "type": "credit.purchased",
  "created_at": 1704067680000,
  "data": {
    "order": {
      "id": "40191cca-475a-461f-9587-d97e0ee48d1b",
      "policy": null,
      "status": "fulfilled",
      "paid_at": null,
      "is_manual": true,
      "tenant_id": "b1b7b362-5c5c-48a5-9454-94c3c4d3e5b3",
      "created_at": "2026-02-09T11:54:41.046Z",
      "expires_at": null,
      "updated_at": "2026-02-09T11:54:48.369Z",
      "change_type": null,
      "customer_id": "ce9479d4-9fe2-4a0d-9674-6a43427c2075",
      "customer_key": "cust_ext_67890",
      "fulfilled_at": "2026-02-09T11:54:48.362Z",
      "order_number": "O3ERD",
      "currency_code": "USD",
      "billing_interval": "monthly",
      "total_in_base_unit": "802500.0",
      "setup_intent_result": null,
      "subtotal_in_base_unit": "802500.0",
      "billing_interval_value": 1,
      "transitioning_subscription_id": null
    },
    "result": [
      {
        "id": "b0069f5d-b4bb-4cba-aed9-934f57e3a4a0",
        "used": "0.0",
        "active": true,
        "amount": "1.0",
        "balance": "1.0",
        "order_id": "40191cca-475a-461f-9587-d97e0ee48d1b",
        "tenant_id": "b1b7b362-5c5c-48a5-9454-94c3c4d3e5b3",
        "wallet_id": "24aa2d8d-9cbc-4719-97ae-df3445a90e18",
        "created_at": "2026-02-09T11:54:50.163Z",
        "expires_at": null,
        "invoice_id": "45b315a1-9985-4aae-9895-7ce922acb682",
        "updated_at": "2026-02-09T11:54:50.163Z",
        "next_reset_at": null,
        "billing_end_date": null,
        "next_provision_at": null,
        "credit_entitlement_id": "ad3ce842-211c-405c-bf23-7e515b7fd632",
        "rollover_source_pool_id": null
      }
    ]
  }
}

Data Fields

The payload includes credit order and result:

data.order

  • id: Internal order ID
  • policy: Policy applied to the order (if any)
  • status: Order status (e.g., “fulfilled”)
  • paid_at: Payment timestamp (if paid)
  • is_manual: Whether the order was created manually
  • tenant_id: The tenant ID this order belongs to
  • created_at: Timestamp when the order was created
  • expires_at: Order expiration timestamp (if any)
  • updated_at: Timestamp when the order was last updated
  • change_type: Order change type (if any)
  • customer_id: ID of the customer who placed the order
  • customer_key: Your external customer identifier
  • fulfilled_at: Timestamp when the order was fulfilled
  • order_number: Human-readable order number
  • currency_code: Currency code (e.g., “USD”, “NGN”)
  • billing_interval: Billing interval (e.g., “monthly”)
  • total_in_base_unit: Total amount in base units
  • setup_intent_result: Setup intent result (if any)
  • subtotal_in_base_unit: Subtotal amount in base units
  • billing_interval_value: Billing interval value
  • transitioning_subscription_id: Transitioning subscription ID (if any)

data.result

  • id: Credit allocation ID
  • used: Amount of credits used
  • active: Whether the allocation is active
  • amount: Amount allocated
  • balance: Remaining balance
  • order_id: Order ID associated with the allocation
  • tenant_id: The tenant ID this allocation belongs to
  • wallet_id: Wallet ID
  • created_at: Timestamp when the allocation was created
  • expires_at: Expiration date (if any)
  • invoice_id: Invoice ID associated with the allocation (if any)
  • updated_at: Timestamp when the allocation was last updated
  • next_reset_at: Next reset timestamp (if any)
  • billing_end_date: Billing end date (if any)
  • next_provision_at: Next provision timestamp (if any)
  • credit_entitlement_id: Credit entitlement ID
  • rollover_source_pool_id: Rollover source pool ID (if any)

Example Use Cases

  • Send credit purchase confirmation emails
  • Update customer credit balance in your system
  • Trigger notifications about available credits
  • Sync credit purchases to your accounting system
  • Track credit usage and analytics
  • Update customer dashboards with credit information