Skip to content
BeeponyBeepony
Back

Documentation and Sources for Tesla's Direct APIs (Official, Community, and Reverse-Engineered Evidence from TeslaMate)

Edit post

Docs and Resources for Calling the Tesla API Directly

When building your own Tesla app, TeslaMate can't tell you "how to send commands to the car": it only reads data and starts/stops its own logging. To trigger commands such as unlock, climate on, or honk, or to get fields TeslaMate doesn't expose, you have to call the Tesla API directly. Below are all the legitimate sources of Tesla API documentation, each labeled with "what you get / when to use it".


0. The Bottom Line (Read This Table First)

What you want to doWhich APIWhere the docs are
Read vehicle state (battery/location/temperature/doors and windows…)Owner API (default) or Fleet API vehicle_dataSee Β§1
Real-time data (per second)Owner Streaming (WebSocket, OAuth mode) or Fleet Telemetry (PubSub, at least 1 minute)See Β§2
Trigger commands (unlock/climate/honk/locate/charging control/Summon…)Owner API commands or Fleet API commandsSee Β§3
Register an app and get an OAuth client_idTesla Developer PortalΒ§1.1
OAuth login flow (PKCE / SSO)auth.tesla.com/oauth2/v3Β§1.2
Can't find a field or don't understand the response structureReverse-engineer TeslaMate's tesla_api/ directorySee Β§5
Want a shortcut and don't want to deal with OAuth yourselfThird-party proxies (MyTeslaMate, Teslemetry)Β§4

1. Official APIs (Most Authoritative, but Spread Across Three Places)

1.1 Tesla Developer Portal (Registration + Main Docs Entry)

1.2 OAuth 2.0 Login Endpoints (Auth)

Taken from TeslaMate's source lib/tesla_api/auth.ex. The official docs are very vague about this, so here it is in one place:

EndpointPurpose
https://auth.tesla.com/oauth2/v3Global OAuth 2.0 endpoint
https://auth.tesla.cn/oauth2/v3China users (switch with the TESLA_AUTH_HOST environment variable)
client_id = ownerapiThe "old" client_id from the Owner API era, still used by TeslaMate
redirect_uri = https://auth.tesla.com/void/callbackTeslaMate's internal OAuth callback
scope = openid email offline_access vehicle_device_data vehicle_cmds vehicle_charging_cmds vehicle_locationRequired scopes (see the Fleet API docs for details)

OAuth flow:

  1. Browser login (PKCE code flow): https://auth.tesla.com/oauth2/v3/authorize?...
  2. Get the code from the callback, then POST to /oauth2/v3/token to exchange it for an access_token + refresh_token
  3. access_token lasts about 8 hours; refresh_token lasts about 3 months
  4. Before expiry, proactively POST the refresh_token to /oauth2/v3/token to renew

Note: Tesla started pushing the Fleet API in 2023, and the old Owner API client (ownerapi) is no longer available for new app registrations. But apps that already have tokens (including TeslaMate) can keep using it, which is why TeslaMate supports both modes (see lib/tesla_api/middleware/fleet_auth.ex).

1.3 Official API Domains (by Region)

From TeslaMate lib/tesla_api/auth.ex + lib/tesla_api/vehicle.ex:

RegionOwner / Fleet API hostStreaming WebSocket
Global (North America, Europe, Asia)https://owner-api.teslamotors.comwss://streaming.vn.teslamotors.com/streaming/
Chinahttps://owner-api.vn.cloud.tesla.cnwss://streaming.vn.cloud.tesla.cn/streaming/
Fleet API (NA)https://fleet-api.prd.na.vn.cloud.tesla.com-
Fleet API (EU)https://fleet-api.prd.eu.vn.cloud.tesla.com-
Fleet API (CN)https://fleet-api.prd.cn.vn.cloud.tesla.cn-

How it decides: decode the access_token JWT and look at the TLD of iss (issuer). If it's cn, it's China; otherwise global.


2. Owner Streaming (Per-Second Data over WebSocket, Most Worth Using)

Tesla's official docs don't fully cover this part, but TeslaMate has used it reliably via reverse engineering for 5+ years. It's the key to building a "real-time display" app.

2.1 WebSocket Endpoint

wss://streaming.vn.teslamotors.com/streaming/

2.2 Protocol (from TeslaMate lib/tesla_api/stream.ex, confirmed working)

Right after connecting, send a subscribe message frame (JSON):

{
  "msg_type": "data:subscribe_oauth",
  "token": "<access_token>",
  "value": "speed,odometer,soc,elevation,est_heading,est_lat,est_lng,power,shift_state,range,est_range,heading",
  "tag": "<vehicle_id>"
}

Subscribed columns (12 fields, fixed order):

