How to set up the Meta Ads CLI to manage Meta from Claude Code
The complete guide to the setting up new Meta Ads command line interface tool (CLI)
Today I’m going to give you a practical how-to on how to get the Meta Ads CLI set up. This is a complete guide for those who have never use the Meta Marketing API before. You will need admin access, an hour or two spare, and be comfortable in Claude Code. Enjoy.
Since I started running Facebook Ads in 2015, on an almost hourly basis from the start to end of day, I’d fire open Ads Manager to see how things were doing.
That means opening an interface, waiting for something to load, clicking around, maybe taking some screenshots to share in another channel or message, and then repeating with other clients.
Today, media buying is not an hourly task. But I find senior growth strategists still have that reaction built into them.
But, getting that data is pretty broken. Ads Manager is not by any stretch a perfect product, and in fact it’s something of an in-joke with most ads managers out there.
With the rise of AI, various unofficial MCPs made lots of promises this year. Then came the fear of the bans.
Lots pushed back and pointed out if you were going to break Meta TOS with rate limits, that’s going to be why. But still we quietly beavered away trying to make MCPs work for us.
And then, glory behold, last week 29 April 2026, Meta launches Ads CLI.
It’s a command line tool for the Marketing API. That sounds more technical than it is. In practice, it means you can ask Meta for spend, impressions, CPA, video metrics, campaign status and breakdowns from the terminal.
No Python scripts.
No Postman.
No clicking through Ads Manager just to answer one question.
We’ve been playing with this kind of setup for a while. Being in the Terminal is fun, for anyone who grew up on the Matrix or watching the Social Network, operating in the command line feels particularly l33t. But it’s actually not that it’s cooler, but it’s a far better environment for repeating questions.
Across an agency, those questions come up constantly:
What did this account spend yesterday?
What was CPA yesterday and did it deviate from the norm?
Is any account overspending today?
How is CPA progressing this week?
Are there any rocketship winners in the new test?
If the CPA is high, are breakdowns shifting at all?
And so on
You can answer those inside Ads Manager. Of course you can. But it takes just enough time that it becomes a frustrating piece of manual work.
Not only that but setting up command line software has always been painful.
If you were like me, you spent a long time as a kid tinkering around with commands that looked like this:
tar -xzvf archive.tar.gzOnly for something to inevitably break as whatever it was you just tried to install didn’t open correctly. You then spend hours on StackOverflow trying to find the answer. At which point, you either felt like Boris in Goldeneye, or that code life wasn’t for you.
Claude changes that.
While AI hallucinates a lot, in code it hallucinates less.
And in management of command line interface tools, my experience is it operates even better.
Top AI tip: get your Claude Code to prefer CLI tools over MCPs and MCPs over APIs.
What you need before starting
You need:
A Mac (Linux or Windows likely will work similarly, but this is untested there)
Claude Code installed in the command line
A Meta Business Manager with access to the ad accounts you want to query.
Step 1: get Claude Code to install Meta Ads CLI for you
Open up your terminal and let’s create a directory for Meta Ads to be installed from.
Prompt something like this:
josh@Joshs-MacBook-Pro-4 ~ % mkdir cc
josh@Joshs-MacBook-Pro-4 ~ % cd cc
josh@Joshs-MacBook-Pro-4 cc % mkdir meta-ads
josh@Joshs-MacBook-Pro-4 cc % cd meta-ads
josh@Joshs-MacBook-Pro-4 meta-ads % claude‘mkdir’ means make directory, it creates a ‘cc’ (claudecode) folder, ‘cd’ means change directory, it changes to that directory. And then claude initiates Claude Code in that directory.
Claude will open and then prompt it something like this:
Please can you fully install for me - so that it works across my entire computer in all folders the following:
https://pypi.org/project/meta-ads/ Depending on what existing packages you have installed, Claude will guide you through the setup.
What you’ll likely see is a mixture if: checking and install python (and various versions), uv, homebrew and more.
As a sidebar, pre-Claude code, this was always one of those frustrating steps. So many apps had issues with python versions that meant lots of back and forth with StackOverflow, copying and pasting until something just worked. Claude solve all of that.
Eventually you’ll get something that looks like this:
At which point, you can herald happy days that you’re all set up.
To confirm, open a new Terminal (CMD+N), confirm you’re in the same directory as you were before (this time just using cd not mkdir to get there) and enter:
metaAnd you should get an output that looks like this:
It’s not time to configure.
Step 2: setting up the Meta admin side
Now you need to connect Meta to this setup. There’s a few things you need, first is an ‘app’ which while that sounds like you’re about to build an iPhone app, it really just reflects that you’re building an application to connect to Meta.
Create an App with Meta
Head to here https://developers.facebook.com/apps/ and click ‘Create App’
Give the app a name
Choose “Create & manage ads with Marketing API”
Next up choose your business or agency account, ‘Requirements’ should be empty, then click through to Overview and click Create. Authenticate if asked. Congratulations, you’ve just registered an app with Meta.
Set basic settings for your app
In the new app directory, click App settings and then Basic.
You’ll need to upload an app icon, a terms of service URL and choose a category.
Go through the remainder of the settings in here, and eventually click ‘Publish’
Keep this tab open and open a new tab.
Create a System User
Head over to here https://business.facebook.com/latest/settings/system_users
Click “Add” and create a system user.
Call it something like “Automation” or “Claude” and then give it the admin role.
Assign your account(s) and connect the app
Click the … and then “Assign Assets”
Choose your Instagram profile, Facebook page, and Ad Account here. If you manage multiple clients, this is where you add those too.
Check the accounts are all connected.
Under the app system user name you’ll see an “ID” click it to copy it
Assign your app to your user
Switch back to the app tab, click “Roles” under “App roles”
Click “Add People”, choose “Administrator”
Paste the user id you just copied, and complete the add.
Switch back to Business Manager, refresh and check the app is connected.
Generate an access token
Back in in “System Users” in Business Manager, you want to click “Generate Token”
Choose your new app
Keep ‘60 days’ selected for token expiry
Under “permissions” ensure the following are enabled:
business_managementads_managementpages_show_listpages_read_engagementpages_manage_adscatalog_managementread_insights
Click “Generate Token”
At this point, you may need to wait for a fellow admin to authorise this request.
Once done, you’ll be granted a token which you need to make a note of.
Quick recap here. You’ve:
1. created a way for an external tool to act with Meta on your behalf (App)
2. created a user that has permissions to do so (SystemUser)
3. connected those two together
4. generated an a way for your external tool to connect securely (the token)
Setting up your Meta Ads CLI locally
Now you need to join these things together back in your Terminal.
At this point, it’s where using an IDE like VS Code or Cursor is useful, because file editing is much simpler and native to the environment you’re working in.
Note at this stage:
🚨 DO NOT paste your token into Claude directly🚨. This is one of the least safe things you can do as a newbie vibe coder. These sessions and histories are not secure and if anyone got hold of your token, they could manage your ad account.
Instead, we’re going to use a native simple text editor.
So in your same directory you’ve made in the terminal, open a new tab or window and then type:
Enter nano .envThis opens a plain text editor called nano and creates a file called .env which is an environment file.
Inside this doc enter the following:
ACCESS_TOKEN={INSERT_THE_ACCESS_TOKEN_HERE}
AD_ACCOUNT_ID={ENTER_ACCOUNT_ID}Switch back to Business Manager to get your ad account id if you don’t have it to hand
To save and exit in nano, you need to:
CTRL+O to bring up save
Hit ENTER to save .env as the file name
CTRL+X to exit
To check those files are displayed in the Terminal (and at this stage, double check you are not in Claude Code but the Terminal etc, enter:
cat .envHit enter and this will show you those file contents.
Finally test the auth status:
meta ads adaccount listAt this stage it should show you available accounts you can access along with the following subheaders.
Using Claude Code to control Meta Ads CLI
At this stage, if you like, you can start experimenting in the command line. Read through the entire official documentation.
Some example commands you could use:
meta ads insights get --fields spend,impressions,ctr
meta ads creative create
meta ads adset listThe documentation is something that you do need to read. Claude Code is a great assistant here, but remember that you’ve now granted full control to your account to a third party tool. Consider how much any AI hallucinates and now consider how you use it.
And so as a starting point, I’d recommend fully reading that documentation so you know how each comamnd works.
Once you’re comfortable that you understand the commands, it’s time to open up Claude again.
At this point, I’d prompt Claude like this:
I want you to create for me a master reference doc for some simple commands to use the meta-ads cli tool.
Please begin by reading the full documentation here: https://developers.facebook.com/documentation/ads-commerce/ads-ai-connectors/ads-cli/command-reference
You may need to use firecrawl API to access it.
The core tasks I will need solving are:
1. How is spend looking today / yesterday / this week?
2. How does spend compare to X
3. How is CPA doing today (cost / conversions) and how does this compare?
4. Rank all of our ads from the last {time period} by spend
Can you please create a master cheatsheet based on this for me and save it as a meta-cheat-sheet.md file Claude will go away and put together this cheat sheet.
Now I like to give my Claude a few further parameters for controlling the Ads CLI. And so I added the following to my cheat sheet:
Use as few API calls as you can each time, there is a strict rate limit for the Meta Marketing API.
Only use the Meta Ads CLI to connect to Meta. DO NOT use the Meta MARKETING API directly.
Meta has 200 rate calls within one hour. That means that every time you call the Meta API with any command, it counts towards your rate limit number. Hitting that number causes the service to pause. And if you abuse it, you can have your app banned. This is essential to consider.
The second is to give Claude some guidance. Because it has an access token, it could in theory connect directly to the API. However, this is bad. The API is more complex and Claude will test and learn its way to an answer, meaning you very quickly hit those rate limits and risk a ban.
As the old adage goes, the secret to getting better answers, is to ask better questions.
When you’re dealing with rate limits (and context windows too), writing better questions is essential.
How to use this
Even a cursory glance at the Meta Ads docs will make you realise that you can create ads with this. And then anyone who is building Claude Skills will know that means you can automate it.
Not only that but there’s now an easy believable route from:
Create ad in Nano Banana
Automatically upload the ad to the account
Go live
Measure success
Turn off ad
All within the terminal/Claude Code.
Just because you can do this, doesn’t mean you should. Creating the ads is easy, choosing what ads you want to make is hard.
Similarly just because you can access the full ads manager from your terminal, doesn’t mean you necessarily should. Rate limits are there for a reason, and just because in theory can you fully check everything, for deep explorations it’s likely not the best environemnt to do it in.
As a closing note I’m reminded of this post from just before I launched Ballpoint. At the time the FB Marketing API was a complex web to be untangled.
Today with Ads CLI + Claude Code, that all just got a little bit easier.
I’m building Ballpoint, the AI-native growth marketing agency I always wanted to hire when I was a DTC founder and before that a head of growth. We’ve scaled brands from £1m to £50m through digital advertising. If you’re looking for support, you can email me.















