On this page

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 → 409 conflict. 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

CodeWhen
validation_errorBad body; agent has no accounts
account_disconnectedAn agent account is disconnected
not_foundCampaign or template not found
conflictCampaign in progress
rate_limitedRPM exceeded
upstream_unavailableUnexpected failure — retry

MCP

Tool: assign_template.