# Agency Campaign Creation API URI ``` https://api.versal.one/ ``` ``` 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
`Authorization`StringBearer token for authentication and authorization.Required. Must be in the format `Bearer [token]`.
--- #### **Query Parameters**
ParameterTypeDescriptionConstraints
`uuid`StringUnique identifier for the agency.Required. Must be a valid UUID format.
--- #### **Request Body Parameters**
FieldTypeDescriptionConstraints
`name`StringCampaign name.Required. Must be unique.
`template_payload`ObjectTemplate details for the campaign.Required. Must include user-defined variables matching `body_variable` and `header_variable`.
`schedule_type`StringType of schedule for the campaign.Required. Allowed values: `"once"`, `"recurring"`.
`days`ObjectDays and times for a recurring schedule.Required for `"recurring"` schedules. Must include days (e.g., `"monday"`) with an array of times.
`schedule`StringDate and time for the campaign.Required. Must follow a valid datetime format.
--- #### **Response Codes**
Status CodeDescription
`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):** ```json POST /53d1bcd3-aaf0-45e1-9298-5395b6a27b61/agency/createCampaign Authorization: Bearer 5395b6a27b61 { "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):** ```json POST /53d1bcd3-aaf0-45e1-9298-5395b6a27b61/agency/createCampaign Authorization: Bearer 5395b6a27b61 { "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):** ```json { "success": true, "message": "Campaign successfully created" } ``` **Response (Missing Variables - 400):** ```json { "success": false, "message": "Name and Template payload are required for the campaign creation" } ``` **Response (Invalid Schedule Type - 400):** ```json { "success": false, "message": "Schedule type should include only 'once' and 'recurring'." } ``` **Response (Days Required for Recurring - 400):** ```json { "success": false, "message": "Days and Times are required for a recurring schedule." } ``` **Response (Conflict - 409):** ```json { "success": false, "message": "Name already exists" } ``` **Response (Internal Server Error - 500):** ```json { "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.