Create an A/B test

Creates a new A/B test.

Usage

Required ACL: editSettings
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
using Algolia.Search.Clients;
using Algolia.Search.Http;
using Algolia.Search.Models.AbtestingV3;

var client = new AbtestingV3Client(
  new AbtestingV3Config(
    "ALGOLIA_APPLICATION_ID",
    "ALGOLIA_API_KEY",
    "ALGOLIA_APPLICATION_REGION"
  )
);

var response = await client.AddABTestsAsync(
  new AddABTestsRequest
  {
    EndAt = "2022-12-31T00:00:00.000Z",
    Name = "myABTest",
    Metrics = new List<CreateMetric> { new CreateMetric { Name = "myMetric" } },
    Variants = new List<AddABTestsVariant>
    {
      new AddABTestsVariant(new AbTestsVariant { Index = "AB_TEST_1", TrafficPercentage = 30 }),
      new AddABTestsVariant(new AbTestsVariant { Index = "AB_TEST_2", TrafficPercentage = 50 }),
    },
  }
);
Did you find this page helpful?