-
Notifications
You must be signed in to change notification settings - Fork 1
Free Trial System
arminrad edited this page Mar 16, 2026
·
2 revisions
3-day free trial with $10 credits for new users
New users automatically receive:
- 3-day trial period
- $10 free credits
- 1000 request limit
- 100K token limit
- Auto-conversion tracking
1. User registers → Trial starts automatically
2. Trial period: 3 days from signup
3. Free credits: $10 (1000 credits)
4. Usage tracked separately from paid credits
5. After 3 days or usage limit → Trial ends
6. User must add payment method to continue
| Metric | Limit |
|---|---|
| Duration | 3 days |
| Credits | $10 (1000 credits) |
| Requests | 1000 total |
| Tokens | 100,000 total |
| Expiration | Auto-expires after 3 days |
curl http://localhost:8000/trials/status \
-H "Authorization: Bearer YOUR_API_KEY"Response:
{
"is_trial": true,
"trial_start": "2024-12-15T10:00:00Z",
"trial_end": "2024-12-18T10:00:00Z",
"days_remaining": 2,
"credits_remaining": 8.50,
"requests_used": 123,
"requests_remaining": 877,
"tokens_used": 45000,
"tokens_remaining": 55000,
"has_converted": false
}Trial automatically starts on user registration:
curl -X POST http://localhost:8000/auth/register \
-H "Content-Type: application/json" \
-d '{
"username": "newuser",
"email": "user@example.com",
"auth_method": "email"
}'GET /trials/status
Returns current trial information.
POST /trials/start
Manually start trial (usually automatic).
POST /trials/convert
Convert to paid account (after payment).
-- Trial fields in api_keys_new
is_trial BOOLEAN DEFAULT true
trial_start_date TIMESTAMP
trial_end_date TIMESTAMP
trial_used_tokens INTEGER DEFAULT 0
trial_used_requests INTEGER DEFAULT 0
trial_used_credits NUMERIC DEFAULT 0
trial_max_tokens INTEGER DEFAULT 100000
trial_max_requests INTEGER DEFAULT 1000
trial_credits NUMERIC DEFAULT 10.0
trial_converted BOOLEAN DEFAULT false
subscription_status TEXT DEFAULT 'trial'has_made_first_purchase BOOLEAN DEFAULT false
trial_converted_at TIMESTAMPis_trial = truesubscription_status = 'trial'- Credits deducted from
trial_credits - Usage tracked separately
- 3 days passed OR limits reached
- API requests return:
402 Payment Required - Message: "Trial expired. Please add payment method"
- User makes first purchase
trial_converted = truesubscription_status = 'active'- Switch to paid credits
# Check trial limits
if api_key.is_trial:
if api_key.trial_used_requests >= api_key.trial_max_requests:
return 402 # Trial limit reached
if api_key.trial_used_tokens >= api_key.trial_max_tokens:
return 402 # Token limit reached
# Deduct from trial credits
api_key.trial_used_credits += cost
api_key.trial_used_requests += 1
api_key.trial_used_tokens += tokens- Check if trial active
- Deduct from
trial_credits - If trial_credits exhausted → trial ends
- Track in
trial_used_credits
Triggered by first purchase webhook:
if user.has_made_first_purchase == False:
# User was on trial
api_key.trial_converted = True
api_key.subscription_status = 'active'
user.has_made_first_purchase = True
user.trial_converted_at = NOW()- Unlimited requests (plan-based)
- Higher token limits
- Access to all models
- Priority support
- No expiration
-- Active trials
SELECT COUNT(*) as active_trials
FROM api_keys_new
WHERE is_trial = true
AND trial_end_date > NOW();
-- Conversion rate
SELECT
COUNT(*) FILTER (WHERE trial_converted = true) * 100.0 /
COUNT(*) as conversion_rate
FROM api_keys_new
WHERE is_trial = true;
-- Average trial usage
SELECT
AVG(trial_used_credits) as avg_credits,
AVG(trial_used_requests) as avg_requests,
AVG(trial_used_tokens) as avg_tokens
FROM api_keys_new
WHERE is_trial = true;{
"error": "Trial expired",
"message": "Your 3-day trial has ended. Add payment method to continue.",
"trial_end": "2024-12-18T10:00:00Z",
"upgrade_url": "/pricing"
}{
"error": "Trial limit reached",
"message": "You've used all trial credits. Upgrade to continue.",
"used": 10.0,
"limit": 10.0
}Can't start new trial if already converted.
Edit src/db/api_keys.py:
TRIAL_CONFIG = {
"duration_days": 3,
"credits": 10.0,
"max_requests": 1000,
"max_tokens": 100000
}-- Extend specific user's trial
UPDATE api_keys_new
SET trial_end_date = trial_end_date + INTERVAL '3 days'
WHERE user_id = 123 AND is_trial = true;- Test thoroughly: Use trial to validate integration
- Monitor usage: Check remaining credits
- Plan upgrade: Don't wait until last day
- Read limits: Understand request/token limits
- Track conversions: Monitor conversion funnel
- Optimize limits: Balance generosity and cost
- Send reminders: Email before trial expires
- Analyze usage: What features convert best?
- Support trials: Help users succeed
Welcome to Gatewayz!
Your 3-day trial includes $10 free credits.
Expires: Dec 18, 2024
Trial ending soon!
1 day remaining
Credits left: $3.50
Upgrade now: /pricing
Trial expired
Add payment to continue using Gatewayz
- Stripe Integration - Payment after trial
- Subscription Plans - Paid plans
- Referral System - Bonus credits
Last Updated: December 2024 Status: Production Ready
- Subscription-Plans — What happens after trial ends
- Stripe-Integration — Payment when converting from trial
- Coupon-System — Coupons can extend trial credits
- Delta Report — P0-7: Trial config mismatch ($5 vs $10)
Reading Path (start here, in order)
- Conceptual Model
- Stability Definition
- Conceptual Model Features
- Features
- Delta Report
- Features-Acceptance-Criteria
Testing
Security & Access
Billing
Monitoring
Features
Providers
Operations
Data References