# `Weavr.AuthenticationFactors`
[🔗](https://github.com/iamkanishka/weavr/blob/main/lib/weavr/resources/authentication_factors.ex#L1)

Authentication factor enrolment — register a device or channel for
multi-factor authentication.

This is distinct from `Weavr.StepUp` (which manages per-operation
challenges). Authentication factors are **one-time setup** that enrols
the user's device so that step-up challenges can be sent to it.

## Confirmed endpoints (from Weavr error-handling docs and curl examples)

  * `POST /authentication_factors/otp/{channel}` — initiate enrolment OTP
  * `POST /authentication_factors/otp/{channel}/verify` — verify enrolment

## Channels

Currently supported: `"SMS"`, `"AUTHY"` (Twilio Authy).

## Sandbox note

On Sandbox, the verification code is always `"123456"`.

# `enrol`

```elixir
@spec enrol(Weavr.Config.t(), String.t(), String.t()) ::
  {:ok, map()} | {:error, Weavr.Error.t()}
```

Initiates enrolment of an authentication factor channel.

`POST /authentication_factors/otp/{channel}`

This triggers an OTP to be sent to the user via the given channel.
On Sandbox, the code is always `"123456"`.

# `supported_channels`

```elixir
@spec supported_channels() :: [String.t()]
```

The supported authentication factor channels.

# `verify_enrolment`

```elixir
@spec verify_enrolment(Weavr.Config.t(), String.t(), String.t(), String.t()) ::
  {:ok, map()} | {:error, Weavr.Error.t()}
```

Verifies the OTP code to complete authentication factor enrolment.

`POST /authentication_factors/otp/{channel}/verify`

On Sandbox, the code is always `"123456"`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
