Webhook

Setting your business webhook with the API, and the messages it receives.

Your business has one webhook. Every shared vehicle's telemetry is posted to it. You can set it on the Webhook page, or with these endpoints.

Setting the webhook

PUT /api/business/webhook sets the webhook, and replaces any webhook you had.

Curl Example
curl --request PUT --header "Authorization: Bearer {token}" --header 'Content-Type: application/json' \
  --data '{"url":"https://fleetco.example/tesla/webhook","format":"teslemetry"}' \
  'https://api.teslemetry.pro/api/business/webhook'
FieldRequiredDescription
urlYesWhere each message is posted. Must be reachable from the internet.
formatYesteslemetry, tesla or splunk. See Payloads.
authNoSent as the Authorization header with every message. Never returned.
verifyNoCheck the TLS certificate of url. Defaults to true.
enabledNoDeliver messages. Defaults to true. Send false to pause delivery without deleting the webhook.
rotate_secretNoIssue a new signing secret. Defaults to false.
Response
{
  "response": {
    "url": "https://fleetco.example/tesla/webhook",
    "format": "teslemetry",
    "auth": false,
    "secret": "whsec_{base64 secret}",
    "verify": true,
    "enabled": true,
    "updated_at": "2026-10-05T00:00:00.000Z"
  }
}

auth in the response only says whether a header is set. secret is the signing secret. Only the PUT and PATCH responses include it.

A URL that is not reachable from the internet, such as localhost, a .local name or a private IP address, is refused with 400 invalid_webhook_url.

Updating the webhook

PATCH /api/business/webhook changes only the fields you send, and keeps every other field as it is, including the Authorization header. It takes the same fields as PUT, with none required and no defaults, but at least one must be sent. A changed url is checked as for PUT.

Curl Example
curl --request PATCH --header "Authorization: Bearer {token}" --header 'Content-Type: application/json' \
  --data '{"rotate_secret":true}' \
  'https://api.teslemetry.pro/api/business/webhook'

The response has the same shape as the PUT response, with secret. PATCH never creates a webhook: it returns 404 webhook_not_found when no webhook is set.

Reading and deleting

  • GET /api/business/webhook returns the webhook in the same shape as above, but without secret.
  • DELETE /api/business/webhook deletes it and returns {"response": true}.

Both return 404 webhook_not_found when no webhook is set.

Signing secret

Teslemetry signs webhook messages with a secret that belongs to your business. The secret starts with whsec_, followed by 32 random bytes in base64.

  • The first PUT /api/business/webhook creates the secret and returns it as secret.
  • Later PUT and PATCH requests without rotate_secret keep the same secret, so changing the url or format does not break your verification.
  • GET /api/business/webhook never returns the secret. Store it when you first receive it.
  • To issue a new secret, send {"rotate_secret": true} with PATCH. The URL, auth header and other settings stay as they are, in the same atomic update. rotate_secret also works with PUT, but a PUT replaces the whole webhook, so it removes auth unless you send it again. The new secret is returned in the response. The old secret stops working at once, with no overlap, so update your receiver as soon as you rotate.
  • The MCP set_webhook tool works like PUT: it takes rotate_secret, replaces the whole webhook, and returns the secret.

On the Webhook page in the portal, the secret is shown only right after you save the webhook or rotate the secret. It is never shown again, because the API does not return it on read. Admins can rotate it there. Rotating keeps the URL, the Authorization header and the other settings.

Verifying messages

Every signed message carries three headers, as defined by Standard Webhooks:

HeaderDescription
webhook-idA unique ID for the message, like msg_{uuid}. A new ID is used for each delivery.
webhook-timestampWhen the message was signed, in Unix seconds.
webhook-signaturev1, followed by the base64 signature.

The signature is the base64 HMAC-SHA256 of {webhook-id}.{webhook-timestamp}.{body}. The key is the secret after whsec_, decoded from base64.

To verify a message:

  1. Read the raw request body. Do not parse and re-serialise it, because that changes the bytes that were signed.
  2. Reject the message if webhook-timestamp is more than five minutes from the current time. This limits how long an attacker can replay a captured message. It does not stop a replay inside that window.
  3. Calculate the signature, and compare it with webhook-signature in constant time.
  4. Store each webhook-id you accept for at least ten minutes (the five-minute tolerance applies on both sides of the current time, so a message stays acceptable for up to ten minutes), and drop a repeat. Without this step, or idempotent handling of each message, a replay inside the window is accepted.
Node.js
import { createHmac, timingSafeEqual } from "node:crypto";

const secret = process.env.TESLEMETRY_WEBHOOK_SECRET; // "whsec_..."

export function verify(headers, rawBody) {
  const id = headers["webhook-id"];
  const timestamp = headers["webhook-timestamp"];
  const signature = headers["webhook-signature"];
  if (!id || !timestamp || !signature) return false;

  // Reject a timestamp more than five minutes from now.
  if (Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return false;

  const key = Buffer.from(secret.replace(/^whsec_/, ""), "base64");
  const expected = createHmac("sha256", key)
    .update(`${id}.${timestamp}.${rawBody}`)
    .digest("base64");

  // `webhook-signature` may hold several space-separated `v1,` signatures.
  return signature.split(" ").some((part) => {
    const [version, value] = part.split(",");
    if (version !== "v1" || !value) return false;
    const a = Buffer.from(value);
    const b = Buffer.from(expected);
    return a.length === b.length && timingSafeEqual(a, b);
  });
}

Teslemetry sends one v1 signature per message. Any Standard Webhooks library can verify the message too: give it the whole whsec_ secret.

The auth field is separate. If you set it, Teslemetry also sends it as the Authorization header. Use https:// so the header and data are encrypted.

Delivery

Each message is an HTTP POST with Content-Type: application/json, sent once. A message your server does not accept is not retried, so answer quickly with a 2xx and process the message afterwards.

Messages carry the vin of the vehicle they are about. Use it with your consented products to find the customer.

Topics

TopicDescription
dataTelemetry data updates, for the fields in the vehicle's streaming config
stateVehicle state changes (online, asleep, driving)
vehicle_dataFull vehicle data responses
alertsAlert notifications
errorsError events from the vehicle
connectivityConnection status changes

Payloads

A data message in each format:

Teslemetry format
{
  "data": {
    "Location": {
      "latitude": 30.2226645,
      "longitude": -97.6213806
    },
    "VehicleSpeed": "34.797"
  },
  "createdAt": "2026-10-05T04:58:44.983607402Z",
  "vin": "5YJ3E1EA7KF000001"
}
Tesla format
{
  "data": [
    {
      "key": "Location",
      "value": {
        "locationValue": {
          "latitude": 30.2226645,
          "longitude": -97.6213806
        }
      }
    },
    {
      "key": "VehicleSpeed",
      "value": {
        "stringValue": "34.797"
      }
    }
  ],
  "createdAt": "2026-10-05T04:58:44.983607402Z",
  "vin": "5YJ3E1EA7KF000001"
}
Splunk format
{
  "time": 1791176324.9836073,
  "host": "na1.teslemetry.com",
  "source": "5YJ3E1EA7KF000001",
  "sourcetype": "tesla:telemetry:data",
  "event": {
    "Location": {
      "latitude": 30.2226645,
      "longitude": -97.6213806
    },
    "VehicleSpeed": "34.797"
  }
}

In the Teslemetry format, alerts and errors messages are keyed by name. The Tesla format is Tesla's own message, unchanged. The Splunk format is a Splunk HTTP Event Collector event; an auth value without a scheme is sent as Splunk <auth>.