Usage Gate

Build

Define access rules

Rules answer one question: what can this user do, and how much? You design them once. Your app never hard-codes plan names or credit amounts — it only asks about feature keys.

The three pieces

Plan

A commercial package: Free, Pro, Team. Tie paid plans to your Stripe Price id.

Feature

Something you gate. The featureKey (e.g. ai_credits) is what the SDK asks about.

Limit

How much of that feature the plan includes (amount + type: boolean, numeric, or metered).

Build it in the dashboard

  1. Open Access rules.
  2. Add a plan node (e.g. Free / Pro). Set the Stripe Price id on paid plans.
  3. Add a feature node with a stable key like ai_credits — engineers will use this string forever.
  4. Add a limit node with an amount (e.g. 1000) and type (METERED / NUMERIC_LIMIT / BOOLEAN).
  5. Connect edges: Plan → Feature (“includes”), Feature → Limit. Save.

Tip: pick boring, stable feature keys. Renaming a key later means updating every canAccess call in your product.

Same graph via API / SDK

The dashboard saves a nodes + edges graph. You can create the same shape from a setup script:

putRules (simplified)
await gate.putRules({
  nodes: [
    { id: "plan_free", kind: "plan", label: "Free", x: 40, y: 80 },
    {
      id: "feat_ai",
      kind: "feature",
      label: "AI credits",
      featureKey: "ai_credits",
      featureType: "METERED",
      x: 280,
      y: 80,
    },
    {
      id: "lim_1k",
      kind: "limit",
      label: "1,000 / month",
      amount: 1000,
      featureType: "METERED",
      x: 520,
      y: 80,
    },
  ],
  edges: [
    { id: "e1", from: "plan_free", to: "feat_ai", label: "includes" },
    { id: "e2", from: "feat_ai", to: "lim_1k", label: "Free" },
  ],
});

After rules exist

Need help drafting rules?

Paste the ready-made prompt on the AI coding agent page into Cursor or Claude — it walks through plans, keys, and first gate calls with you.