Apply Template to Campaign
URL |
Required Values |
HTTP Methods |
|---|---|---|
https://app.tingting.io/api/v1/survey-templates/<id>/apply-to-campaign/ |
campaign_id |
POST |
Applies a survey template to an existing SURVEY campaign. Replace <id> with the template ID.
This action:
Copies
voiceandlength_factorfrom the template to the campaign.Deletes all existing steps from the campaign’s survey.
Creates new
SurveySteprecords from the template’scontent.
Request Body:
Field |
Type |
Required |
Description |
|---|---|---|---|
campaign_id |
integer |
Yes |
ID of the target campaign. Must be a SURVEY campaign owned by the user. |
Sample Request:
{
"campaign_id": 42
}
Sample Response — Success (201 Created):
{
"message": "Template applied successfully.",
"steps": [
{
"id": 101,
"order": 0,
"content_type": "say",
"response_type": "dtmf",
"input_name": "rating",
"audio_file": null,
"survey": 15
},
{
"id": 102,
"order": 1,
"content_type": "info",
"response_type": "none",
"input_name": "outro",
"audio_file": null,
"survey": 15
}
]
}
Sample Response — Partial success, some steps failed (207 Multi-Status):
{
"created": [
{ "id": 103, "order": 0 }
],
"errors": [
{ "content_type": ["This field is required."] }
]
}
Error Responses (400 Bad Request):
Missing campaign_id:
{ "error": "campaign_id is required." }
Campaign is not a SURVEY type:
{ "error": "Template can only be applied to SURVEY campaigns." }
Template has no steps:
{ "error": "Template has no steps to apply." }
Error Responses (404 Not Found):
Template not found or not owned by user:
{ "detail": "No SurveyTemplate matches the given query." }
Campaign not found:
{ "error": "Campaign not found." }