Skip to main content
Based on the Batch operations on one index API operation. This helper method creates a batch write request with the addObject action and automatically sends records in batches of 1,000. This method is subject to indexing rate limits.

Usage

var response = await client.SaveObjectsAsync(
  "INDEX_NAME",
  new List<Object>
  {
    new Dictionary<string, string>
    {
      { "objectID", "1" },
      { "visibility", "public" },
      { "name", "Hot 100 Billboard Charts" },
      { "playlistId", "d3e8e8f3-0a4f-4b7d-9b6b-7e8f4e8e3a0f" },
      { "createdAt", "1500240452" },
    },
  },
  false,
  1000,
  new RequestOptionBuilder().AddExtraHeader("X-Algolia-User-ID", "*").Build()
);
response, err := client.SaveObjects(
  "INDEX_NAME",
  []map[string]any{
    {
      "objectID":   "1",
      "visibility": "public",
      "name":       "Hot 100 Billboard Charts",
      "playlistId": "d3e8e8f3-0a4f-4b7d-9b6b-7e8f4e8e3a0f",
      "createdAt":  "1500240452",
    },
  },
  search.WithWaitForTasks(false),
  search.WithBatchSize(1000),
  search.WithHeaderParam("X-Algolia-User-ID", "*"),
)
if err != nil {
  // handle the eventual error
  panic(err)
}
List response = client.saveObjects(
  "INDEX_NAME",
  Arrays.asList(
    new HashMap() {
      {
        put("objectID", "1");
        put("visibility", "public");
        put("name", "Hot 100 Billboard Charts");
        put("playlistId", "d3e8e8f3-0a4f-4b7d-9b6b-7e8f4e8e3a0f");
        put("createdAt", "1500240452");
      }
    }
  ),
  false,
  1000,
  new RequestOptions().addExtraHeader("X-Algolia-User-ID", "*")
);
const response = await client.saveObjects(
  {
    indexName: 'playlists',
    objects: [
      {
        objectID: '1',
        visibility: 'public',
        name: 'Hot 100 Billboard Charts',
        playlistId: 'd3e8e8f3-0a4f-4b7d-9b6b-7e8f4e8e3a0f',
        createdAt: '1500240452',
      },
    ],
    waitForTasks: false,
    batchSize: 1000,
  },
  {
    headers: { 'X-Algolia-User-ID': '*' },
  },
);
var response =
  client.saveObjects(
    indexName = "INDEX_NAME",
    objects =
      listOf(
        buildJsonObject {
          put("objectID", JsonPrimitive("1"))
          put("visibility", JsonPrimitive("public"))
          put("name", JsonPrimitive("Hot 100 Billboard Charts"))
          put("playlistId", JsonPrimitive("d3e8e8f3-0a4f-4b7d-9b6b-7e8f4e8e3a0f"))
          put("createdAt", JsonPrimitive("1500240452"))
        }
      ),
    waitForTasks = false,
    batchSize = 1000,
    requestOptions = RequestOptions(headers = buildMap { put("X-Algolia-User-ID", "*") }),
  )
$response = $client->saveObjects(
    'INDEX_NAME',
    [
        ['objectID' => '1',
            'visibility' => 'public',
            'name' => 'Hot 100 Billboard Charts',
            'playlistId' => 'd3e8e8f3-0a4f-4b7d-9b6b-7e8f4e8e3a0f',
            'createdAt' => '1500240452',
        ],
    ],
    false,
    1000,
    [
        'headers' => [
            'X-Algolia-User-ID' => '*',
        ],
    ]
);
response = client.save_objects(
    index_name="INDEX_NAME",
    objects=[
        {
            "objectID": "1",
            "visibility": "public",
            "name": "Hot 100 Billboard Charts",
            "playlistId": "d3e8e8f3-0a4f-4b7d-9b6b-7e8f4e8e3a0f",
            "createdAt": "1500240452",
        },
    ],
    wait_for_tasks=False,
    batch_size=1000,
    request_options={
        "headers": loads("""{"X-Algolia-User-ID":"*"}"""),
    },
)
response = client.save_objects(
  "INDEX_NAME",
  [
    {
      objectID: "1",
      visibility: "public",
      name: "Hot 100 Billboard Charts",
      playlistId: "d3e8e8f3-0a4f-4b7d-9b6b-7e8f4e8e3a0f",
      createdAt: "1500240452"
    }
  ],
  false,
  1000,
  {:header_params => {"X-Algolia-User-ID" => "*"}}
)
val response = Await.result(
  client.saveObjects(
    indexName = "INDEX_NAME",
    objects = Seq(
      JObject(
        List(
          JField("objectID", JString("1")),
          JField("visibility", JString("public")),
          JField("name", JString("Hot 100 Billboard Charts")),
          JField("playlistId", JString("d3e8e8f3-0a4f-4b7d-9b6b-7e8f4e8e3a0f")),
          JField("createdAt", JString("1500240452"))
        )
      )
    ),
    waitForTasks = false,
    batchSize = 1000,
    requestOptions = Some(
      RequestOptions
        .builder()
        .withHeader("X-Algolia-User-ID", "*")
        .build()
    )
  ),
  Duration(100, "sec")
)
let response = try await client.saveObjects(
    indexName: "INDEX_NAME",
    objects: [[
        "objectID": "1",
        "visibility": "public",
        "name": "Hot 100 Billboard Charts",
        "playlistId": "d3e8e8f3-0a4f-4b7d-9b6b-7e8f4e8e3a0f",
        "createdAt": "1500240452",
    ]],
    waitForTasks: false,
    batchSize: 1000,
    requestOptions: RequestOptions(
        headers: ["X-Algolia-User-ID": "*"]
    )
)

Parameters

indexName
string
required
Name of the index to which to add records.
objects
IEnumerable<T>
required
Records to add.
T
type parameter
required
The model of your index’s records.
waitForTasks
bool
default:false
Whether to wait until all batch requests are done.
batchSize
int
default:1000
Number of records to process in one batch.
requestOptions
RequestOptions
Additional request options.
Last modified on March 11, 2026