The Meta ads CLI is a new command-line tool designed for developers and AI agents to manage Meta ad campaigns efficiently without writing custom code. It simplifies repetitive programming tasks such as authentication, pagination, output formatting, and error handling, enabling faster development and smoother integration into automated workflows.
Key Features of Meta ads CLI
Ad Creation and Management
Users can create, list, update, and delete campaigns, ad sets, ads, and creatives directly from the terminal. Campaigns are created in a PAUSED state by default to prevent accidental live launches. The CLI supports commands for setting budgets, optimization goals, billing events, targeting, and connecting creatives to campaigns. Campaigns and ads can be activated when ready.
Example commands include:
meta ads campaign create --name "Summer Sale" --objective OUTCOME_SALES --daily-budget 5000
meta ads adset create CAMPAIGN_ID --name "My Ad Set" --optimization-goal LINK_CLICKS --billing-event IMPRESSIONS --bid-amount 500 --targeting-countries US
meta ads creative create --name "Hero Banner" --page-id 111222333 --image ./banner.jpg --body "50% off everything!" --title "Shop Now" --link-url https://example.com/sale --call-to-action SHOP_NOW
meta ads ad create ADSET_ID --name "Hero Banner Ad" --creative-id CREATIVE_ID
meta ads campaign update CAMPAIGN_ID --status ACTIVE
Performance Insights
The CLI allows querying campaign performance metrics such as spend, impressions, CTR, and ROAS with flexible date ranges and breakdowns by demographics or platform. This supports detailed analysis at various aggregation levels.
Example:
meta ads insights get --campaign_id COMPAIGN_ID --fields=impressions,conversions --date-preset last_7d
Catalog Creation and Management
Users can create and manage product catalogs, add products, and list product sets, facilitating e-commerce campaign management.
Example:
meta ads catalog create --name "My Catalog"
meta ads product-item create --catalog-id 123456 --retailer-id sku_a --name "Blue Shirt" --url https://example.com/blue_shirt --price "999" --currency "USD" --image-url https://example.com/blue_shirt.jpg
meta ads product-set list --catalog-id 123456
Datasets and Conversion Tracking
The CLI supports creating conversion pixels, connecting them to ad accounts and catalogs, and setting up end-to-end conversion tracking.
Example:
meta ads dataset create --name "Website Pixel"
meta ads dataset connect 111222 --ad-account-id 333444 --catalog-id 555666
Designed for Automation and Integration
The Meta ads CLI supports multiple output formats—table (human-readable), json (for tools like jq), and plain (tab-separated for Unix tools like sort, awk, cut). It includes flags like --no-input and --force to suppress interactive prompts, making it suitable for CI/CD pipelines and scripting.
Standard exit codes simplify error handling:
0for success3for authentication errors4for API errors
Environment variables can store tokens, secrets, and account IDs to keep sensitive information secure and out of command history or version control.
Requirements and Resources
The CLI requires Python 3.12+ and tools like pip and uv. Comprehensive developer documentation and Meta Marketing API references are available to help users get started.
The Meta ads CLI streamlines ad campaign management by consolidating powerful Meta Marketing API functions into a single, reliable, and automation-friendly command-line interface.










