---
title: Execute graphql query
slug: graph/api/execute-graphql-query
docTags: 
createdAt: 2026-08-28T18:28:55.472Z
---

{
  "id": "oDkvXHTNUiBcWmQAGK48L",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://cg.optimizely.com/content/v2",
    "servers": [
      {
        "url": "https://cg.optimizely.com/content/v2"
      }
    ],
    "name": "Execute graphql query",
    "description": "Retrieve content respect to graphql query",
    "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": [
        {
          "kind": "optional",
          "name": "body",
          "type": "object",
          "description": "",
          "customType": "GraphQLRequest",
          "schema": [
            {
              "name": "query",
              "kind": "optional",
              "type": "string",
              "description": ""
            },
            {
              "name": "mutation",
              "kind": "optional",
              "type": "string",
              "description": ""
            },
            {
              "name": "operationName",
              "kind": "optional",
              "type": "string",
              "description": ""
            },
            {
              "name": "variables",
              "kind": "optional",
              "type": "object",
              "description": "",
              "complexType": "anyOf",
              "complexItems": [
                {
                  "name": "object",
                  "description": "",
                  "schema": []
                }
              ],
              "schema": []
            }
          ],
          "modelRef": "#/components/schemas/GraphQLRequest",
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "epi-single",
          "name": "auth",
          "kind": "optional",
          "type": "apiKey",
          "description": "Single key authentication",
          "in": "query"
        },
        {
          "id": "epi-hmac",
          "name": "Authorization",
          "kind": "optional",
          "type": "apiKey",
          "description": "<p>HMAC authentication (<code>epi-hmac xxx</code>)</p>",
          "in": "header"
        },
        {
          "id": "Bearer",
          "name": "Bearer",
          "kind": "optional",
          "type": "http",
          "description": "JWT token",
          "scheme": "bearer"
        },
        {
          "id": "Basic",
          "name": "Basic",
          "kind": "optional",
          "type": "http",
          "description": "HMAC credentials",
          "scheme": "basic"
        }
      ],
      "cookieParameters": []
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "Returns query result",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "GraphQLResponse",
            "schema": [
              {
                "name": "data",
                "kind": "optional",
                "type": "object",
                "description": "Construct a type with a set of properties K of type T",
                "modelRef": "#/components/schemas/Record_string.any_",
                "customType": "Record_string.any_",
                "schema": []
              },
              {
                "name": "extensions",
                "kind": "optional",
                "type": "object",
                "description": "Construct a type with a set of properties K of type T",
                "modelRef": "#/components/schemas/Record_string.any_",
                "customType": "Record_string.any_",
                "schema": []
              }
            ],
            "modelRef": "#/components/schemas/GraphQLResponse",
            "isExpanded": true
          }
        ]
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "rC72pRdMOd3HZ9Ji1rwkX",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://cg.optimizely.com/content/v2 \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/json' \\\n     --data '{\n     \"variables\": {}\n     }'"
        },
        {
          "id": "2KZcL6kQLaNv21hUq2i3T",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar raw = JSON.stringify({\n   \"variables\": {}\n});\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"https://cg.optimizely.com/content/v2\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "XWQj70NxKPxRTVC2Myq1h",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://cg.optimizely.com/content/v2\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\nrequest.body = JSON.dump({\n   \"variables\": {}\n})\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "wHtBEHUwWsHZ2h-bjplNa",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://cg.optimizely.com/content/v2\"\n\npayload = json.dumps({\n   \"variables\": {}\n})\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "rC72pRdMOd3HZ9Ji1rwkX"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "// Returns query result\n{\n  \"data\": {},\n  \"extensions\": {}\n}"
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}