POST/campaigns/:id/template
Assign an agent to a campaign, or clear the assignment. Same body → same end state (no Idempotency-Key needed).
0 credits. Rate class: campaign_control (default 20/min).
Request
POST /campaigns/search_abc/template
X-API-Key: sk_live_...
Content-Type: application/json
{ "templateId": "tpl_abc" }
Clear:
{ "templateId": null }
templateId is required (null clears). Unknown keys → 400. The agent name is always read from the template — do not send templateName.
Gates
- Campaign
CAMPAIGN_IN_PROGRESS→ 409conflict. Pause first (POST …/pause). Applies to assign and clear. - Assign requires the agent to have ≥ 1 selected connected account → otherwise 400 / 403
account_disconnected.
Response
Campaign detail (same shape as GET /campaigns/:id); assignedTemplateId reflects the change.
Errors
| Code | When |
|---|---|
validation_error | Bad body; agent has no accounts |
account_disconnected | An agent account is disconnected |
not_found | Campaign or template not found |
conflict | Campaign in progress |
rate_limited | RPM exceeded |
upstream_unavailable | Unexpected failure — retry |
MCP
Tool: assign_template.