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

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