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

# Create a Batch Job

POST https://api.withpersona.com/api/v1/batch-jobs
Content-Type: application/json

Submits a batch of rows to update or upsert Accounts, or update Inquiries, in bulk. Persona
processes the rows asynchronously as a Batch Job; poll the returned job or retrieve its
errors to check progress.

- **`object: account`** supports `operation: update` (lookup by `token` or `reference_id`) or
  `operation: upsert` (lookup by `reference_id` only, and requires `account_type_id` on the
  pipeline or on each row).
- **`object: inquiry`** only supports `operation: update` with `lookup_field: token`.


Reference: https://docs.withpersona.com/api-reference/batch-jobs/create-a-batch-job

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Query parameters

- `include` (string, optional) — A comma-separated list of relationship paths. This can be used to customize which related resources will be fully serialized in the `included` key in the response. See [Serialization](https://docs.withpersona.com/serialization#inclusion-of-related-resources) for more details.
- `fields` (map from string to string, optional) — Comma-separated list(s) of attributes to include in the response. This can be used to customize which attributes will be serialized in the response. See [Serialization](https://docs.withpersona.com/serialization#sparse-fieldsets) for more details.

### Headers

- `Key-Inflection` (enum, optional) — Determines casing for the API response.
  - Allowed values: `camel`, `kebab`, `snake`
- `Idempotency-Key` (string, optional) — Ensures the request is idempotent.
- `Persona-Version` (enum, optional) — Server API version. More info on versioning can be found [here](https://docs.withpersona.com/versioning).
  - Allowed values: `2025-12-08`, `2025-10-27`, `2023-01-05`, `2022-09-01`, `2021-08-18`, `2021-07-05`, `2021-02-21`, `2020-05-18`

### Body (application/json)

This endpoint expects an object.

- `data` (BatchJobsPostRequestBodyContentApplicationJsonSchemaData, required)

## Response

### 202

The Batch Job has been created and processing has started.

- `data` (batch-job, required) — A Batch Job object.

## Errors

### 400 Bad Request Error

The request was unacceptable, often due to invalid parameters.

- `errors` (list of BatchJobsPostResponsesContentApplicationJsonSchemaErrorsItems, optional)

### 401 Unauthorized Error

An invalid API key was provided.

- `errors` (list of BatchJobsPostResponsesContentApplicationJsonSchemaErrorsItems, optional)

### 403 Forbidden Error

The given API key doesn’t have permissions to perform the request or a quota has been exceeded.

- `errors` (list of BatchJobsPostResponsesContentApplicationJsonSchemaErrorsItems, optional)

### 409 Conflict Error

The request conflicts with another request, often due to attempting to create a duplicate resource.

- `errors` (list of BatchJobsPostResponsesContentApplicationJsonSchemaErrorsItems, optional)

### 422 Unprocessable Entity Error

The request modifies the resource in an unacceptable way, often due to an invalid action or parameter.

- `errors` (list of BatchJobsPostResponsesContentApplicationJsonSchemaErrorsItems, optional)

### 429 Too Many Requests Error

Your organization’s rate limit has been exceeded. We recommend an exponential backoff on requests.

- `errors` (list of BatchJobsPostResponsesContentApplicationJsonSchemaErrorsItems, optional)

## Types

### BatchJobsPostRequestBodyContentApplicationJsonSchemaData

- `attributes` (BatchJobsPostRequestBodyContentApplicationJsonSchemaDataAttributes, required)

### batch-job

A Batch Job object.

- `type` ("batch-job", optional)
- `id` (string, optional)
- `attributes` (BatchJobAttributes, optional)

### BatchJobsPostResponsesContentApplicationJsonSchemaErrorsItems

- `title` (string, optional)
- `details` (string, optional)

### BatchJobsPostRequestBodyContentApplicationJsonSchemaDataAttributes

- `operation` (string, required) — Whether to only update existing objects, or create them if they don't already exist. One of `update` or `upsert`. `upsert` is only supported for `object: account`.
- `object` (string, required) — The kind of object each row updates. One of `account` or `inquiry`.
- `lookup-field` (string, required) — The field used to find the object each row applies to. One of `token` or `reference_id`. `token` is required for `object: inquiry`.
- `rows` (list of map from string to any, required) — The rows to process, up to 1000 rows per request. Each row is a flat object whose keys are field names (for example `reference_id`, `token`, `account_type_id`, or a custom field key) and whose values are the data to write.
- `emit-events` (boolean, optional, default: true) — Whether to emit events for objects affected by this run. Defaults to `true`. When `false` and `object` is `account`: suppresses the `account.updated-fields` event, and suppresses `account.tag-added` / `account.tag-removed` (so workflows and webhooks that trigger on those events do not run for this row). When `false` and `object` is `inquiry`: has no effect today, since updating an Inquiry's tags or fields through this endpoint does not emit any event regardless of this flag. In both cases, this only suppresses events -- it never affects the write itself, and Elasticsearch reindexing and the graph Kafka sync are not events and always run.
- `account-type-id` (string, optional) — The default Account Type token to use for rows that create a new Account and don't specify their own `account_type_id`. Only applicable when `object` is `account`.

### BatchJobAttributes

- `status` (string, optional) — Current status of the batch job. Possible values include `pending`, `running`, `paused`, `canceled`, `completed`, `errored`, and `killed`.
- `run-count` (integer, optional) — Number of times this batch job has been executed
- `started-at` (datetime, optional, nullable) — When the batch job started processing
- `ended-at` (datetime, optional, nullable) — When the batch job finished processing
- `created-at` (datetime, optional) — When the batch job was created
- `updated-at` (datetime, optional) — When the batch job was last updated
- `redacted-at` (datetime, optional, nullable) — When the batch job was redacted
- `run-data` (BatchJobAttributesRunData, optional) — Runtime data and statistics for the batch job

### BatchJobAttributesRunData

Runtime data and statistics for the batch job

- `column-names` (list of string, optional) — Names of columns being processed
- `error-count` (integer, optional) — Number of errors encountered
- `rows-read` (integer, optional) — Number of rows read from the source
- `row-count` (integer, optional) — Total number of rows processed
- `success-count` (integer, optional) — Number of rows successfully processed
- `created-count` (integer, optional) — Number of new records created
- `updated-count` (integer, optional) — Number of existing records updated

## Examples

**Request**

```json
{
  "data": {
    "attributes": {
      "operation": "update",
      "object": "account",
      "lookup-field": "reference_id",
      "rows": [
        {
          "name_first": "Jane",
          "name_last": "Doe",
          "reference_id": "a-123"
        },
        {
          "name_first": "John",
          "name_last": "Smith",
          "reference_id": "a-456"
        }
      ],
      "account-type-id": "acttp_ABC123"
    }
  }
}
```

**Response**

```json
{
  "data": {
    "type": "batch-job",
    "id": "mprtpr_ABC123DEF456",
    "attributes": {
      "status": "pending",
      "run-count": 1,
      "started-at": null,
      "ended-at": null,
      "created-at": "2024-01-15T09:59:45.000Z",
      "updated-at": "2024-01-15T09:59:45.000Z",
      "redacted-at": null,
      "run-data": {
        "column-names": [
          "reference_id",
          "name_first",
          "name_last"
        ],
        "error-count": 0,
        "rows-read": 0,
        "row-count": 2,
        "success-count": 0,
        "created-count": 0,
        "updated-count": 0
      }
    }
  }
}
```

**SDK Code**

```python Success
import requests

url = "https://api.withpersona.com/api/v1/batch-jobs"

payload = { "data": { "attributes": {
            "operation": "update",
            "object": "account",
            "lookup-field": "reference_id",
            "rows": [
                {
                    "name_first": "Jane",
                    "name_last": "Doe",
                    "reference_id": "a-123"
                },
                {
                    "name_first": "John",
                    "name_last": "Smith",
                    "reference_id": "a-456"
                }
            ],
            "account-type-id": "acttp_ABC123"
        } } }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Success
const url = 'https://api.withpersona.com/api/v1/batch-jobs';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"data":{"attributes":{"operation":"update","object":"account","lookup-field":"reference_id","rows":[{"name_first":"Jane","name_last":"Doe","reference_id":"a-123"},{"name_first":"John","name_last":"Smith","reference_id":"a-456"}],"account-type-id":"acttp_ABC123"}}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Success
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.withpersona.com/api/v1/batch-jobs"

	payload := strings.NewReader("{\n  \"data\": {\n    \"attributes\": {\n      \"operation\": \"update\",\n      \"object\": \"account\",\n      \"lookup-field\": \"reference_id\",\n      \"rows\": [\n        {\n          \"name_first\": \"Jane\",\n          \"name_last\": \"Doe\",\n          \"reference_id\": \"a-123\"\n        },\n        {\n          \"name_first\": \"John\",\n          \"name_last\": \"Smith\",\n          \"reference_id\": \"a-456\"\n        }\n      ],\n      \"account-type-id\": \"acttp_ABC123\"\n    }\n  }\n}")

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

	req.Header.Add("Authorization", "Bearer <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 Success
require 'uri'
require 'net/http'

url = URI("https://api.withpersona.com/api/v1/batch-jobs")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"data\": {\n    \"attributes\": {\n      \"operation\": \"update\",\n      \"object\": \"account\",\n      \"lookup-field\": \"reference_id\",\n      \"rows\": [\n        {\n          \"name_first\": \"Jane\",\n          \"name_last\": \"Doe\",\n          \"reference_id\": \"a-123\"\n        },\n        {\n          \"name_first\": \"John\",\n          \"name_last\": \"Smith\",\n          \"reference_id\": \"a-456\"\n        }\n      ],\n      \"account-type-id\": \"acttp_ABC123\"\n    }\n  }\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.withpersona.com/api/v1/batch-jobs")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"data\": {\n    \"attributes\": {\n      \"operation\": \"update\",\n      \"object\": \"account\",\n      \"lookup-field\": \"reference_id\",\n      \"rows\": [\n        {\n          \"name_first\": \"Jane\",\n          \"name_last\": \"Doe\",\n          \"reference_id\": \"a-123\"\n        },\n        {\n          \"name_first\": \"John\",\n          \"name_last\": \"Smith\",\n          \"reference_id\": \"a-456\"\n        }\n      ],\n      \"account-type-id\": \"acttp_ABC123\"\n    }\n  }\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.withpersona.com/api/v1/batch-jobs', [
  'body' => '{
  "data": {
    "attributes": {
      "operation": "update",
      "object": "account",
      "lookup-field": "reference_id",
      "rows": [
        {
          "name_first": "Jane",
          "name_last": "Doe",
          "reference_id": "a-123"
        },
        {
          "name_first": "John",
          "name_last": "Smith",
          "reference_id": "a-456"
        }
      ],
      "account-type-id": "acttp_ABC123"
    }
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Success
using RestSharp;

var client = new RestClient("https://api.withpersona.com/api/v1/batch-jobs");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"data\": {\n    \"attributes\": {\n      \"operation\": \"update\",\n      \"object\": \"account\",\n      \"lookup-field\": \"reference_id\",\n      \"rows\": [\n        {\n          \"name_first\": \"Jane\",\n          \"name_last\": \"Doe\",\n          \"reference_id\": \"a-123\"\n        },\n        {\n          \"name_first\": \"John\",\n          \"name_last\": \"Smith\",\n          \"reference_id\": \"a-456\"\n        }\n      ],\n      \"account-type-id\": \"acttp_ABC123\"\n    }\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Success
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["data": ["attributes": [
      "operation": "update",
      "object": "account",
      "lookup-field": "reference_id",
      "rows": [
        [
          "name_first": "Jane",
          "name_last": "Doe",
          "reference_id": "a-123"
        ],
        [
          "name_first": "John",
          "name_last": "Smith",
          "reference_id": "a-456"
        ]
      ],
      "account-type-id": "acttp_ABC123"
    ]]] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.withpersona.com/api/v1/batch-jobs")! 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()
```