import { init } from "metrifox-js";
const metrifoxClient = init({
apiKey: process.env.METRIFOX_API_KEY
});
// Get customer details
const customerId = "ac85f76a-9c20-4509-9453-daa9480a1ac6";
const response = await metrifoxClient.customers.getDetails(customerId);
console.log("Customer info:", response.data.customer_key, response.data.primary_email);
console.log("Product subscriptions:", response.data.subscriptions);
// Access details for each product
response.data.subscriptions.forEach(productSub => {
console.log(`Product: ${productSub.product_name}`);
console.log(`Subscription:`, productSub.subscription);
console.log(`Entitlements:`, productSub.entitlements);
console.log(`Wallets:`, productSub.wallets);
});{
"statusCode": 200,
"message": "Customer Details Fetched Successfully",
"meta": {},
"data": {
"metrifox_id": "ac85f76a-9c20-4509-9453-daa9480a1ac6",
"customer_key": "DEV-TJH3UUAHA",
"customer_type": "BUSINESS",
"primary_email": "[email protected]",
"display_name": "Example Company",
"full_name": "Example Company Inc",
"billing_email": "[email protected]",
"billing_address": {
"line1": "123 Main St",
"line2": "Suite 100",
"city": "San Francisco",
"state": "CA",
"postal_code": "94105",
"country": "US"
},
"currency": "USD",
"timezone": "America/Los_Angeles",
"language": "en",
"tenant_checkout_username": "example-company",
"subscriptions": [
{
"product_key": "ai-recruitment-agent",
"product_name": "AI Recruitment Agent",
"status": "active",
"subscription": {
"id": "6ba0132d-a886-4ccc-85fa-385f6d515d91",
"status": "active",
"starts_at": "2025-08-27T11:56:54.820Z",
"ends_at": null,
"renews_at": "2025-09-27T11:56:54.819Z",
"trial_end_date": null,
"post_trial_action": null,
"plan_name": "Basic Plan",
"plan_version": 1,
"default_plan_id": null,
"default_plan_name": null,
"product_name": "AI Recruitment Agent",
"product_key": "ai-recruitment-agent",
"offering_key": "standard-offering",
"currency_code": "USD",
"created_at": "2025-08-27T11:56:54.824Z",
"next_billing_date": "Sep 27, 2025",
"next_billing_amount": 1440.0208,
"current_billing_period_start": "2025-08-27T11:56:54.820Z",
"current_billing_period_end": "2025-09-27T11:56:54.820Z",
"subscription_items": [],
"upcoming_invoice": null,
"can_update_quantities": false
},
"entitlements": [
{
"id": "db10505c-55ac-4780-a59f-ddd2aee11bdb",
"name": "Candidate Sourcing",
"used_quantity": 710,
"carryover_quantity": 0,
"quota": "unlimited",
"included_usage": 10,
"reset_interval": "monthly",
"next_reset_at": "2025-09-27T00:00:00.000Z",
"feature_type": "metered"
}
],
"wallets": [
{
"id": "c6bbd894-f6fa-4614-9795-b7f24a0932c9",
"name": "Tokens",
"credit_unit_singular": "Token",
"credit_unit_plural": "Tokens",
"balance": 36,
"allocations": [],
"credit_key": "tokens"
},
{
"id": "92f6d7fc-ad24-4adb-b614-bd6d1350e02c",
"name": "Cowries",
"credit_unit_singular": "Cowrie",
"credit_unit_plural": "Cowries",
"balance": 0,
"allocations": [],
"credit_key": "cowries"
}
],
"subscriptions_history": [
{
"id": "5ba0132d-a886-4ccc-85fa-385f6d515d91",
"status": "cancelled",
"starts_at": "2025-07-01T00:00:00.000Z",
"ends_at": "2025-08-27T11:56:54.820Z",
"renews_at": null,
"trial_end_date": null,
"post_trial_action": null,
"plan_name": "Starter Plan",
"plan_version": 1,
"default_plan_id": null,
"default_plan_name": null,
"product_name": "AI Recruitment Agent",
"product_key": "ai-recruitment-agent",
"offering_key": "standard-offering",
"currency_code": "USD",
"created_at": "2025-07-01T00:00:00.000Z",
"next_billing_date": null,
"next_billing_amount": null,
"current_billing_period_start": "2025-07-27T00:00:00.000Z",
"current_billing_period_end": "2025-08-27T00:00:00.000Z",
"subscription_items": [],
"upcoming_invoice": null,
"can_update_quantities": false
}
],
"payment_method": {
"type": "card",
"brand": "visa",
"last4": "4242",
"exp_month": "12",
"exp_year": "2026",
"display_name": "Visa ending in 4242",
"bank_name": null
}
}
]
},
"errors": {}
}Retrieve the details of one customer, including their wallet balances, entitlements and subscriptions
import { init } from "metrifox-js";
const metrifoxClient = init({
apiKey: process.env.METRIFOX_API_KEY
});
// Get customer details
const customerId = "ac85f76a-9c20-4509-9453-daa9480a1ac6";
const response = await metrifoxClient.customers.getDetails(customerId);
console.log("Customer info:", response.data.customer_key, response.data.primary_email);
console.log("Product subscriptions:", response.data.subscriptions);
// Access details for each product
response.data.subscriptions.forEach(productSub => {
console.log(`Product: ${productSub.product_name}`);
console.log(`Subscription:`, productSub.subscription);
console.log(`Entitlements:`, productSub.entitlements);
console.log(`Wallets:`, productSub.wallets);
});{
"statusCode": 200,
"message": "Customer Details Fetched Successfully",
"meta": {},
"data": {
"metrifox_id": "ac85f76a-9c20-4509-9453-daa9480a1ac6",
"customer_key": "DEV-TJH3UUAHA",
"customer_type": "BUSINESS",
"primary_email": "[email protected]",
"display_name": "Example Company",
"full_name": "Example Company Inc",
"billing_email": "[email protected]",
"billing_address": {
"line1": "123 Main St",
"line2": "Suite 100",
"city": "San Francisco",
"state": "CA",
"postal_code": "94105",
"country": "US"
},
"currency": "USD",
"timezone": "America/Los_Angeles",
"language": "en",
"tenant_checkout_username": "example-company",
"subscriptions": [
{
"product_key": "ai-recruitment-agent",
"product_name": "AI Recruitment Agent",
"status": "active",
"subscription": {
"id": "6ba0132d-a886-4ccc-85fa-385f6d515d91",
"status": "active",
"starts_at": "2025-08-27T11:56:54.820Z",
"ends_at": null,
"renews_at": "2025-09-27T11:56:54.819Z",
"trial_end_date": null,
"post_trial_action": null,
"plan_name": "Basic Plan",
"plan_version": 1,
"default_plan_id": null,
"default_plan_name": null,
"product_name": "AI Recruitment Agent",
"product_key": "ai-recruitment-agent",
"offering_key": "standard-offering",
"currency_code": "USD",
"created_at": "2025-08-27T11:56:54.824Z",
"next_billing_date": "Sep 27, 2025",
"next_billing_amount": 1440.0208,
"current_billing_period_start": "2025-08-27T11:56:54.820Z",
"current_billing_period_end": "2025-09-27T11:56:54.820Z",
"subscription_items": [],
"upcoming_invoice": null,
"can_update_quantities": false
},
"entitlements": [
{
"id": "db10505c-55ac-4780-a59f-ddd2aee11bdb",
"name": "Candidate Sourcing",
"used_quantity": 710,
"carryover_quantity": 0,
"quota": "unlimited",
"included_usage": 10,
"reset_interval": "monthly",
"next_reset_at": "2025-09-27T00:00:00.000Z",
"feature_type": "metered"
}
],
"wallets": [
{
"id": "c6bbd894-f6fa-4614-9795-b7f24a0932c9",
"name": "Tokens",
"credit_unit_singular": "Token",
"credit_unit_plural": "Tokens",
"balance": 36,
"allocations": [],
"credit_key": "tokens"
},
{
"id": "92f6d7fc-ad24-4adb-b614-bd6d1350e02c",
"name": "Cowries",
"credit_unit_singular": "Cowrie",
"credit_unit_plural": "Cowries",
"balance": 0,
"allocations": [],
"credit_key": "cowries"
}
],
"subscriptions_history": [
{
"id": "5ba0132d-a886-4ccc-85fa-385f6d515d91",
"status": "cancelled",
"starts_at": "2025-07-01T00:00:00.000Z",
"ends_at": "2025-08-27T11:56:54.820Z",
"renews_at": null,
"trial_end_date": null,
"post_trial_action": null,
"plan_name": "Starter Plan",
"plan_version": 1,
"default_plan_id": null,
"default_plan_name": null,
"product_name": "AI Recruitment Agent",
"product_key": "ai-recruitment-agent",
"offering_key": "standard-offering",
"currency_code": "USD",
"created_at": "2025-07-01T00:00:00.000Z",
"next_billing_date": null,
"next_billing_amount": null,
"current_billing_period_start": "2025-07-27T00:00:00.000Z",
"current_billing_period_end": "2025-08-27T00:00:00.000Z",
"subscription_items": [],
"upcoming_invoice": null,
"can_update_quantities": false
}
],
"payment_method": {
"type": "card",
"brand": "visa",
"last4": "4242",
"exp_month": "12",
"exp_year": "2026",
"display_name": "Visa ending in 4242",
"bank_name": null
}
}
]
},
"errors": {}
}Metrifox customer ID (UUID)
Customer details fetched successfully
200
"Customer Details Fetched Successfully"
Additional metadata
Show child attributes
Unique customer identifier in Metrifox system
Customer key in your application
Type of customer (BUSINESS or INDIVIDUAL)
Primary email address for the customer
Display name of the customer
Full name of the customer
Email address for billing communications
Billing address information
Show child attributes
First line of billing address
Second line of billing address
City
State or province
Postal/ZIP code
Country code
Preferred currency for billing
Customer's timezone
Preferred language for communications
Username for tenant checkout
Array of product subscriptions with their details
Show child attributes
Unique identifier for the product
Name of the product
Overall status of customer's relationship with this product
Show child attributes
Unique subscription identifier
Subscription status
When the subscription starts
When the subscription ends (null for active subscriptions)
When the subscription renews
When the trial period ends
Action to take after trial ends
Name of the subscription plan
Version number of the plan
ID of the default plan
Name of the default plan
Name of the product
Unique key for the product
Unique key for the offering
Currency code for billing
When the subscription was created
Next billing date in human-readable format
Amount for next billing
Start of current billing period
End of current billing period
Array of subscription items with pricing details
Details of the upcoming invoice
Whether subscription quantities can be updated
Array of entitlements for this product
Show child attributes
Unique entitlement identifier
Name of the entitlement
Quantity used
Quantity carried over from previous period
Quota limit (e.g., "unlimited")
Included usage amount
How often the entitlement resets
When the entitlement next resets
Type of feature (e.g., metered, boolean)
Array of wallets for this product
Show child attributes
Unique wallet identifier
Name of the wallet
Singular form of the credit unit name
Plural form of the credit unit name
Current balance in the wallet
Array of credit allocations
Unique key for the credit type
Historical subscriptions for this product
Show child attributes
Unique subscription identifier
Subscription status
When the subscription starts
When the subscription ends (null for active subscriptions)
When the subscription renews
When the trial period ends
Action to take after trial ends
Name of the subscription plan
Version number of the plan
ID of the default plan
Name of the default plan
Name of the product
Unique key for the product
Unique key for the offering
Currency code for billing
When the subscription was created
Next billing date in human-readable format
Amount for next billing
Start of current billing period
End of current billing period
Array of subscription items with pricing details
Details of the upcoming invoice
Whether subscription quantities can be updated
Payment method used for this product subscription
Show child attributes
Type of payment method (e.g., card, bank_account)
Brand of payment method (e.g., visa, mastercard)
Last four digits of card/account
Expiration month
Expiration year
Display name for the payment method
Name of the bank (for bank accounts)
Any errors that occurred