Overview
Meta Ads Kit wraps Meta’s Graph API, but you can also call it directly using curl or your own scripts. This guide covers token management, rate limits, error codes, and retry logic.API Version
Meta Ads Kit uses Graph API v22.0:Meta releases new API versions quarterly. v22.0 is supported until Q1 2027.
Authentication
Getting Your Access Token
Meta Ads Kit uses social-cli for authentication:Required Scopes
Token Lifespan
User access tokens expire after 60 days. Check expiration:Ad Account Setup
List Your Ad Accounts
Set Default Account
workspace/brand/stack.md to avoid setting every time:
stack.md
Core Endpoints
Upload Image
Create Ad Creative
Create Ad
Always create ads in
PAUSED status. Review in Ads Manager before activating.Get Ad Insights
Update Ad Status
Rate Limits
How Meta’s Rate Limiting Works
Meta uses score-based rate limiting, not a simple per-minute cap. Each API call consumes a score based on complexity:
Your rate limit budget refreshes over time. If you exceed it, you get error 294.
Check Rate Limit Headers
Every API response includes rate limit headers:Handling Rate Limit Errors (294)
Best Practices
- Batch requests - Upload multiple images in one call instead of separate calls
- Add delays - Wait 1-2 seconds between calls in loops
- Monitor headers - Check
x-business-use-case-usageto see when you’re approaching limits - Retry with backoff - Wait 10s, then 20s, then 40s on error 294
- Use webhooks - For insights, set up webhooks instead of polling
Error Codes
Common Errors
- 190 - Token Invalid
- 200 - Permission Denied
- 294 - Rate Limited
- 100 - Invalid Parameter
- 2615 - Policy Violation
- 1487395 - Invalid Hash
- 368 - Temporarily Blocked
Meaning: Access token expired or revokedCheck token validity:Fix:
Error Response Format
All Graph API errors follow this structure:Retry Logic
Exponential Backoff Strategy
retry.sh
Error-Specific Retry
Debugging
Verbose Output
Save Requests for Replay
Test Token Validity
Inspect Creative Before Creating Ad
Next Steps
OpenClaw Integration
Natural language ad management
Batch Operations
Upload multiple ads at once