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

# Phoneotp

The Mobile number with OTP authentication allows your client to authenticate using OTP method. The endpoints are pre-built and are easy to manage your authentication flow and users. To get your `{auth_base_url}`, check it out here - [Get started with base url](/authentication/api/generalinfo#get-started-with-base-url).

<Info>
  Note: **APP-KEY** to be passed in Headers can be obtained from the settings in the project dashboard
</Info>

<Note>
  **Sending SMS OTP** - Currently, we send SMS OTP via Twilio. It is necessary for configure your twilio integration in the dashboard. Click here for [twilio integration](/integrations/twilio)
</Note>

## 1. Signup API

This endpoints allows you to create a new user using the mobile number and otp method.

<Accordion title="Endpoint" defaultOpen="true">
  <ParamField path="POST" type="{auth_base_url}/mobile-otp-signup" />
</Accordion>

<Accordion title="Header">
  <ParamField query="APP-KEY" type="string" required>
    App key of the particular project
  </ParamField>
</Accordion>

<Accordion title="Body Data">
  POST the data in the **application/json** format.

  <ParamField body="country_code" type="string" required>
    Country code of the mobile number. Check the [supported country codes](/authentication/api/basicauth/phoneotp#supported-country-codes)
  </ParamField>

  <ParamField body="mobile" type="string" required>
    Mobile number of the user
  </ParamField>
</Accordion>

<Accordion title="Response Body Data">
  <ResponseField name="user_id" type="string">
    User Id of the new created user
  </ResponseField>

  <ResponseField name="mobile" type="string">
    Mobile number of the user
  </ResponseField>
</Accordion>

#### Example

```jsx Request theme={null}
POST https://authn.zeromagic.cloud/auth/353d1499ab5149e194a53cf0f6c837f4/development/mobile-otp-signup 
HTTP/1.1
APP-KEY : ldM6yPAAE3PRTZbHXrjqGGzZY2Yjm7GwjAyjbNqWH48

{
   "country_code" : "+91",
   "mobile": "9876543211"
}
```

```jsx Response theme={null}
HTTP/1.1 
201 CREATED

{
   "user_id": "1",
   "mobile": "9876543211"
}
```

## 2. Login API

This endpoints allows you to login a user using the mobile number and otp method.

<Accordion title="Endpoint">
  <ParamField path="POST" type="{auth_base_url}/mobile-otp-login" />
</Accordion>

<Accordion title="Header">
  <ParamField query="APP-KEY" type="string" required>
    App key of the particular project
  </ParamField>
</Accordion>

<Accordion title="Body Data">
  POST the data in the **application/json** format.

  <ParamField body="mobile" type="string" required>
    Mobile number of the user
  </ParamField>
</Accordion>

<Accordion title="Response Body Data">
  The response with **200 OK** status code represents that the OTP is sent to the mobile number

  <ResponseField name="user_id" type="string">
    User Id of the user
  </ResponseField>

  <ResponseField name="mobile" type="string">
    Mobile number of the user
  </ResponseField>
</Accordion>

#### Example

```jsx Request theme={null}
POST https://authn.zeromagic.cloud/auth/353d1499ab5149e194a53cf0f6c837f4/development/mobile-otp-login 
HTTP/1.1
APP-KEY : ldM6yPAAE3PRTZbHXrjqGGzZY2Yjm7GwjAyjbNqWH48

{
   "mobile": "9876543211"
}
```

```jsx Response theme={null}
HTTP/1.1 
200 OK

{
   "user_id": "1",
   "mobile": "9876543211"
}
```

## 3. Verify OTP API

This endpoints allows you to verify the otp of the respective mobile number.

<Accordion title="Endpoint">
  <ParamField path="POST" type="{auth_base_url}/mobile-otp-verify" />
</Accordion>

<Accordion title="Header">
  <ParamField query="APP-KEY" type="string" required>
    App key of the particular project
  </ParamField>
</Accordion>

<Accordion title="Body Data">
  POST the data in the **application/json** format.

  <ParamField body="mobile" type="string" required>
    Mobile number of the user
  </ParamField>

  <ParamField body="otp_code" type="integer" required>
    OTP sent to the mobile number
  </ParamField>
</Accordion>

<Accordion title="Response Body Data">
  <ResponseField name="user_id" type="string">
    User Id of the user
  </ResponseField>

  <ResponseField name="mobile" type="string">
    Mobile number of the user
  </ResponseField>

  <ResponseField name="access_token" type="string">
    JWT access token is returned
  </ResponseField>

  <ResponseField name="token_type" type="string">
    Value is *bearer*
  </ResponseField>

  <ResponseField name="expires_in" type="string">
    Currently no expiry time for token, Returns null
  </ResponseField>
</Accordion>

#### Example

```jsx Request theme={null}
POST https://authn.zeromagic.cloud/auth/353d1499ab5149e194a53cf0f6c837f4/development/mobile-otp-login 
HTTP/1.1
APP-KEY : ldM6yPAAE3PRTZbHXrjqGGzZY2Yjm7GwjAyjbNqWH48

{
   "mobile": "9876543211",
   "otp_code" : 1234
}
```

```jsx Response theme={null}
HTTP/1.1 
200 OK

{
   "user_id": "1",
   "mobile": "9876543211",
   "access_token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTIzNDU2Nzg5LCJuYW1lIjoiSm9zZXBoIn0.OpOSSw7e485LOP5PrzScxHb7SR6sAOMRckfFwi4rp7o",
   "token_type" :"bearer",
   "expires_in" : null
}
```

## Supported Country Codes

Below are the list of country codes supported currently. Please, reach out to our support team,if your country code is not listed.

| Country | Country Code |
| ------- | ------------ |
| India   | +91          |
