> 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/unified-api/customising-authentication-redirects.md).

# Authentication redirect pages

Set where Terra sends the end user after they connect a provider, and read the parameters added to that URL.

After the end user completes the authentication flow, they are redirected to a default final URL: a success or failure screen, before they go back to your app. You can replace these URLs when you call one of the `/auth` endpoints.

## Default redirect pages

When the user authenticates a health account (e.g. Oura), before they go back to your app, they see a final URL (screen) of the authentication flow, which is either a success or failure screen.

<div align="center"><figure><img src="https://464213908-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVGMJVuZnZyOtvV4b53cY%2Fuploads%2Fgit-blob-dca5241cf04f5656798ab3e8118199177222a7c9%2FCapture%20d%E2%80%99%C3%A9cran%202025-03-28%20%C3%A0%2021.17.40.png?alt=media" alt="" width="188"><figcaption><p>Default <strong>Success</strong> Redirect URL</p></figcaption></figure> <figure><img src="https://464213908-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVGMJVuZnZyOtvV4b53cY%2Fuploads%2Fgit-blob-d27d18585346ec99b902080bc799619bcdb3176a%2FCapture%20d%E2%80%99%C3%A9cran%202025-03-28%20%C3%A0%2021.13.32.png?alt=media" alt="" width="188"><figcaption><p>Default <strong>Failure</strong> Redirect URL</p></figcaption></figure></div>

The final url will append the following parameters:

* `user_id` (not Null)
* `resource` (not Null)
* `reference_id` (can be Null if you did not pass it in the auth endpoint).

{% code title="Success Auth URL (Example)" %}

```url
https://widget.tryterra.co/session/demo/success?user_id=bc205b50-dabe-4680-9d35-38517b915dc1&resource=GOOGLE&reference_id=null
```

{% endcode %}

## Set your redirect URLs

Terra provides these urls by default, and they can also be customized in the `/auth` endpoints. They can be specified in the **body** of the authentication request as:

* `auth_success_redirect_url`
* `auth_failure_redirect_url`

## Redirect targets

You can redirect to a:

* **Web page:** A specific page on your web application, including any useful query parameters.
  * Example: `https://somereallycoolcompany.com?terra_auth_success=true`
* **Deep link:** A deep link into your mobile application.
  * Example: `reallycoolapp://success`

### Mobile-only sources

{% hint style="warning" %}

* When using the widget, when the user selects one of the [Mobile SDK-based integrations](https://docs.tryterra.co/mobile-sdks/mobile-only-sources.md) (e.g. Apple Health, Samsung Health, Health Connect), they will by default be redirected to the `auth_success_redirect_url` with a **null** `user_id`.
* This Redirect URL can be used to redirect your end-user to your mobile app instead so that they complete the connection flow to the Mobile-only integrations using **Deep Links.**
  {% endhint %}

## Next steps

* [Event delivery](https://docs.tryterra.co/destinations/events.md): how Terra sends events to your destinations, and what their statuses mean.
* [Health data events](https://docs.tryterra.co/unified-api/receiving-data-updates.md): process the data Terra sends for connected users.
* [Mobile SDKs](https://docs.tryterra.co/mobile-sdks/mobile-only-sources.md): connect Apple Health, Samsung Health and Health Connect from your app.
