> ## Documentation Index
> Fetch the complete documentation index at: https://algolia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Save records with transformation

> Adds records to an index using the transformation pipeline.

**Required ACL:** `addObject`

Before using this method, [set up the transformation region](/doc/guides/sending-and-managing-data/send-and-update-your-data/connectors/push#set-up-the-transformation-region) on the search client.

To use this method, you must have only one [Push to Algolia](/doc/guides/sending-and-managing-data/send-and-update-your-data/connectors/push) connector.
The API returns a `400` error if you have more than one Push connector,
or you use [Collections](/doc/guides/solutions/ecommerce/browse/tutorials/collections) *and* a Push connector.

For more information, see [`WithTransformation` helper methods](/doc/guides/sending-and-managing-data/send-and-update-your-data/connectors/push#search-api-client-withtransformation-helper-methods).

This helper method creates [push tasks](/doc/rest-api/ingestion/push) with
the `addObject` action and sends these requests in batches of 1,000.

This method is subject to [indexing rate limits](https://support.algolia.com/hc/en-us/articles/4406975251089-Is-there-a-rate-limit-for-indexing-on-Algolia)
and [connector limits](/doc/guides/scaling/algolia-service-limits#connectors-limits).

## Usage

<CodeGroup>
  ```cs C# theme={"system"}
  var response = await client.SaveObjectsWithTransformationAsync(
    "INDEX_NAME",
    new List<Object>
    {
      new Dictionary<string, string> { { "objectID", "1" }, { "name", "Adam" } },
      new Dictionary<string, string> { { "objectID", "2" }, { "name", "Benoit" } },
    },
    true
  );
  ```

  ```dart Dart theme={"system"}
  final response = await client.saveObjectsWithTransformation(
    indexName: "INDEX_NAME",
    objects: [
      {
        'objectID': "1",
        'name': "Adam",
      },
      {
        'objectID': "2",
        'name': "Benoit",
      },
    ],
    waitForTasks: true,
  );
  ```

  ```go Go theme={"system"}
  response, err := client.SaveObjectsWithTransformation(
    "INDEX_NAME",
    []map[string]any{{"objectID": "1", "name": "Adam"}, {"objectID": "2", "name": "Benoit"}}, search.WithWaitForTasks(true))
  if err != nil {
    // handle the eventual error
    panic(err)
  }
  ```

  ```java Java theme={"system"}
  List response = client.saveObjectsWithTransformation(
    "INDEX_NAME",
    Arrays.asList(
      new HashMap() {
        {
          put("objectID", "1");
          put("name", "Adam");
        }
      },
      new HashMap() {
        {
          put("objectID", "2");
          put("name", "Benoit");
        }
      }
    ),
    true
  );
  ```

  ```js JavaScript theme={"system"}
  const response = await client.saveObjectsWithTransformation({
    indexName: 'cts_e2e_saveObjectsWithTransformation_javascript',
    objects: [
      { objectID: '1', name: 'Adam' },
      { objectID: '2', name: 'Benoit' },
    ],
    waitForTasks: true,
  });
  ```

  ```kotlin Kotlin theme={"system"}
  var response =
    client.saveObjectsWithTransformation(
      indexName = "INDEX_NAME",
      objects =
        listOf(
          buildJsonObject {
            put("objectID", JsonPrimitive("1"))
            put("name", JsonPrimitive("Adam"))
          },
          buildJsonObject {
            put("objectID", JsonPrimitive("2"))
            put("name", JsonPrimitive("Benoit"))
          },
        ),
      waitForTasks = true,
    )
  ```

  ```php PHP theme={"system"}
  $response = $client->saveObjectsWithTransformation(
      'INDEX_NAME',
      [
          ['objectID' => '1',
              'name' => 'Adam',
          ],

          ['objectID' => '2',
              'name' => 'Benoit',
          ],
      ],
      true,
  );
  ```

  ```python Python theme={"system"}
  response = client.save_objects_with_transformation(
      index_name="INDEX_NAME",
      objects=[
          {
              "objectID": "1",
              "name": "Adam",
          },
          {
              "objectID": "2",
              "name": "Benoit",
          },
      ],
      wait_for_tasks=True,
  )
  ```

  ```ruby Ruby theme={"system"}
  response = client.save_objects_with_transformation(
    "INDEX_NAME",
    [{objectID: "1", name: "Adam"}, {objectID: "2", name: "Benoit"}],
    true
  )
  ```

  ```scala Scala theme={"system"}
  val response = Await.result(
    client.saveObjectsWithTransformation(
      indexName = "INDEX_NAME",
      objects = Seq(
        JObject(List(JField("objectID", JString("1")), JField("name", JString("Adam")))),
        JObject(List(JField("objectID", JString("2")), JField("name", JString("Benoit"))))
      ),
      waitForTasks = true
    ),
    Duration(100, "sec")
  )
  ```

  ```swift Swift theme={"system"}
  let response = try await client.saveObjectsWithTransformation(
      indexName: "INDEX_NAME",
      objects: [["objectID": "1", "name": "Adam"], ["objectID": "2", "name": "Benoit"]],
      waitForTasks: true
  )
  ```
</CodeGroup>

## Parameters

<Tabs>
  <Tab title="Go">
    <ParamField body="indexName" type="string" required>
      Name of the index to save records to.
    </ParamField>

    <ParamField body="objects" type="[]map[string]any" required>
      Records to save.
    </ParamField>

    <ParamField body="opts..." type="ChunkedBatchOption">
      Functional options to provide extra arguments.

      <Expandable title="available functions">
        <ParamField body="search.WithWaitForTasks" type="function">
          **Signature:** `func(withWaitForTasks bool) chunkedBatchOption`

          Whether to wait until all batch requests are done.
        </ParamField>

        <ParamField body="search.WithBatchSize" type="function">
          **Signature:** `func(batchSize int) chunkedBatchOption`

          Sets the number of records to process in one batch.
          The default batch size is 1,000.
        </ParamField>

        <ParamField body="search.WithHeaderParam" type="function">
          **Signature:** `func(key string, value string) requestOption`

          Sets extra header parameters for this request.
          To learn more, see [request options](/doc/libraries/sdk/request-options).
        </ParamField>

        <ParamField body="search.WithQueryParam" type="function">
          **Signature:** `func(key string, value string) requestOption`

          Sets extra query parameters for this request.
          To learn more, see [request options](/doc/libraries/sdk/request-options).
        </ParamField>
      </Expandable>
    </ParamField>
  </Tab>

  <Tab title="Java">
    <ParamField body="indexName" type="String" required>
      Name of the index to save records to.
    </ParamField>

    <ParamField body="objects" type="Iterable<T>" required>
      Records to save.
    </ParamField>

    <ParamField body="T" type="Type parameter" required>
      The model of your index's records.
    </ParamField>

    <ParamField body="waitForTasks" type="boolean" default={false}>
      Whether to wait until all batch requests are done.
    </ParamField>

    <ParamField body="batchSize" type="int" default={1000}>
      Number of records to process in one batch.
    </ParamField>

    <ParamField body="requestOptions" type="RequestOptions">
      Additional [request options](/doc/libraries/sdk/request-options).
    </ParamField>
  </Tab>

  <Tab title="JavaScript">
    <ParamField body="indexName" type="string" required>
      Name of the index to save records to.
    </ParamField>

    <ParamField body="objects" type="Record<string,unknown>[]" required>
      Records to save.
    </ParamField>

    <ParamField body="waitForTasks" type="boolean" default={false}>
      Whether to wait until all batch requests are done.
    </ParamField>

    <ParamField body="batchSize" type="number" default={1000}>
      Number of records to process in one batch.
    </ParamField>

    <ParamField body="requestOptions" type="RequestOptions">
      Additional [request options](/doc/libraries/sdk/request-options).
    </ParamField>
  </Tab>

  <Tab title="PHP">
    <ParamField body="indexName" type="string" required>
      Name of the index to save records to.
    </ParamField>

    <ParamField body="objects" type="array" required>
      Records to save.
    </ParamField>

    <ParamField body="waitForTasks" type="bool" default={false}>
      Whether to wait until all batch requests are done.
    </ParamField>

    <ParamField body="batchSize" type="int" default={1000}>
      Number of records to process in one batch.
    </ParamField>

    <ParamField body="requestOptions" type="array">
      Additional [request options](/doc/libraries/sdk/request-options).
    </ParamField>
  </Tab>

  <Tab title="Python">
    <ParamField body="index_name" type="str" required>
      Name of the index to save records to.
    </ParamField>

    <ParamField body="objects" type="list[dict]" required>
      Records to save.
    </ParamField>

    <ParamField body="wait_for_tasks" type="bool" default={false}>
      Whether to wait until all batch requests are done.
    </ParamField>

    <ParamField body="batch_size" type="int" default={1000}>
      Number of records to process in one batch.
    </ParamField>

    <ParamField body="request_options" type="dict | RequestOptions">
      Additional [request options](/doc/libraries/sdk/request-options).
    </ParamField>
  </Tab>
</Tabs>
