Affitor

CLI Command Reference

Complete reference for all npx affitor commands, flags, and options.

Full reference for the npx affitor CLI.

Global Flags

These flags work with every command:

FlagDescription
--jsonOutput as JSON (for AI agents and scripts)
--no-interactiveSkip all prompts, fail on missing values
--auto-confirmAuto-yes to confirmation prompts
--quietSuppress non-essential output
--api-key <key>Override API key from config
--api-url <url>Override API URL
--verboseShow debug output
-V, --versionShow version number
-h, --helpShow help

affitor init

Create a new affiliate program and generate config files.

npx affitor init
FlagDescriptionDefault
--name <name>Program name(prompted)
--domain <domain>Root domain(prompted)
--commission-type <type>percent, fixed, recurring_percent, recurring_fixed(prompted)
--commission-rate <rate>Commission rate (% or $)40
--cookie-duration <days>Cookie window in days90
--duration-months <months>Recurring commission duration (0 = lifetime)12

Example (non-interactive):

npx affitor init \
  --name "My SaaS" \
  --domain example.com \
  --commission-type recurring_percent \
  --commission-rate 30 \
  --duration-months 12 \
  --no-interactive

Files created:

FilePurpose
.affitor/config.jsonProgram ID, API key, settings
.affitor/.env.exampleEnvironment variables template
.affitor/skills.mdTracking code snippets and AI agent instructions

affitor setup stripe

Connect your Stripe account for automatic payment tracking.

npx affitor setup stripe

What happens:

  1. Opens Stripe Connect OAuth in your browser
  2. You authorize Affitor to read your payment data
  3. Webhook endpoints are auto-created on your Stripe account
  4. Connection is saved to your program config
FlagDescription
--stripe-client-id <id>Override Stripe Connect client ID
--stripe-secret-key <key>Override Stripe secret key

Environment variables (alternative to flags):

  • STRIPE_CONNECT_CLIENT_ID or AFFITOR_STRIPE_CLIENT_ID
  • STRIPE_SECRET_KEY or AFFITOR_STRIPE_SECRET_KEY

Webhook events configured:

EventPurpose
customer.createdLead tracking
checkout.session.completedSale tracking
invoice.paidRecurring commission
invoice.payment_failedFailed payment alerts
charge.refundedAutomatic commission clawback
customer.subscription.deletedChurn tracking

affitor setup dns

Set up DNS CNAME tracking for first-party tracking.

npx affitor setup dns

:::note DNS tracking is coming soon. For now, use the tracking script or Stripe integration. :::

When available, add this DNS record:

Type:   CNAME
Name:   t.yourdomain.com
Target: track.affitor.com
TTL:    300

affitor status

Show program health: tracking, Stripe connection, recent events.

npx affitor status

Example output:

  ╭──────────────────╮
  │   My SaaS        │
  │   example.com    │
  │                  │
  │   Program ID: 42 │
  ╰──────────────────╯

✓ Stripe: connected
⚠ DNS: not configured

  Events (last 24h):
    Clicks:  142
    Leads:   23
    Sales:   8

  Active partners:      5
  Pending commissions:  3

affitor test [event-type]

Send a test tracking event to verify your integration.

npx affitor test click    # Test click event
npx affitor test lead     # Test lead event
npx affitor test sale     # Test sale event
TypeWhat it tests
clickClick tracking pipeline
leadSignup/lead tracking
salePayment/sale tracking

Test events are marked with is_test: true and appear in your dashboard with a test badge.


Config File

The CLI stores configuration in .affitor/config.json:

{
  "version": 1,
  "program_id": "430",
  "domain": "example.com",
  "commission": {
    "type": "recurring_percent",
    "rate": 40,
    "duration_months": 12
  },
  "cookie": {
    "name": "_aff",
    "duration_days": 90
  },
  "stripe_connected": false,
  "api_key": "affitor_...",
  "api_url": "https://api.affitor.com"
}

Error Messages

ErrorMessage
No configNo Affitor config found. Run npx affitor init to set up your program.
Invalid API keyAPI key expired or invalid. Run npx affitor init to get a new one.
Already configuredAffitor already configured in this directory. Use npx affitor status to check.
Stripe OAuth cancelledStripe authorization cancelled. Run npx affitor setup stripe to try again.
Network errorNetwork error: <details>. Check your internet connection and try again.
Edit on GitHub