> 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/help-center/help-topics/something-else/connections-auth-and-permissions/check-healthkit-connection-state.md).

# How do I check whether a HealthKit connection exists?

HealthKit doesn't expose whether permissions were granted, but you can check whether a connection was previously created

HealthKit doesn't expose whether permissions were granted, but you can **check whether a connection was previously created**:

{% stepper %}
{% step %}
Initialise the [Terra SDK](https://docs.tryterra.co/reference/health-and-fitness-api/sdk-references/ios-swift).
{% endstep %}

{% step %}
Call `getUserId`.
{% endstep %}
{% endstepper %}

A non-null user ID means a Terra connection exists for the device; `null` means it doesn't. It does not tell you which HealthKit permissions were granted, because Apple doesn't expose read permissions to apps. Use it to drive your connect UI, and judge permissions from the data that arrives.
