A powerful CLI for the Meta/Facebook Marketing API — manage campaigns, ad sets, ads, creatives, and insights from your terminal.
Package Exports
adpilot
adpilot/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (adpilot) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
adpilot
A powerful CLI for the Meta/Facebook Marketing API. Manage campaigns, ad sets, ads, creatives, audiences, budgets, and performance insights -- all from your terminal. Built for both human use and machine (LLM pipeline) consumption with first-class JSON output and stdin piping.
Features
Full Campaign Lifecycle -- Create, update, pause, resume, archive, copy, and delete campaigns, ad sets, ads, and creatives
Performance Insights -- Pull metrics at any level with date ranges, breakdowns, and CSV export
AI Ad Copy Pipeline -- Generate LLM prompts for ad copy, parse responses into deployable templates, feed performance back for iteration
Template Deploy System -- Define entire campaign stacks in JSON and deploy with a single command
Variant Generation -- Auto-generate combinatorial ad variants across headlines, bodies, CTAs, countries, and age groups
Test Cycle Orchestration -- End-to-end test cycles: deploy, evaluate, kill losers, scale winners
Performance Monitoring -- Threshold-based auto-pause, winner/loser detection with composite scoring
Budget Allocation -- Dynamic cross-project budget allocation by demand score, performance, or equal split
Audience Discovery -- Analyze campaign breakdowns to discover top-performing segments and auto-create targeted ad sets
Targeting Builder -- Interactive wizard and API search for interests, locations, demographics, and audience size estimates
A/B Split Testing -- Create and monitor ad studies with statistical confidence tracking
Automated Rules -- Create metric-based rules to auto-pause, scale, or notify on performance thresholds
Lead Management -- List forms, download leads to CSV, create new lead gen forms
Saved Reports -- Save, run, and compare report templates across time periods with async support
Batch API -- Execute up to 50 API calls in a single HTTP request
Webhook Subscriptions -- Subscribe to ad account change notifications
Multi-Account Profiles -- Switch between multiple ad accounts and tokens instantly
OAuth 2.0 Flow -- Built-in OAuth with long-lived token exchange and refresh
Shell Completions -- Auto-install for Bash, Zsh, and Fish
Installation
npm (global)
npminstall-g adpilot
From source
git clone https://github.com/connorodea/adpilot.git
cd adpilot
npminstallnpm run build
npmlink
Development
npm run dev -- campaigns list # Run via ts-node
Quick Start
# 1. Authenticate
adpilot auth login
# 2. Set your ad account
adpilot config set adAccountId act_123456789
# 3. List campaigns
adpilot campaigns list
# 4. Pull last 7 days of insights
adpilot insights account --date-preset last_7d
# 5. Export campaign insights to CSV
adpilot insights campaign 123456789--csv report.csv
# Save a report template
adpilot reports save --name weekly-perf --level campaign \--fields impressions,clicks,spend,ctr,cpc --date-preset last_7d
# Run it anytime
adpilot reports run weekly-perf --csv weekly.csv
# Compare two time periods
adpilot reports compare --level account \--period12025-01-01,2025-01-31 \--period22025-02-01,2025-02-28
# Large async report
adpilot reports async --level ad --fields impressions,clicks,spend --date-preset last_90d
adpilot reports async-wait <report_run_id>--csv large-report.csv
AI Pipeline
ai -- AI-assisted ad copy
Subcommand
Description
ai generate-copy
Generate an LLM prompt for ad copy variants
ai parse-copy
Parse LLM-generated JSON into a deployable template
ai feedback
Generate performance feedback for LLM iteration
# Step 1: Generate prompt for your LLM
adpilot ai generate-copy --product"Widget Pro"\--description"A better widget"--tone casual --variants5# Step 2: Paste LLM response into a file, then parse it
adpilot ai parse-copy --input llm-response.json \--product"Widget Pro"--url https://example.com --output template.json
# Step 3: Deploy the template
adpilot deploy run -t template.json
# Step 4: After data collects, generate feedback for next iteration
adpilot ai feedback --campaign123456 --date-preset last_7d --output feedback.md
generate -- Variant generation
Subcommand
Description
generate variants
Generate combinatorial ad variants from headlines, bodies, CTAs
adpilot deploy run -t campaign.json --dry-run # Preview what would be created
adpilot deploy run -t campaign.json # Deploy for real
adpilot deploy run -t campaign.json --varheadline="New Text"--varbudget=5000
adpilot deploy validate -t campaign.json # Validate only
cycle -- Test cycle orchestrator
Subcommand
Description
cycle run
Full test cycle: deploy template, link to project, evaluate, act
cycle status <campaignId>
Quick health check of a running campaign
cycle report <campaignId>
Detailed report with winners, losers, and recommendations
# Full pipeline: deploy + link + monitor
adpilot cycle run -t campaign.json --project my-product \
--min-ctr 0.5 --max-cpa 50--evaluate# Post-run analysis
adpilot cycle report 123456 --date-preset last_7d
validate -- Market validation
Subcommand
Description
validate market <projectId>
Generate a market validation report with verdict
Produces a structured report with STRONG/MODERATE/WEAK/INSUFFICIENT DATA verdict and actionable next steps.
adpilot validate market my-product --date-preset maximum --output report.md
# Auto-kill underperformers
adpilot monitor run --min-ctr 0.5 --max-cpa 50 --max-cpc 5 --dry-run
adpilot monitor run --project my-product # Scope to a project# Scale winners by 1.5x
adpilot monitor winners --top5 --scale-budget 1.5# Pause bottom performers
adpilot monitor losers --bottom5--pause
budget -- Budget allocation & scheduling
Subcommand
Description
budget allocate
Dynamically allocate budget across projects by strategy
budget status
Show budget utilization and pacing across projects
budget schedule
Set a scheduled budget change for a campaign
budget schedule-list
List all budget schedules
budget schedule-apply
Apply/revert pending budget schedules
budget schedule-delete <id>
Delete a schedule
# Allocate $500/day across all projects by demand score
adpilot budget allocate --total-budget 50000--strategy demand_score --dry-run
# Schedule a budget increase for a sale
adpilot budget schedule --campaign-id 123--budget10000\
--start-date 2025-03-01 --end-date 2025-03-07 --original-budget 5000
adpilot uses JSON template files to define complete campaign stacks (campaign + ad sets + ads + creatives) that can be deployed in a single command.
Template structure
{"name":"My Test Campaign","description":"Optional description","variables":{"headline":{"description":"Ad headline","default":"Buy Now"},"budget":{"description":"Daily budget in cents","default":"1500"}},"campaign":{"name":"{{headline}} Campaign","objective":"OUTCOME_TRAFFIC","status":"PAUSED","special_ad_categories":[]},"adsets":[{"name":"US Broad","billing_event":"IMPRESSIONS","optimization_goal":"LINK_CLICKS","daily_budget":"{{budget}}","targeting":{"geo_locations":{"countries":["US"]}},"status":"PAUSED"}],"ads":[{"name":"Ad Variant 1","adset_index":0,"creative":{"name":"Creative V1","title":"{{headline}}","body":"Check out our product!","link_url":"https://example.com","call_to_action_type":"LEARN_MORE"},"status":"PAUSED"}]}
Template variables
Templates support {{variable}} placeholders that are resolved at deploy time:
adpilot deploy run -t template.json --varheadline="Shop Now"--varbudget=3000
Workflow
# Validate first
adpilot deploy validate -t template.json
# Preview the deploy plan
adpilot deploy run -t template.json --dry-run
# Deploy for real
adpilot deploy run -t template.json
AI Ad Testing Pipeline
adpilot supports a full end-to-end AI-driven ad testing pipeline:
1. REGISTER adpilot projects create -n "Widget Pro" -u https://example.com
|
2. GENERATE adpilot ai generate-copy --product "Widget Pro" --description "..." --variants 5
| (copy prompt to LLM, save response as variants.json)
|
3. PARSE adpilot ai parse-copy --input variants.json --product "Widget Pro" --url https://...
| (outputs a deployable template)
|
4. DEPLOY adpilot deploy run -t template.json
| (creates campaign, ad sets, creatives, and ads)
|
5. LINK adpilot projects link widget-pro <campaign_id>
|
6. MONITOR adpilot monitor status --project widget-pro
| adpilot monitor run --project widget-pro --dry-run
|
7. EVALUATE adpilot monitor winners --top 5 --scale-budget 1.5
| adpilot monitor losers --bottom 5 --pause
|
8. FEEDBACK adpilot ai feedback --campaign <id> --output feedback.md
| (feed report back into LLM for next iteration)
|
9. VALIDATE adpilot validate market widget-pro
(go/no-go verdict: STRONG, MODERATE, WEAK, INSUFFICIENT DATA)
Or use cycle run to orchestrate steps 4-7 in a single command:
Tokens are resolved in this order: active profile > config file > ADPILOT_TOKEN > FACEBOOK_ACCESS_TOKEN.
Configuration
Configuration is stored in ~/.config/adpilot/ (or ~/.adpilot/) via the conf library.
Key
Default
Description
adAccountId
(none)
Your ad account ID (act_XXXXX)
apiVersion
v25.0
Meta Graph API version
defaultOutputFormat
table
Default output: table or json
pageSize
25
Default results per page
accessToken
(none)
Stored access token
appId
(none)
Facebook App ID (for OAuth)
appSecret
(none)
Facebook App Secret (for OAuth)
tokenExpiresAt
(none)
Token expiry timestamp
adpilot config show # View current config
adpilot config set adAccountId act_123456 # Set account
adpilot config set apiVersion v24.0 # Change API version
adpilot config path # Show config file path
Shell Completions
# Auto-detect and install
adpilot completions install# Or manually:# Bash
adpilot completions bash>> ~/.bashrc &&source ~/.bashrc
# Zsh
adpilot completions zsh> ~/.zsh/completions/_adpilot
# Add to .zshrc: fpath=(~/.zsh/completions $fpath) && autoload -Uz compinit && compinit# Fish
adpilot completions fish > ~/.config/fish/completions/adpilot.fish
API Version
Defaults to v25.0. Change with:
adpilot config set apiVersion v24.0
Global Options
Available on most commands:
Flag
Description
--json
Output as JSON instead of table
--fields <fields>
Comma-separated fields to return
--account-id <id>
Override the configured ad account
--limit <n>
Max results per page
-v, --version
Show version
--help
Show help for any command
Contributing
git clone https://github.com/connorodea/adpilot.git
cd adpilot
npminstallnpm run build
npmtest# Run 93+ testsnpm run lint # Type-check
Module system: CommonJS (not ESM). Chalk v4, ora v5, inquirer v8, node-fetch v2 are pinned for CJS compatibility.
Commands: Add new command files in src/commands/, register in src/index.ts.