Skip to main content
POST
/
api
/
v1
/
usage
/
events
Javascript SDK
import { init } from "metrifox-js";

const metrifoxClient = init({
  apiKey: process.env.METRIFOX_API_KEY
});

// Basic usage recording
await metrifoxClient.usages.recordUsage({
  customerKey: "cust-6d11ca90",
  eventName: "candidate.sourced",
  amount: 2
});

// Usage recording with all optional fields
await metrifoxClient.usages.recordUsage({
  customerKey: "cust-6d11ca90",
  eventName: "premium.feature",
  amount: 3,
  creditUsed: 10,
  eventId: "evt_external_789",
  timestamp: 1703246400000,
  metadata: {
    feature_type: "advanced",
    user_tier: "premium"
  }
});
{
  "message": "Usage recorded",
  "event_name": "candidate.sourced",
  "customer_key": "cust-6d11ca90",
  "amount": 2
}

Authorizations

x-api-key
string
header
required

Body

application/json
customer_key
string
required

The unique customer identifier in your application

event_name
string
required

The name of the event/feature being used

amount
number
default:1

The quantity/amount of usage. Defaults to 1 if not provided

credit_used
integer | null

Optional credits used for this event

event_id
string | null

Optional external event identifier

timestamp
integer | null

Optional Unix timestamp (in milliseconds) when the event occurred. Defaults to current time if not provided

metadata
object

Optional metadata to attach to the event

Response

Usage recorded successfully

message
string
Example:

"Usage recorded"

event_name
string

The event name that was recorded

customer_key
string

The customer key for which usage was recorded

amount
number

The amount that was recorded