Last updated 27-Nov-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.
We are currently unable to send requests to cars once they reach the later 2023.38.x software releases. This is due to changes that Tesla are making. We are considering complying with Teslas requirements but if this requires payment, we will be unable to continue with a free service. For now, read/get_data requests still appear to work ok although token refresh is also failing for some.
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.
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.
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.
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.
Tesla have started to reorder the cars on your account and it's now not always safe to assume the order if you have more than one car. While we will default to the first car on the account if no car is specified, and this is fine for accounts with only one car, it is prudent to provide the car id to be sure the right car is used when there are multiple cares on an account.
Finally, some of the commands are dependant on state, e.g. the heated steering wheel and heated seats require the HVAC to be turned on first.
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).
https://tesla-info.com/api/control_v3.php?refresh=[refresh]&request=[command]
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%:
https://tesla-info.com/api/control_v3.php?refresh=abcdefghijklmnopqrstuvwxyz&request=set_charge_limit&value=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.
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:
Because the request may need to wake the car first, they can take up to 30 seconds to run.
If you wish to register an email address with us so we can contact you in the event of material changes to the service, issues or other changes, then you can do so. This is purely voluntary and we store the email address in an encrypted format against the car otherwise identified in the request. We will only use this email for the purposes of the API service, and in the event the car is sold or the tokens become invalid, we will delete the entire car record for the car including the email address. This email address does not need to be the one associated with your Tesla account.
To register an email address, please use the following format:
https://tesla-info.com/api/control_v2.php?refresh=[refresh]&request=contact&value=[your email address]
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.
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