> 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/authentication-users-and-connection-state/multiple-terra-users-per-reference-id.md).

# Why are there multiple Terra users for one reference\_id?

A single provider account maps to **exactly one Terra user**. Multiple Terra users for the same `reference_id` and provider occur when **two different provider accounts** are authenticated under that `reference_id`. Each distinct provider account gets its own Terra user by design.

If two Terra user IDs appear to receive identical data from the same device, the likely cause is a logging error on your side, or both users authenticating the same provider account.

* **To clean up**: deauthenticate the stale user via `/auth/deauthenticateUser`.
* **To prevent it**: check existing active connections via List Users before initiating auth.

For **Apple Health** specifically, `provider_user_id` identifies the same device and stays stable as long as the same app (same vendor and package) remains installed. It resets on uninstall/reinstall, which is why reinstalling between test connections yields different IDs.


---

# 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/authentication-users-and-connection-state/multiple-terra-users-per-reference-id.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.
