---
title: Return the datafile for the given environment. If you need strict consistency, you can pass the datafile to other Optimizely instances. so that all initialize from exactly the same datafile version (rather than each fetching the datafile separately from t
slug: feature-experimentation/api/return-the-datafile-for-the-given-environment-if-you-need-strict-consistency-you-can-pass-the-datafile-to-other-optimizely-instances-so-that-all-initialize-from-exactly-the-same-datafile-version-rather-than-
docTags: 
createdAt: 2026-08-28T15:54:06.731Z
---

{
  "id": "ycJhsUK6aiGGTDvrZs6Np",
  "type": "api-oas-v2",
  "data": {
    "method": "GET",
    "url": "/v1/datafile",
    "servers": [],
    "name": "Return the datafile for the given environment. If you need strict consistency, you can pass the datafile to other Optimizely instances. so that all initialize from exactly the same datafile version (rather than each fetching the datafile separately from the Optimizely CDN).",
    "description": "Returns the json datafile for the given environment.",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [
        {
          "name": "accept",
          "type": "string",
          "kind": "optional",
          "description": "Generated from available response content types",
          "enum": [
            "application/json"
          ],
          "default": "application/json"
        }
      ],
      "queryParameters": [],
      "bodyDataParameters": [],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "SdkKeyAuth",
          "name": "X-Optimizely-SDK-Key",
          "kind": "optional",
          "type": "apiKey",
          "in": "header"
        },
        {
          "id": "TokenAuth",
          "name": "TokenAuth",
          "kind": "optional",
          "type": "http",
          "scheme": "bearer"
        }
      ],
      "cookieParameters": []
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "Valid response",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "Optimizely Datafile",
            "schema": [],
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "401",
        "description": "<p>Unauthorized, invalid JWT</p>",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "403",
        "description": "You do not have necessary permissions for the resource",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "Error",
            "schema": [
              {
                "name": "error",
                "kind": "optional",
                "type": "string",
                "description": ""
              }
            ],
            "modelRef": "#/components/schemas/Error",
            "isExpanded": true
          }
        ]
      }
    ],
    "hasXCodeSamples": false,
    "deprecated": false,
    "examples": {
      "languages": [
        {
          "id": "IvIbLwohY9Hbr51OfdYs7",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request GET \\\n     --url /v1/datafile \\\n     --header 'accept: application/json'"
        },
        {
          "id": "hdlrVeaaphSYggOFrwi5m",
          "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(\"/v1/datafile\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "7n_GiXNoxT7HZu40-mRSp",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"/v1/datafile\")\n\nhttp = Net::HTTP.new(url.host, url.port);\nrequest = Net::HTTP::Get.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\n\nresponse = http.request(request)\nputs response.read_body\n"
        },
        {
          "id": "uthsbvm5XlLETFmA2lm2m",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"/v1/datafile\"\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": "IvIbLwohY9Hbr51OfdYs7"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "// Valid response\n{}"
        },
        {
          "id": "response-1-401",
          "language": "401",
          "code": "// Unauthorized, invalid JWT\n"
        },
        {
          "id": "response-2-403",
          "language": "403",
          "code": "// You do not have necessary permissions for the resource\n{\n  \"error\": \"\"\n}"
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}