Dev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideProduct feedbackGitHubNuGetDev CommunitySubmit a ticketLog In

Get started with the Optimizely Web Experimentation REST API

Describes how to get started with Optimizely Web Experimentation REST API

This tutorial lets you get started in your development efforts by using the Optimizely Optimizely Web Experimentation API. This sample demonstrates how to programmatically:

  • Set up a developer account and obtain an access token.
  • Use that token to invoke your first REST request.

Generate a token

To use the REST API you must obtain a token:

  1. Access your developer account at app.optimizely.com. Once logged in, the dashboard is displayed.
  2. Click Profile on the bottom left-hand corner of the navigation tree.
  3. Select the API Access tab.
  4. Click Generate New Token.
  5. Enter a name for the new token on the popup and click Create. The website will redirect to the dashboard.
  6. Copy the token value from the Token column on the dashboard.

Make your first API call

In this section, you will invoke the List Projects endpoint to obtain a list of projects.

To use the Optimizely Web Experimentation REST API, you must include a request header called Authorization, set it to specify a Bearer token, and include the access token generated above.

In the following example, replace {personal_token} with the access token that you generated above and then execute the command using a terminal window:

curl -H "Authorization: Bearer {personal_token}" "https://api.optimizely.com/v2/projects"

The response contains a collection listing all of your projects:

[
  {
    "account_id": 5935064,
    "confidence_threshold": 0.9,
    "created": "2022-01-11T17:19:41.401142Z",
    "description": "",
    "id": 21014920239,
    "is_classic": false,
    "is_flags_enabled": false,
    "last_modified": "2024-01-23T20:17:13.304965Z",
    "name": "Combined Dev Docs",
    "platform": "web",
    "sdks": [],
    "status": "active",
    "web_snippet": {
      "code_revision": 6281,
      "enable_force_variation": false,
      "exclude_disabled_experiments": false,
      "exclude_names": true,
      "include_jquery": false,
      "ip_anonymization": false,
      "js_file_size": 89333,
      "library": "none"
    }
  },
  {
    "account_id": 5935064,
    "confidence_threshold": 0.9,
    "created": "2022-02-10T01:09:22.479578Z",
    "description": "Demo Sandbox Account for web experiments ",
    "id": 21187142045,
    "is_classic": false,
    "is_flags_enabled": false,
    "last_modified": "2024-02-22T20:45:11.048997Z",
    "name": "Attic and Button",
    "platform": "web",
    "sdks": [],
    "status": "active",
    "web_snippet": {
      "code_revision": 75,
      "enable_force_variation": true,
      "exclude_disabled_experiments": false,
      "exclude_names": false,
      "include_jquery": false,
      "ip_anonymization": false,
      "js_file_size": 84966,
      "library": "none"
    }
  },
  {
    "account_id": 5935064,
    "confidence_threshold": 0.9,
    "created": "2022-06-02T13:39:49.328271Z",
    "description": "",
    "id": 21562231775,
    "is_classic": false,
    "is_flags_enabled": false,
    "last_modified": "2024-02-21T12:06:13.433610Z",
    "name": "[Craig] Playground",
    "platform": "web",
    "sdks": [],
    "status": "active",
    "web_snippet": {
      "code_revision": 47,
      "enable_force_variation": false,
      "exclude_disabled_experiments": false,
      "exclude_names": true,
      "include_jquery": false,
      "ip_anonymization": false,
      "js_file_size": 84945,
      "library": "none"
    }
  },
  {
    "account_id": 5935064,
    "confidence_threshold": 0.9,
    "created": "2022-07-12T20:40:05.099614Z",
    "description": "",
    "id": 21770491416,
    "is_classic": false,
    "is_flags_enabled": true,
    "last_modified": "2023-10-17T21:30:09.195688Z",
    "name": "Web Demo",
    "platform": "custom",
    "sdks": [],
    "status": "active"
  },
  {
    "account_id": 5935064,
    "confidence_threshold": 0.9,
    "created": "2024-01-12T22:44:32.576778Z",
    "description": "Personalization campaign for the dev doc site.",
    "id": 27211030214,
    "is_classic": false,
    "is_flags_enabled": false,
    "last_modified": "2024-01-17T06:31:19.988677Z",
    "name": "Personalization",
    "platform": "web",
    "sdks": [],
    "status": "active",
    "web_snippet": {
      "code_revision": 2,
      "enable_force_variation": false,
      "exclude_disabled_experiments": false,
      "exclude_names": true,
      "include_jquery": false,
      "ip_anonymization": false,
      "js_file_size": 85095,
      "library": "none"
    }
  },
  {
    "account_id": 5935064,
    "confidence_threshold": 0.9,
    "created": "2024-01-12T22:41:57.672289Z",
    "description": "",
    "id": 27216770080,
    "is_classic": false,
    "is_flags_enabled": false,
    "last_modified": "2024-01-17T06:31:20.085922Z",
    "name": "Edge project",
    "platform": "web",
    "sdks": [],
    "status": "active",
    "web_snippet": {
      "code_revision": 2,
      "enable_force_variation": false,
      "exclude_disabled_experiments": false,
      "exclude_names": true,
      "include_jquery": false,
      "ip_anonymization": false,
      "js_file_size": 85004,
      "library": "none"
    }
  }
]

Start building

After performing the steps above, you can start building an application with Optimizely Web Experimentation See Optimizely API for information about all of our supported endpoints.

You can download our Postman collection to experiment with the APIs using Postman.

Questions about using the REST API? Submit a ticket to the developer support team.