# Create campaign POST https://alsona.com/rest/accounts/account_cd855c2bb1cc72097238/campaigns Content-Type: application/json Create a new campaign. If `campaign_id` is omitted, it will be generated. **Request body fields (wrapped in `campaign` object):** - `name` (string, required) — Human-readable campaign name. - `account_id` (string, required) — Target account ID. - `status` (string, optional) — `DRAFT` | `RUN` | `PAUSE` | `DONE`. Defaults to `DRAFT`. - `seats` (array of strings, required) — Seat IDs to run this campaign. - `schedule` (object, required) — Day-of-week schedule. Each day key maps to `[enabled (bool), start_hour (int), end_hour (int)]`. - `timezone` (integer, optional) — UTC offset in minutes (e.g. `-300` = UTC-5). - `campaign_id` (string, optional) — Supply to create with a specific ID; omit to auto-generate. Reference: https://api.hublinks.io/alsona-api/campaigns/create-campaign ## OpenAPI Specification ```yaml openapi: 3.1.0 info: title: collection version: 1.0.0 paths: /rest/accounts/account_cd855c2bb1cc72097238/campaigns: post: operationId: create-campaign summary: Create campaign description: >- Create a new campaign. If `campaign_id` is omitted, it will be generated. **Request body fields (wrapped in `campaign` object):** - `name` (string, required) — Human-readable campaign name. - `account_id` (string, required) — Target account ID. - `status` (string, optional) — `DRAFT` | `RUN` | `PAUSE` | `DONE`. Defaults to `DRAFT`. - `seats` (array of strings, required) — Seat IDs to run this campaign. - `schedule` (object, required) — Day-of-week schedule. Each day key maps to `[enabled (bool), start_hour (int), end_hour (int)]`. - `timezone` (integer, optional) — UTC offset in minutes (e.g. `-300` = UTC-5). - `campaign_id` (string, optional) — Supply to create with a specific ID; omit to auto-generate. tags: - subpackage_campaigns parameters: - name: X-API-KEY in: header required: true schema: type: string responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Campaigns_Create campaign_Response_200' '400': description: Bad Request content: application/json: schema: $ref: >- #/components/schemas/PostRestAccountsAccount_cd855c2bb1cc72097238CampaignsRequestBadRequestError '401': description: Unauthorized content: application/json: schema: $ref: >- #/components/schemas/PostRestAccountsAccount_cd855c2bb1cc72097238CampaignsRequestUnauthorizedError requestBody: content: application/json: schema: type: object properties: campaign: $ref: >- #/components/schemas/RestAccountsAccountCd855C2Bb1Cc72097238CampaignsPostRequestBodyContentApplicationJsonSchemaCampaign required: - campaign servers: - url: https://alsona.com components: schemas: RestAccountsAccountCd855C2Bb1Cc72097238CampaignsPostRequestBodyContentApplicationJsonSchemaCampaignSchedule: type: object properties: friday: type: array items: type: boolean monday: type: array items: type: boolean sunday: type: array items: type: boolean tuesday: type: array items: type: boolean saturday: type: array items: type: boolean thursday: type: array items: type: boolean wednesday: type: array items: type: boolean required: - friday - monday - sunday - tuesday - saturday - thursday - wednesday title: >- RestAccountsAccountCd855C2Bb1Cc72097238CampaignsPostRequestBodyContentApplicationJsonSchemaCampaignSchedule RestAccountsAccountCd855C2Bb1Cc72097238CampaignsPostRequestBodyContentApplicationJsonSchemaCampaign: type: object properties: name: type: string seats: type: array items: type: string status: type: string schedule: $ref: >- #/components/schemas/RestAccountsAccountCd855C2Bb1Cc72097238CampaignsPostRequestBodyContentApplicationJsonSchemaCampaignSchedule account_id: type: string created_at: type: integer required: - name - seats - status - schedule - account_id - created_at title: >- RestAccountsAccountCd855C2Bb1Cc72097238CampaignsPostRequestBodyContentApplicationJsonSchemaCampaign RestAccountsAccountCd855C2Bb1Cc72097238CampaignsPostResponsesContentApplicationJsonSchemaCampaignSchedule: type: object properties: friday: type: array items: type: boolean monday: type: array items: type: boolean sunday: type: array items: type: boolean tuesday: type: array items: type: boolean saturday: type: array items: type: boolean thursday: type: array items: type: boolean wednesday: type: array items: type: boolean required: - friday - monday - sunday - tuesday - saturday - thursday - wednesday title: >- RestAccountsAccountCd855C2Bb1Cc72097238CampaignsPostResponsesContentApplicationJsonSchemaCampaignSchedule RestAccountsAccountCd855C2Bb1Cc72097238CampaignsPostResponsesContentApplicationJsonSchemaCampaign: type: object properties: name: type: string seats: type: array items: type: string status: type: string priority: type: integer schedule: $ref: >- #/components/schemas/RestAccountsAccountCd855C2Bb1Cc72097238CampaignsPostResponsesContentApplicationJsonSchemaCampaignSchedule timezone: type: integer account_id: type: string created_at: type: integer wait_until: type: integer campaign_id: type: string required: - name - seats - status - priority - schedule - timezone - account_id - created_at - wait_until - campaign_id title: >- RestAccountsAccountCd855C2Bb1Cc72097238CampaignsPostResponsesContentApplicationJsonSchemaCampaign Campaigns_Create campaign_Response_200: type: object properties: success: type: boolean campaign: $ref: >- #/components/schemas/RestAccountsAccountCd855C2Bb1Cc72097238CampaignsPostResponsesContentApplicationJsonSchemaCampaign required: - success - campaign title: Campaigns_Create campaign_Response_200 PostRestAccountsAccount_cd855c2bb1cc72097238CampaignsRequestBadRequestError: type: object properties: error: type: string message: type: string required: - error - message title: >- PostRestAccountsAccount_cd855c2bb1cc72097238CampaignsRequestBadRequestError PostRestAccountsAccount_cd855c2bb1cc72097238CampaignsRequestUnauthorizedError: type: object properties: error: type: string message: type: string required: - error - message title: >- PostRestAccountsAccount_cd855c2bb1cc72097238CampaignsRequestUnauthorizedError securitySchemes: apiKeyAuth: type: apiKey in: header name: X-API-KEY ``` ## SDK Code Examples ```python Campaigns_Create campaign_example import requests url = "https://alsona.com/rest/accounts/account_cd855c2bb1cc72097238/campaigns" payload = { "campaign": { "name": "Test Rest", "seats": ["seat_6a13e661ecc6a86e3fb7"], "status": "DRAFT", "schedule": { "friday": [True, True, True], "monday": [True, True, True], "sunday": [False, True, True], "tuesday": [True, True, True], "saturday": [False, True, True], "thursday": [True, True, True], "wednesday": [True, True, True] }, "account_id": "account_136ce10b5f8a7682efb3", "created_at": 1756551947499 } } headers = { "X-API-KEY": "", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript Campaigns_Create campaign_example const url = 'https://alsona.com/rest/accounts/account_cd855c2bb1cc72097238/campaigns'; const options = { method: 'POST', headers: {'X-API-KEY': '', 'Content-Type': 'application/json'}, body: '{"campaign":{"name":"Test Rest","seats":["seat_6a13e661ecc6a86e3fb7"],"status":"DRAFT","schedule":{"friday":[true,true,true],"monday":[true,true,true],"sunday":[false,true,true],"tuesday":[true,true,true],"saturday":[false,true,true],"thursday":[true,true,true],"wednesday":[true,true,true]},"account_id":"account_136ce10b5f8a7682efb3","created_at":1756551947499}}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go Campaigns_Create campaign_example package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://alsona.com/rest/accounts/account_cd855c2bb1cc72097238/campaigns" payload := strings.NewReader("{\n \"campaign\": {\n \"name\": \"Test Rest\",\n \"seats\": [\n \"seat_6a13e661ecc6a86e3fb7\"\n ],\n \"status\": \"DRAFT\",\n \"schedule\": {\n \"friday\": [\n true,\n true,\n true\n ],\n \"monday\": [\n true,\n true,\n true\n ],\n \"sunday\": [\n false,\n true,\n true\n ],\n \"tuesday\": [\n true,\n true,\n true\n ],\n \"saturday\": [\n false,\n true,\n true\n ],\n \"thursday\": [\n true,\n true,\n true\n ],\n \"wednesday\": [\n true,\n true,\n true\n ]\n },\n \"account_id\": \"account_136ce10b5f8a7682efb3\",\n \"created_at\": 1756551947499\n }\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("X-API-KEY", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby Campaigns_Create campaign_example require 'uri' require 'net/http' url = URI("https://alsona.com/rest/accounts/account_cd855c2bb1cc72097238/campaigns") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["X-API-KEY"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"campaign\": {\n \"name\": \"Test Rest\",\n \"seats\": [\n \"seat_6a13e661ecc6a86e3fb7\"\n ],\n \"status\": \"DRAFT\",\n \"schedule\": {\n \"friday\": [\n true,\n true,\n true\n ],\n \"monday\": [\n true,\n true,\n true\n ],\n \"sunday\": [\n false,\n true,\n true\n ],\n \"tuesday\": [\n true,\n true,\n true\n ],\n \"saturday\": [\n false,\n true,\n true\n ],\n \"thursday\": [\n true,\n true,\n true\n ],\n \"wednesday\": [\n true,\n true,\n true\n ]\n },\n \"account_id\": \"account_136ce10b5f8a7682efb3\",\n \"created_at\": 1756551947499\n }\n}" response = http.request(request) puts response.read_body ``` ```java Campaigns_Create campaign_example import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://alsona.com/rest/accounts/account_cd855c2bb1cc72097238/campaigns") .header("X-API-KEY", "") .header("Content-Type", "application/json") .body("{\n \"campaign\": {\n \"name\": \"Test Rest\",\n \"seats\": [\n \"seat_6a13e661ecc6a86e3fb7\"\n ],\n \"status\": \"DRAFT\",\n \"schedule\": {\n \"friday\": [\n true,\n true,\n true\n ],\n \"monday\": [\n true,\n true,\n true\n ],\n \"sunday\": [\n false,\n true,\n true\n ],\n \"tuesday\": [\n true,\n true,\n true\n ],\n \"saturday\": [\n false,\n true,\n true\n ],\n \"thursday\": [\n true,\n true,\n true\n ],\n \"wednesday\": [\n true,\n true,\n true\n ]\n },\n \"account_id\": \"account_136ce10b5f8a7682efb3\",\n \"created_at\": 1756551947499\n }\n}") .asString(); ``` ```php Campaigns_Create campaign_example request('POST', 'https://alsona.com/rest/accounts/account_cd855c2bb1cc72097238/campaigns', [ 'body' => '{ "campaign": { "name": "Test Rest", "seats": [ "seat_6a13e661ecc6a86e3fb7" ], "status": "DRAFT", "schedule": { "friday": [ true, true, true ], "monday": [ true, true, true ], "sunday": [ false, true, true ], "tuesday": [ true, true, true ], "saturday": [ false, true, true ], "thursday": [ true, true, true ], "wednesday": [ true, true, true ] }, "account_id": "account_136ce10b5f8a7682efb3", "created_at": 1756551947499 } }', 'headers' => [ 'Content-Type' => 'application/json', 'X-API-KEY' => '', ], ]); echo $response->getBody(); ``` ```csharp Campaigns_Create campaign_example using RestSharp; var client = new RestClient("https://alsona.com/rest/accounts/account_cd855c2bb1cc72097238/campaigns"); var request = new RestRequest(Method.POST); request.AddHeader("X-API-KEY", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"campaign\": {\n \"name\": \"Test Rest\",\n \"seats\": [\n \"seat_6a13e661ecc6a86e3fb7\"\n ],\n \"status\": \"DRAFT\",\n \"schedule\": {\n \"friday\": [\n true,\n true,\n true\n ],\n \"monday\": [\n true,\n true,\n true\n ],\n \"sunday\": [\n false,\n true,\n true\n ],\n \"tuesday\": [\n true,\n true,\n true\n ],\n \"saturday\": [\n false,\n true,\n true\n ],\n \"thursday\": [\n true,\n true,\n true\n ],\n \"wednesday\": [\n true,\n true,\n true\n ]\n },\n \"account_id\": \"account_136ce10b5f8a7682efb3\",\n \"created_at\": 1756551947499\n }\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift Campaigns_Create campaign_example import Foundation let headers = [ "X-API-KEY": "", "Content-Type": "application/json" ] let parameters = ["campaign": [ "name": "Test Rest", "seats": ["seat_6a13e661ecc6a86e3fb7"], "status": "DRAFT", "schedule": [ "friday": [true, true, true], "monday": [true, true, true], "sunday": [false, true, true], "tuesday": [true, true, true], "saturday": [false, true, true], "thursday": [true, true, true], "wednesday": [true, true, true] ], "account_id": "account_136ce10b5f8a7682efb3", "created_at": 1756551947499 ]] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://alsona.com/rest/accounts/account_cd855c2bb1cc72097238/campaigns")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```