> ## Documentation Index
> Fetch the complete documentation index at: https://docs.finhost.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Auth & Authorization

> Learn how to get started with our API.

## Cognito Authorization

Required to have:

* User Pool Region (example: `eu-central-1`)
* User Pool ID (example: `eu_central_111111`)
* User Pool Web Client ID (example: `1234qwerty7890asdfg`)
* UsernameID (example: `e7c6ae40-ca66-4d2a-8d37-337d3e8c92bb`) - is required to generate username (uuid v5) based on UsernameID and email. Ask LabelRails team for access.

(User Pool Region, User Pool ID, User Pool Web Client ID - will be provided by LabelRails tech team)

Install AWS Amplify and connect Auth API according to the documentation: [Amplify Auth API](https://docs.amplify.aws/react/build-a-backend/auth/connect-your-frontend/).

You can either use a custom UI by connecting Auth API: [Custom UI](https://docs.amplify.aws/react/build-a-backend/auth/connect-your-frontend/sign-up/) or Amplify Authenticator Component: [Authenticator Component](https://docs.amplify.aws/react/build-a-backend/auth/connect-your-frontend/using-the-authenticator/).

## API Usage

Required to have:

* API host URL (will be provided by LabelRails tech team).

If you want to use AWS Amplify to fetch data, which we recommend, then follow this documentation: [REST API with AWS Amplify](https://docs.amplify.aws/react/build-a-backend/add-aws-services/rest-api/existing-resources/).

You can also use any other tool to fetch data. To use authorization via Cognito User Pool, you must retrieve the user idToken and send it in headers.

```
import { fetchAuthSession } from 'aws-amplify/auth'

const session = await fetchAuthSession();
const token = session.tokens?.idToken;
const headers = { Authorization: token };
```
