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

# userData

> Custom data

export const Setting = ({type, default: defaultValue, defaultNote, scope, min, max, formerly}) => {
  const renderedDefault = defaultValue === '' ? '""' : defaultValue;
  const renderedNote = defaultNote ? `(${defaultNote})` : '';
  return <ul>
      <li><strong>Type:</strong> <code>{type}</code></li>
      <li><strong>Default:</strong> <code>{renderedDefault}</code>{renderedNote}</li>
      {min && <li><strong>Min:</strong> <code>{min}</code></li>}
      {max && <li><strong>Max:</strong> <code>{max}</code></li>}
      <li><strong>Scope:</strong> <a href="/doc/api-reference/api-parameters"><code>{scope}</code></a></li>
      {formerly && <li>
          <strong>Deprecated name:</strong> <code>{formerly}</code>
        </li>}
    </ul>;
};

<Setting type="object" default="{}" scope="settings" />

The `userData` object lets you store custom data in your index settings.

## Usage

* The object must be serializable as JSON.
* You can store up to 32 kB. Larger objects may break your search.
* To access previously stored `userData`, use the [`getSettings`](/doc/rest-api/search/get-settings) method.

## Example

<AccordionGroup>
  <Accordion title="Current API clients" defaultOpen="true">
    <CodeGroup>
      ```cs C# theme={"system"}
      var response = await client.SetSettingsAsync(
        "INDEX_NAME",
        new IndexSettings
        {
          UserData = new Dictionary<string, object>
          {
            { "extraData", "This is the custom data that you want to store in your index" },
          },
        }
      );
      ```

      ```dart Dart theme={"system"}
      final response = await client.setSettings(
        indexName: "INDEX_NAME",
        indexSettings: IndexSettings(
          userData: {
            'extraData':
                'This is the custom data that you want to store in your index',
          },
        ),
      );
      ```

      ```go Go theme={"system"}
      response, err := client.SetSettings(client.NewApiSetSettingsRequest(
        "INDEX_NAME",
        search.NewEmptyIndexSettings().SetUserData(map[string]any{"extraData": "This is the custom data that you want to store in your index"})))
      if err != nil {
        // handle the eventual error
        panic(err)
      }
      ```

      ```java Java theme={"system"}
      UpdatedAtResponse response = client.setSettings(
        "INDEX_NAME",
        new IndexSettings().setUserData(
          new HashMap() {
            {
              put("extraData", "This is the custom data that you want to store in your index");
            }
          }
        )
      );
      ```

      ```js JavaScript theme={"system"}
      const response = await client.setSettings({
        indexName: 'theIndexName',
        indexSettings: { userData: { extraData: 'This is the custom data that you want to store in your index' } },
      });
      ```

      ```kotlin Kotlin theme={"system"}
      var response =
        client.setSettings(
          indexName = "INDEX_NAME",
          indexSettings =
            IndexSettings(
              userData =
                buildJsonObject {
                  put("extraData", "This is the custom data that you want to store in your index")
                }
            ),
        )
      ```

      ```php PHP theme={"system"}
      $response = $client->setSettings(
          'INDEX_NAME',
          ['userData' => ['extraData' => 'This is the custom data that you want to store in your index'],
          ],
      );
      ```

      ```python Python theme={"system"}
      response = client.set_settings(
          index_name="INDEX_NAME",
          index_settings={
              "userData": {
                  "extraData": "This is the custom data that you want to store in your index"
              },
          },
      )
      ```

      ```ruby Ruby theme={"system"}
      response = client.set_settings(
        "INDEX_NAME",
        Algolia::Search::IndexSettings.new(
          user_data: {:"extraData" => "This is the custom data that you want to store in your index"}
        )
      )
      ```

      ```scala Scala theme={"system"}
      val response = Await.result(
        client.setSettings(
          indexName = "INDEX_NAME",
          indexSettings = IndexSettings(
            userData = Some(
              JObject(
                List(
                  JField("extraData", JString("This is the custom data that you want to store in your index"))
                )
              )
            )
          )
        ),
        Duration(100, "sec")
      )
      ```

      ```swift Swift theme={"system"}
      let response = try await client.setSettings(
          indexName: "INDEX_NAME",
          indexSettings: IndexSettings(
              userData: ["extraData": "This is the custom data that you want to store in your index"]
          )
      )
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Legacy API clients">
    <CodeGroup>
      ```cs C# theme={"system"}
      var extraData =  new Object { extraData= "This is the custom data that you want to store in your index"};
      IndexSettings settings = new IndexSettings();
      settings.UserData = extraData;

      index.SetSettings(settings);
      ```

      ```go Go theme={"system"}
      userData := opt.UserData(map[string]interface{}{
      	"extraData": "This is the custom data that you want to sore in your index",
      })

      res, err := index.SetSettings(search.Settings{
      	UserData: userData,
      })
      ```

      ```java Java theme={"system"}
      index.setSettings(
        new IndexSettings()
          .setUserData( new HashMap() {
          {
            put("UserDataKey", "This is the custom data that you want to store in your index");
          }
        });
      ```

      ```js JavaScript theme={"system"}
      index
        .setSettings({
          userData: {
            extraData: "This is the custom data that you want to store in your index",
          },
        })
        .then(() => {
          // done
        });
      ```

      ```kotlin Kotlin theme={"system"}
      val settings = settings {
          userData = (json { "extraData" to "This is the custom data you want to store in your index"})
      }

      index.setSettings(settings)
      ```

      ```php PHP theme={"system"}
      $index->setSettings([
        'userData' =>   [
          'extraData' => 'This is the custom data that you want to store in your index',
         ]
      ]);
      ```

      ```python Python theme={"system"}
      index.set_settings(
          {
              "userData": {
                  "extra_data": "This is the custom data that you want to store in your index"
              }
          }
      )
      ```

      ```ruby Ruby theme={"system"}
      index.set_settings(
        {
          userData: {
            extraData: "This is the custom data that you want to store in your index"
          }
        }
      )
      ```

      ```scala Scala theme={"system"}
      val customData = Some(Map(
        "extraData" -> "This is the custom data that you want to store in your index"
      ))

      client.execute {
        setSettings of "myIndex" `with` IndexSettings(
          userData = customData
        )
      }
      ```

      ```swift Swift theme={"system"}
      let settings = Settings()
        .set(\.userData, to: ["extraData": "This is the custom data you want to store in your index"])

      index.setSettings(settings) { result in
        if case .success(let response) = result {
          print("Response: \(response)")
        }
      }
      ```
    </CodeGroup>
  </Accordion>
</AccordionGroup>
