Backend

Usage

The user's plan and how much of each limit they use: storage, AI tokens, API keys and webhooks, ready for UsageMeter.

pleate_backend.usage answers one question for a billing or settings page: how much of each limit has this user used. It reads the counters the other apps already keep, with one query per item, and caches the numbers per user for 30 seconds.

Endpoint

MethodPathPurpose
GET/usageSigned in, session or API key. {plan, items: [{id, label, used, limit, unit}]}.
GET /api/usage
{
  "plan": "pro",
  "items": [
    { "id": "storage", "label": "Storage", "used": 73400320, "limit": 524288000, "unit": "bytes" },
    { "id": "ai_tokens", "label": "AI tokens today", "used": 4210, "limit": 200000, "unit": "tokens" },
    { "id": "api_keys", "label": "API keys", "used": 2, "limit": 25, "unit": "keys" },
    { "id": "webhooks", "label": "Webhook endpoints", "used": 1, "limit": 20, "unit": "endpoints" }
  ]
}

plan is the plan of the active subscription, else the free plan, or null without billing. limit is null when there is none. An item is present only when its app is installed. Labels follow the request language.

idUsedLimit
storageBytes of the user's filesFILES["USER_QUOTA"]
ai_tokensInput plus output tokens todayAI["DAILY_TOKEN_LIMIT"]
api_keysActive keys25
webhooksWebhook endpoints20

From React

tsx
import { UsageMeter } from "pleate";
import { useUsage } from "pleate-client/react";

const usage = useUsage();
return usage.usageMeterProps.map((props) => <UsageMeter key={props.label} {...props} />);

Byte quotas are shown in GB or MB; items without a limit are left out of usageMeterProps.