API Authentication

Authentication is done with a token passed in an HTTP header. Let's walk through how that's done.

To start making API calls, you must create a new API Token.

Accomplished at:

Account > Integrations. Name your new API Token and click the Create New Token button. Thermostat will show you the token only once.

The token will be long.

You need to set the Authorization header on your HTTP requests to the Thermostat API. This header requires you to set the content of the Authorization header with the format of Authorization: Bearer API TOKEN HERE.

Here's an example of an API request used to list all surveys for the authenticated user:

curl -H "Accept: application/json" \
     -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImNjYTgzOGIyYjIzODljZTJiZjJiNWJkNTU3Y2VjOWZiZDdjNDRmN2U5ZmQ4YTQyNzc1YmM4ZGUwY2M5ZTZkMzM4ZjAyM2VhYmRlN2EzYWVlIn0.eyJhdWQiOiIxIiwianRpIjoiY2NhODM4YjJiMjM4OWNlMmJmMmI1YmQ1NTdjZWM5ZmJkN2M0NGY3ZTlmZDhhNDI3NzViYzhkZTBjYzllNmQzMzhmMDIzZWFiZGU3YTNhZWUiLCJpYXQiOjE0OTQ4ODM0NjgsIm5iZiI6MTQ5NDg4MzQ2OCwiZXhwIjoxNTI2NDE5NDY4LCJzdWIiOiIyNyIsInNjb3BlcyI6W119.qvH4xIPW2I6OrsbrBeKvCS4yLYTBKn6t9gZPkMfA3ARxiqUxD0yIgY2_WOYizoQ7O9NoT7gvPpff-9_tyug9qumAqjqN9Vq3pQbD9OUwMHrqFfbXa79DVw6UVsaZDk9STu5f4D_3HcOfQOvTUmWC_H4bCR90AC5oVWV0GZ0HdTctSACdHAvoWvRZDyg4TJuCBzmchh4mYnDTi9V5jsQe0E1GQmSYLmeDTsbV_9lGe8pc7zgTM-tk1VTfk5PDn1vhH6NOJzQQjzd614KeKPcH2S0IQUf4TTfjYwoASWSLPeZhcefQnwMRGvy9ub8NNdw259FQhirwKM2-kolOQ9Dgyg8rMTqWWz5lyTeFWsjbdf-QRXvVsNVfB7-kMLL792_2ixQ23KhJJuOMNLF8Sz9pT1qOqUKkGI5bbYhS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