Agency Campaign Creation
POST /agency/createCampaign
dev url = "https://dev.templatebackend.versal.one/api/v2"
staging url = "https://staging.template.versalence.online/api/v2"
prod url = "https://template.versalence.online/api/v2"
Description
This API allows agencies to create a campaign by specifying a name, schedule type, and other campaign details. The client must provide a valid uuid
as a query parameter. Only accepted variables will be processed, and all user-defined variables must match the expected format.
Request Headers
Header | Type | Description | Constraints |
---|---|---|---|
Authorization |
String | Bearer token for authentication and authorization. | Required. Must be in the format Bearer [token] . |
Query Parameters
Parameter | Type | Description | Constraints |
---|---|---|---|
uuid |
String | Unique identifier for the agency. | Required. Must be a valid UUID format. |
Request Body Parameters
Field | Type | Description | Constraints |
---|---|---|---|
name |
String | Campaign name. | Required. Must be unique. |
template_payload |
Object | Template details for the campaign. | Required. Must include user-defined variables matching body_variable and header_variable . |
schedule_type |
String | Type of schedule for the campaign. | Required. Allowed values: "once" , "recurring" . |
days |
Object | Days and times for a recurring schedule. | Required for "recurring" schedules. Must include days (e.g., "monday" ) with an array of times. |
schedule |
String | Date and time for the campaign. | Required. Must follow a valid datetime format. |
Response Codes
Status Code | Description |
---|---|
201 |
Campaign successfully created. |
400 |
Bad request. Missing required fields, invalid schedule_type , or user-defined variables mismatch. |
403 |
Forbidden. Invalid HMAC signature. |
404 |
No company found with the provided uuid . |
409 |
Conflict. Campaign name already exists. |
500 |
Internal server error while saving the campaign. |
Example Requests
Request (Carousel Template):
POST /agency/createCampaign?uuid=53d1bcd3-aaf0-45e1-9298-5395b6a27b61 Authorization: Bearer [your-jwt-token]
{ "name": "temp3",
"template_payload": { "cards": [ { "card_image_url": "https://example.com/image1.jpg", "card_body_variables": [] }, { "card_image_url": "https://example.com/image2.jpg", "card_body_variables": [] } ], "image_url": "", "group_name": "test_group", "body_variable": [], "template_name": "carousel_milk", "header_variable": [] },
"schedule_type": "recurring",
"days": { "monday": ["10:00"], "wednesday": ["10:00"] },
"schedule": "2025-01-15 14:50"
}
Request (Header and Body Variables):
POST /agency/createCampaign?uuid=53d1bcd3-aaf0-45e1-9298-5395b6a27b61 Authorization: Bearer [your-jwt-token]
{ "name": "temp3", "template_payload": { "image_url": "", "group_name": "Team Testing", "body_variable": ["world"], "template_name": "test_template_1", "header_variable": ["hello"] }, "schedule_type": "once", "schedule": "2025-01-15 14:50" }
Response (Created - 201):
{ "success": true, "message": "Campaign successfully created" }
Response (Missing Variables - 400):
{ "success": false, "message": "Name and Template payload are required for the campaign creation" }
Response (Invalid Schedule Type - 400):
{ "success": false, "message": "Schedule type should include only 'once' and 'recurring'." }
Response (Days Required for Recurring - 400):
{ "success": false, "message": "Days and Times are required for a recurring schedule." }
Response (Conflict - 409):
{ "success": false, "message": "Name already exists" }
Response (Internal Server Error - 500):
{ "success": false, "message": "An unexpected error occurred while saving the campaign. Please try again later." }
Notes
- Authentication: A valid authorization token is required for all requests.
- Validation: All user-defined variables must exactly match the template's
body_variable
andheader_variable
. - Recurring Schedules:
days
andtimes
must be included forrecurring
schedules; otherwise, the request will fail. - Conflict Handling: Campaign names must be unique.