// Initialize the client
var client = new AbtestingClient(
new AbtestingConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION")
);
// Call the API
var response = await client.AddABTestsAsync(
new AddABTestsRequest
{
EndAt = "2022-12-31T00:00:00.000Z",
Name = "myABTest",
Variants = new List<AddABTestsVariant>
{
new AddABTestsVariant(new AbTestsVariant { Index = "AB_TEST_1", TrafficPercentage = 30 }),
new AddABTestsVariant(new AbTestsVariant { Index = "AB_TEST_2", TrafficPercentage = 50 }),
},
}
);
// print the response
Console.WriteLine(response);
// Initialize the client with your application region, eg. abtesting.ALGOLIA_APPLICATION_REGION
client, err := abtesting.NewClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", abtesting.US)
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err := client.AddABTests(client.NewApiAddABTestsRequest(
abtesting.NewEmptyAddABTestsRequest().SetEndAt("2022-12-31T00:00:00.000Z").SetName("myABTest").SetVariants(
[]abtesting.AddABTestsVariant{*abtesting.AbTestsVariantAsAddABTestsVariant(
abtesting.NewEmptyAbTestsVariant().SetIndex("AB_TEST_1").SetTrafficPercentage(30)), *abtesting.AbTestsVariantAsAddABTestsVariant(
abtesting.NewEmptyAbTestsVariant().SetIndex("AB_TEST_2").SetTrafficPercentage(50))})))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)
// Initialize the client
AbtestingClient client = new AbtestingClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION");
// Call the API
ABTestResponse response = client.addABTests(
new AddABTestsRequest()
.setEndAt("2022-12-31T00:00:00.000Z")
.setName("myABTest")
.setVariants(
Arrays.asList(
new AbTestsVariant().setIndex("AB_TEST_1").setTrafficPercentage(30),
new AbTestsVariant().setIndex("AB_TEST_2").setTrafficPercentage(50)
)
)
);
// print the response
System.out.println(response);
// Initialize the client
// Replace 'us' with your Algolia Application Region
const client = algoliasearch('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY').initAbtesting({ region: 'us' });
// Call the API
const response = await client.addABTests({
endAt: '2022-12-31T00:00:00.000Z',
name: 'myABTest',
variants: [
{ index: 'AB_TEST_1', trafficPercentage: 30 },
{ index: 'AB_TEST_2', trafficPercentage: 50 },
],
});
// print the response
console.log(response);
// Initialize the client
val client =
AbtestingClient(
appId = "ALGOLIA_APPLICATION_ID",
apiKey = "ALGOLIA_API_KEY",
region = "ALGOLIA_APPLICATION_REGION",
)
// Call the API
var response =
client.addABTests(
addABTestsRequest =
AddABTestsRequest(
endAt = "2022-12-31T00:00:00.000Z",
name = "myABTest",
variants =
listOf(
AbTestsVariant(index = "AB_TEST_1", trafficPercentage = 30),
AbTestsVariant(index = "AB_TEST_2", trafficPercentage = 50),
),
)
)
// print the response
println(response)
// Initialize the client
var client = new AbtestingClient(
new AbtestingConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION")
);
// Call the API
var response = await client.AddABTestsAsync(
new AddABTestsRequest
{
EndAt = "2022-12-31T00:00:00.000Z",
Name = "myABTest",
Variants = new List<AddABTestsVariant>
{
new AddABTestsVariant(new AbTestsVariant { Index = "AB_TEST_1", TrafficPercentage = 30 }),
new AddABTestsVariant(new AbTestsVariant { Index = "AB_TEST_2", TrafficPercentage = 50 }),
},
}
);
// print the response
Console.WriteLine(response);
// Initialize the client with your application region, eg. abtesting.ALGOLIA_APPLICATION_REGION
client, err := abtesting.NewClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", abtesting.US)
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err := client.AddABTests(client.NewApiAddABTestsRequest(
abtesting.NewEmptyAddABTestsRequest().SetEndAt("2022-12-31T00:00:00.000Z").SetName("myABTest").SetVariants(
[]abtesting.AddABTestsVariant{*abtesting.AbTestsVariantAsAddABTestsVariant(
abtesting.NewEmptyAbTestsVariant().SetIndex("AB_TEST_1").SetTrafficPercentage(30)), *abtesting.AbTestsVariantAsAddABTestsVariant(
abtesting.NewEmptyAbTestsVariant().SetIndex("AB_TEST_2").SetTrafficPercentage(50))})))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)
// Initialize the client
AbtestingClient client = new AbtestingClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION");
// Call the API
ABTestResponse response = client.addABTests(
new AddABTestsRequest()
.setEndAt("2022-12-31T00:00:00.000Z")
.setName("myABTest")
.setVariants(
Arrays.asList(
new AbTestsVariant().setIndex("AB_TEST_1").setTrafficPercentage(30),
new AbTestsVariant().setIndex("AB_TEST_2").setTrafficPercentage(50)
)
)
);
// print the response
System.out.println(response);
// Initialize the client
// Replace 'us' with your Algolia Application Region
const client = algoliasearch('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY').initAbtesting({ region: 'us' });
// Call the API
const response = await client.addABTests({
endAt: '2022-12-31T00:00:00.000Z',
name: 'myABTest',
variants: [
{ index: 'AB_TEST_1', trafficPercentage: 30 },
{ index: 'AB_TEST_2', trafficPercentage: 50 },
],
});
// print the response
console.log(response);
// Initialize the client
val client =
AbtestingClient(
appId = "ALGOLIA_APPLICATION_ID",
apiKey = "ALGOLIA_API_KEY",
region = "ALGOLIA_APPLICATION_REGION",
)
// Call the API
var response =
client.addABTests(
addABTestsRequest =
AddABTestsRequest(
endAt = "2022-12-31T00:00:00.000Z",
name = "myABTest",
variants =
listOf(
AbTestsVariant(index = "AB_TEST_1", trafficPercentage = 30),
AbTestsVariant(index = "AB_TEST_2", trafficPercentage = 50),
),
)
)
// print the response
println(response)
Your Algolia API key with the necessary permissions to make the request.
Permissions are controlled through access control lists (ACL) and access restrictions.
The required ACL to make a request is listed in each endpoint's reference.
A successful API response means that a task was added to a queue.
It might not run immediately.
You can check the task's progress with the task operation and this task ID.
Example:
1514562690001
Last modified on September 9, 2026
Was this page helpful?
{"docsConfig":{"theme":"aspen","$schema":"https://mintlify.com/docs.json","name":"Algolia","description":"Build search, discovery, and AI experiences with Algolia. Guides, API references, libraries, UI components, and integrations for your stack.","colors":{"primary":"#3970ff","light":"#3970ff","dark":"#003DFF"},"logo":{"light":"https://mintcdn.com/algolia/kiecJp3hu-WXhj-3/logo/light.svg?fit=max\u0026auto=format\u0026n=kiecJp3hu-WXhj-3\u0026q=85\u0026s=bf613e260ca94c0eb23384e6c0d5c77f","dark":"https://mintcdn.com/algolia/kiecJp3hu-WXhj-3/logo/dark.svg?fit=max\u0026auto=format\u0026n=kiecJp3hu-WXhj-3\u0026q=85\u0026s=31a97f60063c111253c518bc0c638e70","href":"/doc"},"favicon":"https://mintcdn.com/algolia/ApgdWRCFtd9v2oPX/favicon.png?fit=max\u0026auto=format\u0026n=ApgdWRCFtd9v2oPX\u0026q=85\u0026s=91df7c93abadfb122ffc8e0f78cc2dc8","api":{"playground":{"display":"simple"},"examples":{"languages":["curl","csharp","dart","go","java","javascript","kotlin","php","python","ruby","scala","swift"],"autogenerate":false}},"navbar":{"links":[{"href":"https://dashboard.algolia.com/users/sign_in","label":"Log in"}],"primary":{"type":"button","label":"Create account","href":"https://www.algolia.com/users/sign_up"}},"footer":{"socials":{"linkedin":"https://www.linkedin.com/company/algolia","x":"https://twitter.com/algolia","discord":"https://alg.li/discord","youtube":"https://www.youtube.com/channel/UCTNkiq-SO8hay1PRx-it9Cw","website":"https://www.algolia.com"},"links":[{"items":[{"label":"Support","href":"https://support.algolia.com/hc/en-us"},{"label":"Glossary","href":"/doc/glossary"},{"label":"Privacy policy","href":"https://www.algolia.com/policies/privacy"},{"label":"Cookie settings","href":"https://www.algolia.com"}]}]},"seo":{"metatags":{"canonical":"https://www.algolia.com"},"organization":{"id":"https://www.algolia.com/#organization","name":"Algolia","url":"https://www.algolia.com","sameAs":["https://www.linkedin.com/company/algolia/","https://github.com/algolia","https://x.com/algolia","https://www.youtube.com/channel/UCTNkiq-SO8hay1PRx-it9Cw"]}},"fonts":{"heading":{"family":"Sora"}},"icons":{"library":"lucide"},"styling":{"eyebrows":"section","codeblocks":"system","latex":true},"integrations":{"segment":{"key":"cKQbv9nMHIUgdWswDLG0c3UdiUgBaUmA"}},"contextual":{"options":["copy","view","chatgpt","claude","perplexity"],"display":"header"},"metadata":{"timestamp":true},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"algolia","hasAudioNarration":false,"actualSubdomain":"algolia","customDomains":["www.algolia.com"],"gitSource":{"type":"github","owner":"algolia","repo":"docs-new","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"feedback":{"thumbs":true,"edits":true,"issues":true,"agentFeedback":false},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"REMOVE_BRANDING":{"status":"ENABLED"},"CONTEXTUAL_FEEDBACK":{"status":"ENABLED"},"CODE_SNIPPET_FEEDBACK":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6af6d147a1481bb7e0cfcbe3","clientVersion":"0.0.4124","searchFilterCounts":[{"language":"default","tag":"Libraries and tools","count":618},{"language":"default","tag":"Guides","count":584},{"language":"default","tag":"API clients","count":407},{"language":"default","tag":"Search and Discovery platform","count":406},{"language":"default","tag":"API reference","count":403},{"language":"default","tag":"UI libraries","count":290},{"language":"default","tag":"Reference","count":282},{"language":"default","tag":"Build Search UI","count":235},{"language":"default","tag":"Search","count":187},{"language":"default","tag":"React InstantSearch","count":169}]},"assistantConfig":{},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":true},"customCss":[{"filePath":"style.css","content":":root{--radius: 0.5rem;--rounded-2xl: var(--radius);--rounded-xl: var(--radius);--rounded-lg: var(--radius);--rounded-md: var(--radius);--rounded-full: var(--radius);--icon-stroke: #000000;--border-color: rgb(var(--gray-200) / 0.5);--font-weight-headings-custom: 700;--docsearch-background-color: #f5f6f7;--filters-token-string-color: #b46900;--filters-token-error-color: #d7263d;--filters-token-paren-color: #005cc5;--filters-token-num-color: #6f42c1;--filters-token-operator-color: #22863a;--docsearch-sidepanel-border: var(--border-color);--docsearch-sidepanel-background: rgb(244, 246, 250);--docsearch-sidepanel-background-dark: #fff;--docsearch-hit-background-muted: rgb(247, 247, 248);--docsearch-searchbox-focus-background: #fff}:root.dark,html[data-theme=dark]{--icon-stroke: #ffffff;--border-color: rgb(var(--gray-900) / 0.8);--docsearch-background-color: #0a0b11 !important;--docsearch-dropdown-menu-background: #10121e;--docsearch-dropdown-menu-item-hover-background: #0a0b11;--docsearch-hit-color: #e5e7eb;--filters-token-string-color: #ffa657;--filters-token-error-color: #ff6b6b;--filters-token-paren-color: #79c0ff;--filters-token-num-color: #d2a8ff;--filters-token-operator-color: #7ee787;--docsearch-sidepanel-background: rgb(15, 17, 23);--docsearch-sidepanel-background-dark: rgba(11, 13, 17, 1);--docsearch-hit-background-muted: rgb(14, 17, 23);--docsearch-modal-background: #0a0b11;--docsearch-hit-focus-background: rgb(var(--gray-900))}.rounded-\\[0\\.85rem\\]{border-radius:var(--radius)}#banner{background-color:#23263b}#banner a{color:inherit}#background-div{background-color:#f6f6fa}.dark #background-div{background-color:#ffffff;opacity:0.03}#pagination{display:none}.background-lines{fill:#c5c9e0}.dark .background-lines{fill:#ffffff;fill-opacity:0.15}th{text-align:left}.tooltip{user-select:text}.prose a{font-weight:inherit}.prose a strong{font-weight:600}.katex-display>.katex{overflow-y:hidden}.prose a.link[href^=\"http\"]:not([href^=\"https://www.algolia.com/doc\"]){white-space:nowrap}.prose a.link[href^=\"http\"]:not([href^=\"https://www.algolia.com/doc\"])::after{display:inline-block;width:14px;height:14px;margin-left:4px;vertical-align:-2px;content:\"\";background-color:currentColor;-webkit-mask:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E\u003cpath d='M15 3h6v6'/%3E\u003cpath d='M10 14 21 3'/%3E\u003cpath d='M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6'/%3E%3C/svg%3E\") center / contain no-repeat;mask:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E\u003cpath d='M15 3h6v6'/%3E\u003cpath d='M10 14 21 3'/%3E\u003cpath d='M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6'/%3E%3C/svg%3E\") center / contain no-repeat}.prose h2 code,.prose h3 code,.prose h4 code{font-weight:700}.prose table a code{word-break:keep-all}[data-component-part=\"field-content\"]{margin-left:1.5rem}[data-component-part=\"code-block-root\"]{border-radius:var(--radius)}#content-area img{margin-inline:auto;background:transparent!important}#content-area img:not(.no-shadow){box-shadow:0 10px 15px -3px rgb(0 0 0 / 0.1),\n 0 4px 6px -4px rgb(0 0 0 / 0.1)}#content-area video{margin-inline:auto}.video-embed{display:block;width:100%;min-width:0;max-width:var(--video-embed-max-width, 644px);aspect-ratio:16 / 9;height:auto;margin-inline:auto}button+div[aria-hidden=\"true\"]{background-color:#23263b;border-radius:var(--radius);box-shadow:0 0 0 1px #23263b0d, 0 4px 8px -2px #23263b40;color:#fff;padding:.5rem .75rem}#feedback-toolbar button{border-radius:var(--radius)}html.no-overflow{overflow:hidden}body.DocSearch--active{overflow:initial!important}.DocSearch-Container{visibility:hidden;opacity:0;transition:opacity 120ms ease;padding-top:5vh;position:fixed;top:0;left:0;right:0;bottom:0;background-color:rgba(0, 0, 0, 0.1);display:flex;align-items:flex-start;justify-content:center;z-index:200;cursor:initial}.DocSearch-Container.docsearch-ready{visibility:visible;opacity:1}.dark .DocSearch-Form,.dark .DocSearch-SearchBar{background-color:transparent!important}.DocSearch-Dropdown{border-top:1px solid var(--docsearch-subtle-color);scrollbar-color:#9698c3 #f5f6f7;scrollbar-width:thin}.dark .DocSearch-Container{--docsearch-text-color: #c4c7dc}.dark .DocSearch-Dropdown{scrollbar-color:#7f8497 #15172a}.dark .DocSearch-Close{color:#5172FF}.dark .DocSearch-Close svg{color:#5172FF}.dark .DocSearch-MagnifierLabel svg{color:#5172FF}.DocSearch-SidepanelButton.floating{display:none}.dark .DocSearch-Dropdown{border-color:#212139}.dark .DocSearch-Divider{border-color:#212139}.dark .DocSearch-Input{color:white;caret-color:white}.dark .DocSearch-Container{background-color:rgba(0, 0, 0, 0.6)!important}.dark .DocSearch-SearchBar,.dark .DocSearch-Form,.dark .DocSearch-Input{color:#ffffff!important}.dark .DocSearch-Input::placeholder{color:#ffffff!important;opacity:0.9}.dark .DocSearch-Reset,.dark .DocSearch-Reset span,.dark .DocSearch-Reset svg,.dark .DocSearch-Close,.dark .DocSearch-Close svg{color:#5172ff!important;fill:#5172ff!important;stroke:#5172ff!important}.dark .DocSearch-Cancel,.dark .DocSearch-Cancel svg{color:#ffffff!important;fill:#ffffff!important;stroke:#ffffff!important}.dark .DocSearch-MagnifierLabel,.dark .DocSearch-MagnifierLabel svg{color:#5172ff!important;fill:#5172ff!important;stroke:#5172ff!important}.dark .DocSearch-Dropdown{background-color:#0a0b11!important}.dark .DocSearch-Hits mark{background-color:transparent!important;color:#7aa2ff!important}.dark .DocSearch-Hit a{color:#e5e7eb!important;border-color:#1b1e29!important}.dark .DocSearch-Hit[aria-selected=true] .DocSearch-Hit-action,.dark .DocSearch-Hit[aria-selected=true] .DocSearch-Hit-icon{color:#7aa2ff}.dark .DocSearch-Title,.dark .DocSearch-Label{background-color:#0f1117!important}.dark .DocSearch-Title,.dark .DocSearch-Label,.dark .DocSearch-Hit-source{color:#e5e7eb!important}.dark .DocSearch-Footer{background-color:#0f1117!important;border-top:1px solid #1b1e29!important;color:#cbd5e1!important}.DocSearch-Hit--AskAI .DocSearch-AskAiScreen-Response .DocSearch-AskAiScreen-RelatedSources-Item-Link{background:var(--docsearch-hit-background-muted)!important}.DocSearch-Hit-AskAIButton-title-query{color:var(--docsearch-highlight-color)}.dark .DocSearch-Hit-AskAIButton-title-query{color:#7aa2ff!important}.dark .DocSearch-AskAiScreen-Response{color:#f5f6f7!important}.dark .DocSearch-Markdown-Content,.dark .DocSearch-Markdown-Content li{color:#cbd5e1!important}.dark .DocSearch-Markdown-Content a{color:#7aa2ff!important}.dark .DocSearch-AskAiScreen-RelatedSources-Item-Link{color:#cbd5e1}.dark .DocSearch-AskAiScreen-Response .DocSearch-CodeSnippet .DocSearch-CodeSnippet-CopyButton{background-color:#0f1117!important;color:#cbd5e1!important}.dark .DocSearch-AskAiScreen-Response .DocSearch-CodeSnippet pre{background-color:#0f1117!important;color:#e5e7eb!important}.dark .DocSearch-AskAiScreen-Response .DocSearch-CodeSnippet pre code{background-color:transparent!important;color:inherit!important}.DocSearch-Modal{position:relative;overflow:hidden;width:700px;max-width:90vw;border-radius:var(--radius);box-shadow:0 4px 12px rgba(0, 0, 0, 0.15)}.docsearch-expanded .DocSearch-Modal{max-height:auto;border-radius:var(--radius);box-shadow:0 25px 50px -12px rgba(0, 0, 0, 0.25)}@media (max-width: 768px){.DocSearch-Container{padding-top:0}.DocSearch-Modal{width:100vw;max-width:100vw;border-radius:var(--radius)}.docsearch-expanded .DocSearch-Modal{max-height:100vh;border-radius:var(--radius)}.DocSearch-Dropdown{height:calc(100vh - var(--docsearch-footer-height) - var(--docsearch-searchbox-height, var(--docsearch-searchbox-initial-height)))}.docsearch-sidepanel-toggle .docsearch-sidepanel-label,.docsearch-sidepanel-toggle .docsearch-sidepanel-shortcut{display:none}.docsearch-sidepanel-toggle{padding:0 0.5rem}}@media (min-width: 769px){.docsearch-sidepanel-toggle{border:1px solid transparent;box-shadow:0 0 0 1px rgba(156, 163, 175, 0.3)}.docsearch-sidepanel-toggle:hover{box-shadow:0 0 0 1px rgba(75, 85, 99, 0.3)}html.dark .docsearch-sidepanel-toggle{box-shadow:0 0 0 1px rgba(75, 85, 99, 0.3)}html.dark .docsearch-sidepanel-toggle:hover{box-shadow:0 0 0 1px rgba(107, 114, 128, 0.3)}}.DocSearch-Sidepanel-Header{height:3.0rem}.DocSearch-Sidepanel-Container.inline.side-right{border-bottom-left-radius:0;border-left:1px solid var(--docsearch-sidepanel-border);border-top-left-radius:0}.DocSearch-Sidepanel-Container{box-shadow:none}.DocSearch-MCP-Callout{font-size:0.875em;display:flex;align-items:center;gap:0.25rem;color:var(--docsearch-text-color);padding-inline:0.25rem 0.5rem;padding-block:0.25rem;border-radius:var(--docsearch-border-radius);background-color:var(--docsearch-hit-focus-background);min-block-size:1.5rem}.DocSearch-MCP-Callout:hover,.DocSearch-MCP-Callout:focus-visible{outline:2px solid var(--docsearch-highlight-color)}.DocSearch-MCP-Callout svg{height:1rem;width:1rem;color:var(--docsearch-highlight-color);margin-block-start:1px}html.dark #filter-validator{background-color:var(--shiki-dark-bg)}#filter-validator{.Token_EOF {\n color: transparent;\n }\n\n .Token_Empty_Str,\n .Token_Incomplete_Str,\n .Token_String,\n .Token_Term {\n color: var(--filters-token-string-color);\n }\n\n .Token_Error {\n color: var(--filters-token-error-color);\n }\n\n .Token_Open_Paren,\n .Token_Close_Paren,\n .Token_Open_Angled_Bracket,\n .Token_Close_Angled_Bracket,\n .Token_Comma,\n .Token_Facet_Separator {\n color: var(--filters-token-paren-color);\n }\n\n .Token_Num {\n color: var(--filters-token-num-color);\n }\n\n .Token_OR,\n .Token_AND,\n .Token_NOT,\n .Token_Operator,\n .Token_Range {\n color: var(--filters-token-operator-color);\n }}.nav-tag-pill-text{text-transform:uppercase;letter-spacing:1px}[data-group-tag]>button>div{display:flex;align-items:center;gap:0.5rem}.steps .step .prose ol{list-style-type:lower-alpha}.no-bullets ul{margin-top:1rem;padding-left:0;margin-left:0;list-style:none}@layer components{.prose .no-bullets li{margin:0.5rem 0;margin-left:0!important;padding-left:0!important;list-style:none}}.no-bullets a.link{border-bottom-color:transparent}.no-bullets a.link:hover,.no-bullets a.link:focus-visible{border-bottom-color:rgb(57, 112, 255)}.no-bullets li::before{content:none!important}.homepage-hero{background-color:#23263b;background-image:linear-gradient(\n 90deg,\n rgba(12, 30, 69, 0.82) 0%,\n rgba(12, 30, 69, 0.72) 34%,\n rgba(12, 30, 69, 0.58) 58%,\n rgba(12, 30, 69, 0.44) 100%\n ),\n url(\"/mintlify-assets/hero.png\");background-position:center, 72% center;background-repeat:no-repeat;background-size:cover}@supports (background-image: image-set(url(\"/mintlify-assets/hero.webp\") type(\"image/webp\") 1x)){.homepage-hero{background-image:linear-gradient(\n 90deg,\n rgba(12, 30, 69, 0.82) 0%,\n rgba(12, 30, 69, 0.72) 34%,\n rgba(12, 30, 69, 0.58) 58%,\n rgba(12, 30, 69, 0.44) 100%\n ),\n image-set(\n url(\"/mintlify-assets/hero.webp\") type(\"image/webp\") 1x,\n url(\"/mintlify-assets/hero.png\") type(\"image/png\") 1x\n )}}@supports (background-image: -webkit-image-set(url(\"/mintlify-assets/hero.webp\") type(\"image/webp\") 1x)){.homepage-hero{background-image:linear-gradient(\n 90deg,\n rgba(12, 30, 69, 0.82) 0%,\n rgba(12, 30, 69, 0.72) 34%,\n rgba(12, 30, 69, 0.58) 58%,\n rgba(12, 30, 69, 0.44) 100%\n ),\n -webkit-image-set(\n url(\"/mintlify-assets/hero.webp\") type(\"image/webp\") 1x,\n url(\"/mintlify-assets/hero.png\") type(\"image/png\") 1x\n )}}.homepage-hero-cta{display:inline-flex;align-items:center;justify-content:center;gap:0;padding:0.5rem 0.875rem;border-radius:var(--radius);background:linear-gradient(220deg, rgb(69, 122, 255) 0%, rgb(30, 89, 255) 60.16%);color:#fff!important;font-family:Sora, sans-serif;font-size:0.875rem;font-weight:700;line-height:1.5rem;letter-spacing:0.28px;text-decoration:none;transition:all 150ms ease}.homepage-hero-cta:hover{background:linear-gradient(138deg, rgba(118, 160, 255, 0.7) 0%, rgba(0, 61, 255, 0.7) 25.08%, rgba(151, 71, 255, 0.7) 56.38%, rgba(118, 160, 255, 0.7) 100%), rgb(0, 61, 255);color:#fff!important}@media (min-width: 1024px){.homepage-hero-cta{padding:0.75rem 1.25rem;font-size:1rem;letter-spacing:0.32px}}.sig-param-link{color:inherit;text-decoration:underline;text-decoration-style:dotted;text-decoration-thickness:1px;text-underline-offset:3px;text-decoration-color:color-mix(in srgb, currentColor 45%, transparent);cursor:pointer;border-radius:2px;transition:text-decoration-color 120ms ease, text-decoration-thickness 120ms ease}.sig-param-link:hover,.sig-param-link:focus-visible,.line:has(.sig-param-link:hover) .sig-param-link,.line:has(.sig-param-link:focus-visible) .sig-param-link{text-decoration-style:solid;text-decoration-thickness:2px;text-decoration-color:currentColor;outline:none}.mint-flavor-switcher-slot{min-height:2.75rem;margin:0.25rem 0 1.5rem}.mint-flavor-switcher-slot .mint-flavor-switcher{margin:0}"}],"page":{"pagePath":"doc/rest-api/abtesting/add-ab-tests","slug":"/doc/rest-api/abtesting/add-ab-tests","pageMetadata":{"title":"Create an A/B test","description":"This endpoint is deprecated. Use the A/B Testing API v3 instead.","openapi":"specs/abtesting.yml post /2/abtests","public":true,"href":"/doc/rest-api/abtesting/add-ab-tests"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"This endpoint is deprecated. Use the A/B Testing API v3 instead.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={code:`code`,p:`p`,strong:`strong`,..._provideComponents(),...props.components};return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`Replaced by `,_jsx(_components.code,{children:`POST /3/abtests`}),`.`]}),`\n`,_jsx(_components.p,{children:`Creates a new A/B test.`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Required ACL:`}),` `,_jsx(_components.code,{children:`editSettings`})]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent}","frontmatter":{},"scope":{"codeStyling":"system","config":{},"pageMetadata":{"title":"Create an A/B test","description":"This endpoint is deprecated. Use the A/B Testing API v3 instead.","openapi":"specs/abtesting.yml post /2/abtests","public":true,"href":"/doc/rest-api/abtesting/add-ab-tests"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[],"codeExamples":{}},"jsLinks":["/_mintlify/custom/algolia/34bdaaeaccaa769c/docsearch.js","/_mintlify/custom/algolia/e18afef8ba6306ba/one-trust.js","/_mintlify/custom/algolia/5a5e6ade8ff45aec/utm-attribution.js","/_mintlify/custom/algolia/a4b9f2f416e55759/iframe-resize.js","/_mintlify/custom/algolia/dbca34a8de6b147e/instantsearch-api-signature-links.js","/_mintlify/custom/algolia/4e6ff31277aab3f2/segment-analytics.js","/_mintlify/custom/algolia/ae5f1d742fc727f6/optinmonster.js"],"openApiReferenceData":{"operation":{"tags":["abtest"],"operationId":"addABTests","deprecated":true,"x-acl":["editSettings"],"summary":"Create an A/B test","description":"This endpoint is deprecated. Use the A/B Testing API v3 instead.","requestBody":"df7f2096-ff3f-4092-a9e4-bb0318a02373","responses":{"200":"9ce2bcd2-7b1f-4ae9-b243-0995d876401a","400":"5bb2f4ae-caa4-4893-ba15-7f0355dbc586","402":"47b3e45c-3468-4bbf-8e16-de71cb4242dd","403":"f24d7793-4014-4e22-95d9-1953c2f05a42","404":"fc61b1a9-da33-4a89-a894-d6ec4576bb6b"},"x-codeSamples":[{"lang":"csharp","label":"C#","source":"// Initialize the client\nvar client = new AbtestingClient(\n new AbtestingConfig(\"ALGOLIA_APPLICATION_ID\", \"ALGOLIA_API_KEY\", \"ALGOLIA_APPLICATION_REGION\")\n);\n\n// Call the API\nvar response = await client.AddABTestsAsync(\n new AddABTestsRequest\n {\n EndAt = \"2022-12-31T00:00:00.000Z\",\n Name = \"myABTest\",\n Variants = new List\u003cAddABTestsVariant>\n {\n new AddABTestsVariant(new AbTestsVariant { Index = \"AB_TEST_1\", TrafficPercentage = 30 }),\n new AddABTestsVariant(new AbTestsVariant { Index = \"AB_TEST_2\", TrafficPercentage = 50 }),\n },\n }\n);\n\n// print the response\nConsole.WriteLine(response);"},{"lang":"go","label":"Go","source":"// Initialize the client with your application region, eg. abtesting.ALGOLIA_APPLICATION_REGION\nclient, err := abtesting.NewClient(\"ALGOLIA_APPLICATION_ID\", \"ALGOLIA_API_KEY\", abtesting.US)\nif err != nil {\n // The client can fail to initialize if you pass an invalid parameter.\n panic(err)\n}\n\n// Call the API\nresponse, err := client.AddABTests(client.NewApiAddABTestsRequest(\n\n abtesting.NewEmptyAddABTestsRequest().SetEndAt(\"2022-12-31T00:00:00.000Z\").SetName(\"myABTest\").SetVariants(\n []abtesting.AddABTestsVariant{*abtesting.AbTestsVariantAsAddABTestsVariant(\n abtesting.NewEmptyAbTestsVariant().SetIndex(\"AB_TEST_1\").SetTrafficPercentage(30)), *abtesting.AbTestsVariantAsAddABTestsVariant(\n abtesting.NewEmptyAbTestsVariant().SetIndex(\"AB_TEST_2\").SetTrafficPercentage(50))})))\nif err != nil {\n // handle the eventual error\n panic(err)\n}\n\n\n// print the response\nprint(response)"},{"lang":"java","label":"Java","source":"// Initialize the client\nAbtestingClient client = new AbtestingClient(\"ALGOLIA_APPLICATION_ID\", \"ALGOLIA_API_KEY\", \"ALGOLIA_APPLICATION_REGION\");\n\n// Call the API\nABTestResponse response = client.addABTests(\n new AddABTestsRequest()\n .setEndAt(\"2022-12-31T00:00:00.000Z\")\n .setName(\"myABTest\")\n .setVariants(\n Arrays.asList(\n new AbTestsVariant().setIndex(\"AB_TEST_1\").setTrafficPercentage(30),\n new AbTestsVariant().setIndex(\"AB_TEST_2\").setTrafficPercentage(50)\n )\n )\n);\n\n// print the response\nSystem.out.println(response);"},{"lang":"javascript","label":"JavaScript","source":"// Initialize the client\n// Replace 'us' with your Algolia Application Region\nconst client = algoliasearch('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY').initAbtesting({ region: 'us' });\n\n// Call the API\nconst response = await client.addABTests({\n endAt: '2022-12-31T00:00:00.000Z',\n name: 'myABTest',\n variants: [\n { index: 'AB_TEST_1', trafficPercentage: 30 },\n { index: 'AB_TEST_2', trafficPercentage: 50 },\n ],\n});\n\n\n// print the response\nconsole.log(response);"},{"lang":"kotlin","label":"Kotlin","source":"// Initialize the client\nval client =\n AbtestingClient(\n appId = \"ALGOLIA_APPLICATION_ID\",\n apiKey = \"ALGOLIA_API_KEY\",\n region = \"ALGOLIA_APPLICATION_REGION\",\n )\n\n// Call the API\nvar response =\n client.addABTests(\n addABTestsRequest =\n AddABTestsRequest(\n endAt = \"2022-12-31T00:00:00.000Z\",\n name = \"myABTest\",\n variants =\n listOf(\n AbTestsVariant(index = \"AB_TEST_1\", trafficPercentage = 30),\n AbTestsVariant(index = \"AB_TEST_2\", trafficPercentage = 50),\n ),\n )\n )\n\n\n// print the response\nprintln(response)"},{"lang":"php","label":"PHP","source":"// Initialize the client\n$client = AbtestingClient::create('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY', 'ALGOLIA_APPLICATION_REGION');\n\n// Call the API\n$response = $client->addABTests(\n ['endAt' => '2022-12-31T00:00:00.000Z',\n 'name' => 'myABTest',\n 'variants' => [\n ['index' => 'AB_TEST_1',\n 'trafficPercentage' => 30,\n ],\n\n ['index' => 'AB_TEST_2',\n 'trafficPercentage' => 50,\n ],\n ],\n ],\n);\n\n\n// print the response\nvar_dump($response);"},{"lang":"python","label":"Python","source":"# Initialize the client\n# In an asynchronous context, you can use AbtestingClient instead, which exposes the exact same methods.\nclient = AbtestingClientSync(\n \"ALGOLIA_APPLICATION_ID\", \"ALGOLIA_API_KEY\", \"ALGOLIA_APPLICATION_REGION\"\n)\n\n# Call the API\nresponse = client.add_ab_tests(\n add_ab_tests_request={\n \"endAt\": \"2022-12-31T00:00:00.000Z\",\n \"name\": \"myABTest\",\n \"variants\": [\n {\n \"index\": \"AB_TEST_1\",\n \"trafficPercentage\": 30,\n },\n {\n \"index\": \"AB_TEST_2\",\n \"trafficPercentage\": 50,\n },\n ],\n },\n)\n\n\n# print the response\nprint(response)"},{"lang":"ruby","label":"Ruby","source":"# Initialize the client\nclient = Algolia::AbtestingClient.create(\"ALGOLIA_APPLICATION_ID\", \"ALGOLIA_API_KEY\", \"ALGOLIA_APPLICATION_REGION\")\n\n# Call the API\nresponse = client.add_ab_tests(\n Algolia::Abtesting::AddABTestsRequest.new(\n end_at: \"2022-12-31T00:00:00.000Z\",\n name: \"myABTest\",\n variants: [\n Algolia::Abtesting::AbTestsVariant.new(index: \"AB_TEST_1\", traffic_percentage: 30),\n Algolia::Abtesting::AbTestsVariant.new(index: \"AB_TEST_2\", traffic_percentage: 50)\n ]\n )\n)\n\n\n# print the response\nputs(response)"},{"lang":"scala","label":"Scala","source":"// Initialize the client\nval client = AbtestingClient(\n appId = \"ALGOLIA_APPLICATION_ID\",\n apiKey = \"ALGOLIA_API_KEY\",\n region = Option(\"ALGOLIA_APPLICATION_REGION\")\n)\n\n// Call the API\nval response = Await.result(\n client.addABTests(\n addABTestsRequest = AddABTestsRequest(\n endAt = \"2022-12-31T00:00:00.000Z\",\n name = \"myABTest\",\n variants = Seq(\n AbTestsVariant(\n index = \"AB_TEST_1\",\n trafficPercentage = 30\n ),\n AbTestsVariant(\n index = \"AB_TEST_2\",\n trafficPercentage = 50\n )\n )\n )\n ),\n Duration(100, \"sec\")\n)\n\n// print the response\nprintln(response)"},{"lang":"swift","label":"Swift","source":"// Initialize the client\nlet client = try AbtestingClient(appID: \"ALGOLIA_APPLICATION_ID\", apiKey: \"ALGOLIA_API_KEY\", region: .us)\n\n// Call the API\nlet response = try await client.addABTests(addABTestsRequest: AbtestingAddABTestsRequest(\n name: \"myABTest\",\n variants: [\n AbtestingAddABTestsVariant.abtestingAbTestsVariant(AbtestingAbTestsVariant(\n index: \"AB_TEST_1\",\n trafficPercentage: 30\n )),\n AbtestingAddABTestsVariant.abtestingAbTestsVariant(AbtestingAbTestsVariant(\n index: \"AB_TEST_2\",\n trafficPercentage: 50\n )),\n ],\n endAt: \"2022-12-31T00:00:00.000Z\"\n))\n\n// print the response\nprint(response)"},{"lang":"cURL","label":"curl","source":"curl --request POST \\\n --url https://analytics.us.algolia.com/2/abtests \\\n --header 'accept: application/json' \\\n --header 'content-type: application/json' \\\n --header 'x-algolia-api-key: ALGOLIA_API_KEY' \\\n --header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID' \\\n --data '\n{\n \"name\": \"Custom ranking sales rank test\",\n \"variants\": [\n {\n \"index\": \"delcourt_production\",\n \"trafficPercentage\": 60,\n \"description\": \"Current production index\"\n },\n {\n \"index\": \"delcourt_production\",\n \"trafficPercentage\": 60,\n \"description\": \"Current production index\"\n }\n ],\n \"endAt\": \"2023-06-17T00:00:00Z\"\n}\n'"}],"method":"post","type":"path","servers":["8336822e-1c83-4d94-9622-2332792b5009","6483a23a-9c9f-4348-be61-ad15b11fc72e"],"security":["fa9abb25-248a-41dd-bcf8-5f5f9f2643f1"],"path":"/2/abtests","baseUrlOptions":["https://analytics.{region}.algolia.com","https://analytics.algolia.com"],"title":"Create an A/B test","codeSamples":[{"label":"C#","lang":"csharp","source":"// Initialize the client\nvar client = new AbtestingClient(\n new AbtestingConfig(\"ALGOLIA_APPLICATION_ID\", \"ALGOLIA_API_KEY\", \"ALGOLIA_APPLICATION_REGION\")\n);\n\n// Call the API\nvar response = await client.AddABTestsAsync(\n new AddABTestsRequest\n {\n EndAt = \"2022-12-31T00:00:00.000Z\",\n Name = \"myABTest\",\n Variants = new List\u003cAddABTestsVariant>\n {\n new AddABTestsVariant(new AbTestsVariant { Index = \"AB_TEST_1\", TrafficPercentage = 30 }),\n new AddABTestsVariant(new AbTestsVariant { Index = \"AB_TEST_2\", TrafficPercentage = 50 }),\n },\n }\n);\n\n// print the response\nConsole.WriteLine(response);"},{"label":"Go","lang":"go","source":"// Initialize the client with your application region, eg. abtesting.ALGOLIA_APPLICATION_REGION\nclient, err := abtesting.NewClient(\"ALGOLIA_APPLICATION_ID\", \"ALGOLIA_API_KEY\", abtesting.US)\nif err != nil {\n // The client can fail to initialize if you pass an invalid parameter.\n panic(err)\n}\n\n// Call the API\nresponse, err := client.AddABTests(client.NewApiAddABTestsRequest(\n\n abtesting.NewEmptyAddABTestsRequest().SetEndAt(\"2022-12-31T00:00:00.000Z\").SetName(\"myABTest\").SetVariants(\n []abtesting.AddABTestsVariant{*abtesting.AbTestsVariantAsAddABTestsVariant(\n abtesting.NewEmptyAbTestsVariant().SetIndex(\"AB_TEST_1\").SetTrafficPercentage(30)), *abtesting.AbTestsVariantAsAddABTestsVariant(\n abtesting.NewEmptyAbTestsVariant().SetIndex(\"AB_TEST_2\").SetTrafficPercentage(50))})))\nif err != nil {\n // handle the eventual error\n panic(err)\n}\n\n\n// print the response\nprint(response)"},{"label":"Java","lang":"java","source":"// Initialize the client\nAbtestingClient client = new AbtestingClient(\"ALGOLIA_APPLICATION_ID\", \"ALGOLIA_API_KEY\", \"ALGOLIA_APPLICATION_REGION\");\n\n// Call the API\nABTestResponse response = client.addABTests(\n new AddABTestsRequest()\n .setEndAt(\"2022-12-31T00:00:00.000Z\")\n .setName(\"myABTest\")\n .setVariants(\n Arrays.asList(\n new AbTestsVariant().setIndex(\"AB_TEST_1\").setTrafficPercentage(30),\n new AbTestsVariant().setIndex(\"AB_TEST_2\").setTrafficPercentage(50)\n )\n )\n);\n\n// print the response\nSystem.out.println(response);"},{"label":"JavaScript","lang":"javascript","source":"// Initialize the client\n// Replace 'us' with your Algolia Application Region\nconst client = algoliasearch('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY').initAbtesting({ region: 'us' });\n\n// Call the API\nconst response = await client.addABTests({\n endAt: '2022-12-31T00:00:00.000Z',\n name: 'myABTest',\n variants: [\n { index: 'AB_TEST_1', trafficPercentage: 30 },\n { index: 'AB_TEST_2', trafficPercentage: 50 },\n ],\n});\n\n\n// print the response\nconsole.log(response);"},{"label":"Kotlin","lang":"kotlin","source":"// Initialize the client\nval client =\n AbtestingClient(\n appId = \"ALGOLIA_APPLICATION_ID\",\n apiKey = \"ALGOLIA_API_KEY\",\n region = \"ALGOLIA_APPLICATION_REGION\",\n )\n\n// Call the API\nvar response =\n client.addABTests(\n addABTestsRequest =\n AddABTestsRequest(\n endAt = \"2022-12-31T00:00:00.000Z\",\n name = \"myABTest\",\n variants =\n listOf(\n AbTestsVariant(index = \"AB_TEST_1\", trafficPercentage = 30),\n AbTestsVariant(index = \"AB_TEST_2\", trafficPercentage = 50),\n ),\n )\n )\n\n\n// print the response\nprintln(response)"},{"label":"PHP","lang":"php","source":"// Initialize the client\n$client = AbtestingClient::create('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY', 'ALGOLIA_APPLICATION_REGION');\n\n// Call the API\n$response = $client->addABTests(\n ['endAt' => '2022-12-31T00:00:00.000Z',\n 'name' => 'myABTest',\n 'variants' => [\n ['index' => 'AB_TEST_1',\n 'trafficPercentage' => 30,\n ],\n\n ['index' => 'AB_TEST_2',\n 'trafficPercentage' => 50,\n ],\n ],\n ],\n);\n\n\n// print the response\nvar_dump($response);"},{"label":"Python","lang":"python","source":"# Initialize the client\n# In an asynchronous context, you can use AbtestingClient instead, which exposes the exact same methods.\nclient = AbtestingClientSync(\n \"ALGOLIA_APPLICATION_ID\", \"ALGOLIA_API_KEY\", \"ALGOLIA_APPLICATION_REGION\"\n)\n\n# Call the API\nresponse = client.add_ab_tests(\n add_ab_tests_request={\n \"endAt\": \"2022-12-31T00:00:00.000Z\",\n \"name\": \"myABTest\",\n \"variants\": [\n {\n \"index\": \"AB_TEST_1\",\n \"trafficPercentage\": 30,\n },\n {\n \"index\": \"AB_TEST_2\",\n \"trafficPercentage\": 50,\n },\n ],\n },\n)\n\n\n# print the response\nprint(response)"},{"label":"Ruby","lang":"ruby","source":"# Initialize the client\nclient = Algolia::AbtestingClient.create(\"ALGOLIA_APPLICATION_ID\", \"ALGOLIA_API_KEY\", \"ALGOLIA_APPLICATION_REGION\")\n\n# Call the API\nresponse = client.add_ab_tests(\n Algolia::Abtesting::AddABTestsRequest.new(\n end_at: \"2022-12-31T00:00:00.000Z\",\n name: \"myABTest\",\n variants: [\n Algolia::Abtesting::AbTestsVariant.new(index: \"AB_TEST_1\", traffic_percentage: 30),\n Algolia::Abtesting::AbTestsVariant.new(index: \"AB_TEST_2\", traffic_percentage: 50)\n ]\n )\n)\n\n\n# print the response\nputs(response)"},{"label":"Scala","lang":"scala","source":"// Initialize the client\nval client = AbtestingClient(\n appId = \"ALGOLIA_APPLICATION_ID\",\n apiKey = \"ALGOLIA_API_KEY\",\n region = Option(\"ALGOLIA_APPLICATION_REGION\")\n)\n\n// Call the API\nval response = Await.result(\n client.addABTests(\n addABTestsRequest = AddABTestsRequest(\n endAt = \"2022-12-31T00:00:00.000Z\",\n name = \"myABTest\",\n variants = Seq(\n AbTestsVariant(\n index = \"AB_TEST_1\",\n trafficPercentage = 30\n ),\n AbTestsVariant(\n index = \"AB_TEST_2\",\n trafficPercentage = 50\n )\n )\n )\n ),\n Duration(100, \"sec\")\n)\n\n// print the response\nprintln(response)"},{"label":"Swift","lang":"swift","source":"// Initialize the client\nlet client = try AbtestingClient(appID: \"ALGOLIA_APPLICATION_ID\", apiKey: \"ALGOLIA_API_KEY\", region: .us)\n\n// Call the API\nlet response = try await client.addABTests(addABTestsRequest: AbtestingAddABTestsRequest(\n name: \"myABTest\",\n variants: [\n AbtestingAddABTestsVariant.abtestingAbTestsVariant(AbtestingAbTestsVariant(\n index: \"AB_TEST_1\",\n trafficPercentage: 30\n )),\n AbtestingAddABTestsVariant.abtestingAbTestsVariant(AbtestingAbTestsVariant(\n index: \"AB_TEST_2\",\n trafficPercentage: 50\n )),\n ],\n endAt: \"2022-12-31T00:00:00.000Z\"\n))\n\n// print the response\nprint(response)"},{"label":"curl","lang":"cURL","source":"curl --request POST \\\n --url https://analytics.us.algolia.com/2/abtests \\\n --header 'accept: application/json' \\\n --header 'content-type: application/json' \\\n --header 'x-algolia-api-key: ALGOLIA_API_KEY' \\\n --header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID' \\\n --data '\n{\n \"name\": \"Custom ranking sales rank test\",\n \"variants\": [\n {\n \"index\": \"delcourt_production\",\n \"trafficPercentage\": 60,\n \"description\": \"Current production index\"\n },\n {\n \"index\": \"delcourt_production\",\n \"trafficPercentage\": 60,\n \"description\": \"Current production index\"\n }\n ],\n \"endAt\": \"2023-06-17T00:00:00Z\"\n}\n'"}],"requestExampleLanguages":["bash","csharp","dart","go","java","javascript","kotlin","php","python","ruby","scala","swift"],"requiredOnlyExamples":false,"disableCodeSampleGeneration":true,"requestExampleType":"codeSamples","responseExampleType":"generated"},"dependencies":{"parameters":{},"requestBody":{"required":true,"content":{"application/json":{"schema":{"title":"addABTestsRequest","type":"object","additionalProperties":false,"properties":{"endAt":{"type":"string","description":"End date and time of the A/B test, in RFC 3339 format.","example":"2023-06-17T00:00:00Z","isRequired":true,"uniqueKey":"endAt","typeLabel":"string"},"name":{"type":"string","description":"A/B test name.","example":"Custom ranking sales rank test","isRequired":true,"uniqueKey":"name","typeLabel":"string"},"variants":{"type":"array","description":"A/B test variants.","minItems":2,"maxItems":2,"items":{"oneOf":[{"type":"object","title":"Variant","required":["index","trafficPercentage"],"properties":{"index":{"type":"string","description":"Index name of the A/B test variant (case-sensitive).","example":"delcourt_production","isRequired":true,"uniqueKey":"variants.items.[INDEX].oneOf.0.index","typeLabel":"string"},"trafficPercentage":{"type":"integer","description":"Percentage of search requests each variant receives.","minimum":0,"maximum":100,"example":60,"isRequired":true,"uniqueKey":"variants.items.[INDEX].oneOf.0.trafficPercentage","typeLabel":"integer"},"description":{"type":"string","description":"Description for this variant.","example":"Current production index","uniqueKey":"variants.items.[INDEX].oneOf.0.description","typeLabel":"string"}},"additionalProperties":false,"uniqueKey":"variants.items.[INDEX].oneOf.0","typeLabel":"Variant · object"},{"type":"object","title":"Variant with search parameters","description":"Search parameters to add to the test variant.\nOnly use this parameter if the two variants use the same index.\n","required":["customSearchParameters","index","trafficPercentage"],"x-discriminator-fields":["customSearchParameters"],"properties":{"index":{"type":"string","description":"Index name of the A/B test variant (case-sensitive).","example":"delcourt_production","isRequired":true,"uniqueKey":"variants.items.[INDEX].oneOf.1.index","typeLabel":"string"},"trafficPercentage":{"type":"integer","description":"Percentage of search requests each variant receives.","minimum":0,"maximum":100,"example":60,"isRequired":true,"uniqueKey":"variants.items.[INDEX].oneOf.1.trafficPercentage","typeLabel":"integer"},"customSearchParameters":{"type":"object","isRequired":true,"uniqueKey":"variants.items.[INDEX].oneOf.1.customSearchParameters","typeLabel":"object"},"description":{"type":"string","description":"Description for this variant.","example":"Current production index","uniqueKey":"variants.items.[INDEX].oneOf.1.description","typeLabel":"string"}},"additionalProperties":false,"uniqueKey":"variants.items.[INDEX].oneOf.1","typeLabel":"Variant with search parameters · object"}],"uniqueKey":"variants.items.[INDEX]","typeLabel":"Variant · object | Variant with search parameters · object"},"isRequired":true,"uniqueKey":"variants","typeLabel":"(Variant · object | Variant with search parameters · object)[]"}},"required":["name","variants","endAt"],"uniqueKey":"","typeLabel":"addABTestsRequest · object"},"examples":{"Example":{"title":"Example","value":{"endAt":"2023-06-17T00:00:00Z","name":"Custom ranking sales rank test","variants":[{"index":"delcourt_production","trafficPercentage":60,"description":"Current production index"}]}}},"exampleType":"generated"}},"exampleType":"generated"},"responses":{"9ce2bcd2-7b1f-4ae9-b243-0995d876401a":{"description":"OK","headers":{"x-ratelimit-limit":{"description":"Number of allowed requests per one minute.","example":100,"schema":{"type":"integer"}},"x-ratelimit-remaining":{"description":"Number of remaining requests in the current period.","example":99,"schema":{"type":"integer"}},"x-ratelimit-reset":{"description":"Timestamp when the rate limit will reset, measured in seconds since the Unix epoch.","example":1710682486,"schema":{"type":"integer"}}},"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"properties":{"abTestID":{"type":"integer","description":"Unique A/B test identifier.","example":224,"isRequired":true,"uniqueKey":"abTestID","typeLabel":"integer"},"index":{"type":"string","description":"Index name of the A/B test variant (case-sensitive).","example":"delcourt_production","isRequired":true,"uniqueKey":"index","typeLabel":"string"},"taskID":{"type":"integer","format":"int64","example":1514562690001,"description":"Unique identifier of a task.\n\nA successful API response means that a task was added to a queue.\nIt might not run immediately.\nYou can check the task's progress with the [`task` operation](https://www.algolia.com/doc/rest-api/search/get-task) and this task ID.\n","isRequired":true,"uniqueKey":"taskID","typeLabel":"integer\u003cint64>"}},"required":["abTestID","index","taskID"],"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"abTestID":224,"index":"delcourt_production","taskID":1514562690001}}},"exampleType":"generated"}},"exampleType":"generated"},"5bb2f4ae-caa4-4893-ba15-7f0355dbc586":{"description":"Bad request or request arguments.","content":{"application/json":{"schema":{"description":"Error.","type":"object","x-keep-model":true,"additionalProperties":true,"properties":{"message":{"type":"string","example":"Invalid Application-Id or API-Key","uniqueKey":"message","typeLabel":"string"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"message":"Invalid Application-Id or API-Key"}}},"exampleType":"generated"}},"exampleType":"generated"},"47b3e45c-3468-4bbf-8e16-de71cb4242dd":{"description":"This feature is not enabled on your Algolia account.","content":{"application/json":{"schema":{"description":"Error.","type":"object","x-keep-model":true,"additionalProperties":true,"properties":{"message":{"type":"string","example":"Invalid Application-Id or API-Key","uniqueKey":"message","typeLabel":"string"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"message":"Invalid Application-Id or API-Key"}}},"exampleType":"generated"}},"exampleType":"generated"},"f24d7793-4014-4e22-95d9-1953c2f05a42":{"description":"Method not allowed with this API key.","content":{"application/json":{"schema":{"description":"Error.","type":"object","x-keep-model":true,"additionalProperties":true,"properties":{"message":{"type":"string","example":"Invalid Application-Id or API-Key","uniqueKey":"message","typeLabel":"string"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"message":"Invalid Application-Id or API-Key"}}},"exampleType":"generated"}},"exampleType":"generated"},"fc61b1a9-da33-4a89-a894-d6ec4576bb6b":{"description":"Index not found.","content":{"application/json":{"schema":{"description":"Error.","type":"object","x-keep-model":true,"additionalProperties":true,"properties":{"message":{"type":"string","example":"Invalid Application-Id or API-Key","uniqueKey":"message","typeLabel":"string"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"message":"Invalid Application-Id or API-Key"}}},"exampleType":"generated"}},"exampleType":"generated"}},"security":{"fa9abb25-248a-41dd-bcf8-5f5f9f2643f1":{"appId":{"type":"apiKey","in":"header","name":"x-algolia-application-id","description":"Your Algolia application ID.","scopes":[]},"apiKey":{"type":"apiKey","in":"header","name":"x-algolia-api-key","description":"Your Algolia API key with the necessary permissions to make the request.\nPermissions are controlled through access control lists (ACL) and access restrictions.\nThe required ACL to make a request is listed in each endpoint's reference.\n","scopes":[]}}},"servers":{"8336822e-1c83-4d94-9622-2332792b5009":{"url":"https://analytics.{region}.algolia.com","variables":{"region":{"description":"The region where your Algolia application is hosted.","enum":["us","de"],"default":"us"}}},"6483a23a-9c9f-4348-be61-ad15b11fc72e":{"url":"https://analytics.algolia.com"}},"processedSecurityOptions":[{"schemes":[{"scheme":{"type":"apiKey","in":"header","name":"x-algolia-application-id","description":"Your Algolia application ID.","scopes":[]},"schema":{"title":"x-algolia-application-id","type":"string","description":"Your Algolia application ID.","isRequired":true,"typeLabel":"string","deprecated":false},"schemeName":"appId","name":"x-algolia-application-id"},{"scheme":{"type":"apiKey","in":"header","name":"x-algolia-api-key","description":"Your Algolia API key with the necessary permissions to make the request.\nPermissions are controlled through access control lists (ACL) and access restrictions.\nThe required ACL to make a request is listed in each endpoint's reference.\n","scopes":[]},"schema":{"title":"x-algolia-api-key","type":"string","description":"Your Algolia API key with the necessary permissions to make the request.\nPermissions are controlled through access control lists (ACL) and access restrictions.\nThe required ACL to make a request is listed in each endpoint's reference.\n","isRequired":true,"typeLabel":"string","deprecated":false},"schemeName":"apiKey","name":"x-algolia-api-key"}],"title":"appId \u0026 apiKey"}]},"originalFileLocation":"specs/abtesting.yml"},"subdomain":"algolia","siteName":"Algolia","title":"Create an A/B test - Algolia","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-09-09T15:56:15.734Z","gitLastModified":"2026-09-09T15:53:19.000Z","originalFileLocation":"doc/rest-api/abtesting/add-ab-tests.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"This endpoint is deprecated. Use the A/B Testing API v3 instead.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Algolia\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/algolia/pODf0GWwkpqTo2Wx/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/algolia/pODf0GWwkpqTo2Wx/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/algolia/pODf0GWwkpqTo2Wx/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/algolia/pODf0GWwkpqTo2Wx/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/algolia/pODf0GWwkpqTo2Wx/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/algolia/pODf0GWwkpqTo2Wx/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/algolia/pODf0GWwkpqTo2Wx/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/algolia/pODf0GWwkpqTo2Wx/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/algolia/pODf0GWwkpqTo2Wx/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Create an A/B test - Algolia\">\u003cmeta data-mint-head property=\"og:description\" content=\"This endpoint is deprecated. Use the A/B Testing API v3 instead.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Algolia\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://www.algolia.com/doc/rest-api/abtesting/add-ab-tests\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://algolia.mintlify.site/_mintlify/api/og/v2?division=A%2FB+testing+API+v2+%28deprecated%29\u0026amp;title=Create+an+A%2FB+test\u0026amp;description=This+endpoint+is+deprecated.+Use+the+A%2FB+Testing+API+v3+instead.\u0026amp;theme=7b696fa6ef3d890ba8a17746\u0026amp;signature=48e3280ea82b42c88ac3a843652e4c16499503e9809e6418ee10d829b78a96a9\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Create an A/B test - Algolia\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"This endpoint is deprecated. Use the A/B Testing API v3 instead.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://algolia.mintlify.site/_mintlify/api/og/v2?division=A%2FB+testing+API+v2+%28deprecated%29\u0026amp;title=Create+an+A%2FB+test\u0026amp;description=This+endpoint+is+deprecated.+Use+the+A%2FB+Testing+API+v3+instead.\u0026amp;theme=7b696fa6ef3d890ba8a17746\u0026amp;signature=48e3280ea82b42c88ac3a843652e4c16499503e9809e6418ee10d829b78a96a9\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/algolia/pODf0GWwkpqTo2Wx/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Algolia\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#3970ff\">\u003clink data-mint-head rel=\"canonical\" href=\"https://www.algolia.com/doc/rest-api/abtesting/add-ab-tests\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/doc/rest-api/abtesting/add-ab-tests.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://www.algolia.com/#organization\",\"name\":\"Algolia\",\"url\":\"https://www.algolia.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/algolia/kiecJp3hu-WXhj-3/logo/light.svg?fit=max\u0026auto=format\u0026n=kiecJp3hu-WXhj-3\u0026q=85\u0026s=bf613e260ca94c0eb23384e6c0d5c77f\"},\"sameAs\":[\"https://www.linkedin.com/company/algolia/\",\"https://github.com/algolia\",\"https://x.com/algolia\",\"https://www.youtube.com/channel/UCTNkiq-SO8hay1PRx-it9Cw\"]},{\"@type\":\"WebSite\",\"@id\":\"https://www.algolia.com#website\",\"name\":\"Algolia\",\"url\":\"https://www.algolia.com\",\"publisher\":{\"@id\":\"https://www.algolia.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://www.algolia.com/doc/rest-api/abtesting/add-ab-tests#webpage\",\"url\":\"https://www.algolia.com/doc/rest-api/abtesting/add-ab-tests\",\"name\":\"Create an A/B test\",\"description\":\"This endpoint is deprecated. Use the A/B Testing API v3 instead.\",\"dateModified\":\"2026-09-09T15:53:19.000Z\",\"isPartOf\":{\"@id\":\"https://www.algolia.com#website\"},\"breadcrumb\":{\"@id\":\"https://www.algolia.com/doc/rest-api/abtesting/add-ab-tests#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://www.algolia.com/doc/rest-api/abtesting/add-ab-tests#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"A/B testing API v2 (deprecated)\",\"item\":\"https://www.algolia.com/doc/rest-api/abtesting\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Create an A/B test\",\"item\":\"https://www.algolia.com/doc/rest-api/abtesting/add-ab-tests\"}]},{\"@type\":[\"TechArticle\",\"APIReference\"],\"@id\":\"https://www.algolia.com/doc/rest-api/abtesting/add-ab-tests#apireference\",\"headline\":\"Create an A/B test\",\"name\":\"Create an A/B test\",\"description\":\"This endpoint is deprecated. Use the A/B Testing API v3 instead.\",\"url\":\"https://www.algolia.com/doc/rest-api/abtesting/add-ab-tests\",\"mainEntityOfPage\":{\"@id\":\"https://www.algolia.com/doc/rest-api/abtesting/add-ab-tests#webpage\"},\"dateModified\":\"2026-09-09T15:53:19.000Z\",\"publisher\":{\"@id\":\"https://www.algolia.com/#organization\"},\"isPartOf\":{\"@id\":\"https://www.algolia.com#website\"}}]}\u003c/script>","agentPointerHref":"/doc/rest-api/abtesting/add-ab-tests.md","siteName":"Algolia","nav":{"global":null,"tabs":[{"tab":"Guides","icon":"book-text","pages":[{"title":"Guides","href":"/doc/guides/get-started"}]},{"tab":"Libraries and tools","icon":"wrench","menu":[{"item":"API clients","versions":[{"version":"current","groups":[{"group":"current","pages":[{"title":"current","href":"/doc/libraries/sdk"}]}]},{"version":"legacy","groups":[{"group":"legacy","pages":[{"title":"legacy","href":"/doc/libraries/sdk/v1/install"}]}]}]},{"item":"Algolia CLI","pages":[{"title":"Algolia CLI","href":"/doc/tools/cli/get-started"}]},{"item":"Algolia Wizard","pages":[{"title":"Algolia Wizard","href":"/doc/tools/algolia-wizard"}]},{"item":"Crawler","pages":[{"title":"Crawler","href":"/doc/tools/crawler/getting-started/overview"}]},{"item":"Django","pages":[{"title":"Django","href":"/doc/framework-integration/django/setup"}]},{"item":"Laravel","pages":[{"title":"Laravel","href":"/doc/framework-integration/laravel/getting-started/introduction-to-scout-extended"}]},{"item":"Ruby on Rails","pages":[{"title":"Ruby on Rails","href":"/doc/framework-integration/rails/getting-started/setup"}]},{"item":"Symfony","pages":[{"title":"Symfony","href":"/doc/framework-integration/symfony/getting-started/algolia-searchbundle"}]},{"item":"All libraries and tools","pages":[{"title":"All libraries and tools","href":"/doc/libraries"}]}],"pages":[{"title":"Libraries and tools","href":"/doc/libraries/sdk"}]},{"tab":"UI libraries","icon":"proportions","menu":[{"item":"InstantSearch.js","pages":[{"title":"InstantSearch.js","href":"/doc/api-reference/widgets/js"}]},{"item":"React InstantSearch","pages":[{"title":"React InstantSearch","href":"/doc/api-reference/widgets/react"}]},{"item":"Vue InstantSearch","pages":[{"title":"Vue InstantSearch","href":"/doc/api-reference/widgets/vue"}]},{"item":"InstantSearch iOS","pages":[{"title":"InstantSearch iOS","href":"/doc/api-reference/widgets/ios"}]},{"item":"InstantSearch Android","pages":[{"title":"InstantSearch Android","href":"/doc/api-reference/widgets/android"}]},{"item":"Algolia for Flutter","pages":[{"title":"Algolia for Flutter","href":"/doc/api-reference/widgets/flutter"}]},{"item":"Autocomplete","pages":[{"title":"Autocomplete","href":"/doc/ui-libraries/autocomplete/introduction/what-is-autocomplete"}]},{"item":"All UI libraries","pages":[{"title":"All UI libraries","href":"/doc/ui-libraries"}]}],"pages":[{"title":"UI libraries","href":"/doc/api-reference/widgets/js"}]},{"tab":"Integrations","icon":"plug","menu":[{"item":"Adobe Commerce/Magento","pages":[{"title":"Adobe Commerce/Magento","href":"/doc/integration/magento-2/getting-started/quick-start"}]},{"item":"BigCommerce","pages":[{"title":"BigCommerce","href":"/doc/integration/bigcommerce/get-started/installation"}]},{"item":"commercetools","pages":[{"title":"commercetools","href":"/doc/integration/commercetools/get-started/installation"}]},{"item":"Make","pages":[{"title":"Make","href":"/doc/integration/make"}]},{"item":"n8n","pages":[{"title":"n8n","href":"/doc/integration/n8n"}]},{"item":"Salesforce B2C Commerce","pages":[{"title":"Salesforce B2C Commerce","href":"/doc/integration/salesforce-commerce-cloud-b2c/getting-started/introduction"}]},{"item":"Shopify","pages":[{"title":"Shopify","href":"/doc/integration/shopify/getting-started/quick-start"}]},{"item":"Stripe Projects","pages":[{"title":"Stripe Projects","href":"/doc/integration/stripe-projects"}]},{"item":"Zapier","pages":[{"title":"Zapier","href":"/doc/integration/zapier"}]},{"item":"Zendesk","pages":[{"title":"Zendesk","href":"/doc/integration/zendesk/get-started"}]},{"item":"Vercel","pages":[{"title":"Vercel","href":"/doc/integration/vercel"}]},{"item":"All integrations","pages":[{"title":"All integrations","href":"/doc/integration"}]}],"pages":[{"title":"Integrations","href":"/doc/integration/magento-2/getting-started/quick-start"}]},{"tab":"API reference","icon":"code","menu":[{"item":"Search","pages":[{"title":"Search","href":"/doc/rest-api/search"}]},{"item":"Agent Studio","pages":[{"title":"Agent Studio","href":"/doc/rest-api/agent-studio"}]},{"item":"A/B testing","groups":[{"group":"A/B testing API v3","icon":"code","pages":[{"title":"A/B Testing API","sidebarTitle":"Overview","href":"/doc/rest-api/abtesting-v3"},{"title":"List all A/B tests","openapi":"specs/abtesting-v3.yml get /3/abtests","href":"/doc/rest-api/abtesting-v3/list-ab-tests"},{"title":"Retrieve A/B test details","openapi":"specs/abtesting-v3.yml get /3/abtests/{id}","href":"/doc/rest-api/abtesting-v3/get-ab-test"},{"title":"Retrieve timeseries of an A/B test","openapi":"specs/abtesting-v3.yml get /3/abtests/{id}/timeseries","href":"/doc/rest-api/abtesting-v3/get-timeseries"},{"title":"Create an A/B test","openapi":"specs/abtesting-v3.yml post /3/abtests","href":"/doc/rest-api/abtesting-v3/add-ab-tests"},{"title":"Estimate the sample size and duration of an A/B test","openapi":"specs/abtesting-v3.yml post /3/abtests/estimate","href":"/doc/rest-api/abtesting-v3/estimate-ab-test"},{"title":"Stop an A/B test","openapi":"specs/abtesting-v3.yml post /3/abtests/{id}/stop","href":"/doc/rest-api/abtesting-v3/stop-ab-test"},{"title":"Delete an A/B test","openapi":"specs/abtesting-v3.yml delete /3/abtests/{id}","href":"/doc/rest-api/abtesting-v3/delete-ab-test"},{"title":"Retrieve captured A/B test settings","openapi":"specs/abtesting-v3.yml get /3/abtests/{id}/settings","href":"/doc/rest-api/abtesting-v3/get-ab-test-settings"},{"title":"Capture a variant's settings and stop the A/B test","openapi":"specs/abtesting-v3.yml post /3/abtests/{id}/settings/{variantId}","href":"/doc/rest-api/abtesting-v3/save-variant-settings"},{"title":"Apply a variant's captured settings to the control index","openapi":"specs/abtesting-v3.yml post /3/abtests/{id}/settings/{variantId}/apply","href":"/doc/rest-api/abtesting-v3/apply-variant-settings"}]},{"group":"A/B testing API v2 (deprecated)","icon":"code","pages":[{"title":"A/B Testing API","sidebarTitle":"Overview","href":"/doc/rest-api/abtesting"},{"title":"List all A/B tests","openapi":"specs/abtesting.yml get /2/abtests","href":"/doc/rest-api/abtesting/list-ab-tests"},{"title":"Retrieve A/B test details","description":"This endpoint is deprecated. Use the A/B Testing API v3 instead.","openapi":"specs/abtesting.yml get /2/abtests/{id}","href":"/doc/rest-api/abtesting/get-ab-test"},{"title":"Create an A/B test","openapi":"specs/abtesting.yml post /2/abtests","href":"/doc/rest-api/abtesting/add-ab-tests"},{"title":"Estimate the sample size and duration of an A/B test","description":"This endpoint is deprecated. Use the A/B Testing API v3 instead.","openapi":"specs/abtesting.yml post /2/abtests/estimate","href":"/doc/rest-api/abtesting/estimate-ab-test"},{"title":"Stop an A/B test","openapi":"specs/abtesting.yml post /2/abtests/{id}/stop","href":"/doc/rest-api/abtesting/stop-ab-test"},{"title":"Delete an A/B test","openapi":"specs/abtesting.yml delete /2/abtests/{id}","href":"/doc/rest-api/abtesting/delete-ab-test"}]}]},{"item":"Advanced Personalization","pages":[{"title":"Advanced Personalization","href":"/doc/rest-api/advanced-personalization"}]},{"item":"Analytics","pages":[{"title":"Analytics","href":"/doc/rest-api/analytics"}]},{"item":"Classic Personalization","pages":[{"title":"Classic Personalization","href":"/doc/rest-api/personalization"}]},{"item":"Composition","pages":[{"title":"Composition","href":"/doc/rest-api/composition"}]},{"item":"Crawler","pages":[{"title":"Crawler","href":"/doc/rest-api/crawler"}]},{"item":"Ingestion","pages":[{"title":"Ingestion","href":"/doc/rest-api/ingestion"}]},{"item":"Insights","pages":[{"title":"Insights","href":"/doc/rest-api/insights"}]},{"item":"Monitoring","pages":[{"title":"Monitoring","href":"/doc/rest-api/monitoring"}]},{"item":"Recommend","pages":[{"title":"Recommend","href":"/doc/rest-api/recommend"}]},{"item":"Query Suggestions","pages":[{"title":"Query Suggestions","href":"/doc/rest-api/query-suggestions"}]},{"item":"Suggested Actions","pages":[{"title":"Suggested Actions","href":"/doc/rest-api/suggested-actions"}]},{"item":"Usage","pages":[{"title":"Usage","href":"/doc/rest-api/usage"}]},{"item":"All APIs","pages":[{"title":"All APIs","href":"/doc/rest-api"}]}]}]},"basePath":"","title":"Create an A/B test - Algolia","buildId":"dpl_8hoxaqFTU7hTr6A2fUraxAyjuiZo","deploymentId":"dpl_8hoxaqFTU7hTr6A2fUraxAyjuiZo","dynamics":["c2aa737661","2b790eda92","b0f84f53ff","a9bb46feb3"],"chunks":["OpenApiReferenceProvider-CDiBsYGW.js","utils-KF9rPlmF.js","cloneDeep-izs3Hzxb.js","_Uint8Array-BVIqJ90l.js","isObjectLike-C8vmzPEN.js","isArray-Dcu1dQ5t.js","utils-C26urKTX.js","toString-BX-iyh8G.js","isSymbol-CSH9U2Gm.js","addUniqueKeysToSchema-BdjmJAC1.js","snippetPresets-3IpDBjt3.js","style-to-object-BY3JEAdk.js","v4-DIgz8zy6.js","conditional-requirements-CFM0id0Q.js","ApiExamples-D4x_2vvo.js","isEqual-BfaiBbcl.js","usePlaygroundInputsStore-BIWdc5Pa.js","shallow-LQqfiMNd.js","getApiPlaygroundDisplay-DryzlOZG.js","CodeSnippet-tcJujU4r.js","CodeSnippets-BHp0nVLL.js","Page-1CZdsdAn.js","getPastedJson-DU-1ayUv.js","icon-CZK2hPr4.js","MethodPill-DOaqmTFC.js","DuplicateIcon-B5-nUxxl.js","createIcon-CDP_U77G.js","DynamicMarkdown-GHvayGOn.js","SectionHeading-BYvpkmUD.js","axios-vUo_bRtp.js","Markdown-uxhlayGT.js","clsx-B35qUV0p.js","lib-DuNMoZ05.js","lib-B8HbPgcC.js","html-void-elements-mCSPHezU.js","dist-BvrGG8gU.js","katex-YMM-FMeD.js","marked.esm-CZWythHk.js","AssistantPageLink-CAf0yVYe.js"]}