Build, automate, and scale ad campaigns programmatically
The Ads Agents API lets you programmatically create accounts, manage ad campaigns, generate AI content, and monitor performance across Facebook and Instagram. It's designed for both human developers and AI agents.
Create an account with one API call. Verify via email or phone.
AI creates ad copy and images from your product description.
Deploy to Facebook & Instagram with budget and targeting.
Real-time analytics and AI-powered optimization.
Go from zero to a running campaign in 6 API calls. Here's the complete flow:
Register with your email. You get an API key immediately.
Check your email for a 6-digit code and submit it.
Set up your business profile — required before creating campaigns.
Set your objective, budget, ad copy, and targeting.
Get notified when campaigns change status, metrics update, or AI suggestions arrive.
Choose a plan and connect your Facebook Ads account. Both use email-based flows.
Tip: All endpoints use the base URL https://app.ads-agents.com/api/v1/. Authenticate with Authorization: Bearer aa_live_... header.
All API requests require a Bearer token in the Authorization header:
API keys are issued immediately on registration. You can create additional keys, scope them, and rotate them via the /auth/keys endpoints.
| Prefix | Environment | Use |
|---|---|---|
aa_live_ | Production | Real campaigns, real spend |
aa_test_ | Sandbox | Testing with mock data |
For third-party integrations, use the OAuth 2.0 Authorization Code flow. Available scopes: campaigns:read, campaigns:write, content:generate, analytics:read, billing:read, billing:write, webhooks:manage, account:read, account:write.
All endpoints are versioned under /v1. JSON request and response bodies. Always use HTTPS.
Creating an account is a single API call. Provide email, password, and your name.
The response includes your API key immediately:
Already have an account? Log in to get your API key:
Important: Store your API key securely. You can create additional keys via POST /v1/auth/keys and list them with GET /v1/auth/keys.
A 6-digit code is sent to your email on registration. Submit it with your email to activate your account:
Code expired? Request a new one:
Subscribe to a plan via an email-based checkout flow. Free plans activate instantly; paid plans send a secure payment link.
API returns a checkout URL and sends an email with a branded "Subscribe Now" button.
Redirects to Stripe checkout (or activates directly in demo mode).
Your app polls the status endpoint to know when the subscription is active.
| Account State | API Access | What You Can Do |
|---|---|---|
| Created (unverified) | Limited | Auth & account endpoints only |
| Verified (Free) | Free tier | Create business, campaigns, webhooks |
| Standard ($49/mo) | Full | Extended campaigns, AI content generation |
| Flexible ($199/mo) | Full | Unlimited campaigns, priority support |
Campaigns are the top-level resource. Before creating a campaign, you need a verified account and a business.
Create a business profile (one-time):
| Objective | Description |
|---|---|
CONVERSIONS | Optimize for purchases, signups, or other conversions |
TRAFFIC | Drive visitors to your website or landing page |
AWARENESS | Maximize brand visibility and reach |
ENGAGEMENT | Get more likes, comments, and shares |
LEADS | Collect leads via forms |
APP_INSTALLS | Drive mobile app installations |
Generate ad copy and images using AI. Powered by GPT-4, Claude, Grok for text and DALL-E, Stable Diffusion for images.
Monitor campaign performance in real time.
| Method | Endpoint | Description |
|---|---|---|
| GET | /v1/analytics/overview | Account-level summary |
| GET | /v1/analytics/campaigns/{id} | Campaign metrics (by platform, by ad set) |
| GET | /v1/analytics/time-series | Time-series data (hourly/daily/weekly) |
| POST | /v1/analytics/reports | Generate custom reports (JSON/CSV/PDF) |
| GET | /v1/analytics/predictions | AI performance predictions |
Connect your Facebook Ads account via a secure email-based OAuth flow. Since Facebook authorization requires a browser, the API sends a one-click connect link to your email.
Call the connect endpoint. You'll receive a connect URL and an email with a branded button.
The user opens their email and clicks "Connect Facebook Ads". This redirects to Facebook's OAuth consent screen.
After granting permissions, Facebook redirects back. The user sees a success page and can close the browser.
Your app can poll the status endpoint to know when the connection is live.
Why email? Facebook OAuth requires a browser for user consent. The email flow lets API-only integrations connect Facebook without building their own OAuth UI. The connect link is single-use and expires in 1 hour.
Get real-time notifications when things happen. All payloads are signed with HMAC-SHA256.
| Event | Description |
|---|---|
account.verified | Account verification completed |
billing.payment_completed | Subscription payment succeeded |
billing.payment_failed | Payment attempt failed |
campaign.created | New campaign created |
campaign.launched | Campaign deployed to platforms |
campaign.paused | Campaign paused |
ad.optimized | AI replaced/modified ad creative |
budget.reallocated | AI shifted budget between ad sets |
generation.completed | AI content generation finished |
alert.spend | Spend threshold reached |
alert.performance | Performance anomaly detected |
| Limit | Free | Starter | Growth | Agency |
|---|---|---|---|---|
| Requests/min | 10 | 30 | 60 | 300 |
| Requests/day | 500 | 5,000 | 10,000 | 100,000 |
| AI generations/mo | 10 | 50 | 500 | Unlimited |
Rate limit headers are included in every response:
All errors return a consistent JSON structure:
| Code | Meaning | When |
|---|---|---|
| 200 | OK | Successful request |
| 201 | Created | Resource created |
| 204 | No Content | Successful delete |
| 400 | Bad Request | Malformed JSON |
| 401 | Unauthorized | Invalid/missing API key |
| 403 | Forbidden | Unverified or insufficient plan |
| 404 | Not Found | Resource doesn't exist |
| 409 | Conflict | Email/phone already registered |
| 422 | Validation Error | Invalid field values |
| 429 | Rate Limited | Too many requests |
| 500 | Server Error | Retry with exponential backoff |
List endpoints use cursor-based pagination:
Coming soon: Official Python and Node.js SDKs. In the meantime, use the REST API directly or generate a client from our OpenAPI spec.
The Ads Agents API is built agent-first. Every action available in the dashboard can be performed programmatically, making it ideal for autonomous AI workflows. Your agent can:
Design Principles: Deterministic JSON schemas. Machine-readable error codes. Predictable pagination. No HTML responses. Every enum is documented. Your agent never has to guess.
Here's the complete flow an AI agent follows to go from nothing to a running, optimized ad campaign:
Agents authenticate the same way humans do — with a Bearer token. The API key returned at registration is immediately usable.
Create limited-scope keys so your agent only has the permissions it needs:
Verification requires a human to check their email or phone for a code. Your agent has two strategies:
If your agent has email access (via IMAP, Gmail API, etc.), it can extract the verification code automatically:
If the agent is working with a human, it can simply ask them to provide the code:
Tip: If verification fails, use POST /v1/auth/verify/resend to request a new code. Codes expire after 15 minutes.
Payment requires a human to click a checkout link. The agent initiates it and waits for confirmation:
Here's how an agent creates a complete campaign with ad sets and ads:
Set up your agent to continuously monitor and improve campaigns:
Let the platform auto-optimize without agent intervention:
The most powerful pattern: your agent listens for events and reacts autonomously.
Reduce API calls when managing multiple campaigns:
Ads Agents provides an MCP (Model Context Protocol) server, allowing LLMs like Claude, GPT-4, and others to use Ads Agents as a native tool.
| Tool | Description |
|---|---|
create_campaign | Create and configure a new ad campaign |
generate_ad_content | Generate AI-powered ad copy and images |
launch_campaign | Deploy a campaign to Facebook/Instagram |
get_analytics | Retrieve campaign performance metrics |
optimize_campaign | Get and apply AI optimization suggestions |
manage_budget | Adjust campaign budgets and allocation |
list_campaigns | View all campaigns with status and metrics |
Build resilient agents that handle errors gracefully:
A complete, runnable Python agent that creates and manages a campaign: