Terra
Integrations
Research

Integration

API
Unified API
SDK
SDK
Authentication
Authentication
Streaming
Streaming
Blood
Blood Report API
Planned Workouts
Planned Workouts
AI Interface
AI Interface

User engagement

Graph API
Graph API
Scores
Health Scores
Rewards
Health Rewards

Use cases

Enterprise
Enterprise
Insurance
Insurance

Developers

Wearable Data
Wearable Data
Community
Community
Documentation
Documentation

Learn

Blog
Blog
Podcast
Podcast
Events
Events
Reports
Reports

Company

Customers
Customers
Careers
Careers
Partners
Partners
Support
Support
Pricing
Become an integrationGet started
IntegrationsResearch
Unified APIUnified APISDKSDKAuthenticationAuthenticationStreamingStreamingGraph APIGraph APIScoresScoresRewardsRewardsBlood Report APIBloodAI InterfaceAI Interface
EnterpriseEnterpriseInsuranceInsuranceWearable DataWearable DataCommunityCommunityDocumentationDocumentationBlogBlogPodcastPodcastEventsEventsReportsReportsCustomersCustomersCareersCareersPartnersPartnersSupportSupport
Pricing
Get startedBecome an integration
next ventures
pioneer fund
samsung next
y combinator
general catalyst

The world's best health apps run on Terra data

Get started
ProductsIntegrations AI Interface Authentication Mobile Development Documentation GraphAPI
DocumentationAPI SDK Quickstart
CommunityBlog Research Community Podcast Github
CompanyAboutCareersCustomersBecome an IntegrationCookies PolicyGDPRPrivacy PolicyTerms of Purchase
© Terra API. 2026 — All rights reserved.

Cookie Preferences

Essential CookiesAlways On
Advertisement Cookies
Analytics Cookies

Crunch Time: Embrace the Cookie Monster Within!

We use cookies to enhance your browsing experience and analyse our traffic. By clicking “Accept All”, you consent to our use of cookies according to our Cookie Policy. You can change your mind any time by visiting out cookie policy.

Cookies Policy
< Blogs
Elliott Yu
Elliott Yu

August 18, 2022

How-Tos: WebHooks

Imagine you went fishing with a giant net. You cast it and pull it back up. Nothing. This is not a very fun way of fishing because you are committing so much manpower and energy to something while not knowing if the method would return any results. Instead, if you used a line with a fishing hook, you can just leave the hook in the waters without you putting much effort into it. This way, as soon as a fish bites, you know instantly and you reel it in.

Similarly in the world of REST APIs, webhooks are saviors in knowing when an event has happened. Imagine you continuously asking a server if there is the data you're looking for. This consumes so much energy and resources on your side (and the server's side) for no reason since you aren't getting what you want 99% of the time. Instead, a better implementation would be opening an endpoint to accept data to which the server will send the data to whenever it's available.

Definitions

Webhooks are actually very simple from the top-level perspective. You open an endpoint on your server and create a "subscription" with the server you're trying to get data from. Once the server accepts the request, it would start sending data for the "subscription" you made whenever it's available.

Webhooks Setup

The server you are allowing webhook requests from would typically use some sort of security system to make sure the events you receive on that endpoint were indeed from them. Everyone does this differently, it could be in the form of a secret encoded hash from the payload, or maybe only whitelisted IPs can send to the webhook.

Usage

Let's set up a quick server and see how webhook works. To do this, I would need to:

  • Set up a local server
  • Expose an endpoint to accept data from a POST request.

To set up the simple server, I will be using Flask in python.

This is it... That's all you need! This simply starts a server locally using the 8080 port. Ideally, you would want something more complicated than this for a server but this will do for now to test webhooks.

Next, we need to create a route for the server to send data to:

Right now, all we do is print the data sent to the endpoint: http://localhost:8080/terra/data. In practice, you would take this data and process it in a way thats useful for you.

Now, if I start the server, (i.e running the whole file), I would have an endpoint http://localhost:8080/terra/data exposed and ready to accept "POST" requests from anyone (who is using the same network as I am, because this server only runs locally on my computer right now).

As you see, we do not ping the server whenever we want to see if there's new data, but rather we wait for the server to send us data to this endpoint. This is the webhook.

We can simulate a post request to this endpoint as if the server has new data to send to this webhook:

On the server logs when this is executed:

The function assigned to the endpoint executed and printed the payload.

Hook it up

It's time... if you are running a backend server, you should definitely start looking for possible ways webhooks can be used to remove polling.

Other than Terra, many APIs out there actually provide ways to get data through webhook:

  • If you use Github, they have a service to tell you when pull requests are made, when reviews are done, when pull requests are closed, etc.
  • If you use Stripe as a payment method, they send you a webhook when someone pays.
  • Youtube also allows you to subscribe to webhooks where you are told when for example a new video is uploaded by a certain YouTuber or when the video's title has been updated.

Next time you see an API allowing Webhook integration, don't skip on it! It may save you a lot of time and resources.

Related Articles

The complete guide: How the new Google Health API works

May 18, 2026

The complete guide: How the new Google Health API works

Google Health API replaces the Fitbit Web API. This is the field guide with code, schemas, and a migration playbook to help you understand where Google Health is heading.

Vanessa Neeff
5 Lessons for Standing Out at HLTH

December 5, 2024

5 Lessons for Standing Out at HLTH

5 lessons from team Terra API for making a lasting impact at HLTH: from engaging senses to building real touch points, here’s what we learned from the HLTH event.

Vanessa Neeff
Strava Pulls the Plug on their API: What This Means for Developers

November 21, 2024

Strava Pulls the Plug on their API: What This Means for Developers

Strava discontinued their API service, changing the ecosystem of third-party apps that have relied on their platform. How can developers react to this?

Terra APITerra API

More Topics

All Blogs
Team Spotlight
Startup Spotlight
How To
Blog
Podcast
Product Updates
Wearables
See All >
The complete guide: How the new Google Health API works

The complete guide: How the new Google Health API works

Google Health API replaces the Fitbit Web API. This is the field guide with code, schemas, and a migration playbook to help you understand where Google Health is heading.

Vanessa NeeffVanessa Neeff
May 18, 2026
September 2025 updates

September 2025 updates

July: Terra Research launches, Lab Reports land in the dashboard with PDF/Image → JSON, and Samsung Health moves to the new Data SDK for a tighter Android integration. 🚀

Alex VenetidisAlex Venetidis
October 1, 2025
August 2025 updates

August 2025 updates

🎉 July Highlights: InBody Goes Global, Faster APIs, and Rock-Solid Data 💪📊

Alex VenetidisAlex Venetidis
September 1, 2025
July 2025 updates

July 2025 updates

July = rock-solid Terra: WHOOP V2, Garmin & Fitbit bug fixes, faster SDKs, plus bulk blood-report uploads with smarter reference ranges. Reliability + data power-ups! 💪🩸

Alex VenetidisAlex Venetidis
August 2, 2025
June 2025 Updates

June 2025 Updates

June brings Terra MCPs for AI-driven setup, Fern-powered Python/JS SDKs with strong typing, and official Expo plugin support—build faster with less friction. 🚀🧰📱

Alex VenetidisAlex Venetidis
July 1, 2025