# Authentication

The Vedpad REST API uses JWT (JSON Web Token)?based authentication to secure its endpoints. Users must first authenticate using the Login API by providing valid credentials. Upon successful login, the API returns a JWT token.

This token must be included in the Authorization header for all subsequent requests to protected endpoints using the Bearer token scheme, as shown below:

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.example.token

Replace 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.example.token' with the token received from the login response. Requests that do not include a valid or non-expired token will be rejected with an authentication error. Ensure the token is stored securely and sent with every request that requires authentication.

```shell
curl -X GET "https://vedaay-api.mulika.in/users" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.example.token" \
  -H "Content-Type: application/json"
```



## Login (Generate Token)

```shell
curl -X POST https://vedaay-api.mulika.in/auth/login
-H "Content-Type: application/json" \
-d '{
    "email":"pixel@gmail.com",
    "password":"11111111"
    }'
```
> Responce:

```json
 
  {
    "status": "success",
    "message": "Login successful.",
    "code": 200,
    "data": {
        "user_id": "107",
        "username": "rohan",
        "email": "rohan@gmail.com",
        "role_id": "2",
        "domain": "192.168.1.180:8084"
    },
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3Njk3NzE4NTIsImV4cCI6MTc2OTg1ODI1MiwidXNlcl9pZCI6IjIwNSIsInVzZXJuYW1lIjoicGl4ZWwiLCJlbWFpbCI6InBpeGVsQGdtYWlsLmNvbSJ9.VzcNp1upoprzO_8wqAZc6oiE7ReuIctSdMWw-GU7gWk"
  }
```

<span style="background: #000; color: white; padding: 10px 10px; border-radius: 4px;  width: 100%;display: block;">
<span  style="background: #08c0b7; color: white; padding: 8px 24px; border-radius: 2px; font-weight: bold; ">POST</span> /auth/login
</span>  


## Email OTP verification

## Send OTP  

```shell
curl -X POST https://vedaay-api.mulika.in/users/send_otp
-H "Content-Type: application/json" \ 
-d '{
    "email": "rohan@gmail.com"
}

```
> Responce:

```json
    {
    "status": "success",
    "message": "OTP generated successfully!",
    "code": 200,
    "data": { 
        "email": "rohan@gmail.com",
        "expires_at": "2026-02-13 09:19:35",
        "user_id": "107"
    }
  }'

```
<span style="background: #000; color: white; padding: 10px 10px; border-radius: 4px;  width: 100%;display: block;">
<span  style="background: #08c0b7; color: white; padding: 8px 24px; border-radius: 2px; font-weight: bold; ">POST</span> /users/send_otp
</span>      
 

## Verify OTP


```shell
curl -X POST https://vedaay-api.mulika.in/users/verify_otp
-H "Content-Type: application/json" \ 
-d '{
     "email": "rohan@gmail.com",
     "otp": "017775"
}'
```
> Responce:

```json
    {
    "status": "success",
    "message": "Email verified successfully.",
    "code": 200,
    "data": {
        "user_id": "107",
        "username": "rohan",
        "email": "rohan@gmail.com",
        "role_id": "2",
        "verified": true
    },
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3NzA5NzQxNjUsImV4cCI6MTc3MTA2MDU2NSwidXNlcl9pZCI6IjEwNyIsInVzZXJuYW1lIjoicm9oYW4iLCJlbWFpbCI6InJvaGFuQGdtYWlsLmNvbSIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlfQ.gWmAUYxK_exW8WM_LixwprayisrJ6xfmI9MCWIBnwqg"
}'
```

<span style="background: #000; color: white; padding: 10px 10px; border-radius: 4px;  width: 100%;display: block;">
<span  style="background: #08c0b7; color: white; padding: 8px 24px; border-radius: 2px; font-weight: bold; ">POST</span> /users/verify_otp
</span> 
 

## Reset Password

## Send email  

```shell
curl -X POST https://vedaay-api.mulika.in/send_email
-H "Content-Type: application/json" \ 
-d '{
    "email": "rohan@gmail.com"
}

```
> Responce:

```json
    '{
    "status": "success",
    "message": "Reset token generated successfully.",
    "code": 200,
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9"
}'

```
<span style="background: #000; color: white; padding: 10px 10px; border-radius: 4px;  width: 100%;display: block;">
<span  style="background: #08c0b7; color: white; padding: 8px 24px; border-radius: 2px; font-weight: bold; ">POST</span> /send_email
</span>      
 

## Update password


```shell
curl -X PUT https://vedaay-api.mulika.in/update_password
-H "Content-Type: application/json" \ 
-d '{
    "token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9",
    "password":"55555555"
    }'
```
> Responce:

```json
    '{
    "status": "success",
    "message": "Password updated successfully.",
    "code": 200
    }'
```

<span style="background: #000; color: white; padding: 10px 10px; border-radius: 4px;  width: 100%;display: block;">
<span  style="background: #08c0b7; color: white; padding: 8px 24px; border-radius: 2px; font-weight: bold; ">PUT</span> /update_password
</span> 
 
 