cURL
curl -X POST https://api.metrifox.com/api/v1/subscriptions/9c3a7180-3a05-4a7c-9b09-2ad1c9a2b8d1/topup_credits \
-H "x-api-key: $METRIFOX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"line_items": [
{ "credit_key": "credit_tokens", "quantity": 100 }
]
}'import requests
url = "https://{defaultHost}/api/v1/subscriptions/{subscription_id}/topup_credits"
payload = { "line_items": [
{
"credit_key": "credit_tokens",
"quantity": 100
}
] }
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({line_items: [{credit_key: 'credit_tokens', quantity: 100}]})
};
fetch('https://{defaultHost}/api/v1/subscriptions/{subscription_id}/topup_credits', 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://{defaultHost}/api/v1/subscriptions/{subscription_id}/topup_credits",
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([
'line_items' => [
[
'credit_key' => 'credit_tokens',
'quantity' => 100
]
]
]),
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://{defaultHost}/api/v1/subscriptions/{subscription_id}/topup_credits"
payload := strings.NewReader("{\n \"line_items\": [\n {\n \"credit_key\": \"credit_tokens\",\n \"quantity\": 100\n }\n ]\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://{defaultHost}/api/v1/subscriptions/{subscription_id}/topup_credits")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"line_items\": [\n {\n \"credit_key\": \"credit_tokens\",\n \"quantity\": 100\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{defaultHost}/api/v1/subscriptions/{subscription_id}/topup_credits")
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 \"line_items\": [\n {\n \"credit_key\": \"credit_tokens\",\n \"quantity\": 100\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"statusCode": 201,
"message": "Topup order created successfully",
"meta": {},
"data": {
"id": "5b1f12a4-7e1e-4d5c-8b7a-2c8a8a4c3a92",
"order_number": "ORD-1042",
"customer_id": "764c80e3-ed59-44a5-ba07-7ee5ba547774",
"status": "pending",
"currency_code": "USD",
"subtotal_in_standard_unit": 100,
"discount_amount_in_standard_unit": 0,
"tax_amount_in_standard_unit": 0,
"total_in_standard_unit": 100,
"invoices": [
{
"id": "5e5d2f9a-4f4e-4f1d-8c9c-2f1c4e3b9a01",
"status": "pending",
"total_in_standard_unit": 100,
"payment_intent": {
"id": "pi_1Nxxxxx",
"client_secret": "pi_1Nxxxxx_secret_xxxxx"
}
}
],
"should_collect_payment": true,
"should_collect_card": false,
"created_at": "2026-05-29T18:42:11Z"
},
"errors": {}
}Subscriptions
Top up credits on a subscription
Create a one-time topup order that grants additional credits against an active subscription. The request body is the credit line items.
POST
/
api
/
v1
/
subscriptions
/
{subscription_id}
/
topup_credits
cURL
curl -X POST https://api.metrifox.com/api/v1/subscriptions/9c3a7180-3a05-4a7c-9b09-2ad1c9a2b8d1/topup_credits \
-H "x-api-key: $METRIFOX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"line_items": [
{ "credit_key": "credit_tokens", "quantity": 100 }
]
}'import requests
url = "https://{defaultHost}/api/v1/subscriptions/{subscription_id}/topup_credits"
payload = { "line_items": [
{
"credit_key": "credit_tokens",
"quantity": 100
}
] }
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({line_items: [{credit_key: 'credit_tokens', quantity: 100}]})
};
fetch('https://{defaultHost}/api/v1/subscriptions/{subscription_id}/topup_credits', 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://{defaultHost}/api/v1/subscriptions/{subscription_id}/topup_credits",
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([
'line_items' => [
[
'credit_key' => 'credit_tokens',
'quantity' => 100
]
]
]),
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://{defaultHost}/api/v1/subscriptions/{subscription_id}/topup_credits"
payload := strings.NewReader("{\n \"line_items\": [\n {\n \"credit_key\": \"credit_tokens\",\n \"quantity\": 100\n }\n ]\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://{defaultHost}/api/v1/subscriptions/{subscription_id}/topup_credits")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"line_items\": [\n {\n \"credit_key\": \"credit_tokens\",\n \"quantity\": 100\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{defaultHost}/api/v1/subscriptions/{subscription_id}/topup_credits")
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 \"line_items\": [\n {\n \"credit_key\": \"credit_tokens\",\n \"quantity\": 100\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"statusCode": 201,
"message": "Topup order created successfully",
"meta": {},
"data": {
"id": "5b1f12a4-7e1e-4d5c-8b7a-2c8a8a4c3a92",
"order_number": "ORD-1042",
"customer_id": "764c80e3-ed59-44a5-ba07-7ee5ba547774",
"status": "pending",
"currency_code": "USD",
"subtotal_in_standard_unit": 100,
"discount_amount_in_standard_unit": 0,
"tax_amount_in_standard_unit": 0,
"total_in_standard_unit": 100,
"invoices": [
{
"id": "5e5d2f9a-4f4e-4f1d-8c9c-2f1c4e3b9a01",
"status": "pending",
"total_in_standard_unit": 100,
"payment_intent": {
"id": "pi_1Nxxxxx",
"client_secret": "pi_1Nxxxxx_secret_xxxxx"
}
}
],
"should_collect_payment": true,
"should_collect_card": false,
"created_at": "2026-05-29T18:42:11Z"
},
"errors": {}
}Authorizations
Path Parameters
The ID of the active subscription the credits should be granted against.
Body
application/json
One or more credits to top up on the subscription identified by the {subscription_id} path
parameter. Each item creates one credit allocation on the corresponding wallet.
Minimum array length:
1Show child attributes
Show child attributes
Response
Topup order created successfully
⌘I

