> For the complete documentation index, see [llms.txt](https://docs.tryterra.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tryterra.co/faq/help-topics/data-api-sdk/webhooks-dedup-and-sync-reliability/webhooks-as-primary-source-best-practice.md).

# How do I make production sync reliable?

**Use** [**webhooks**](https://docs.tryterra.co/health-and-fitness-api/managing-user-health-data/receiving-data-updates) **as your primary data source.** Terra polls the provider and fires a webhook on new or updated data, so you do not need your own polling. (Background syncs cannot be disabled, but you can choose not to process events and instead pull via the API on your own schedule.)

Key behaviours:

* Provider data is eventually consistent (sleep and readiness finalise hours later, daily totals accumulate), so you will receive multiple webhooks for the same date. **Always overwrite** rather than treating the first delivery as final.
* [Historical data](https://docs.tryterra.co/health-and-fitness-api/managing-user-health-data/requesting-historical-data) is not pulled automatically on connect; request specific date ranges via REST for backfill.

On a first cloud-provider connect, an empty `GET` array is expected because Terra fetches in the background. Do not poll the read endpoint in a loop. Instead:

{% stepper %}
{% step %}
Listen for the [auth-success webhook](https://docs.tryterra.co/health-and-fitness-api/user-authentication/handling-authentication-events) (`type` auth, `status` success) carrying `user_id`.
{% endstep %}

{% step %}
Immediately call the `GET` endpoint with a `start_date`, a window of 28 days or less, and `to_webhook=false` to get it synchronously.
{% endstep %}
{% endstepper %}

A nightly REST pull for the previous day is a reasonable safety net, but most customers do fine with webhooks alone.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tryterra.co/faq/help-topics/data-api-sdk/webhooks-dedup-and-sync-reliability/webhooks-as-primary-source-best-practice.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
