Tesla automation

Last updated 06-May-2023

The options for automating the control of your Tesla, including the timing of Tesla charging, are relatively limited. There are a number of reasons why owners may want to control their Tesla without going via the app. They may either want to create an IoS shortcut that can be added to their iwatch, execute the request on a timed basis as part of automation, or access data to be included in other applications or via a PC.

If we take charging, the Tesla API provides the ability to stop and start charging manually, and one or the other on a schedule. Owners may however want to automate both the start and stop times, something not achievable with the app.

Why can I not call the Tesla API myself?

You can, the API is documented on the internet, however it is not that straightforward.

To execute a command such as start charging, the following steps are required:

To make life easier, we perform all these steps behind the scenes, youjust provide the refresh token and the request, optionally the car Id if you have multiple cars on the account (otherwise we default to the first car on the account) and then report back success or fail. If the request is for information, then we return the information in JSON format enabling the information to be used in other programmes.

How to use the Tesla API for automation

If you wish to use our API, then you can generate the URLs using the tool below, although the syntax is pretty easy. You can then embed the URL in a IoS or Android shortcut, bookmark the link, or use it in multiple other ways and when you call the link, we'll take the information and execute the command.

Token generation

We have created a utility to generate a Tesla token. This utility uses a Tesla feature so we do not need your Tesla user name and password, and will return the Tesla token and the vehicle ID for each car on your account. We also supply the refresh token for those that want to use the tokens on a 3rd party application but wish to use an independant website to generate the token.

The only way to expire a refresh token is to change your password on MyTesla.

For the purposes of the examples below we will use [token] to represent the use of the API token, and [refresh] the use of the refresh token.

Command builder

You can generate your own commands using the simple command builder below.

We used to allow you to provide the API token directly, however they expire so quickly, this is relatively pointless and so we require the refresh token. This however means we have to keep regenerating them, and while this is something we can do, it slows everything down. Our new API V3 now securely encrypts and stores your refresh token and resulting API token, and if you resubmit the same refresh token, we will retrieve the API token we have and refresh it if necessary. The advantage of this is when you want to do a string of commands or control charging overnight. The API token can be reused and the performance of the API will be more reliable. The onlder API version 2 is however still available.

Examples of the commands

We have created a fairly simple API which in practice just looks like a web page URL. The format for the API is as follows, which will work on the first car on your Tesla account (for most people this will be their only car on the account).


The response to a successful command looks similar to this

{"car":"MyTeslaCarName", "status":"success", "cause":"Command door_lock succeeded"}

If a paramter is required then this is added by using an extra parameter as follows which sets the charge limit to 70%:


If you have more than one car on your account you can also specify the car Id (we list these when we generate tokens)

https://tesla-info.com/api/control_v3.php?refresh=[refresh]&request=[command]&id=[car id]

The refresh token is very long! An example of a request is:

An example of the response is:

{"car":"MyTeslaCarName", "response":{"battery_heater":false, "battery_heater_no_power":null, "climate_keeper_mode":"off", "defrost_mode":0, "driver_temp_setting":20.0, "fan_status":0, "inside_temp":8.7, "is_auto_conditioning_on":false, "is_climate_on":false, "is_front_defroster_on":false, "is_preconditioning":false, "is_rear_defroster_on":false, "left_temp_direction":906, "max_avail_temp":28.0, "min_avail_temp":15.0, "outside_temp":5.5, "passenger_temp_setting":20.0, "remote_heater_control_enabled":false, "right_temp_direction":897, "seat_heater_left":0, "seat_heater_rear_center":0, "seat_heater_rear_left":0, "seat_heater_rear_right":0, "seat_heater_right":0, "side_mirror_heaters":false, "timestamp":1637933181574, "wiper_blade_heater":false}, "token":"qts-abcdefghijklmnopqrstuvwxyz"}

These types of commands can be relatively easily integrated into IFTTT type programming for those that like to do more sophisticated automation. The response from the API is in JSON format which is fairly easy to understand with basic technical skills, but can also be used in a programming context to capture the success or otherwise of the request for those wanting to embed them in a more sophisticated set up. IFTTT is likely to be required as part of controlling charging if it is linked to solar power availability.

The links can also be saved as web pages in a web browser and you can simply select the web page and the command will execute. Alternatively the links can be put into a fairly simple Apple Shortcut which can take advantage of those capabilities and even Siri or the equivalent on Android phones.

Note, not all commands are supported by all cars.

Range of requests

Some of the request choices are below although the link builder has the most complete list including some options which would ordinarily require an optional parameter:

The requests which require a parameter are: There is now only one general request which gets information: We have also created a composite command to unlock the car, stop charging if charging, and release the charge cable. This is useful in the morning as you can execute the command as you approach the car and simply unplug the car without needing to access any other features.

Because the request may need to wake the car first, they can take up to 30 seconds to run.

Tesla API tokens expire every few hours and as a result we now require the refresh token. Once provided, we will maintain a working API token which we will use on receipt of the same refresh token. After the first successful request, you can just provide the end of the refresh token, at least 100 characters, which we will use to match to the refresh token. This avoids you needing to store or resend the full refresh token each time. If we do not achieve a match, we will not execute amy commands.

If at any time you feel your phone or security has been compromised, or ours, visit tesla.com and change your Tesla password.

tesla-info on facebook Contact tesla-info on linkedin tesla-info on twitter tesla-info on youtube tesla-info on Discord

By using our site, you acknowledge that you have read and understand our Privacy and Cookie Policy. Your use of the tesla-info website is subject to these policies and terms. All data is provided on a reasonable endeavours basis but errors and omissions may exist. No data should be relied upon as being accurate and additional checks should be made if the information is material to any purchase or use of the car. We provide product listings on Amazon for which we will receive a small commission if you chose to buy.
Ways you can support tesla-info