Usage Gate

Reference

HTTP API

Prefer the SDK when you can. These endpoints are what it calls. Most /api/v1/* routes need Authorization: Bearer <api_key>.

GET /api/v1/check

code
GET /api/v1/check?userId=user_123&feature=ai_credits

→ { "allowed": true, "balance": 42, "feature": "ai_credits", "userId": "user_123" }

Does this end user still have access? Hot path reads Redis first.

POST /api/v1/consume

code
POST /api/v1/consume
{ "userId": "user_123", "feature": "ai_credits", "amount": 1 }

→ { "allowed": true, "remaining": 41, ... }

amount must be a positive integer. Atomic consume prevents concurrent overspend.

POST /api/v1/grant

code
POST /api/v1/grant
{ "userId": "user_123", "feature": "ai_credits", "balance": 100 }

→ { "ok": true, "userId": "user_123", "feature": "ai_credits", "balance": 100, "resetAt": null }

Absolute entitlement set for one of your end users. Optional resetAt ISO expiry.

GET / PUT /api/v1/rules

code
GET /api/v1/rules
→ { "nodes": [...], "edges": [...], "updatedAt": "…" }

PUT /api/v1/rules
{ "nodes": [...], "edges": [...] }

Same Plan → Feature → Limit graph as the dashboard. Also accepts the dashboard session cookie.

POST /api/webhooks/stripe

Stripe-signed webhook. Handles invoice.paid and customer.subscription.updated. See Connect Stripe.

GET /api/v1/health

Liveness probe for deploys and monitoring.