# Duplicate a Batch POST https://api.prolific.com/api/v1/data-collection/batches/{batch_id}/duplicate Content-Type: application/json Create a duplicate of an existing AI Task Builder batch. The dataset does not need to be in READY status for duplication. Supports two modes: - Duplicate with dataset (default): Creates a copy with the same dataset (the dataset is shared between both batches, not duplicated) - Duplicate without dataset: Creates a copy that requires a new dataset upload (set upload_new_dataset to true) You can optionally provide a new name for the duplicated batch. If no name is provided, the duplicate will be named "[Original Batch Name] (Copy)". Reference: https://beta-docs.prolific.com/api-reference/ai-task-builder/duplicate-task-builder-batch ## OpenAPI Specification ```yaml openapi: 3.1.1 info: title: Duplicate a Batch version: endpoint_aiTaskBuilder.DuplicateTaskBuilderBatch paths: /api/v1/data-collection/batches/{batch_id}/duplicate: post: operationId: duplicate-task-builder-batch summary: Duplicate a Batch description: >- Create a duplicate of an existing AI Task Builder batch. The dataset does not need to be in READY status for duplication. Supports two modes: - Duplicate with dataset (default): Creates a copy with the same dataset (the dataset is shared between both batches, not duplicated) - Duplicate without dataset: Creates a copy that requires a new dataset upload (set upload_new_dataset to true) You can optionally provide a new name for the duplicated batch. If no name is provided, the duplicate will be named "[Original Batch Name] (Copy)". tags: - - subpackage_aiTaskBuilder parameters: - name: batch_id in: path description: The unique identifier of the batch to duplicate required: true schema: type: string - 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: >- Optional name for the duplicated batch. If not provided, a default name will be generated. upload_new_dataset: type: boolean default: false description: >- If true, creates the batch without copying the dataset (user must upload a new one). If false or omitted, duplicates with the existing dataset. components: schemas: 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/batch_id/duplicate" payload = {} 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/batch_id/duplicate'; const options = { method: 'POST', headers: {Authorization: '', 'Content-Type': 'application/json'}, body: '{}' }; 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/batch_id/duplicate" payload := strings.NewReader("{}") 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/batch_id/duplicate") 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 = "{}" response = http.request(request) puts response.read_body ``` ```java HttpResponse response = Unirest.post("https://api.prolific.com/api/v1/data-collection/batches/batch_id/duplicate") .header("Authorization", "") .header("Content-Type", "application/json") .body("{}") .asString(); ``` ```php request('POST', 'https://api.prolific.com/api/v1/data-collection/batches/batch_id/duplicate', [ 'body' => '{}', 'headers' => [ 'Authorization' => '', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp var client = new RestClient("https://api.prolific.com/api/v1/data-collection/batches/batch_id/duplicate"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "", "Content-Type": "application/json" ] let parameters = [] 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/batch_id/duplicate")! 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() ```