> This page is for version v1.3 (default).
> For other versions, use one of these documentation indexes:
> - v1.3 (default): https://docs.twelvelabs.io/v1.3/llms.txt

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

# Create multiple entities in bulk

POST https://api.twelvelabs.io/v1.3/entity-collections/{entity_collection_id}/entities/bulk
Content-Type: application/json

This method creates multiple entities within a specified entity collection in a single request. Each entity must be associated with at least one asset. This endpoint is useful for efficiently adding multiple entities, such as a roster of players or a group of characters.


Reference: https://docs.twelvelabs.io/api-reference/entities/entity-collections/entities/create-bulk

## Authentication

- `x-api-key` header (required) — Your API key. You can find your API key on the API Keys page.

## Request

### Path parameters

- `entity_collection_id` (string, required) — The unique identifier of the entity collection in which to create the entities.

### Body (application/json)

This endpoint expects an object.

- `entities` (list of EntityCollectionsEntityCollectionIdEntitiesBulkPostRequestBodyContentApplicationJsonSchemaEntitiesItems, required)

## Response

### 201

The entities have been successfully created.

- `success_count` (integer, optional) — The number of entities that were successfully created.
- `failed_count` (integer, optional) — The number of entities that failed to be created due to errors, such as missing assets.
- `entities` (list of BulkCreateEntityResponseEntitiesItems, optional) — An array of objects representing the entities that were successfully created. Each object includes the unique identifier, name, and current status.
- `errors` (list of BulkCreateEntityResponseErrorsItems, optional) — An array of error objects for entities that failed to be created. Each error object provides details about the failure, including the index of the entity in the original request, the entity's name, and the reason for the failure.

## Errors

### 400 Bad Request Error

The request has failed.

- `code` (string, optional) — A string representing the code associated with the error. See the [Error codes](/v1.3/api-reference/error-codes) page for details.
- `message` (string, optional) — A human-readable string describing the error, intended to be suitable for display in a user interface.

## Types

### EntityCollectionsEntityCollectionIdEntitiesBulkPostRequestBodyContentApplicationJsonSchemaEntitiesItems

- `name` (string, required) — The name of the entity.
- `asset_ids` (list of string, required) — An array of asset IDs to associate with the entity. At least one asset ID is required.
- `description` (string, optional) — Optional description of the entity.
- `metadata` (EntityCollectionsEntityCollectionIdEntitiesBulkPostRequestBodyContentApplicationJsonSchemaEntitiesItemsMetadata, optional) — Optional metadata for the entity, provided as key-value pairs.

### BulkCreateEntityResponseEntitiesItems

- `_id` (string, optional) — The unique identifier of the entity.
- `name` (string, optional) — The name of the entity.
- `status` (string, optional) — The current status of the entity creation process. **Values**: - `processing`: The entity is being processed and is not yet ready for use in searches. - `ready``: The entity is fully processed and can be used in search queries.

### BulkCreateEntityResponseErrorsItems

- `entity_index` (integer, optional) — The zero-based index of the entity in the original request array. This helps identify which specific entity failed to be created.
- `entity_name` (string, optional) — The name of the entity that failed to be created, as provided in the request.
- `error_reason` (string, optional) — A message explaining why the entity failed to be created.

### EntityCollectionsEntityCollectionIdEntitiesBulkPostRequestBodyContentApplicationJsonSchemaEntitiesItemsMetadata

Optional metadata for the entity, provided as key-value pairs.

## Examples

**Request**

```json
{
  "entities": [
    {
      "name": "My entity",
      "asset_ids": [
        "6298d673f1090f1100476d4c",
        "6298d673f1090f1100476d4d"
      ]
    }
  ]
}
```

**Response**

```json
{
  "success_count": 8,
  "failed_count": 2,
  "entities": [
    {
      "_id": "6298d673f1090f1100476d4c",
      "name": "My first entity",
      "status": "ready"
    }
  ],
  "errors": [
    {
      "entity_index": 3,
      "entity_name": "My second entity",
      "error_reason": "You must specify at least 1 asset for images"
    }
  ]
}
```

**SDK Code**

```python
import requests

url = "https://api.twelvelabs.io/v1.3/entity-collections/6298d673f1090f1100476d4c/entities/bulk"

payload = { "entities": [
        {
            "name": "My entity",
            "asset_ids": ["6298d673f1090f1100476d4c", "6298d673f1090f1100476d4d"]
        }
    ] }
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.twelvelabs.io/v1.3/entity-collections/6298d673f1090f1100476d4c/entities/bulk';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"entities":[{"name":"My entity","asset_ids":["6298d673f1090f1100476d4c","6298d673f1090f1100476d4d"]}]}'
};

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.twelvelabs.io/v1.3/entity-collections/6298d673f1090f1100476d4c/entities/bulk"

	payload := strings.NewReader("{\n  \"entities\": [\n    {\n      \"name\": \"My entity\",\n      \"asset_ids\": [\n        \"6298d673f1090f1100476d4c\",\n        \"6298d673f1090f1100476d4d\"\n      ]\n    }\n  ]\n}")

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

	req.Header.Add("x-api-key", "<apiKey>")
	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.twelvelabs.io/v1.3/entity-collections/6298d673f1090f1100476d4c/entities/bulk")

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

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"entities\": [\n    {\n      \"name\": \"My entity\",\n      \"asset_ids\": [\n        \"6298d673f1090f1100476d4c\",\n        \"6298d673f1090f1100476d4d\"\n      ]\n    }\n  ]\n}"

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.twelvelabs.io/v1.3/entity-collections/6298d673f1090f1100476d4c/entities/bulk")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"entities\": [\n    {\n      \"name\": \"My entity\",\n      \"asset_ids\": [\n        \"6298d673f1090f1100476d4c\",\n        \"6298d673f1090f1100476d4d\"\n      ]\n    }\n  ]\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.twelvelabs.io/v1.3/entity-collections/6298d673f1090f1100476d4c/entities/bulk', [
  'body' => '{
  "entities": [
    {
      "name": "My entity",
      "asset_ids": [
        "6298d673f1090f1100476d4c",
        "6298d673f1090f1100476d4d"
      ]
    }
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.twelvelabs.io/v1.3/entity-collections/6298d673f1090f1100476d4c/entities/bulk");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"entities\": [\n    {\n      \"name\": \"My entity\",\n      \"asset_ids\": [\n        \"6298d673f1090f1100476d4c\",\n        \"6298d673f1090f1100476d4d\"\n      ]\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["entities": [
    [
      "name": "My entity",
      "asset_ids": ["6298d673f1090f1100476d4c", "6298d673f1090f1100476d4d"]
    ]
  ]] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.twelvelabs.io/v1.3/entity-collections/6298d673f1090f1100476d4c/entities/bulk")! 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()
```