# Laravel

You can find out the Laravel auth APIs public repo [here](https://github.com/crema-git/crema-laravel.git)

All Auth APIs listed here -

## Register User

<mark style="color:green;">`POST`</mark> `https://www.your-domain.com/api/v1/users`

This API is used for the register user

#### Request Body

| Name                                       | Type   | Description              |
| ------------------------------------------ | ------ | ------------------------ |
| name<mark style="color:red;">\*</mark>     | String | Name of the user         |
| email<mark style="color:red;">\*</mark>    | String | Email of the user        |
| password<mark style="color:red;">\*</mark> | String | Password for the account |

{% tabs %}
{% tab title="200: OK User registered sucessfully" %}

```javascript
{
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkIjoiNWY0ZjE5ZWNjN2Y5ZGEwMDE3ZDg1YmFkIn0sImlhdCI6MTU5OTAxOTUwMSwiZXhwIjoxNTk5NDUxNTAxfQ.diJyrzPOY-FD7quqhbJ9D5sDdN8Oym40qqfgHoldpdg"
}
```

{% endtab %}

{% tab title="400: Bad Request User registration failed " %}

```javascript
{
    "error": "User already exists"
}
```

{% endtab %}
{% endtabs %}

## Login User

<mark style="color:green;">`POST`</mark> `https://www.your-domain.com/api/v1/auth`

This API is used for the login user

#### Request Body

| Name                                       | Type   | Description             |
| ------------------------------------------ | ------ | ----------------------- |
| email<mark style="color:red;">\*</mark>    | String | Email of the user       |
| password<mark style="color:red;">\*</mark> | String | Password of the account |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkIjoiNWY0ZjE5ZWNjN2Y5ZGEwMDE3ZDg1YmFkIn0sImlhdCI6MTU5OTA3MDc3MCwiZXhwIjoxNTk5NTAyNzcwfQ.fK3L6ZmU8S7I-i21kJj_0sA212JOPgFaTWeSeAUaORQ"
}
```

{% endtab %}

{% tab title="400: Bad Request " %}

```javascript
{
    "error": "Invalid Credentials"
}
```

{% endtab %}
{% endtabs %}

## Auth User

<mark style="color:blue;">`GET`</mark> `https://www.your-domain.com/api/v1/auth`

This API is used to check the auth token validation

#### Headers

| Name                                            | Type   | Description  |
| ----------------------------------------------- | ------ | ------------ |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer token |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "id": 4,
    "name": "Demo User",
    "email": "demo@ample.com",
    "email_verified_at": null,
    "created_at": "2020-09-03T04:25:55.000000Z",
    "updated_at": "2020-09-03T04:25:55.000000Z"
}
```

{% endtab %}
{% endtabs %}
