Skip to main content
POST
cURL — COUNT_UNIQUE event
Usage endpoints are served from https://api-meter.metrifox.com. Other API calls stay on https://api.metrifox.com.
Important Notes:
  • event_id (required) is required for idempotency: You generate a unique UUID per real event. This prevents duplicates if sent multiple times. Metrifox will always send back a 200 response if the event is consumable but will record it only once per event_id.
  • feature_key (this is required if there is no event_name): The unique key of the metered feature (from dashboard).
  • event_name (optional if feature_key is already provided): One of the event names configured on the feature (e.g., “api_request” or “image_generated”)
  • Include a timestamp (ms) when possible to aid ordering/debugging.
  • properties (required for COUNT_UNIQUE features): The values of the feature’s aggregation properties for this event, e.g. { "account_id": "acct_1" }. Send the values as strings — they are compared exactly and as strings, so 1 and "1" are the same value but 1.0 is a different one. null counts as omitting the property, and is rejected. Optional otherwise — SUM and COUNT features ignore it.
A COUNT_UNIQUE feature records one unit the first time a value is seen in the period, and nothing for repeats. An event that omits a configured property is rejected. On persistent-use features, send the same property values with a negative quantity to release the value. See Understanding Features for the full behaviour.
Example response:

Authorizations

x-api-key
string
header
required

Body

application/json
customer_key
string
required

The unique customer identifier in your application

event_id
string
required

Required idempotency key for this event. Must be unique per event.

event_name
string | null

The name of the event as set up in the Metrifox platform. Either event_name or feature_key is required.

feature_key
string | null

Feature key associated with this usage event. Either event_name or feature_key is required.

quantity
number
default:1

The quantity of usage. Defaults to 1 if not provided

credit_used
integer | null

Optional credits used for this event

timestamp
integer | null

Unix timestamp (in milliseconds) when the event occurred. Defaults to current time if not provided. Supplying this improves ordering and debugging.

properties
object

The values of the feature's aggregation properties for this event. Required for features whose aggregation method is count_unique, which counts one unit the first time a value is seen in the period; an event that omits a configured property, or sends it as null, is rejected. Values are compared exactly and as strings: ACC_1 and acc_1 are two different values, while 1 and "1" are the same one. Send identifiers as strings — a value sent as 1 by one client and 1.0 by another would otherwise count twice. Ignored by sum and count features.

metadata
object

Optional metadata to attach to the event

Response

Usage recorded successfully

data
object
message
string
Example:

"Event received"