Skip to main content

Agency Campaign Creation

POST /agency/createCampaign 

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

HeaderTypeDescriptionConstraints
AuthorizationStringBearer token for authentication and authorization.Required. Must be in the format Bearer [token].

Query Parameters

ParameterTypeDescriptionConstraints
uuidStringUnique identifier for the agency.Required. Must be a valid UUID format.

Request Body Parameters

FieldTypeDescriptionConstraints
nameStringCampaign name.Required. Must be unique.
template_payloadObjectTemplate details for the campaign.Required. Must include user-defined variables matching body_variable and header_variable.
schedule_typeStringType of schedule for the campaign.Required. Allowed values: "once", "recurring".
daysObjectDays and times for a recurring schedule.Required for "recurring" schedules. Must include days (e.g., "monday") with an array of times.
scheduleStringDate and time for the campaign.Required. Must follow a valid datetime format.

Response Codes

Status CodeDescription
201Campaign successfully created.
400Bad request. Missing required fields, invalid schedule_type, or user-defined variables mismatch.
403Forbidden. Invalid HMAC signature.
404No company found with the provided uuid.
409Conflict. Campaign name already exists.
500Internal 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 and header_variable.
  • Recurring Schedules: days and times must be included for recurring schedules; otherwise, the request will fail.
  • Conflict Handling: Campaign names must be unique.