Single key
API key to fetch publicly available data
Single key authentication provides read-only access to publicly available GraphQL data in Optimizely Graph. Use this method to test queries in GraphiQL (an in-browser GraphQL explorer) or retrieve published content without user-specific authorization. Single key authentication is available only at the GraphQL query endpoint.
Include the single key in the Authorization header using the following format:
Authorization: epi-single TOKENOptimizely Graph returns only published content accessible to the public user (users in the Everyone group in Optimizely CMS).
The returned content must meet all the following conditions:
- The content is not deleted (
_deleted = false). - The content has not expired (
StopPublishisnullorStopPublishis in the future). - The content is published (
Status = Published). - The content is readable by everyone (RBAC includes
r:Everyone:Read).
Request examples
The following snippets show how to call the Optimizely Graph query endpoint with a single key from common client environments.
cURL example
Use this curl command to send a GraphQL query authenticated with a single key.
curl "https://cg.optimizely.com/content/v2?auth=YOUR_SINGLE_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "{ Article { items { title } } }"}'JavaScript example
Use the following JavaScript snippet to call the same endpoint with the Fetch API.
const response = await fetch("https://cg.optimizely.com/content/v2?auth=YOUR_SINGLE_KEY", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ query: "{ Article { items { title } } }" }),
});
const data = await response.json();
console.log(data);Updated 7 days ago