ColumnMeaningUnit
speedSpeedmph
odometerOdometermi
socState of Charge (battery percentage)%
elevationElevationm
est_headingEstimated heading (GPS-calculated)Β°
est_latEstimated latitudeΒ°
est_lngEstimated longitudeΒ°
powerInstant power (positive = discharging, negative = charging)kW
shift_stateGearP / D / N / R / ""
rangeRated range (based on battery percentage)mi
est_rangeEstimated rangemi
headingCompass headingΒ°

Watch the units: streaming returns imperial (mph/mi), while the Owner API's vehicle_data is metric (km/h/km). Both line up; just multiply by 0.621371 / 1.60934 yourself.

Receiving data: each frame looks like data: <csv>, with columns in the same order as the subscription string, for example:

data: 45,12345.6,82,120,180,37.7749,-122.4194,-12,P,250,238,180

TeslaMate parsing example (lib/tesla_api/stream.ex decode_frame!/1):

Enum.zip([:time | @columns], String.split(value, ","))
|> Enum.into(%Map{})

2.3 Unsubscribe + Heartbeat

2.4 Trade-offs vs. Fleet Telemetry

DimensionOwner StreamingFleet Telemetry
Frequency1 Hz (in practice 1-5 seconds)At least 1 minute (depending on the fields you configure)
ProtocolWebSocket (bidirectional)Google PubSub push (one-way)
Deployment complexityMedium (need to keep the WebSocket alive)High (need GCP PubSub + a public callback)
Officially recommended by TeslaTransitionalThe new approach
Recommended for personal appsβœ… YesFallback
Field coverage12 core fields100+ configurable fields

β†’ For a mobile app or personal project, Owner Streaming is the first choice. Fleet Telemetry suits "company-level / multi-vehicle monitoring".


3. Owner API Command Endpoints (Unlock, Climate, etc.)

