# Create a Batch POST https://api.prolific.com/api/v1/data-collection/batches Content-Type: application/json Create a new AI Task Builder batch. The dataset does not need to be in READY status at creation time. Reference: https://beta-docs.prolific.com/api-reference/ai-task-builder/create-task-builder-batch ## OpenAPI Specification ```yaml openapi: 3.1.1 info: title: Create a Batch version: endpoint_aiTaskBuilder.CreateTaskBuilderBatch paths: /api/v1/data-collection/batches: post: operationId: create-task-builder-batch summary: Create a Batch description: >- Create a new AI Task Builder batch. The dataset does not need to be in READY status at creation time. tags: - - subpackage_aiTaskBuilder parameters: - name: Authorization in: header description: Header authentication of the form `undefined ` required: true schema: type: string responses: '201': description: Created content: application/json: schema: $ref: '#/components/schemas/AITaskBuilderBatchCreate' '400': description: Error content: {} requestBody: content: application/json: schema: type: object properties: name: type: string description: The name of the batch workspace_id: type: string description: The ID of the Prolific workspace dataset_id: type: string description: The ID of the dataset to attach (optional at creation time) task_details: $ref: >- #/components/schemas/ApiV1DataCollectionBatchesPostRequestBodyContentApplicationJsonSchemaTaskDetails description: Task metadata displayed to participants required: - name - workspace_id - task_details components: schemas: ApiV1DataCollectionBatchesPostRequestBodyContentApplicationJsonSchemaTaskDetails: type: object properties: task_name: type: string description: The title displayed to participants task_introduction: type: string description: HTML formatted introduction shown at the start of the task task_steps: type: string description: HTML formatted step-by-step instructions required: - task_name - task_introduction - task_steps AiTaskBuilderBatchCreateDatasetsItems: type: object properties: id: type: string format: uuid total_datapoint_count: type: integer required: - id - total_datapoint_count AiTaskBuilderBatchCreateStatus: type: string enum: - value: UNINITIALISED - value: PROCESSING - value: READY - value: ERROR AiTaskBuilderBatchCreateTaskDetails: type: object properties: task_name: type: string task_introduction: type: string description: HTML formatted task introduction task_steps: type: string description: HTML formatted task steps required: - task_name AITaskBuilderBatchCreate: type: object properties: id: type: string format: uuid created_at: type: string format: date-time description: >- An ISO-8601 formatted string representing the batch creation time, in UTC. created_by: type: string description: User ID of the Prolific user that created the resource. datasets: type: array items: $ref: '#/components/schemas/AiTaskBuilderBatchCreateDatasetsItems' name: type: string status: $ref: '#/components/schemas/AiTaskBuilderBatchCreateStatus' total_task_count: type: integer total_instruction_count: type: integer workspace_id: type: string task_details: $ref: '#/components/schemas/AiTaskBuilderBatchCreateTaskDetails' required: - id - created_at - created_by - datasets - name - status - total_task_count - total_instruction_count - workspace_id - task_details ``` ## SDK Code Examples ```python import requests url = "https://api.prolific.com/api/v1/data-collection/batches" payload = { "name": "Sentiment Analysis Batch", "workspace_id": "6278acb09062db3b35bcbeb0", "task_details": { "task_name": "Evaluate Product Reviews", "task_introduction": "

In this task, you will analyze product reviews and categorize their sentiment.

", "task_steps": "
  1. Read each review carefully
  2. Select the appropriate sentiment
  3. Provide a brief explanation
" }, "dataset_id": "1234acb09999db4b99bcded1" } headers = { "Authorization": "", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.prolific.com/api/v1/data-collection/batches'; const options = { method: 'POST', headers: {Authorization: '', 'Content-Type': 'application/json'}, body: '{"name":"Sentiment Analysis Batch","workspace_id":"6278acb09062db3b35bcbeb0","task_details":{"task_name":"Evaluate Product Reviews","task_introduction":"

In this task, you will analyze product reviews and categorize their sentiment.

