> 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/mobile-sdk-setup-permissions-and-crashes/init-sequence-before-data-calls.md).

# Why do SDK data calls say permission not granted?

**Data functions like `getActivity` / `getDaily` only work after the SDK is fully initialised.**

{% stepper %}
{% step %}
Call `initTerra()`. This should run on every app launch.
{% endstep %}

{% step %}
Call `initConnection()` with an auth token generated from your backend, which triggers the permissions flow.
{% endstep %}
{% endstepper %}

`initConnection` only needs to run once per install, unless you expand permissions or the app is reinstalled.

`Not connected to Health Connect` / `permission not granted` errors usually mean a data call ran before init completed. Confirm the connection with `getUserId()`: a non-null user id means the connection is established. See the [Android SDK reference](https://docs.tryterra.co/reference/health-and-fitness-api/sdk-references/android-kotlin).


---

# 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/mobile-sdk-setup-permissions-and-crashes/init-sequence-before-data-calls.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.