Tesla official: the "Commands" section of the Fleet API docs (https://developer.tesla.com/docs/fleet-api#commands) requires Fleet API registration + the Vehicle Command Protocol (mTLS + private-key signing).

Owner API (the unofficial interface TeslaMate uses): the command endpoints have no official documentation; the community reverse-engineered them from the Tesla app over the years.

3.1 Owner API Command Endpoints (Community Consensus)

Tesla hasn't formally documented these endpoints and could change them at any time. But they still work today (2026).

POST /api/1/vehicles/{id}/command/{command_name}

Common commands (from the community tesla-api Python library outside TeslaMate, plus consensus across many GitHub issues):

CommandEffectRequired parameters
wake_upWake the vehicle-
lock / unlockLock-
honk_hornHonk-
flash_lightsFlash lights-
climate_start / climate_stopClimate on/off-
set_tempsSet temperaturedriver_temp, passenger_temp
set_preconditioning_max"MAX" mode-
auto_conditioning_start / stopAuto climate-
charge_start / charge_stopStart/stop charging-
set_charge_limitSet charge limitpercent
set_charging_ampSet charging ampscharging_amps
charge_port_door_open / closeCharge port door-
actuate_trunkOpen the trunk (some models)which_trunk
remote_start_driveRemote startpassword
shareShare navigation/data to the car-
schedule_software_updateSchedule OTAscheduled_time
cancel_software_updateCancel scheduled update-
media_toggle_playback / next_track / prev_track / volume_up / volume_downMedia controls-
trigger_homelinkTrigger HomeLink (garage door)lat, lon
set_sentry_modeSentry Modeon
set_valet_modeValet Modeon, password
reset_valet_pinReset valet PIN-
speed_limit_set_limitSpeed limitlimit_mph
speed_limit_activate / deactivate / clear_pinSpeed limit control-
enable_calendar_syncSync calendar-
add_favorite / remove_favoriteFavorite locationsid (favorite id)

⚠️ Warning: these endpoints have no SLA. Tesla may change, remove, or rate-limit them at any time. Use the Fleet API command interface in production.

3.2 Fleet API Commands (Official but Complex)

Goes through the Vehicle Command Protocol:

  1. Generate an ECDSA P-256 key pair and keep the private key yourself
  2. Bind the public key to your app in the Tesla Developer Portal
  3. The owner gets a "Pairing Request" in the Tesla app; approving it produces a signed "vehicle command authorization"
  4. After that, each command = an HTTP POST to https://fleet-api.prd.<region>.vn.cloud.tesla.com/api/1/vehicles/{id}/command/<cmd>, with the HTTP body containing a JWT message signed with your private key

Full spec: https://developer.tesla.com/docs/vehicle-command/vehicle-command Reference implementation: https://github.com/teslamotors/vehicle-command


4. Third-Party Proxies (The Easiest Option)

If you don't want to handle OAuth + command signing + public callbacks yourself, third parties have already done it:

4.1 MyTeslaMate (Free, Closest to TeslaMate Style)

4.2 Teslemetry (Paid)


5. The "Reverse-Engineering Evidence" in the TeslaMate Repo

This is the most important hidden resource. TeslaMate puts every Tesla API call in lib/tesla_api/, so the whole directory is effectively reverse-engineered documentation.

5.1 Complete File Index

FileContentPurpose
lib/tesla_api.exBase HTTP client (Tesla + Finch)See the User-Agent and base URL
lib/tesla_api/auth.exOAuth client + region detectionSee the auth.tesla.com endpoints and region detection (JWT iss decoding)
lib/tesla_api/auth/refresh.exrefresh_token renewalSee the /oauth2/v3/token request body
lib/tesla_api/stream.exWebSocket streaming implementationSee the subscribe protocol, column names, and heartbeat
lib/tesla_api/vehicle.ex/api/1/products, /api/1/vehicles/{id}, /vehicle_dataSee the read endpoints
lib/tesla_api/vehicle/state.exVehicle state field definitionsThe most complete field dictionary: every Owner API response field is here
lib/tesla_api/middleware/fleet_auth.exFleet API token switchingSee where the qts-/eu-/cn- token prefixes come from
lib/tesla_api/middleware/token_auth.exOwner API bearer tokenSee how Authorization: Bearer ... is injected
lib/tesla_api/error.exError code definitionsSee unauthorized / vehicle_not_found / vehicle_in_service / too_many_request / timeout

5.2 Key State Fields

lib/tesla_api/vehicle/state.ex defines five modules: Charge / Climate / Drive / VehicleConfig / VehicleState. Each module is a field table, matching the fields returned by the Owner API's /vehicle_data one-to-one.

For example, VehicleState.result/1 includes:

β†’ Treat this file as the source of truth for the full field list. One file is worth ten blog posts.

5.3 URL / Path Cheat Sheet

Source: TeslaMate lib/tesla_api/vehicle.ex, cross-checked with the official docs:

PurposePath
List all products (vehicles + energy products)GET /api/1/products
List my vehiclesGET /api/1/vehicles (filter the vehicle_id field from /products)
Basic vehicle infoGET /api/1/vehicles/{id}
Full vehicle state (charge/climate/drive/vehicle_config/vehicle_state, etc.)GET /api/1/vehicles/{id}/vehicle_data?endpoints=charge_state;climate_state;closures_state;drive_state;gui_settings;location_data;vehicle_config;vehicle_state;vehicle_data_combo
Single endpoint (faster)GET /api/1/vehicles/{id}/data/{endpoint_name}
Nearby dataGET /api/1/vehicles/{id}/data_request/{nearby_sites,charge_history,...}
Mobile Smart SummonGET /api/1/vehicles/{id}/data_request/drive_state_v2
CommandPOST /api/1/vehicles/{id}/command/{cmd_name} (for the body, see Β§3.1)
SharingPOST /api/1/vehicles/{id}/share
Mobile access stateGET /api/1/vehicles/{id}/mobile_enabled

6. Community Ecosystem (Where to Catch the Latest Changes)

ResourceURLValue
teslamate-org/teslamatehttps://github.com/teslamate-org/teslamateReference implementation of the reverse-engineered API
teslamotors/vehicle-commandhttps://github.com/teslamotors/vehicle-commandOfficial command protocol + Go SDK
teslamotors/fleet-telemetryhttps://github.com/teslamotors/fleet-telemetryGo implementation of the official telemetry service (see dispatchers)
MyTeslaMate/websockethttps://github.com/MyTeslaMate/websocketA project that repackages Fleet Telemetry into the Owner streaming protocol
timdorr/tesla-apihttps://github.com/timdorr/tesla-apiThe classic Tesla API docs (since 2020, the most complete "unofficial docs"), but Tesla has changed things many times, so parts are outdated
Python tesla-api libhttps://github.com/tdorssers/TeslaPyPython library, still actively updated
TeslaMate Discord / Forumhttps://discord.gg/teslamateAny API change usually shows up first as an issue here
developer.tesla.com forumshttps://forums.tesla.com/categories/developerOfficial responses (slow)

7. Practical Advice for Building Your Own App

7.1 Minimum Viable Setup (Personal Toy Project)

# 1. Register: https://developer.tesla.com β†’ create an app and note the client_id
# 2. Log in with the PKCE flow (the timdorr/tesla-api docs have diagrams)
# 3. Call with the access_token:

curl -H "Authorization: Bearer $TOKEN" \
     "https://owner-api.teslamotors.com/api/1/vehicles"
# β†’ list vehicles

curl -H "Authorization: Bearer $TOKEN" \
     "https://owner-api.teslamotors.com/api/1/vehicles/$ID/data_request/charge_state"
# β†’ battery state (lowest-frequency API, looser rate limits)

# 4. Connect the WebSocket:
wscat -c wss://streaming.vn.teslamotors.com/streaming/
# send: {"msg_type":"data:subscribe_oauth","token":"...","value":"speed,soc,est_lat,est_lng","tag":"$VID"}
# receive: data: 0,12345.6,82,...,...

7.2 Choosing an Approach for a Production App

StageApproachReason
MVP / personalOwner API + Owner StreamingDirect, no detours, rate limits are enough
Paid productFleet API + Fleet TelemetryOfficial, stable, has an SLA
Don't want to maintain infrastructureMyTeslaMate / Teslemetry proxyGet JSON directly, no need to deal with OAuth/mTLS/PubSub
Want to monitor other people's vehicles (fleets)Fleet API + your own Telemetry serverThe only legitimate option

8. Cheat Sheet: URLs / Endpoints / Libraries (Paste into Your Notes)

─────────────────────────────────────────────
OAuth / Auth
  https://auth.tesla.com/oauth2/v3/authorize  (PKCE flow)
  https://auth.tesla.com/oauth2/v3/token      (token / refresh)
  client_id (Owner API, old):  ownerapi
  client_id (Fleet API, new):  <your-app-client-id>
  scopes: openid email offline_access vehicle_device_data vehicle_cmds vehicle_charging_cmds vehicle_location

─────────────────────────────────────────────
Owner / Fleet REST API hosts
  Global:  https://owner-api.teslamotors.com
  China:   https://owner-api.vn.cloud.tesla.cn
  Fleet NA: https://fleet-api.prd.na.vn.cloud.tesla.com
  Fleet EU: https://fleet-api.prd.eu.vn.cloud.tesla.com
  Fleet CN: https://fleet-api.prd.cn.vn.cloud.tesla.cn

─────────────────────────────────────────────
Read endpoints (Owner style)
  GET /api/1/products
  GET /api/1/vehicles
  GET /api/1/vehicles/{id}
  GET /api/1/vehicles/{id}/vehicle_data?endpoints=charge_state;...;vehicle_state
  GET /api/1/vehicles/{id}/data_request/{charge_state,climate_state,drive_state,vehicle_state,gui_settings,location_data,vehicle_config,closures_state,nearby_sites,...}

─────────────────────────────────────────────
Command endpoints (Owner style, undocumented, may break)
  POST /api/1/vehicles/{id}/command/{wake_up,lock,unlock,honk_horn,flash_lights,
       climate_start,climate_stop,set_temps,set_preconditioning_max,
       auto_conditioning_start,auto_conditioning_stop,
       charge_start,charge_stop,set_charge_limit,set_charging_amp,
       charge_port_door_open,charge_port_door_close,
       actuate_trunk,remote_start_drive,
       media_toggle_playback,media_next_track,media_prev_track,
       media_volume_up,media_volume_down,
       trigger_homelink,set_sentry_mode,set_valet_mode,reset_valet_pin,
       speed_limit_set_limit,speed_limit_activate,speed_limit_deactivate,
       schedule_software_update,cancel_software_update,
       share,add_favorite,remove_favorite,enable_calendar_sync}

─────────────────────────────────────────────
Streaming (Owner style, seconds-level)
  wss://streaming.vn.teslamotors.com/streaming/
  Send: {"msg_type":"data:subscribe_oauth","token":"<access_token>",
         "value":"speed,odometer,soc,elevation,est_heading,est_lat,est_lng,
                  power,shift_state,range,est_range,heading",
         "tag":"<vehicle_id>"}
  Recv: data: <csv with 12 values in same order, prefixed by timestamp>

─────────────────────────────────────────────
Telemetry (Fleet style, minutes-level)
  https://developer.tesla.com/docs/fleet-telemetry
  β†’ GCP PubSub β†’ your webhook β†’ your app
─────────────────────────────────────────────

9. Reference Source Locations (Summary)

ContentPath (TeslaMate repo)
HTTP clientlib/tesla_api.ex
OAuth flowlib/tesla_api/auth.ex, lib/tesla_api/auth/refresh.ex
Fleet vs. Owner switchinglib/tesla_api/middleware/fleet_auth.ex, lib/tesla_api/middleware/token_auth.ex
/api/1/products, /vehicles, /vehicle_datalib/tesla_api/vehicle.ex
Full field dictionary (must read)lib/tesla_api/vehicle/state.ex
Streaming protocollib/tesla_api/stream.ex
Official docs (summarized)website/docs/configuration/api.md

Edit post
Share this post:

Previous post
Kindle Paperwhite 1 Jailbreak, Repair, and KOReader Recovery Handbook
Next post
A Minimal Guide to Pi Agent