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

# Overview

> Authentication Overview

## API Authentication

The backend supports both browser cookie and bearer `token` authorization header methods.

For the bearer authentication header of the form `Bearer <token>`, where `<token>` is your auth token.

## User Authentication

Users will receive a 6-digit one-time password (OTP) for every login, utilizing passwordless authentication.

<Warning>
  The OTP will only last for 15 minutes, and users will not be able to generate a new one within this timeframe.
</Warning>

## Authentication Flows

### New User Flow

<Steps>
  <Step title="Register">
    The user registers to create a new account.
  </Step>

  <Step title="OTP Creation">
    An OTP is sent to the user's email or phone. If the user has both an email and a phone number, the OTP will be sent to the email.
  </Step>

  <Step title="OTP Verification">
    The OTP is verified, and a session `token` is returned. This `token` is used as a bearer token.
  </Step>
</Steps>

Use this Register API for the flow above

<Card title="Register API" icon="user-plus" href="/auth/register">
  API to register new user
</Card>

### Existing User Flow

<Steps>
  <Step title="Login">
    The user logs in with their username or email.
  </Step>

  <Step title="OTP Creation">
    An OTP is sent to the user's email or phone. If the user has both an email and a phone number, the OTP will be sent to the email.
  </Step>

  <Step title="OTP Verification">
    The OTP is verified, and a session `token` is returned. This `token` is used as a bearer token.
  </Step>
</Steps>

Use this Login API for the flow above

<Card title="Login API" icon="user" href="/auth/login">
  API to login existing user
</Card>
