cURL
curl -X POST "https://api-meter.metrifox.com/usage/access" \
-H "x-api-key: your_api_key" \
-H "Content-Type: application/json" \
-d '{
"customer_key": "cust-6d11ca90",
"feature_key": "feature_interview_booking",
"quantity": 1,
"event_id": "evt_chk_001"
}'import requests
url = "https://api-meter.metrifox.com/usage/access"
payload = {
"customer_key": "cust-6d11ca90",
"feature_key": "feature_interview_booking",
"quantity": 1,
"event_id": "evt_chk_001"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
customer_key: 'cust-6d11ca90',
feature_key: 'feature_interview_booking',
quantity: 1,
event_id: 'evt_chk_001'
})
};
fetch('https://api-meter.metrifox.com/usage/access', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-meter.metrifox.com/usage/access",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'customer_key' => 'cust-6d11ca90',
'feature_key' => 'feature_interview_booking',
'quantity' => 1,
'event_id' => 'evt_chk_001'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-meter.metrifox.com/usage/access"
payload := strings.NewReader("{\n \"customer_key\": \"cust-6d11ca90\",\n \"feature_key\": \"feature_interview_booking\",\n \"quantity\": 1,\n \"event_id\": \"evt_chk_001\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api-meter.metrifox.com/usage/access")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"customer_key\": \"cust-6d11ca90\",\n \"feature_key\": \"feature_interview_booking\",\n \"quantity\": 1,\n \"event_id\": \"evt_chk_001\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-meter.metrifox.com/usage/access")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"customer_key\": \"cust-6d11ca90\",\n \"feature_key\": \"feature_interview_booking\",\n \"quantity\": 1,\n \"event_id\": \"evt_chk_001\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"customer_key": "cust-6d11ca90",
"feature_key": "feature_interview_booking",
"requested_quantity": 1,
"can_access": true,
"recorded": true,
"unlimited": false,
"balance": 3,
"used_quantity": 7,
"entitlement_active": true,
"prepaid": false,
"wallet_balance": 0,
"message": "Feature found"
}
}Usage
Check Access & Record
Checks if a customer can use a feature and records the usage in one call. If access is granted the usage is recorded; if not, nothing happens.
POST
/
usage
/
access
cURL
curl -X POST "https://api-meter.metrifox.com/usage/access" \
-H "x-api-key: your_api_key" \
-H "Content-Type: application/json" \
-d '{
"customer_key": "cust-6d11ca90",
"feature_key": "feature_interview_booking",
"quantity": 1,
"event_id": "evt_chk_001"
}'import requests
url = "https://api-meter.metrifox.com/usage/access"
payload = {
"customer_key": "cust-6d11ca90",
"feature_key": "feature_interview_booking",
"quantity": 1,
"event_id": "evt_chk_001"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
customer_key: 'cust-6d11ca90',
feature_key: 'feature_interview_booking',
quantity: 1,
event_id: 'evt_chk_001'
})
};
fetch('https://api-meter.metrifox.com/usage/access', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-meter.metrifox.com/usage/access",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'customer_key' => 'cust-6d11ca90',
'feature_key' => 'feature_interview_booking',
'quantity' => 1,
'event_id' => 'evt_chk_001'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-meter.metrifox.com/usage/access"
payload := strings.NewReader("{\n \"customer_key\": \"cust-6d11ca90\",\n \"feature_key\": \"feature_interview_booking\",\n \"quantity\": 1,\n \"event_id\": \"evt_chk_001\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api-meter.metrifox.com/usage/access")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"customer_key\": \"cust-6d11ca90\",\n \"feature_key\": \"feature_interview_booking\",\n \"quantity\": 1,\n \"event_id\": \"evt_chk_001\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-meter.metrifox.com/usage/access")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"customer_key\": \"cust-6d11ca90\",\n \"feature_key\": \"feature_interview_booking\",\n \"quantity\": 1,\n \"event_id\": \"evt_chk_001\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"customer_key": "cust-6d11ca90",
"feature_key": "feature_interview_booking",
"requested_quantity": 1,
"can_access": true,
"recorded": true,
"unlimited": false,
"balance": 3,
"used_quantity": 7,
"entitlement_active": true,
"prepaid": false,
"wallet_balance": 0,
"message": "Feature found"
}
}Usage endpoints are served from https://api-meter.metrifox.com. Other API calls stay on https://api.metrifox.com.For example, before a customer generates an AI image, check they have quota and record the generation in a single call.
If the action doesnβt complete β or the customer ends up using a different amount β correct the
recorded usage with Adjust a Usage Event.
Authorizations
Body
application/json
The unique customer identifier in your application.
Required idempotency key. The usage is recorded at most once per event_id, so retries are safe.
Feature to check and record against. Either feature_key or event_name is required.
Event name configured on the feature. Either event_name or feature_key is required.
Quantity to check and record. Defaults to 1.
Optional credits used for this event (prepaid features).
Response
Access checked. When can_access is true the usage was recorded.
Show child attributes
Show child attributes

