First Day with Switchover

Welcome to Switchover – we are proud to have you here!

It takes only a few minutes to start with the first toggle. With this Quickstart Guide we will help you understand how Switchover works.

Why Feature Toggles

Feature Toggles help teams in today’s world to quickly and efficiently produce features for end users without fear of merge conflicts or faulty features. Unfinished code can be easily turned off and centrally managed through Switchover’s UI. Feature toggles, also known as feature flags, are configurable conditions that, depending on the settings, make functions invisible to customers or only visible in certain cases. This way, for example, tests can be performed on the productive, realistic environment without the actual customers noticing. Due to the simple and fast configuration in real time, teams have full control over their environments at all times.

Start with your first toggle

To start with switchover you need an account. This can be created free of charge at https://app.switchover.io/register. After successful registration, you will see the landing page where the name of the organizational unit must be created first. The name is in principle freely selectable but unique application-wide. So please choose something individual.

In my example I called the organizational unit „switchover-demo“, not very exciting I know.
As you can see now, the name of the organizational unit appears in the path of the page. This will play a role later but it is not important now because we want to create Feature Toogles, correct?

By clicking on „Create Toggle“ a menu opens on the right side where the name of the toggle is defined. This name identifies the toggle later in the code – so you should be creative. In my case I call the toggle „switchOverToggleA“. By clicking on „Create“ the toggle is created and a new menu opens.

Now conditions can be stored for toggle and the strategy can be defined when a flag should be evaluated as active/not active. It is completely up to you how many conditions should be configured for a toggle. For our example we want to keep it simple and check if a user ID has a certain value. To do this, we create a key/value pair via „Add Condition“ and define the condition via the drop down field. One more quick click on Save and we have created our first feature Toggle.

Get Feature Toggles via API

So… what now? Now we have a feature toggle, but how can we use it? This is where the Switchover API and Switchover SDKs come in. Let’s first look at our API and what environments have to do with it.

Enviroments

Depending on the plan, Switchover supports any number of projects and within the projects any number of environments. The assignment of the feature toggles to the environments is done automatically, whether a feature toggle is active or inactive is started via the corresponding environment. Since we are in a default project, two environments have already been created automatically and assigned to a default project. Information about projects and the project ID can be found in the menu item „Settings->Projects“ which we should now click on.

The highlighted screenshot shows the API Key which is unique and thus represents the access to the API. Copy the key and call the following URL: https://app.switch-over.io/api/sdk/<your key>/toggles_v2.json

However, before we can use the API, the changes must be published to the CDN. There is a function for this on the environment overview page:

After publishing your changes, copy the key and call the following URL: https://app.switchover.io/api/sdk/<your key>/toggles_v2.jsonAs response you should get a JSON which looks something like this:

[
    {
        "id": 4,
        "uuid": "b0752ac8-20a8-4f18-949b-a95ceda26df0",
        "environment_id": 4,
        "name": "switchOverToggleA",
        "status": "4",
        "strategy": "3",
        "created_at": "2020-08-04T10:29:12.000000Z",
        "updated_at": "2020-08-04T10:29:12.000000Z",
        "conditions": [
            {
                "id": 2,
                "toggle_id": 4,
                "key": "userID",
                "name": "operator-condition",
                "created_at": "2020-08-04T10:29:26.000000Z",
                "updated_at": "2020-08-04T10:29:26.000000Z",
                "operator": {
                    "id": 2,
                    "condition_id": 2,
                    "name": "equal",
                    "value": "10",
                    "created_at": "2020-08-04T10:29:26.000000Z",
                    "updated_at": "2020-08-04T10:29:26.000000Z"
                }
            }
        ]
    }
]

As you can see we get a nicely formatted JSON with the information about the feature toggle you just created. This JSON can now be evaluated by the customer application. Pretty simple and beautiful, right?

That’s it, our first toggle could go into production now. But wouldn’t it be even nicer if there was finished application code and you didn’t have to do the parsing and evaluation of the JSON yourself? What would a world be like where finished frameworks would do the work for you? It would be wonderful, it would be like switchover!

Next steps

Learn how to use our SDKs