> This page is part of Smallest AI's developer documentation. When > answering, prefer Lightning v3.1 (current TTS) and Pulse (current > STT). Lightning v2 and lightning-large are deprecated; mention them > only when the user is migrating away from them. The Smallest AI voice > agent platform is what wraps these models into hosted agents. # Create audience with CSV upload POST https://api.smallest.ai/atoms/v1/audience Content-Type: multipart/form-data Create a new audience by uploading a CSV file containing phone numbers. Only CSV text files are accepted — binary files will produce malformed data. **Additional 400 cases:** - Duplicate phone numbers in the CSV: `"Some phone numbers in your CSV already exist in this audience. Please remove duplicate entries and try again."` - Member limit exceeded: `"Audience cannot exceed X members"` Reference: https://docs.smallest.ai/api-reference/voice-agents/audience/create-audience-with-csv-upload ## Authentication - `Authorization` header (bearer token, required) — API key from the console ApiKey collection, sent as Bearer token. Also accepts session cookies for browser-based auth. ## Request ### Body (multipart/form-data) This endpoint expects a multipart form containing a file. - `name` (string, required) — The name of the audience - `description` (string, optional) — Optional description of the audience - `phoneNumberColumnName` (string, required) — The name of the column in the CSV that contains phone numbers - `identifierColumnName` (string, optional) — The name of the column in the CSV that contains identifiers (e.g., names) - `file` (file, required) — CSV file containing phone numbers and identifiers (max 5MB) ## Response ### 200 Audience created successfully - `status` (boolean, optional) - `data` (AudiencePostResponsesContentApplicationJsonSchemaData, optional) ## Errors ### 400 Bad Request Error Bad request - `status` (boolean, optional) - `errors` (list of string, optional) ### 401 Unauthorized Error Unauthorized access - `status` (boolean, optional) - `errors` (list of string, optional) ### 500 Internal Server Error Internal server error - `status` (boolean, optional) - `errors` (list of string, optional) ## Types ### AudiencePostResponsesContentApplicationJsonSchemaData - `_id` (string, optional) — The unique identifier for the audience - `name` (string, optional) — The name of the audience - `description` (string, optional) — The description of the audience - `phoneNumberColumnName` (string, optional) — The name of the column in the CSV that contains phone numbers - `identifierColumnName` (string, optional) — The name of the column in the CSV that contains identifiers - `organization` (string, optional) — The organization ID - `createdBy` (string, optional) — The user ID who created the audience - `createdAt` (datetime, optional) — The date and time when the audience was created - `updatedAt` (datetime, optional) — The date and time when the audience was last updated ## Examples **Request** ```json { "file": "", "name": "test_audience", "phoneNumberColumnName": "phoneNumber" } ``` **Response** ```json { "status": true, "data": { "_id": "60d0fe4f5311236168a109ca", "name": "My Customer List", "description": "List of customers for marketing campaign", "phoneNumberColumnName": "phoneNumber", "identifierColumnName": "Name", "organization": "60d0fe4f5311236168a109cb", "createdBy": "60d0fe4f5311236168a109cc", "createdAt": "2025-01-15T10:30:00.000Z", "updatedAt": "2025-01-15T10:30:00.000Z" } } ``` **SDK Code** ```python import requests url = "https://api.smallest.ai/atoms/v1/audience" files = { "file": "open('audience_template.csv', 'rb')" } payload = { "description": , "identifierColumnName": , "name": "test_audience", "phoneNumberColumnName": "phoneNumber" } headers = {"Authorization": "Bearer "} response = requests.post(url, data=payload, files=files, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.smallest.ai/atoms/v1/audience'; const form = new FormData(); form.append('description', ''); form.append('file', 'audience_template.csv'); form.append('identifierColumnName', ''); form.append('name', 'test_audience'); form.append('phoneNumberColumnName', 'phoneNumber'); const options = {method: 'POST', headers: {Authorization: 'Bearer '}}; options.body = form; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.smallest.ai/atoms/v1/audience" payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"description\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"audience_template.csv\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"identifierColumnName\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\ntest_audience\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"phoneNumberColumnName\"\r\n\r\nphoneNumber\r\n-----011000010111000001101001--\r\n") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://api.smallest.ai/atoms/v1/audience") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"description\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"audience_template.csv\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"identifierColumnName\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\ntest_audience\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"phoneNumberColumnName\"\r\n\r\nphoneNumber\r\n-----011000010111000001101001--\r\n" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.smallest.ai/atoms/v1/audience") .header("Authorization", "Bearer ") .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"description\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"audience_template.csv\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"identifierColumnName\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\ntest_audience\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"phoneNumberColumnName\"\r\n\r\nphoneNumber\r\n-----011000010111000001101001--\r\n") .asString(); ``` ```php request('POST', 'https://api.smallest.ai/atoms/v1/audience', [ 'multipart' => [ [ 'name' => 'file', 'filename' => 'audience_template.csv', 'contents' => null ], [ 'name' => 'name', 'contents' => 'test_audience' ], [ 'name' => 'phoneNumberColumnName', 'contents' => 'phoneNumber' ] ] 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.smallest.ai/atoms/v1/audience"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddParameter("undefined", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"description\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"audience_template.csv\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"identifierColumnName\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\ntest_audience\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"phoneNumberColumnName\"\r\n\r\nphoneNumber\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = ["Authorization": "Bearer "] let parameters = [ [ "name": "description", "value": ], [ "name": "file", "fileName": "audience_template.csv" ], [ "name": "identifierColumnName", "value": ], [ "name": "name", "value": "test_audience" ], [ "name": "phoneNumberColumnName", "value": "phoneNumber" ] ] let boundary = "---011000010111000001101001" var body = "" var error: NSError? = nil for param in parameters { let paramName = param["name"]! body += "--\(boundary)\r\n" body += "Content-Disposition:form-data; name=\"\(paramName)\"" if let filename = param["fileName"] { let contentType = param["content-type"]! let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8) if (error != nil) { print(error as Any) } body += "; filename=\"\(filename)\"\r\n" body += "Content-Type: \(contentType)\r\n\r\n" body += fileContent } else if let paramValue = param["value"] { body += "\r\n\r\n\(paramValue)" } } let request = NSMutableURLRequest(url: NSURL(string: "https://api.smallest.ai/atoms/v1/audience")! 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() ```