DEVELOPER SURFACE / DOCS
FROM API KEY TOLIVE METER.
The full integration model for authentication, products, funded balances, session lifecycle events, route groups, billing logic, MCP tools, and final session records.
LIVE SYSTEM MAPSTATE / ACTIVEThe schemas and route shapes below preserve the previous public contract. Confirm the active API origin, enabled rails, and account-specific capabilities during onboarding before production integration.
QUICK START / 01
FROM ACCOUNT
TO FIRST SESSION.
Create an approved merchant account, register one product, then open a session after the customer has a funded balance.
Apply and verify your identity
Submit the first-party merchant application, then sign in with the same email through Privy. Approval remains a separate Metr review.
1. Open /merchant/apply
2. Submit product and rail requirements
3. Verify the same email at /merchant/login
4. Wait for merchant status = approvedDefine a product
Describe the billable service, rate unit, price, rail, grace period, and optional session cap.
curl -X POST "$METR_API/api/v1/merchant/products" \
-H "authorization: Bearer $TOKEN" \
-H "content-type: application/json" \
-d '{
"name": "GPU access",
"chain": "base",
"rateUnit": "minute",
"pricePerUnit": "0.10",
"graceSeconds": 30,
"maxSpendPerSession": "5.00"
}'Start a session
After the customer is identified and funded, open a session and control the metering lifecycle from your product.
curl -X POST "$METR_API/api/v1/customer/sessions/start" \
-H "authorization: Bearer $CUSTOMER_TOKEN" \
-H "content-type: application/json" \
-d '{ "productId": "prod_abc123" }'AUTHENTICATION / 02
IDENTITY BEFORE
VALUE MOVES.
Merchant sign-in uses a short-lived Privy access token. The Metr server verifies that token and independently checks the linked application’s approval status. Programmatic product access uses scoped merchant API keys, which should remain outside client code.
PRIVYMerchant identity
Email OTP establishes identity; it does not automatically grant an approved merchant workspace.
metr_…API keys
Merchant keys are created for programmatic access, displayed once, and revocable by identifier.
x-api-keyAgent clients
Machine integrations can authenticate through a header on approved API and MCP connections.
authorization: Bearer PRIVY_ACCESS_TOKENCORE CONCEPTS / 03
ONE OBJECT CONNECTS
THE LIFECYCLE.
A product defines the commercial rule. A funded balance authorizes spend. A session connects the customer, rate, active time, total charge, and final record.
Product fields
| FIELD | TYPE | PURPOSE |
|---|---|---|
name | string | Human-readable product name |
chain | configured network | Settlement environment selected for the product |
rateUnit | minute | hour | day | Billing interval exposed by the legacy contract |
pricePerUnit | numeric string | Price applied to one rate unit |
allowedAssets | usdc | native | both | custom | Asset policy for the product |
customTokenId | string | null | Registered token rail when custom is selected |
graceSeconds | integer | Uncharged time before billing begins |
maxSpendPerSession | numeric string | null | Maximum charge for one session |
Session lifecycle
BALANCEPrepaid
Access begins against funds already available to the customer on the configured product rail.
GRACEGrace period
Time may be observed before charges begin, based on the product’s configured allowance.
CAPSpend ceiling
The session stops accruing charges at the explicit maximum set for the product.
CUSTOM TOKENS / 04
CONFIGURE THE RAIL.
VERIFY THE ASSET.
The legacy contract included merchant-registered SPL and ERC-20 rails. The safe operational model is register → validate contract and decimals → verify pricing/liquidity assumptions → enable per product.
POST /api/v1/merchant/tokens
{
"chain": "base",
"tokenAddress": "0x…",
"symbol": "TOKEN",
"name": "Example Token",
"decimals": 18
}A listed asset or network is not automatically enabled for every account. Production support depends on the configured rail and verification path.
API REFERENCE / 05
THE COMPLETE
ROUTE MAP.
All legacy routes were grouped under /api/v1. Requests and responses use JSON unless a specific integration says otherwise.
| METHOD | PATH | AUTH | PURPOSE |
|---|---|---|---|
POST | /merchant/applications | Public | Submit or update an access application |
GET | /merchant/access | Privy | Verify identity and read merchant approval status |
GET | /merchant/products | Merchant | List billable products |
POST | /merchant/products | Merchant | Create a billable product |
DELETE | /merchant/products/:id | Merchant | Remove a product |
GET | /merchant/api-keys | Merchant | List API-key prefixes |
POST | /merchant/api-keys | Merchant | Create an API key |
GET | /merchant/tokens | Merchant | List registered token rails |
POST | /merchant/tokens | Merchant | Register a token configuration |
GET | /customer/balances | Customer | Read funded balances |
GET | /customer/sessions | Customer | List session history |
POST | /customer/sessions/start | Customer | Open a metered session |
POST | /customer/sessions/pause | Customer | Pause active-time accrual |
POST | /customer/sessions/resume | Customer | Resume a paused session |
POST | /customer/sessions/end | Customer | Finalize usage and close |
{
"id": "session_uuid",
"status": "active",
"startedAt": "2026-08-27T18:00:00.000Z",
"totalSeconds": 0,
"totalCharged": "0"
}BILLING LOGIC / 06
VISIBLE RULES.
DETERMINISTIC MATH.
The legacy billing model tracked elapsed time, applied any configured grace period, rounded billable time to engine intervals, then enforced the remaining session cap before recording a charge.
rate = $0.10 / minute
elapsed = 45 seconds
grace = 30 seconds
billable = 15 seconds
charge = billable × rate_per_secondCHAINS & ASSETS / 07
PRODUCT-SCOPED
SETTLEMENT.
The prior docs modeled products on Solana, Polygon, Base, and Robinhood Chain, with stablecoin, native, or configured custom-token paths. Treat this as architecture scope; enabled production rails are confirmed per account.
Each product is pinned to its configured environment. A balance on one network should not be represented as spendable on another without an explicit bridge or messaging design.
MCP SERVER / 08
LET AGENTS DISCOVER
THE BILLING SURFACE.
The legacy MCP design exposed public discovery tools and authenticated session tools over streamable HTTP. The same deposit and session policies apply; the MCP layer does not bypass verification.
| TOOL | AUTH | PURPOSE |
|---|---|---|
list_agents | Public | Search marketplace listings by category or rail |
get_agent | Public | Read one listing’s product details |
get_payment_requirements | Public | Read a product’s 402 payment requirements |
register_customer | API key | Identify a customer for a merchant |
get_customer_balance | API key | Read a customer’s available balance |
submit_deposit | API key | Submit a deposit for verification |
start_session | API key | Open a metered session |
end_session | API key | Finalize a session charge |
{
"mcpServers": {
"metr": {
"url": "$METR_API/api/v1/mcp",
"headers": { "x-api-key": "metr_your_key" }
}
}
}ERROR HANDLING / 09
FAIL CLEARLY.
STOP SAFELY.
| STATUS | MEANING | COMMON CAUSES |
|---|---|---|
400 | Bad request | Invalid input, missing field, or insufficient balance |
401 | Unauthorized | Missing, invalid, or wrong credential type |
404 | Not found | Product, customer, or session does not exist |
500 | Server error | Unexpected internal failure |
{
"message": "insufficient balance for this product"
}BUILD WHAT
GETS METERED.
Metr is live. Access is currently approved individually for businesses, developers, and agent builders.
Request access