","task_steps":"
  1. Read each review carefully
  2. Select the appropriate sentiment
  3. Provide a brief explanation
"},"dataset_id":"1234acb09999db4b99bcded1"}' }; 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.prolific.com/api/v1/data-collection/batches" payload := strings.NewReader("{\n \"name\": \"Sentiment Analysis Batch\",\n \"workspace_id\": \"6278acb09062db3b35bcbeb0\",\n \"task_details\": {\n \"task_name\": \"Evaluate Product Reviews\",\n \"task_introduction\": \"

In this task, you will analyze product reviews and categorize their sentiment.

\",\n \"task_steps\": \"
  1. Read each review carefully
  2. Select the appropriate sentiment
  3. Provide a brief explanation
\"\n },\n \"dataset_id\": \"1234acb09999db4b99bcded1\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "") 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 require 'uri' require 'net/http' url = URI("https://api.prolific.com/api/v1/data-collection/batches") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"name\": \"Sentiment Analysis Batch\",\n \"workspace_id\": \"6278acb09062db3b35bcbeb0\",\n \"task_details\": {\n \"task_name\": \"Evaluate Product Reviews\",\n \"task_introduction\": \"

In this task, you will analyze product reviews and categorize their sentiment.

\",\n \"task_steps\": \"
  1. Read each review carefully
  2. Select the appropriate sentiment
  3. Provide a brief explanation
\"\n },\n \"dataset_id\": \"1234acb09999db4b99bcded1\"\n}" response = http.request(request) puts response.read_body ``` ```java HttpResponse response = Unirest.post("https://api.prolific.com/api/v1/data-collection/batches") .header("Authorization", "") .header("Content-Type", "application/json") .body("{\n \"name\": \"Sentiment Analysis Batch\",\n \"workspace_id\": \"6278acb09062db3b35bcbeb0\",\n \"task_details\": {\n \"task_name\": \"Evaluate Product Reviews\",\n \"task_introduction\": \"

In this task, you will analyze product reviews and categorize their sentiment.

\",\n \"task_steps\": \"
  1. Read each review carefully
  2. Select the appropriate sentiment
  3. Provide a brief explanation
\"\n },\n \"dataset_id\": \"1234acb09999db4b99bcded1\"\n}") .asString(); ``` ```php request('POST', 'https://api.prolific.com/api/v1/data-collection/batches', [ 'body' => '{ "name": "Sentiment Analysis Batch", "workspace_id": "6278acb09062db3b35bcbeb0", "task_details": { "task_name": "Evaluate Product Reviews", "task_introduction": "

In this task, you will analyze product reviews and categorize their sentiment.

", "task_steps": "
  1. Read each review carefully
  2. Select the appropriate sentiment
  3. Provide a brief explanation
" }, "dataset_id": "1234acb09999db4b99bcded1" }', 'headers' => [ 'Authorization' => '', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp var client = new RestClient("https://api.prolific.com/api/v1/data-collection/batches"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"name\": \"Sentiment Analysis Batch\",\n \"workspace_id\": \"6278acb09062db3b35bcbeb0\",\n \"task_details\": {\n \"task_name\": \"Evaluate Product Reviews\",\n \"task_introduction\": \"

In this task, you will analyze product reviews and categorize their sentiment.

\",\n \"task_steps\": \"
  1. Read each review carefully
  2. Select the appropriate sentiment
  3. Provide a brief explanation
\"\n },\n \"dataset_id\": \"1234acb09999db4b99bcded1\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "", "Content-Type": "application/json" ] let parameters = [ "name": "Sentiment Analysis Batch", "workspace_id": "6278acb09062db3b35bcbeb0", "task_details": [ "task_name": "Evaluate Product Reviews", "task_introduction": "

In this task, you will analyze product reviews and categorize their sentiment.

", "task_steps": "
  1. Read each review carefully
  2. Select the appropriate sentiment
  3. Provide a brief explanation
" ], "dataset_id": "1234acb09999db4b99bcded1" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.prolific.com/api/v1/data-collection/batches")! 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() ```