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

# Capture a variant's settings and stop the A/B test

> Captures the settings of the given variant and of the control, then stops the A/B test.

**Required ACL:** `analytics`, `editSettings`

The captured settings can later be applied to the control index with the `applyVariantSettings` operation, and read back with the `getABTestSettings` operation.

The A/B test must have reached 80% of its planned duration. Earlier requests return `400`.

Settings can only be captured once per A/B test. A second request returns `409`.

`synonyms` and `enableRules` are not captured, so applying the captured settings never changes them on the control index.

## Usage

<CodeGroup>
  ```cs C# theme={"system"}
  // Initialize the client
  var client = new AbtestingV3Client(
    new AbtestingV3Config(
      "ALGOLIA_APPLICATION_ID",
      "ALGOLIA_API_KEY",
      "ALGOLIA_APPLICATION_REGION"
    )
  );

  // Call the API
  await client.SaveVariantSettingsAsync(
    42,
    2,
    new SaveSettingsRequest { SaveFeaturesSettings = true }
  );
  ```

  ```dart Dart theme={"system"}
  // Initialize the client
  final client = AbtestingV3Client(
      appId: 'ALGOLIA_APPLICATION_ID',
      apiKey: 'ALGOLIA_API_KEY',
      region: 'ALGOLIA_APPLICATION_REGION');

  // Call the API
  await client.saveVariantSettings(
    id: 42,
    variantId: 2,
    saveSettingsRequest: SaveSettingsRequest(
      saveFeaturesSettings: true,
    ),
  );
  ```

  ```go Go theme={"system"}
  // Initialize the client with your application region, eg. abtestingV3.ALGOLIA_APPLICATION_REGION
  client, err := abtestingV3.NewClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", abtestingV3.US)
  if err != nil {
    // The client can fail to initialize if you pass an invalid parameter.
    panic(err)
  }

  // Call the API
  err = client.SaveVariantSettings(client.NewApiSaveVariantSettingsRequest(
    42, 2,
    abtestingV3.NewEmptySaveSettingsRequest().SetSaveFeaturesSettings(true)))
  if err != nil {
    // handle the eventual error
    panic(err)
  }
  ```

  ```java Java theme={"system"}
  // Initialize the client
  AbtestingV3Client client = new AbtestingV3Client("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION");

  // Call the API
  client.saveVariantSettings(42, 2, new SaveSettingsRequest().setSaveFeaturesSettings(true));
  ```

  ```js JavaScript theme={"system"}
  // Initialize the client
  // Replace 'us' with your Algolia Application Region
  const client = algoliasearch('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY').initAbtestingV3({ region: 'us' });

  // Call the API
  await client.saveVariantSettings({ id: 42, variantId: 2, saveSettingsRequest: { saveFeaturesSettings: true } });
  ```

  ```kotlin Kotlin theme={"system"}
  // Initialize the client
  val client =
    AbtestingV3Client(
      appId = "ALGOLIA_APPLICATION_ID",
      apiKey = "ALGOLIA_API_KEY",
      region = "ALGOLIA_APPLICATION_REGION",
    )

  // Call the API
  client.saveVariantSettings(
    id = 42,
    variantId = 2,
    saveSettingsRequest = SaveSettingsRequest(saveFeaturesSettings = true),
  )
  ```

  ```php PHP theme={"system"}
  // Initialize the client
  $client = AbtestingV3Client::create('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY', 'ALGOLIA_APPLICATION_REGION');

  // Call the API
  $client->saveVariantSettings(
      42,
      2,
      ['saveFeaturesSettings' => true,
      ],
  );
  ```

  ```python Python theme={"system"}
  # Initialize the client
  # In an asynchronous context, you can use AbtestingV3Client instead, which exposes the exact same methods.
  client = AbtestingV3ClientSync(
      "ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION"
  )

  # Call the API
  client.save_variant_settings(
      id=42,
      variant_id=2,
      save_settings_request={
          "saveFeaturesSettings": True,
      },
  )
  ```

  ```ruby Ruby theme={"system"}
  # Initialize the client
  client = Algolia::AbtestingV3Client.create("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION")

  # Call the API
  client.save_variant_settings(42, 2, Algolia::AbtestingV3::SaveSettingsRequest.new(save_features_settings: true))
  ```

  ```scala Scala theme={"system"}
  // Initialize the client
  val client = AbtestingV3Client(
    appId = "ALGOLIA_APPLICATION_ID",
    apiKey = "ALGOLIA_API_KEY",
    region = Option("ALGOLIA_APPLICATION_REGION")
  )

  // Call the API
  Await.result(
    client.saveVariantSettings(
      id = 42,
      variantId = 2,
      saveSettingsRequest = SaveSettingsRequest(
        saveFeaturesSettings = Some(true)
      )
    ),
    Duration(100, "sec")
  )
  ```

  ```swift Swift theme={"system"}
  // Initialize the client
  let client = try AbtestingV3Client(appID: "ALGOLIA_APPLICATION_ID", apiKey: "ALGOLIA_API_KEY", region: .us)

  // Call the API
  try await client.saveVariantSettings(
      id: 42,
      variantId: 2,
      saveSettingsRequest: SaveSettingsRequest(saveFeaturesSettings: true)
  )
  ```
</CodeGroup>

<Card icon="folder-code" horizontal="true" title="See the full API reference" arrow="true" href="/doc/rest-api/abtesting-v3/save-variant-settings">
  For more details about input parameters
  and response fields.
</Card>
