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

# SMS OTP

> Implement SMS OTP in your mobile apps using the Authsignal SDKs for iOS, Android, React Native, and Flutter.

<Info>
  All SMS OTP SDK methods require you to [initiate an action first](/sdks/client/mobile/actions).
  Check out our [guide on SMS authentication](/authentication-methods/sms-otp) for more details.
</Info>

## Enroll SMS

Start enrollment for a new SMS OTP authenticator by sending the user an SMS containing an OTP code.

This method is typically used when you've **not yet verified** the user's phone number.

<CodeGroup>
  ```swift iOS theme={null}
  await authsignal.sms.enroll(phoneNumber: "+64270000000")
  ```

  ```kotlin Android theme={null}
  authsignal.sms.enroll(phoneNumber = "+64270000000")
  ```

  ```ts React Native theme={null}
  await authsignal.sms.enroll({ phoneNumber: "+64270000000" });
  ```

  ```dart Flutter theme={null}
  await authsignal.sms.enroll("+64270000000");
  ```
</CodeGroup>

<Info>
  If you've already verified a user's phone number independently of Authsignal, you can
  alternatively use a Server SDK to [enroll the user
  programmatically](/advanced-usage/programmatic-authenticator-management).
</Info>

### Parameters

<ResponseField name="phoneNumber" type="string">
  The user's phone number in [E.164 format](https://en.wikipedia.org/wiki/E.164) e.g. +14155552671.
</ResponseField>

### Response

<ResponseField name="response" type="AuthsignalResponse<void>">
  <Expandable title="properties">
    <ResponseField name="error" type="string">
      An unstructured error description present if the SDK call encountered an error.
    </ResponseField>
  </Expandable>
</ResponseField>

## Challenge SMS

Start an SMS challenge by sending the user an SMS containing an OTP code.

<CodeGroup>
  ```swift iOS theme={null}
  await authsignal.sms.challenge()
  ```

  ```kotlin Android theme={null}
  authsignal.sms.challenge()
  ```

  ```ts React Native theme={null}
  await authsignal.sms.challenge();
  ```

  ```dart Flutter theme={null}
  await authsignal.sms.challenge();
  ```
</CodeGroup>

### Response

<ResponseField name="response" type="AuthsignalResponse<void>">
  <Expandable title="properties">
    <ResponseField name="error" type="string">
      An unstructured error description present if the SDK call encountered an error.
    </ResponseField>
  </Expandable>
</ResponseField>

## Verify SMS

Finish enrolling or re-authenticating a new or existing SMS OTP authenticator by verifying the code submitted by the user.

<CodeGroup>
  ```swift iOS theme={null}
  await authsignal.sms.verify(code: "123456")
  ```

  ```kotlin Android theme={null}
  authsignal.sms.verify(code = "123456")
  ```

  ```ts React Native theme={null}
  await authsignal.sms.verify({ code: "123456" });
  ```

  ```dart Flutter theme={null}
  await authsignal.sms.verify("123456");
  ```
</CodeGroup>

### Parameters

<ResponseField name="code" type="string">
  The OTP code inputted by the user.
</ResponseField>

### Response

<ResponseField name="response" type="AuthsignalResponse<VerifyResponse>">
  <Expandable title="properties">
    <ResponseField name="error" type="string">
      An unstructured error description present if the SDK call encountered an error.
    </ResponseField>
  </Expandable>

  <ResponseField name="data" type="VerifyResponse">
    <Expandable title="properties">
      <ResponseField name="isVerified" type="boolean" required>
        True if the verification was successful.
      </ResponseField>

      <ResponseField name="token" type="string">
        A token which can be used for [server-side
        validation](/sdks/server/challenges#validate-challenge).
      </ResponseField>

      <ResponseField name="failureReason" type="string">
        A structured code present if the verification failed due to user error. Possible values are:
        `CODE_INVALID_OR_EXPIRED` or `MAX_ATTEMPTS_EXCEEDED`.
      </ResponseField>
    </Expandable>
  </ResponseField>
</ResponseField>
