---
title: Select a Winning Variant
description: Select a winning variant for a completed experiment.
url: https://storyblok.com/docs/api/management/experiments/select-a-winning-variant
---

# Select a Winning Variant

Select a winning variant for a completed experiment that had no winner. Once you select a non-control variant as the winning variant, it supersedes the control and becomes the only published story. To complete an experiment and pick the winning variant in a single call, use the [complete an experiment with a winning variant endpoint](/docs/api/management/experiments/complete-an-experiment-with-a-winning-variant) instead.

PATCH

```html
https://mapi.storyblok.com/v1/spaces/:space_id/experiments/:experiment_id/select_winner
```

## Path parameters

-   `:space_id` (required) (number)
    
    Numeric ID of a space.
    
-   `:experiment_id` (required) (number)
    
    Numeric ID of the experiment.
    

## Query parameters

-   `variant_id` (required) (number)
    
    Numeric ID of the winning variant.
    

## Response properties

-   `experiment` (The Experiment Object)
    
    The [experiment object](/docs/api/management/experiments/the-experiment-object) with `winning_variant_id` set.
    

## Examples

-   cURL
    
    ```shellscript
    curl "https://mapi.storyblok.com/v1/spaces/288868932106293/experiments/176070002766742/select_winner\
    ?variant_id=176070002791237" \
      -X PATCH \
      -H "Authorization: YOUR_OAUTH_TOKEN" \
      -H "Content-Type: application/json" \
      -d "{}"
    ```
    
-   JS
    
    ```javascript
    // storyblok-js-client@>=7, node@>=18
    import Storyblok from "storyblok-js-client";
    
    const storyblok = new Storyblok({
      oauthToken: "YOUR_PERSONAL_ACCESS_TOKEN",
    });
    
    try {
      const response = await storyblok.patch('spaces/288868932106293/experiments/176070002766742/select_winner?variant_id=176070002791237', {})
      console.log({ response })
    } catch (error) {
      console.log(error)
    }
    ```
    
-   PHP
    
    ```php
    $client = new \Storyblok\ManagementClient('YOUR_OAUTH_TOKEN');
    
    $payload = [];
    
    $client->patch('spaces/288868932106293/experiments/176070002766742/select_winner?variant_id=176070002791237', $payload)->getBody();
    ```
    
-   Java
    
    ```java
    HttpResponse<String> response = Unirest.patch("https://mapi.storyblok.com/v1/spaces/288868932106293/experiments/176070002766742/select_winner?variant_id=176070002791237")
      .header("Content-Type", "application/json")
      .header("Authorization", "YOUR_OAUTH_TOKEN")
      .body({})
      .asString();
    ```
    
-   C#
    
    ```csharp
    var client = new RestClient("https://mapi.storyblok.com/v1/spaces/288868932106293/experiments/176070002766742/select_winner?variant_id=176070002791237");
    var request = new RestRequest(Method.PATCH);
    
    request.AddHeader("Content-Type", "application/json");
    request.AddHeader("Authorization", "YOUR_OAUTH_TOKEN");
    request.AddParameter("application/json", "{}", ParameterType.RequestBody);
    IRestResponse response = client.Execute(request);
    ```
    
-   Python
    
    ```python
    import requests
    
    url = "https://mapi.storyblok.com/v1/spaces/288868932106293/experiments/176070002766742/select_winner"
    
    querystring = {"variant_id":"176070002791237"}
    
    payload = {}
    headers = {
      'Content-Type': "application/json",
      'Authorization': "YOUR_OAUTH_TOKEN"
    }
    
    response = requests.request("PATCH", url, data=payload, headers=headers, params=querystring)
    
    print(response.text)
    ```
    
-   Ruby
    
    ```ruby
    require 'storyblok'
    client = Storyblok::Client.new(oauth_token: 'YOUR_OAUTH_TOKEN')
    
    payload = {}
    
    client.patch('spaces/288868932106293/experiments/176070002766742/select_winner', {:params => {
      "variant_id" => "176070002791237"
    }}, payload)
    ```
    
-   Swift
    
    ```swift
    let storyblok = URLSession(storyblok: .mapi(accessToken: .oauth("YOUR_OAUTH_TOKEN")))
    var request = URLRequest(storyblok: storyblok, path: "spaces/288868932106293/experiments/176070002766742/select_winner")
    request.url!.append(queryItems: [
        URLQueryItem(name: "variant_id", value: "176070002791237")
    ])
    request.httpMethod = "PATCH"
    request.httpBody = try JSONSerialization.data(withJSONObject: [ ])
    let (data, _) = try await storyblok.data(for: request)
    print(try JSONSerialization.jsonObject(with: data))
    ```
    
-   Kotlin
    
    ```kotlin
    val client = HttpClient {
        install(Storyblok(MAPI)) {
            accessToken = OAuth("YOUR_OAUTH_TOKEN")
        }
    }
    
    val response = client.patch("spaces/288868932106293/experiments/176070002766742/select_winner") {
        url {
            parameters.append("variant_id", "176070002791237")
        }
        setBody(buildJsonObject { })
    }
    
    println(response.body<JsonElement>())
    ```

## Pagination

-   [Previous: Retrieve Multiple Experiments](/docs/api/management/experiments/retrieve-multiple-experiments)
-   [Next: The Experiment Object](/docs/api/management/experiments/the-experiment-object)
