Setup guide
Codex Meta Ads
This setup lets Codex connect to your Meta ad account using Meta's Marketing API. Go to developers.facebook.com and log in or create your Meta Developer account. Then: ads_read
Meta Ads + Codex | Setup Guide
Meta Ads + Codex
Simplified Setup Guide
What This Setup Does
This setup lets Codex connect to your Meta ad account using Meta's Marketing API.
Codex can then help you:
- Pull campaign data
- Read ad performance
- Create draft campaigns and ads
- Suggest optimizations
- Update budgets or pause ads (if you allow it)
Step 1: Create a Meta Developer App
Go to developers.facebook.com and log in or create your Meta Developer account. Then:
- Go to My Apps
- Click Create App
- Give your app a name
- Select the required options
- Create the app
- Open the app dashboard
Step 2: Get Your Access Token
Inside Meta Developer tools
- Go to Tools
- Open Graph API Explorer
- Select your app
- Generate an access token
- Copy the token
The important permissions for Meta Ads are
ads_read ads_management
Step 3: Get Your Ad Account ID
Go to Meta Ads Manager and find your Ad Account ID. It looks like this
act_123456789 Always include act_ before the number. Page 1
Meta Ads + Codex | Setup Guide
Step 4: Create a Project Folder
On your computer, create a folder for your Meta Ads automation files
meta-ads-codex
Step 5: Create a .env File
Inside the folder, create a file named .env and add the following
META_ACCESS_TOKEN=your_access_token_here
META_AD_ACCOUNT_ID=act_123456789
META_API_VERSION=v21.0
Replace the placeholder values with your real access token and ad account ID.
Step 6: Open the Folder in Codex
Open the Codex app, then open the meta-ads-codex folder. Codex can now work inside that folder.
Step 7: Ask Codex to Connect Meta API
In Codex, type this prompt
I have saved my Meta access token and ad account ID in the .env file. Do not print the token.
Create a Meta Marketing API connection test that
reads the .env file and lists my campaigns.
Codex will create a script that reads your .env file, connects to the Meta Marketing API, and pulls your campaign
list.
Step 8: Run the Connection Test
Ask Codex
Run the connection test and show me if Meta API is working. If everything is correct, Codex will display your campaign data.
Step 9: Ask Codex to Analyze or Create
Once connected, you can ask Codex things like
Analyze my campaigns from yesterday and find poor-performing ads. Create a draft campaign for lead generation, but keep it paused. Page 2
Meta Ads + Codex | Setup Guide
Show me ads with high spend and low results. Suggest budget changes based on performance.
IMPORTANT SAFETY RULE
Do not paste your real token directly into Codex chat. Always use the .env file. The script reads the .env file, then connects to Meta Ads. Your token stays private.
How It Works
You are not directly connecting Codex to Meta Ads Manager. The full flow is:
Codex App
-> local script -> .env file
-> Meta Marketing API
-> your ad account This keeps your credentials secure while giving Codex the ability to read and manage your Meta Ads. Page 3
Final checklist
- The required app, command, or service opens correctly.
- Credentials are stored outside public files and screenshots.
- A small test run completes before you use the setup for real work.
- You know where logs, output files, and error messages are stored.