Core Concepts

Target Users

7 min read

Target Users lets you release a feature to specific people before rolling it out to everyone else. Define an explicit list of user IDs — FlagPilot evaluates them in sub-millisecond time, before any percentage rollout runs.

How it Works

  • FlagPilot never knows who your users are. We do not sync or import your user databases.
  • Only opaque IDs are stored. We match against plain strings that you provide.
  • User IDs come directly from your application. You pass them dynamically during flag evaluation.

Quick Start

Pass the user ID during flag evaluation. FlagPilot checks the Target Users list before applying any rollout percentage:

example.ts
const enabled = await flagpilot.evaluate("checkout-v2", {
  userId: currentUser.id
});

Use this same userId when adding Target Users inside the dashboard. If the ID is in the target list, the flag resolves to true immediately.

Architecture

The evaluation chain runs entirely within the SDK — no network call is made at request time:

User Logs In
Your Application
currentUser.id
FlagPilot SDK
Target User Check
Percentage Rollout
Default Evaluation
Feature Enabled / Disabled
💡
Note
The Target User check is the first step in flag evaluation. If the user ID matches, the flag resolves immediately and no further checks run.

Complete Integration Example

A full example showing user authentication, flag evaluation, and conditional rendering in a Next.js Server Component:

app/checkout/page.tsx
import { auth } from '@/lib/auth';
import { FlagPilot } from '@flagpilot/node';

const FlagPilotClient = new FlagPilot({
  apiKey: process.env.FLAGPILOT_SECRET_KEY,
  environment: 'production',
});

export default async function CheckoutPage() {
  const currentUser = await auth();

  const enabled = await FlagPilotClient.evaluate('checkout-v2', {
    userId: currentUser.id,
  });

  return enabled ? <CheckoutV2 /> : <CheckoutV1 />;
}

Why use Target Users?

  • YourselfValidate code logic directly in production without touching other users.
  • Your QA TeamRun verification flows on the live environment before any public launch.
  • Internal employeesDogfood the feature company-wide before opening it to customers.
  • Selected beta customersCollect early feedback from trusted partners or pilot accounts.
  • Customer previewsLet a specific enterprise customer preview features under NDA.

Integration Guide

ClerkcurrentUser.id → userId
Supabaseuser.id → userId
Firebaseuid → userId
Auth0sub → userId
NextAuthsession.user.id → userId
Custom JWTjwt.sub → userId

REST API Examples

HTTP Add
POST /v1/flags/checkout-v2/users
Authorization: Bearer fk_secret_xxxxxxxxxxxxxxxx
Content-Type: application/json

{
  "userId": "user_123"
}
HTTP List
GET /v1/flags/checkout-v2/users
Authorization: Bearer fk_secret_xxxxxxxxxxxxxxxx
HTTP Remove
DELETE /v1/flags/checkout-v2/users/user_123
Authorization: Bearer fk_secret_xxxxxxxxxxxxxxxx
curl
curl -X POST https://api.tryflagpilot.com/v1/flags/checkout-v2/users \
  -H "Authorization: Bearer fk_secret_xxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{"userId": "user_123"}'

Evaluation Responses

Target Usertarget_user
{
  "enabled": true,
  "reason": "target_user"
}
Percentage Rolloutrollout_percentage
{
  "enabled": true,
  "reason": "rollout_percentage"
}

Audit Logging

Every target user modification generates an immutable audit log entry:

Timestamp2026-07-04 14:32 UTC
ActorTeam Admin
ActionAdded Target User (user_123)

Performance Validation

List SizeP95 LatencyResult
100 users< 1 msPASS
1,000 users< 5 msPASS
5,000 users< 20 msPASS

Security Best Practices

⚠️
Important
Never expose management API keys to browser clients. All target user updates should flow through your server backend.

When to Use Target Users

Use Target Users for QA teams, developer accounts, or a controlled alpha test. For general canary releases or scaling to thousands of users, use a **Percentage Rollout** instead.

Best Practices

  • Clean up targeted users after graduating features to 100%.
  • Use opaque identifiers (like UUIDs) rather than emails or names.
  • Separate production and staging targeting criteria.

FAQ

Is there a limit on target list size?

We recommend keeping target lists below 5,000 user IDs to ensure sub-millisecond local evaluations.

Does FlagPilot store names or emails?

No, FlagPilot evaluates opaque user IDs and stores no personally identifiable information.

Was this page helpful?