Build Campaign API
AI-driven campaign strategy: generate a strategy, optimize an existing campaign, configure A/B tests, and optimize budgets across channels. Routes are served under /v1/campaigns and backed by module-a (with module-G).
Authentication
Authorization: Bearer ai92_live_<key> # production
Authorization: Bearer ai92_test_<key> # sandboxMutating requests support Idempotency-Key and are brand-gated.
Credit costs at a glance
| Endpoint | Cost |
|---|---|
POST /v1/campaigns/build | 25 cr |
POST /v1/campaigns/optimize | 10 cr |
POST /v1/campaigns/ab-test | 5 cr |
POST /v1/campaigns/budget-optimize | 15 cr |
POST /v1/campaigns/build
Cost: 25 credits
AI campaign strategy generation for a brand and objective.
Auth: Bearer
| Field | Type | Required | Description |
|---|---|---|---|
brand_id | string | Yes | The brand. |
campaign_objective | string | Yes | The campaign objective (e.g. lead_gen, awareness). |
budget_usd | number / null | No | Total budget in USD. |
Request
curl https://api.ai92.ai/v1/campaigns/build \
-H "Authorization: Bearer ai92_test_51a9c0de…" \
-H "Content-Type: application/json" \
-d '{"brand_id": "acme", "campaign_objective": "lead_gen", "budget_usd": 5000}'Response 200 OK
{
"brand_id": "acme",
"strategy_id": "strat_88",
"objective": "lead_gen",
"recommended_channels": ["email", "search", "linkedin"],
"messaging_angles": ["ROI", "ease of migration"]
}Errors
| Status | Code | When |
|---|---|---|
402 | INSUFFICIENT_CREDITS | Balance below 25 credits. |
POST /v1/campaigns/optimize
Cost: 10 credits
Run an optimization pass on an existing campaign.
Auth: Bearer
| Field | Type | Required | Description |
|---|---|---|---|
campaign_id | string | Yes | The campaign to optimize. |
Request
curl https://api.ai92.ai/v1/campaigns/optimize \
-H "Authorization: Bearer ai92_test_51a9c0de…" \
-H "Content-Type: application/json" \
-d '{"campaign_id": "camp_77a2"}'Response 200 OK
{
"campaign_id": "camp_77a2",
"recommendations": [
{ "type": "subject_line", "current": "Spring lineup", "suggested": "See the Spring lineup" }
],
"projected_lift": 0.12
}Errors
| Status | Code | When |
|---|---|---|
402 | INSUFFICIENT_CREDITS | Balance below 10 credits. |
POST /v1/campaigns/ab-test
Cost: 5 credits
Configure N variants for an existing campaign with statistical significance calculations baked in.
Auth: Bearer
| Field | Type | Required | Description |
|---|---|---|---|
campaign_id | string | Yes | The campaign to test. |
variant_count | integer | No | Number of variants. Default 2. Range 2–8. |
primary_metric | string | No | Optimization metric. Default conversion_rate. |
Request
curl https://api.ai92.ai/v1/campaigns/ab-test \
-H "Authorization: Bearer ai92_test_51a9c0de…" \
-H "Content-Type: application/json" \
-d '{"campaign_id": "camp_77a2", "variant_count": 3, "primary_metric": "conversion_rate"}'Response 200 OK
{
"campaign_id": "camp_77a2",
"variants": ["A", "B", "C"],
"primary_metric": "conversion_rate",
"min_sample_per_variant": 1840
}Errors
| Status | Code | When |
|---|---|---|
402 | INSUFFICIENT_CREDITS | Balance below 5 credits. |
POST /v1/campaigns/budget-optimize
Cost: 15 credits
AI-driven allocation of a total budget across the requested channels.
Auth: Bearer
| Field | Type | Required | Description |
|---|---|---|---|
brand_id | string | Yes | The brand. |
total_budget_usd | number | Yes | Total budget (> 0). |
channels | string[] | Yes | Channels to allocate across. Length 1–8. |
Request
curl https://api.ai92.ai/v1/campaigns/budget-optimize \
-H "Authorization: Bearer ai92_test_51a9c0de…" \
-H "Content-Type: application/json" \
-d '{"brand_id": "acme", "total_budget_usd": 10000, "channels": ["email", "search", "social"]}'Response 200 OK
{
"brand_id": "acme",
"total_budget_usd": 10000,
"allocation": { "email": 2500, "search": 5000, "social": 2500 },
"projected_roas": 3.6
}Errors
| Status | Code | When |
|---|---|---|
402 | INSUFFICIENT_CREDITS | Balance below 15 credits. |