Overview

Entitlements management lets your team instantly update entitlements for your users, based on their organization, pricing plan, or user ID without redeploying your app.

Problem

Without entitlements management:

  • Sales and customer success can't easily enable access to features or increase usage limits for prospects and customers they're speaking with.

  • The logic for entitlements, feature access, and usage limits, is scattered across the codebase with no single source of truth, making it hard to understand and prone to errors.

  • Changes to entitlements require complex, coordinated code changes, app rebuilds, and redeploys.

Solution

Define entitlements in Hypertune as flags instead of hardcoded values:

type Root {
  entitlements: Entitlements!
}

type Entitlements {
  teamRolesEnabled: Boolean!
  maxTeamSize: Int!
  maxApiRequestsPerDay: Int!
  versionHistoryEnabled: Boolean!
}

Then reference them in your code:

app/api/add-team-member/route.ts
import { waitUntil } from '@vercel/functions'
import { NextResponse } from 'next/server'
import addUserToTeam from '@/lib/addUserToTeam'
import getHypertune from '@/lib/getHypertune'
import getTeamSize from '@/lib/getTeamSize'

export const runtime = 'edge'

export async function POST(request: Request) {
  const hypertune = await getHypertune({ isRouteHandler: true })

  const { userId, teamId } = await request.json()

  const teamSize = getTeamSize()

  const maxTeamSize = hypertune.entitlements().maxTeamSize({
    args: {},
    fallback: 5,
  })

  waitUntil(hypertune.flushLogs())

  if (teamSize >= maxTeamSize) {
    return NextResponse.json(
      {
        error: 'Team size limit reached',
        teamSize,
        maxTeamSize,
        message: `Your team has reached the maximum size of ${maxTeamSize} members. Please upgrade your plan to add more members.`,
      },
      { status: 403 }
    )
  }

  const result = await addUserToTeam(userId, teamId)

  return NextResponse.json({
    success: true,
    currentTeamSize: teamSize + 1,
    maxTeamSize,
    result,
  })
}

This empowers product, sales, and customer success to instantly update entitlements from the Hypertune dashboard without any code changes or redeploys:

Benefits

  • Sales and customer success can instantly enable access to features or increase usage limits for prospects and customers they're speaking with.

  • The configuration logic for entitlements, feature access, and usage limits, is extracted out of the codebase into a single source of truth that's visible to all stakeholders.

  • Entitlements can be updated instantly at runtime without any code changes or redeploys.

ROI

These benefits help teams:

  • Close more prospects, boost customer satisfaction, and generate more revenue.

  • Improve product reliability for users.

Last updated