> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.prolific.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.prolific.com/_mcp/server.

# Sync a Batch

POST https://api.prolific.com/api/v1/data-collection/batches/{batch_id}/sync

Triggers an asynchronous sync job that materialises tasks for any datapoints appended to the
batch's attached dataset since it was set up (or since the last sync). Returns immediately
with a `sync_id`; the work is performed by a background worker.

The batch must be in `READY` status and have an attached dataset. Syncs for the same batch are
serialised, so a new sync picks up wherever the previous one left off.

Poll `GET /batches/{batch_id}/syncs/{sync_id}` until the returned job reaches a terminal
status (`complete` or `failed`).

Reference: https://docs.prolific.com/api-reference/ai-task-builder/sync-task-builder-batch

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Prolific API for Data Collectors
  version: 1.0.0
paths:
  /api/v1/data-collection/batches/{batch_id}/sync:
    post:
      operationId: sync-task-builder-batch
      summary: Sync a Batch
      description: >-
        Triggers an asynchronous sync job that materialises tasks for any
        datapoints appended to the

        batch's attached dataset since it was set up (or since the last sync).
        Returns immediately

        with a `sync_id`; the work is performed by a background worker.


        The batch must be in `READY` status and have an attached dataset. Syncs
        for the same batch are

        serialised, so a new sync picks up wherever the previous one left off.


        Poll `GET /batches/{batch_id}/syncs/{sync_id}` until the returned job
        reaches a terminal

        status (`complete` or `failed`).
      tags:
        - aiTaskBuilder
      parameters:
        - name: batch_id
          in: path
          description: The unique identifier of the batch to sync
          required: true
          schema:
            type: string
            format: uuid
        - name: Authorization
          in: header
          description: >-
            The Prolific API uses API token to authenticate requests. You can
            create an API token directly from your settings.


            Your API token does not have an expiry date and carries full
            permission, so be sure to keep them secure.


            If your token is leaked, delete it and create a new one directly in
            the app.


            In your requests add `Authorization` header with the value `Token
            <your token>`.
          required: true
          schema:
            type: string
      responses:
        '202':
          description: >-
            Sync job accepted and queued. The returned job has status `queued`;
            poll the sync-status

            endpoint for progress.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SyncJob'
        '400':
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
servers:
  - url: https://api.prolific.com
    description: Production
components:
  schemas:
    SyncJobStatus:
      type: string
      enum:
        - queued
        - processing
        - complete
        - failed
      description: Current status of the sync job.
      title: SyncJobStatus
    SyncJob:
      type: object
      properties:
        batch_id:
          type: string
          format: uuid
          description: The batch this sync job belongs to.
        dataset_id:
          type: string
          format: uuid
          description: The dataset whose appended datapoints are being synced.
        sync_id:
          type: string
          format: uuid
          description: The unique identifier of the sync job.
        created_at:
          type: string
          format: date-time
          description: When the sync job was created (ISO 8601, UTC).
        updated_at:
          type: string
          format: date-time
          description: When the sync job was last updated (ISO 8601, UTC).
        status:
          $ref: '#/components/schemas/SyncJobStatus'
          description: Current status of the sync job.
        tasks_created:
          type: integer
          description: >-
            Number of tasks created this sync. Present when status is
            `complete`.
        datapoints_processed:
          type: integer
          description: >-
            Number of datapoints processed this sync. Present when status is
            `complete`.
        groups_created:
          type: integer
          description: >-
            Number of new task groups created this sync. Present when status is
            `complete`.
        groups_expanded:
          type: integer
          description: >-
            Number of existing task groups grown this sync. Non-zero only for
            predetermined-grouping

            batches; always `0` for tasks-per-group batches. Present when status
            is `complete`.
        reason:
          type: string
          description: Human-readable reason for failure. Present when status is `failed`.
      required:
        - batch_id
        - dataset_id
        - sync_id
        - created_at
        - updated_at
        - status
      description: >-
        Tracks the asynchronous materialisation of tasks for datapoints appended
        to a batch's dataset

        since setup or the last sync. Created by `POST
        /batches/{batch_id}/sync`; poll

        `GET /batches/{batch_id}/syncs/{sync_id}` until a terminal status
        (`complete` or `failed`).


        The shape depends on `status`: the fields below marked as terminal-only
        are present only for

        the corresponding status.
      title: SyncJob
    SyncTaskBuilderBatchRequestBadRequestError:
      type: object
      properties:
        message:
          type: string
          description: Human-readable reason the batch cannot be synced.
        detail:
          type: string
          description: Additional context, when available.
      title: SyncTaskBuilderBatchRequestBadRequestError
    ErrorDetailDetail2:
      type: object
      properties:
        any_field:
          type: array
          items:
            type: string
          description: >-
            Name of the field with a validation error and as a value an array
            with the error descriptions
      description: All fields with validation errors
      title: ErrorDetailDetail2
    ErrorDetailDetail:
      oneOf:
        - type: string
        - type: array
          items:
            type: string
        - $ref: '#/components/schemas/ErrorDetailDetail2'
      description: Error detail
      title: ErrorDetailDetail
    ErrorDetail:
      type: object
      properties:
        status:
          type: integer
          description: Status code as in the http standards
        error_code:
          type: integer
          description: Internal error code
        title:
          type: string
          description: Error title
        detail:
          $ref: '#/components/schemas/ErrorDetailDetail'
          description: Error detail
        additional_information:
          type: string
          description: Optional extra information
        traceback:
          type: string
          description: Optional debug information
        interactive:
          type: boolean
      required:
        - status
        - error_code
        - title
        - detail
      title: ErrorDetail
    Error:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetail'
      required:
        - error
      title: Error
  securitySchemes:
    token:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        The Prolific API uses API token to authenticate requests. You can create
        an API token directly from your settings.


        Your API token does not have an expiry date and carries full permission,
        so be sure to keep them secure.


        If your token is leaked, delete it and create a new one directly in the
        app.


        In your requests add `Authorization` header with the value `Token <your
        token>`.

```

## Examples



**Request**

```json
{}
```

**Response**

```json
{
  "batch_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "dataset_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
  "sync_id": "1c6b147e-8f3a-4d2a-9f3b-2a1e4d5f6b7c",
  "created_at": "2024-01-15T09:30:00Z",
  "updated_at": "2024-01-15T09:30:00Z",
  "status": "queued"
}
```

**SDK Code**

```python
import requests

url = "https://api.prolific.com/api/v1/data-collection/batches/batch_id/sync"

payload = {}
headers = {
    "Authorization": "Token <token>",
    "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/sync';
const options = {
  method: 'POST',
  headers: {Authorization: 'Token <token>', '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/sync"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Token <token>")
	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/sync")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Token <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.prolific.com/api/v1/data-collection/batches/batch_id/sync")
  .header("Authorization", "Token <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.prolific.com/api/v1/data-collection/batches/batch_id/sync', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Token <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.prolific.com/api/v1/data-collection/batches/batch_id/sync");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Token <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Token <token>",
  "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/sync")! 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()
```