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

# Stop A/B test

> Stop an A/B test.

export const Legacy = ({title, href}) => {
  return <Note>

    This page documents an earlier version of the API client.
    For the latest version, see <a href={href}>{title}</a>.

    </Note>;
};

<Legacy title="Stop an A/B test" href="/doc/libraries/sdk/methods/abtesting/stop-ab-test" />

**Required ACL:** `editSettings`

Marks the A/B test as stopped.
The test can't be restarted.
Index A resumes normal operation and receives all search requests.

## Examples

<CodeGroup>
  ```cs C# theme={"system"}
  AnalyticsClient analytics = new AnalyticsClient("YourApplicationID", "YourWriteAPIKey");
  analytics.StopABTest(42);

  // Asynchronous
  await analytics.StopABTestAsync(42);
  ```

  ```go Go theme={"system"}
  client := analytics.NewClient("YourApplicationID", "YourWriteAPIKey")
  res, err := client.StopABTest(42)
  ```

  ```java Java theme={"system"}
  AnalyticsClient analytics = 
  DefaultAnalyticsClient.create("YourApplicationID", "YourWriteAPIKey");

  StopAbTestResponse res = analytics.stopABTest(42);

  // Asynchronous
  CompletableFuture<StopAbTestResponse> res = analytics.stopABTestAsync(42);
  ```

  ```js JavaScript theme={"system"}
  const analytics = client.initAnalytics({
    // optional parameters
    region: 'de',
    appId: 'YourApplicationID',
    apiKey: 'YourWriteAPIKey',
  });
  analytics.stopABTest(42).then(({ abTestID }) => {
    console.log(abTestID);
  });
  ```

  ```kotlin Kotlin theme={"system"}
  clientAnalytics.stopABTest(ABTestID(42))
  ```

  ```php PHP theme={"system"}
  $analytics = AnalyticsClient::create(
    'YourApplicationID',
    'YourWriteAPIKey'
  );

  $analytics->stopABTest(42);
  ```

  ```python Python theme={"system"}
  analytics = AnalyticsClient.create(
      'YourApplicationID',
      'YourWriteAPIKey'
  )

  analytics.stop_ab_test(42)
  ```

  ```ruby Ruby theme={"system"}
  analytics = Algolia::Analytics::Client.create('YourApplicationID', 'YourWriteAPIKey')
  response = analytics.stop_ab_test(42)
  ```

  ```scala Scala theme={"system"}
  client.execute {
    stop abTest 42
  }
  ```

  ```swift Swift theme={"system"}
  analyticsClient.stopABTest(withID: 42) { result in
    if case .success(let response) = result {
      print("Response: \(response)")
    }
  }
  ```
</CodeGroup>

## Parameters

<ParamField body="abTestID" type="integer" required>
  The ID of the A/B test you want to stop.
</ParamField>

## Response

<ResponseField name="abTestID" type="integer">
  Generated ID of the A/B test.
</ResponseField>

<ResponseField name="index" type="string">
  Base index name for the A/B test.
</ResponseField>

<ResponseField name="taskID" type="integer">
  The task ID used with the [`waitTask`](/doc/libraries/sdk/v1/methods/wait-task) method.
</ResponseField>

### Response as JSON

This section shows the JSON response returned by the API.
Each API client wraps this response in language-specific objects, so the structure may vary.
To view the response, use the `getLogs` method.
Don't rely on the order of properties—JSON objects don't preserve key order.

```jsonc JSON icon=braces theme={"system"}
{
  "abTestID": 78,
  "taskID": 111885720
  "index": "atis-abtest-default",
}
```
