Webhooks

Webhook

Webhooks are the most basic Destination to set up, and involve Terra making a POST request to a predefined callback URL you pass in when setting up the Webhook.

They are automated messages sent from apps when something happens.

Terra uses webhooks to notify you whenever new data is made available for any of your users. New data, such as activity, sleep, etc will be normalised and sent to your webhook endpoint URL where you can process it however you see fit.

After a user authenticates with your service through Terra, you will automatically begin receiving webhook messages containing data from their wearable..

Security

Exposing a URL on your server can pose a number of security risks, allowing a potential attacker to

  • Launch denial of service (DoS) attacks to overload your server.

  • Tamper with data by sending malicious payloads.

  • Replay legitimate requests to cause duplicated actions.

among other exploits.

In order to secure your URL, Terra offers two separate methods of securing your URL endpoint

Payload signing

Every webhook sent by Terra includes an HMAC-based signature header terra-signature, which takes the form:

t=1723808700,v1=a5ee9dba96b4f65aeff6c841aa50121b1f73ec7990d28d53b201523776d4eb00

In order to verify the payload, you may use one of Terra's SDKs as follows:

circle-exclamation

IP Whitelisting

IP Whitelisting allows you to only allow requests from a preset list of allowed IPs. An attacker trying to reach your URL from an IP outside this list will have their request rejected.

Terra sends all outbound requests (webhooks, database connections, etc.) from the same set of IPs. See the full IP list on the data destinations overview page.

Retries

If your server fails to respond with a 2XX code (either due to timing out, or responding with a 3XX, 4XX or 5XX HTTP code), the request will be retried up to 10 times with exponential backoff. The delay doubles each time, starting at 30 seconds and capping at 8 hours:

Retry
Delay

1st

30s

2nd

1 min

3rd

2 min

4th

4 min

5th

8 min

6th

16 min

7th

32 min

8th

1h 4min

9th

2h 8min

10th

4h 16min

After 10 failed attempts, the event is dropped.

Timeout handling

Terra waits 8 seconds for your server to respond before considering the request timed out.

When your endpoint repeatedly times out, Terra activates a per-destination circuit breaker to avoid overwhelming your server. While the circuit is open, new events for that destination are held back with exponential backoff (same 30s-to-8h schedule). The circuit automatically closes once the backoff period expires and your server responds successfully.

The circuit breaker is only triggered by timeouts — other errors (4xx, 5xx, connection refused) trigger normal per-event retries without opening the circuit.

Ping mode (S3 payload delivery)

For high-volume integrations or large payloads, Terra supports a ping mode that keeps webhook payloads small. Instead of sending the full data payload in the POST body, Terra uploads it to cloud storage and sends a lightweight summary with a pre-signed download URL.

When ping mode is enabled, your webhook receives:

  • url — A pre-signed link to the full data payload, hosted on Terra's infrastructure. Download it with a GET request.

  • expires_in — URL validity in seconds (300 = 5 minutes).

How to process ping mode payloads:

  1. Receive the webhook POST as usual and verify the signature.

  2. Check if the type field is "s3_payload".

  3. Download the full payload from the url field using a GET request.

  4. Process the downloaded JSON as you would a normal webhook payload.

circle-info

Authentication and connection events (auth success, deauth, etc.) are always delivered inline in the POST body, even when ping mode is enabled. Only data payloads use the S3 URL delivery.

circle-info

To enable ping mode, submit a request to Terra support. It is configured per destination and does not require any changes to your webhook URL.

Last updated

Was this helpful?