Skip to main content
Resources are claimable capacity entitlements included in subscriptions. They represent countable units that customers can reserve and release—like team seats, API keys, concurrent connections, or projects. Unlike usage-based billing which tracks consumption, resources track allocation: who has reserved what.

The Resource Data Model

Resources let you implement allocation-based pricing models. Here’s how the key components work together:
  1. Resources: Define the types of capacity you offer. Each resource has a slug (like seats or api_keys) and belongs to a pricing model. Think of it as describing what can be allocated.
  2. Subscription Item Features: When a customer subscribes to a product, their subscription includes features that grant resource capacity. For example, a “Team Plan” might include 10 seats. This defines how much of each resource a customer can claim.
  3. Resource Claims: Individual allocations from a customer’s capacity pool. When a user joins a team and takes a seat, that’s a claim. Claims can be anonymous (just a count) or named (with an identifier like a user ID).
Resources are different from Usage: usage tracks consumption that gets billed (like tokens), while resources track allocations (like seats) that can be reserved and released.

Key Concepts

Capacity

Each subscription has a capacity limit for resources, determined by the product features. If a customer subscribes to a plan with “10 seats included,” their seat capacity is 10. Capacity can vary by pricing tier—a Pro plan might offer 25 seats while an Enterprise plan offers unlimited.

Resource Claims

A claim represents an allocation from the capacity pool. When you claim a resource, you’re reserving it for use. Claims track:
  • When it was claimed (claimedAt)
  • Who it’s for (externalId, optional)
  • Custom data (metadata, optional)
  • Release status (releasedAt, releaseReason)

Named vs Anonymous Claims

Resources support two claiming modes: Named Claims use an identifier (externalId) to track exactly what each allocation is for:
  • Idempotent—claiming the same ID twice returns the existing claim
  • Easy to look up and release by identifier
  • Ideal for tracking: “user_john has seat #3”
Anonymous Claims use a simple quantity count:
  • No identifier attached
  • Released in FIFO order (oldest first)
  • Ideal for: “we need 3 more seats, don’t care which”

Common Use Cases

Setting Up Resources

Step 1: Create a Resource in Your Pricing Model

  1. Navigate to the Pricing Models page in your dashboard
  2. Select the pricing model you want to add the resource to
  3. Click “Create Resource”
  4. Provide a descriptive name (e.g., “Team Seats”) and slug (e.g., seats)
  5. Save the resource

Step 2: Add Resource Capacity to a Product

When creating or editing a product’s features:
  1. Add a new feature of type Resource
  2. Select the resource you created
  3. Set the capacity (e.g., 10 seats)
  4. Save the product
When customers subscribe to this product, they’ll receive the specified capacity for that resource.

Working with Resources in Your App

Checking Available Capacity

Before allowing users to claim resources, check what’s available:
lib/check-capacity.ts

Claiming Resources

Use named claims when you need to track what each allocation is for:
lib/team-management.ts
Use anonymous claims when you just need a count:
lib/connection-pool.ts

Releasing Resources

Release named claims by their identifier:
lib/team-management.ts
Release anonymous claims by quantity (FIFO order):
lib/connection-pool.ts

Listing Active Claims

View all active claims for a resource:
lib/team-management.ts

API Response Shapes

Resource Usage

Resource Claim

Important Behaviors

Idempotent Named Claims

Claiming with the same externalId twice returns the existing claim without creating a duplicate. This makes the API safe for retries:

Capacity Enforcement

Claims fail if they would exceed capacity. Always check availability before attempting to claim, or handle the error gracefully:

Capacity Aggregation

When a subscription has multiple items that provide capacity for the same resource (e.g., a base plan + add-on), the total capacity is aggregated across all subscription items. For example:
  • Pro Plan provides 10 seats
  • Seat Add-On provides 5 additional seats
  • Total capacity = 15 seats
This aggregation happens automatically when calculating usage. The getResourceUsages endpoint returns one entry per resource with the total aggregated capacity, not per subscription item.

Subscription Lifecycle

On Cancellation: When a subscription is canceled, all associated resource claims are automatically released with a releaseReason of "subscription_canceled". This ensures clean capacity management without manual cleanup. Claims Persist Across Adjustments: Resource claims are scoped to the subscription and resource, not to individual subscription items. This means claims survive subscription adjustments—when you upgrade or downgrade plans, existing claims are preserved as long as they fit within the new capacity. On Downgrade: When adjusting a subscription to a plan with lower capacity, Flowglad validates that existing claims fit within the new capacity. If the current claimed count exceeds the new capacity, the adjustment is blocked with an error message:
The customer must first release enough resources before the downgrade can proceed. Scheduled Downgrade Interim Period: When a downgrade is scheduled for the end of the billing period (rather than immediately), customers retain their current capacity until the change takes effect. During this interim, new claims that exceed the future capacity are allowed but marked as temporary—they have an expiredAt timestamp set to the billing period end and automatically expire when the downgrade executes.

Auto-Resolution

If a customer has exactly one active subscription, the subscriptionId parameter is optional—Flowglad automatically resolves it. For customers with multiple subscriptions, you must specify which one:

Full Example: Team Seat Management

Here’s a complete example showing how to implement team seat management:
lib/team-seats.ts

Adjusting Subscriptions with Resources

When customers upgrade or downgrade plans, resource claims are preserved—but capacity validation ensures you can’t reduce capacity below active claims.

Upgrade Flow: Adding More Seats

The most common upgrade is adding more seats to an existing plan. Use the quantity parameter to set the exact number of seats:
lib/add-seats.ts
You can also upgrade to an entirely different plan:
lib/upgrade-plan.ts

Downgrade Flow

Downgrading requires releasing excess claims first. Flowglad validates capacity before allowing the change:
lib/downgrade-with-seats.ts
Both immediate and scheduled downgrades are blocked if claimed resources exceed the new capacity. The expiredAt mechanism only applies to new claims made during an interim period after a valid downgrade is scheduled—not to allowing downgrades when excess claims already exist.

Building a Seat Adjustment UI

Here’s how to build a UI that handles seat-aware plan changes:
lib/plan-change-handler.ts