Skip to main content

A/B test prompts

Goal: compare variants by splitting an agent's leads into weighted buckets that override prompts, model config, or outreach settings.

These are A/B campaigns (/v1/campaigns/), distinct from the outbound outreach campaigns (/v1/outreach-campaigns/).

# 1) Create the campaign (leave inactive while you add buckets)
curl -s https://api.sance.ai/v1/campaigns/ \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{ "name": "Greeting A/B", "product_id": 42, "agent_id": 3, "is_active": false,
"batch_names": "q3-import" }'

# 2) Add weighted buckets — active campaigns require weights to sum to 100
curl -s https://api.sance.ai/v1/campaigns/9/buckets \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{ "campaign_id": 9, "name": "Variant A", "weight_pct": 50,
"config": { "prompt_overrides": {} } }'

curl -s https://api.sance.ai/v1/campaigns/9/buckets \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{ "campaign_id": 9, "name": "Variant B", "weight_pct": 50,
"config": { "prompt_overrides": {} } }'

# 3) Activate
curl -s -X PUT https://api.sance.ai/v1/campaigns/9 \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{ "is_active": true }'

What happens next: while active and within its time window, the campaign assigns matching leads to buckets by weight; each bucket applies its overrides (prompt_overrides, models_config_override, outreach_config_override). Bucket prompt overrides must reference prompts owned by the campaign's agent. You can replace the whole bucket set atomically with PUT /v1/campaigns/{id}/buckets/bulk, and inspect or set assignments under /v1/campaigns/{id}/assignments.

See: POST /v1/campaigns/, POST /v1/campaigns/{id}/buckets, PUT /v1/campaigns/{id}/buckets/bulk, GET /v1/campaigns/{id}/assignments.