---
title: Fetch a Single Variation
slug: feature-experimentation/api/fetch-a-single-variation
docTags: 
createdAt: 2026-08-28T15:54:06.731Z
---

{
  "id": "8Jbzmls-scURkLgUWus1e",
  "type": "api-oas-v2",
  "data": {
    "method": "GET",
    "url": "https://api.optimizely.com/flags/v1//projects/{project_id}/flags/{flag_key}/variations/{variation_key}",
    "servers": [
      {
        "url": "https://api.optimizely.com/flags/v1//projects/{project_id}/flags/{flag_key}/variations/{variation_key}"
      }
    ],
    "name": "Fetch a Single Variation",
    "description": "<p>Fetch a single Variation for a Flag by its key.</p>\n<p>This operation corresponds to the <code>fetch_variation_url</code> in a Variations response.</p>",
    "contentType": "application/json",
    "request": {
      "pathParameters": [
        {
          "kind": "required",
          "name": "project_id",
          "type": "integer",
          "example": 12345,
          "description": "The project identifier"
        },
        {
          "kind": "required",
          "name": "flag_key",
          "type": "string",
          "example": "recurring_deposit",
          "description": "The Flag identifier"
        },
        {
          "kind": "required",
          "name": "variation_key",
          "type": "string",
          "example": "high_discount",
          "description": "The Variation identifier"
        }
      ],
      "headerParameters": [],
      "queryParameters": [],
      "bodyDataParameters": [],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "apiKey",
          "name": "apiKey",
          "kind": "optional",
          "type": "http",
          "scheme": "bearer"
        },
        {
          "id": "OAuth2",
          "name": "OAuth2",
          "kind": "optional",
          "type": "oauth2",
          "description": "Write applications that authenticate with the REST API via OAuth 2.0.",
          "oauth2Flows": {
            "authorizationCode": {
              "authorizationUrl": "https://app.optimizely.com/oauth2/authorize",
              "tokenUrl": "https://app.optimizely.com/oauth2/token",
              "scopes": {
                "all": "Grants all access"
              }
            }
          },
          "requiredScopes": [
            "read",
            "write"
          ]
        }
      ],
      "cookieParameters": []
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "<p>Successful retrieval, creation or update of a Variation for a Flag.</p>\n<p>The response includes RESTful JSON (<a href=\"https://restfuljson.org/\" target=\"_blank\">https://restfuljson.org/</a>) styled links. If a\nlink is not present in the response, it indicates a user is not authorized to access\nthe related resource.</p>",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "example": "{\"archive_url\":\"...\",\"archived\":false,\"created_time\":\"2019-05-08T00:00:00.000Z\",\"delete_url\":\"...\",\"description\":\"Use this to provide high discounts\",\"enabled\":true,\"environment_usage_count\":{\"development\":2,\"production\":3},\"fetch_flag_url\":\"...\",\"flag_key\":\"recurring_deposit\",\"id\":45633995,\"key\":\"high_discount\",\"name\":\"High Discount\",\"revision\":1,\"unarchive_url\":\"...\",\"update_url\":\"...\",\"updated_time\":\"2019-05-08T00:00:00.000Z\",\"url\":\"...\",\"urn\":\"variations.flag.optimizely.com::45633995\",\"variables\":{\"advanced\":{\"key\":\"advanced\",\"type\":\"json\",\"value\":\"{\\n\\t\\\"hello\\\": 123\\n}\"},\"amount\":{\"key\":\"amount\",\"type\":\"double\",\"value\":\"10.0\"},\"message\":{\"key\":\"message\",\"type\":\"string\",\"value\":\"Enjoy!!\"}}}",
            "description": "",
            "customType": "Variation",
            "schema": [
              {
                "name": "archive_url",
                "kind": "optional",
                "type": "object",
                "readOnly": true,
                "description": "Link to archive this Variation",
                "complexType": "allOf",
                "complexItems": [
                  {
                    "name": "UrlValue",
                    "description": "",
                    "modelRef": "#/components/schemas/UrlValue",
                    "schema": []
                  }
                ],
                "schema": []
              },
              {
                "name": "archived",
                "kind": "optional",
                "type": "boolean",
                "description": "Indicates if the Variation is archived or not"
              },
              {
                "name": "created_time",
                "kind": "required",
                "type": "string<date-time>",
                "readOnly": true,
                "description": "Timestamp when the Variation is created",
                "format": "date-time"
              },
              {
                "name": "delete_url",
                "kind": "optional",
                "type": "object",
                "readOnly": true,
                "description": "Link to delete this Variation",
                "complexType": "allOf",
                "complexItems": [
                  {
                    "name": "UrlValue",
                    "description": "",
                    "modelRef": "#/components/schemas/UrlValue",
                    "schema": []
                  }
                ],
                "schema": []
              },
              {
                "name": "description",
                "kind": "optional",
                "type": "string",
                "description": "Additional context of the Variation"
              },
              {
                "name": "enabled",
                "kind": "optional",
                "type": "boolean",
                "readOnly": true,
                "description": "Indicates if the Variation is enabled or not"
              },
              {
                "name": "environment_usage_count",
                "kind": "optional",
                "type": "map",
                "readOnly": true,
                "description": "<p>Map of rule/ruleset count associated with the variation in each environment that includes environment key as key and count as value</p>",
                "example": "{\"development\":15,\"production\":20}",
                "customType": "map<string, integer>",
                "schema": []
              },
              {
                "name": "fetch_flag_url",
                "kind": "optional",
                "type": "object",
                "readOnly": true,
                "description": "Link to flag url of this variation",
                "complexType": "allOf",
                "complexItems": [
                  {
                    "name": "UrlValue",
                    "description": "",
                    "modelRef": "#/components/schemas/UrlValue",
                    "schema": []
                  }
                ],
                "schema": []
              },
              {
                "name": "flag_key",
                "kind": "required",
                "type": "string",
                "description": "The Key of the Flag this Variation belongs to"
              },
              {
                "name": "id",
                "kind": "required",
                "type": "integer",
                "readOnly": true,
                "description": "System generated Unique ID of the Variation"
              },
              {
                "name": "in_use",
                "kind": "optional",
                "type": "boolean",
                "readOnly": true,
                "description": "Indicates if the Variation is in use by a rule or a ruleset"
              },
              {
                "name": "key",
                "kind": "required",
                "type": "string",
                "description": "<p>User-facing Unique identifier of the Variation</p>"
              },
              {
                "name": "name",
                "kind": "required",
                "type": "string",
                "description": "<p>User-facing name of the Variation</p>"
              },
              {
                "name": "revision",
                "kind": "optional",
                "type": "integer",
                "readOnly": true,
                "description": "Revision number for tracking changes"
              },
              {
                "name": "role",
                "kind": "optional",
                "type": "string",
                "readOnly": true,
                "description": "Granular permission role",
                "example": "admin"
              },
              {
                "name": "screenshot_name",
                "kind": "optional",
                "type": "string",
                "nullable": true,
                "description": "Original filename of the uploaded screenshot image. Null when no screenshot has been attached.",
                "example": "hero-banner.png",
                "maxLength": 255
              },
              {
                "name": "screenshot_url",
                "kind": "optional",
                "type": "string",
                "nullable": true,
                "description": "<p>Backend proxy path to the variation's uploaded screenshot image. Null when no screenshot has been attached. Format: /projects/{project_id}/files/{file_id}</p>",
                "example": "/projects/123/files/a1b2c3d4-e5f6-7890-abcd-ef1234567890",
                "maxLength": 2000
              },
              {
                "name": "unarchive_url",
                "kind": "optional",
                "type": "object",
                "readOnly": true,
                "description": "Link to unarchive this Variation",
                "complexType": "allOf",
                "complexItems": [
                  {
                    "name": "UrlValue",
                    "description": "",
                    "modelRef": "#/components/schemas/UrlValue",
                    "schema": []
                  }
                ],
                "schema": []
              },
              {
                "name": "update_url",
                "kind": "optional",
                "type": "object",
                "readOnly": true,
                "description": "Link to update this Variation",
                "complexType": "allOf",
                "complexItems": [
                  {
                    "name": "UrlValue",
                    "description": "",
                    "modelRef": "#/components/schemas/UrlValue",
                    "schema": []
                  }
                ],
                "schema": []
              },
              {
                "name": "updated_time",
                "kind": "required",
                "type": "string<date-time>",
                "readOnly": true,
                "description": "Timestamp when the Variation is updated",
                "format": "date-time"
              },
              {
                "name": "url",
                "kind": "required",
                "type": "object",
                "readOnly": true,
                "description": "Link to self",
                "complexType": "allOf",
                "complexItems": [
                  {
                    "name": "UrlValue",
                    "description": "",
                    "modelRef": "#/components/schemas/UrlValue",
                    "schema": []
                  }
                ],
                "schema": []
              },
              {
                "name": "urn",
                "kind": "required",
                "type": "string",
                "readOnly": true,
                "description": "The URN for the Variation"
              },
              {
                "name": "variables",
                "kind": "optional",
                "type": "map",
                "description": "Map of flag variables that include variable key and value",
                "example": "",
                "customType": "map<string, VariableValue>",
                "schema": []
              }
            ],
            "modelRef": "#/components/schemas/Variation",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "400",
        "description": "Malformed requests and invalid parameter names and types",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "401",
        "description": "Invalid credentials",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "403",
        "description": "Do not have permission to perform the operation",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "404",
        "description": "Not found. No content",
        "jsonExample": "",
        "isExpanded": true
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "YdU1nVJ3Dbo4DjBl3Zyyd",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request GET \\\n     --url https://api.optimizely.com/flags/v1//projects/{project_id}/flags/{flag_key}/variations/{variation_key} \\\n     --header 'accept: application/json'"
        },
        {
          "id": "atIVicW5_B-4GbekAJKZe",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar requestOptions = {\n   method: 'GET',\n   headers: myHeaders,\n   redirect: 'follow'\n};\n\nfetch(\"https://api.optimizely.com/flags/v1//projects/{project_id}/flags/{flag_key}/variations/{variation_key}\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "PtDZDFGREIeZ7UWwHW1YX",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.optimizely.com/flags/v1//projects/{project_id}/flags/{flag_key}/variations/{variation_key}\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Get.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "hyVHllF04kQ-0A7xs-gUE",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://api.optimizely.com/flags/v1//projects/{project_id}/flags/{flag_key}/variations/{variation_key}\"\n\npayload = {}\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"GET\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "YdU1nVJ3Dbo4DjBl3Zyyd"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "// Successful retrieval, creation or update of a Variation for a Flag.\nThe response includes RESTful JSON (https://restfuljson.org/) styled links. If a\nlink is not present in the response, it indicates a user is not authorized to access\nthe related resource.\n{\n  \"archive_url\": {},\n  \"archived\": false,\n  \"created_time\": \"\",\n  \"delete_url\": {},\n  \"description\": \"\",\n  \"enabled\": false,\n  \"environment_usage_count\": \"{\\\"development\\\":15,\\\"production\\\":20}\",\n  \"fetch_flag_url\": {},\n  \"flag_key\": \"\",\n  \"id\": 0,\n  \"in_use\": false,\n  \"key\": \"\",\n  \"name\": \"\",\n  \"revision\": 0,\n  \"role\": \"admin\",\n  \"screenshot_name\": \"hero-banner.png\",\n  \"screenshot_url\": \"/projects/123/files/a1b2c3d4-e5f6-7890-abcd-ef1234567890\",\n  \"unarchive_url\": {},\n  \"update_url\": {},\n  \"updated_time\": \"\",\n  \"url\": {},\n  \"urn\": \"\",\n  \"variables\": \"\"\n}"
        },
        {
          "id": "response-1-400",
          "language": "400",
          "code": "// Malformed requests and invalid parameter names and types\n"
        },
        {
          "id": "response-2-401",
          "language": "401",
          "code": "// Invalid credentials\n"
        },
        {
          "id": "response-3-403",
          "language": "403",
          "code": "// Do not have permission to perform the operation\n"
        },
        {
          "id": "response-4-404",
          "language": "404",
          "code": "// Not found. No content\n"
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}