> For the complete documentation index, see [llms.txt](https://docs.vendex.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.vendex.app/developer/cloud-api-for-app/user.md).

# User

## User signup

<mark style="color:green;">`POST`</mark> `https://api.vendex.app/api/user/signup/`

For user signup.

#### Headers

| Name             | Type   | Description                                              |
| ---------------- | ------ | -------------------------------------------------------- |
| Api-Client-Token | string | Client token obtained from client authentication method. |

#### Request Body

| Name        | Type   | Description                  |
| ----------- | ------ | ---------------------------- |
| first\_name | string | First name                   |
| last\_name  | string | Last name                    |
| email       | string | Email                        |
| phone\_no   | string | Phone number (+XXX-XXXXXXXX) |
| password    | string | Password                     |

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

```javascript
{
    "status": "success",
    "detail": "Signup success",
}
```

{% endtab %}
{% endtabs %}

## User login

<mark style="color:green;">`POST`</mark> `https://api.vendex.app/api/user/login/`

Method to obtain user token. This token is used in communication header for all API command.

#### Headers

| Name             | Type   | Description                                             |
| ---------------- | ------ | ------------------------------------------------------- |
| Api-Client-Token | string | Client token obtained from client authentication method |

#### Request Body

| Name     | Type   | Description                                                 |
| -------- | ------ | ----------------------------------------------------------- |
| username | string | Email or phone number. Phone number format is +XXX-XXXXXXXX |
| password | string | Password                                                    |

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

```javascript
// If login success
{
    "status": "success",
    "detail": "Login successs",
    "data": {
        "token": "232dc3166fdcd3fab2434104e73af97dcc96e870"
    }
}

// If username and password is correct but phone number is not validated
{
    "status": "error",
    "detail": "Verification code is expired. New verification code has been sent",
    "data": {
        "error_code": "phone_no_not_validated",
        "phone_no": "+XXXXXXXXXXX"
    }
}
```

{% endtab %}
{% endtabs %}

## User logout

<mark style="color:blue;">`GET`</mark> `https://api.vendex.app/api/user/logout/`

This endpoint allows to logout user from client app(s). &#x20;

#### Headers

| Name             | Type   | Description                                              |
| ---------------- | ------ | -------------------------------------------------------- |
| Api-Client-Token | string | Client token obtained from client authentication method. |
| Api-User-Token   | string | User token obtained from user login method.              |

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

```javascript
{
    "status": "success",
    "detail": "Logout success"
}
```

{% endtab %}
{% endtabs %}

## Get user details

<mark style="color:blue;">`GET`</mark> `https://api.vendex.app/api/user/`

To get user details.

#### Headers

| Name             | Type   | Description                                              |
| ---------------- | ------ | -------------------------------------------------------- |
| Api-Client-Token | string | Client token obtained from client authentication method. |
| Api-User-Token   | string | User token obtained from login method.                   |

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

```javascript
[
    {
        "id": 1,
        "first_name": "Irsyad",
        "last_name": "Saidin",
        "phone_no": "+974xxxxxxxx",
        "email": "xxx@nuvapay.com",
        "profile_image_url": "https://nxpay-uploaded-media.s3.ap-south-1.amazonaws.com/upload/9c900a41-9027-4218-9737-f91db6cf4f53.png"
    }
]
```

{% endtab %}
{% endtabs %}

## Validate phone number

<mark style="color:green;">`POST`</mark> `https://api.vendex.app/api/user/validate_phone_number/`

To validate phone number upon sign up.

#### Headers

| Name             | Type   | Description                                              |
| ---------------- | ------ | -------------------------------------------------------- |
| Api-Client-Token | string | Client token obtained from client authentication method. |

#### Request Body

| Name      | Type   | Description                                          |
| --------- | ------ | ---------------------------------------------------- |
| phone\_no | string | Phone number in format of +XXXXXXXXXXX               |
| pin       | string | 6 digit VendexApp verification pin received from SMS |

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

```javascript
{
    "status": "success",
    "detail": "Validation successs",
}
```

{% endtab %}
{% endtabs %}

## Upload profile image

<mark style="color:green;">`POST`</mark> `https://api.vendex.app/api/user/update_profile_image/`

This endpoint allows to update user profile picture.

#### Headers

| Name             | Type   | Description                                              |
| ---------------- | ------ | -------------------------------------------------------- |
| Api-Client-Token | string | Client token obtained from client authentication method. |
| API-User-Token   | string | User token obtained from login method.                   |

#### Request Body

| Name | Type   | Description                                                         |
| ---- | ------ | ------------------------------------------------------------------- |
| file | object | Image should be uploaded as form data with field name as **"file"** |

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

```javascript
{
    "status": "success",
    "detail": "The profile image updated successfully"
}
```

{% endtab %}
{% endtabs %}
