---
title: Download a file
slug: feature-experimentation/api/download-a-file
docTags: 
createdAt: 2026-10-13T18:16:15.508Z
---

{
  "id": "o6yUMmXwLqS8fgbr8yLNC",
  "type": "api-oas-v2",
  "data": {
    "method": "GET",
    "url": "https://api.optimizely.com/flags/v1//projects/{project_id}/files/{file_id}",
    "servers": [
      {
        "url": "https://api.optimizely.com/flags/v1//projects/{project_id}/files/{file_id}"
      }
    ],
    "name": "Download a file",
    "description": "<p>Download an uploaded file. The backend checks that the user has\nat least FLAGS_READ permission on the project, then streams the\nfile content from GCS.</p>",
    "contentType": "application/json",
    "request": {
      "pathParameters": [
        {
          "kind": "required",
          "name": "project_id",
          "type": "integer",
          "example": 12345,
          "description": "The project identifier"
        },
        {
          "kind": "required",
          "name": "file_id",
          "type": "string",
          "description": "<p>File identifier (UUID from upload response)</p>"
        }
      ],
      "headerParameters": [
        {
          "name": "accept",
          "type": "string",
          "kind": "optional",
          "description": "Generated from available response content types",
          "enum": [
            "application/octet-stream"
          ],
          "default": "application/octet-stream"
        }
      ],
      "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": "File content streamed",
        "jsonExample": "",
        "isExpanded": true,
        "headers": [
          {
            "kind": "optional",
            "name": "Content-Disposition",
            "type": "string",
            "description": "Attachment with original filename"
          },
          {
            "kind": "optional",
            "name": "Content-Type",
            "type": "string",
            "description": "MIME type of the file"
          }
        ]
      },
      {
        "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": "File not found or deleted",
        "jsonExample": "",
        "isExpanded": true
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "MyCbDt_HxFro98i5kT4PQ",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request GET \\\n     --url https://api.optimizely.com/flags/v1//projects/{project_id}/files/{file_id} \\\n     --header 'accept: application/octet-stream'"
        },
        {
          "id": "S7IfyYiYd9RE71Cz8gWOB",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/octet-stream\");\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}/files/{file_id}\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "OrUQP8q7cRVVpMHHsEPOH",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.optimizely.com/flags/v1//projects/{project_id}/files/{file_id}\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Get.new(url)\nrequest[\"accept\"] = \"application/octet-stream\"\nrequest[\"content-type\"] = \"application/json\"\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "wIppuHHNWu4uCeGLGCtvm",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://api.optimizely.com/flags/v1//projects/{project_id}/files/{file_id}\"\n\npayload = {}\nheaders = {\n   'accept': 'application/octet-stream',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"GET\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "MyCbDt_HxFro98i5kT4PQ"
    },
    "results": {
      "languages": [
        {
          "id": "eAeS3x401cpsGjjInWU2O",
          "language": "200",
          "code": "// File content streamed\n"
        },
        {
          "id": "BJDdvFABhh617eF1PtgIj",
          "language": "401",
          "code": "// Invalid credentials\n"
        },
        {
          "id": "4kKsndlYKO00z8rPR6Byr",
          "language": "403",
          "code": "// Do not have permission to perform the operation\n"
        },
        {
          "id": "yC33XkiOo5witLlIe4A93",
          "language": "404",
          "code": "// File not found or deleted\n"
        }
      ],
      "selectedLanguageId": "eAeS3x401cpsGjjInWU2O"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}