Getting Started Tutorial for Optimizely's REST API

This tutorial enables you to quickly get started in your development efforts to use Optimizely's REST API. This sample demonstrates how to programmatically:

1. Create a Developer Account

If you don't have an Optimizely account already, sign up for a free developer account. This account will give you free access to all of Optimizely’s APIs and services.

2. Generate a token

In order to use our 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.

3. Make your first API call

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

To use the 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:

[
  {
    "name": "Test Project",
    "confidence_threshold": 0.9,
    "dcp_service_id": 121234,
    "description": "Project for user sign up flow",
    "platform": "web",
    "sdks": [
      "android"
    ],
    "status": "active",
    "web_snippet": {
      "enable_force_variation": false,
      "exclude_disabled_experiments": false,
      "exclude_names": true,
      "include_jquery": true,
      "ip_anonymization": false,
      "ip_filter": "^206\\.23\\.100\\.([5-9][0-9]|1([0-4][0-9]|50))$",
      "library": "jquery-1.11.3-trim",
      "project_javascript": "alert(\"Active Experiment\")",
      "code_revision": 0,
      "js_file_size": 63495
    },
    "account_id": 12345,
    "created": "2018-05-11T17:59:51.753Z",
    "id": 1000,
    "is_classic": true,
    "last_modified": "2018-05-11T17:59:51.753Z",
    "socket_token": "AABBCCDD~123456789"
  }
]

Start building!

You can now start building an application with Optimizely! See our API reference for information about all of our supported endpoints.

For a more in-depth tutorial illustrating how to consume our REST APIs using Python, see our FullStack REST Customer example that walks you through all of the endpoints required to construct an Experiment using Python scripts. You can also download our Postman collection to experiment with the APIs using Postman.

If you have any questions about using the REST API, you can ask the developer community, or you can submit a ticket to the developer support team. We'll be happy to help as you build your application.