To start using the REST API you'll need to first create an account as explained in Toggle Tools: How to Create a Feature Toggle. In the "API" tab of the account page, you can find your API token and make note of it. On this screen you'll also find rate limit usage in real time.

Gentle Rate Limiting

We know what it's like to manage an app. When rate limits are met, we don't immediately "shut it down". Your team will be reminded over the course of gracious timespan.

Authorization

When making requests to the REST API you can use the API token from the account page in a token based authentication scheme. This might look something like the following.

curl -X GET "https://www.foo.software/api/v1/account/${ENVIRONMENT_ID}/toggle" \
  -H "accept: application/json" \
  -H "Authorization: ${API_TOKEN}" \
  -H "Content-Type: application/json"

You may not need to supply a token for client-side requests in certain endpoints (specified in this documentation) if you provide the origin option in the toggle settings. This value would need to be the full domain that will be making requests to the API, for example https://www.google.com.

Methods

Environment Toggle State

Gets the toggle state denoted by the value of data.on in the response payload. If data.on is true the feature is toggled on. This endpoint supports the origin seting instead of an authentication token.

GET "https://www.toggle.tools/api/v1/account/${ACCOUNT_ID}/toggle/${ENVIRONMENT}/${TOGGLE}/state"

The exact URL for this endpoint can be found when you login to your account and navigate to the toggle details page. In the dashboard, you can navigate to the toggle detail page by clicking into the environment list and then on the arrow icon by the toggle name. At the bottom of this page you'll find the exact URL endpoint.

Example response body

{
  "code" : "SUCCESS_GENERIC",
  "namespace" : "route/Account/findToggleStateByAccount",
  "status" : 200,
  "message" : "Success!",
  "data" : {
    "on" : true
  }
}

All Environments and Toggles

Gets all data for an account in a single request. This endpoint requires authentication and doesn't support the origin setting. The data from this endpoint includes all environments and data for their corresponding toggles. This data includes settings and stats (typically number of views for gradual rollouts).

GET "https://www.foo.software/api/v1/account/${ACCOUNT_ID}/toggle"

The exact URL for this endpoint can be found at the bottom of the dashboard page when logged into your account.

Example response body

{
  "namespace" : "route/Account/findTogglesByAccountId",
  "message" : "Success!",
  "code" : "SUCCESS_GENERIC",
  "status" : 200,
  "data" : {
    "apiRate" : {
      "limitExceeded" : {},
      "todayDate" : "05/05/2020",
      "todayCount" : 1
    },
    "list" : {
      "toggle1" : {
        "label" : "toggle 1"
      }
    },
    "environments" : {
      "production" : {
        "label" : "production",
        "list" : {
          "toggle1" : {
            "settings" : {
              "origin" : "https://www.foo.software",
              "gradual" : {
                "start" : {
                  "date" : 1586448000000,
                  "percent" : 0
                },
                "enabled" : true,
                "end" : {
                  "percent" : 100,
                  "date" : 1587052800000
                }
              },
              "splitPercentEnabled" : false,
              "splitPercent" : 100
            },
            "stats" : {
              "off" : {
                "04/14/2020" : 9,
                "04/09/2020" : 9,
                "04/16/2020" : 4,
                "04/18/2020" : 0,
                "04/13/2020" : 10,
                "04/17/2020" : 0,
                "04/12/2020" : 18,
                "04/10/2020" : 17,
                "04/15/2020" : 6,
                "04/11/2020" : 11
              },
              "on" : {
                "04/13/2020" : 10,
                "04/18/2020" : 8,
                "04/17/2020" : 15,
                "04/16/2020" : 24,
                "04/09/2020" : 0,
                "04/14/2020" : 14,
                "04/15/2020" : 18,
                "04/11/2020" : 4,
                "04/10/2020" : 2,
                "04/12/2020" : 10
              }
            },
            "on" : true
          }
        }
      }
    }
  }
}