Meter Quick Start

Track API usage with Solenoid Meter in under 2 minutes.

Prerequisites

Base URL

https://api.solenoid.systems/v1

All endpoints require a Bearer token. See Authentication.

Create a Meter and Check Balance

Meters are multi-tenant — each meterId tracks an end-user’s credits. Meters are created implicitly on first use.

curl https://api.solenoid.systems/v1/meter/user-123/balance \
  -H "Authorization: Bearer sm_your_key_here"
{
  "balance": 0,
  "meter_id": "user-123"
}

Refill Credits

curl -X POST https://api.solenoid.systems/v1/meter/user-123/refill \
  -H "Authorization: Bearer sm_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{"amount": 1000}'
{
  "balance": 1000,
  "meter_id": "user-123"
}

Deduct Credits

curl -X POST https://api.solenoid.systems/v1/meter/user-123/deduct \
  -H "Authorization: Bearer sm_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{"amount": 10}'
{
  "balance": 990,
  "meter_id": "user-123"
}

If the balance is too low, the API returns 402 with error code insufficient_balance.

JavaScript Example

const res = await fetch("https://api.solenoid.systems/v1/meter/user-123/deduct", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.SOLENOID_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ amount: 10 }),
});

if (!res.ok) throw new Error((await res.json()).error.code);
const { balance } = await res.json();

Next Steps