# Referrals

## Get Referral Code

<mark style="color:blue;">`GET`</mark> `{{url}}/v1/users/referrals/code`

Return referral code

#### Headers

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

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

```json
{
    "status": true,
    "code": 200,
    "message": "Account updated successfully.",
    "data": {
        "referralCode": "VAHL-68151491"
    },
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2NDRiYjAwOGMzYzVlNzlhYzI4NTdjZWYiLCJ1c2VybmFtZSI6IlZpY29sYXMiLCJ2YWhsaWRfaWQiOiI2ODE1MTQ5MSIsInJlZmVycmFsQ29kZSI6IlZBSEwtNjgxNTE0OTEiLCJhY2NvdW50cyI6W3sic291cmNlIjoiYXBpIiwiZGV2X21vZGUiOiJsaXZlIiwiX2lkIjoiNjQ3OGM3Y2E2MWRiZjc3NDYxNThiMTNlIiwibmFtZSI6IkFLT0ggVklDT0xBUyIsIm51bWJlciI6IjIxMzU5NDU2MDEiLCJiYW5rX25hbWUiOiJHdWFyYW50eSBUcnVzdCBCYW5rIiwiYmFua19jb2RlIjoiMDU5IiwidXNlciI6IjY0NGJiMDA4YzNjNWU3OWFjMjg1N2NlZiIsImN1cnJlbmN5IjoiTkdOIiwidXBkYXRlZF9hdCI6IjIwMjItMDUtMjdUMTA6NDc6MjcuODM3WiJ9XSwiYWNjb3VudCI6eyJzb3VyY2UiOiJhcGkiLCJkZXZfbW9kZSI6ImxpdmUiLCJfaWQiOiI2NDc4YzdjYTYxZGJmNzc0NjE1OGIxM2UiLCJuYW1lIjoiQUtPSCBWSUNPTEFTIiwibnVtYmVyIjoiMjEzNTk0NTYwMSIsImJhbmtfbmFtZSI6Ikd1YXJhbnR5IFRydXN0IEJhbmsiLCJiYW5rX2NvZGUiOiIwNTkiLCJ1c2VyIjoiNjQ0YmIwMDhjM2M1ZTc5YWMyODU3Y2VmIiwiY3VycmVuY3kiOiJOR04iLCJ1cGRhdGVkX2F0IjoiMjAyMi0wNS0yN1QxMDo0NzoyNy44MzdaIn0sImlhdCI6MTY4NjQwODA5OCwiZXhwIjoxNjg2NDk0NDk4fQ.Z0L0owOBWNRmHX2pvdVfULNUuFe0kBCcYX5UCp4b0_w",
    "expiredAt": 1686494498
}
```

{% endtab %}
{% endtabs %}

## Get Referral Count

<mark style="color:blue;">`GET`</mark> `{{url}}/v1/users/referrals/count`

Return the referral count

#### Headers

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

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

```json
{
    "status": true,
    "code": 200,
    "message": "Retrieved referral count successfully.",
    "data": {
        "referralCount": 0
    }
}
```

{% endtab %}
{% endtabs %}

## Get Referral Points

<mark style="color:blue;">`GET`</mark> `{{url}}/v1/users/referrals/points`

Return referral points

#### Headers

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

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

```json
{
    "status": true,
    "code": 200,
    "message": "Retrieved referral count successfully.",
    "data": {
        "referralPoints": 0
    }
}
```

{% endtab %}
{% endtabs %}

## Get All Users' Referrals

<mark style="color:blue;">`GET`</mark> `{{url}}/v1/users/referrals`

Return a list of referred users

#### Headers

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

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

```json
{
    "status": "success",
    "code": 200,
    "count": 1,
    "message": "Data retrieved successfully",
    "data": [
        {
            "_id": "618ceaf430adb7f84e2bec70",
            "user": "644bb008c3c5e79ac2857cef",
            "dev_mode": "live",
            "source": "developer",
            "referred": {
                "firstname": null,
                "lastname": null,
                "phone": null,
                "photo": "https://res.cloudinary.com/vahlid/image/upload/v1639921868/vahlid_mern/avatar/nh8sldg1qyhes6sydhgx.jpg",
                "username": "solagbele@twixt.biz",
                "vahlid_id": "68430847",
                "email": "solagbele@twixt.biz"
            }
        }
    ]
}
```

{% endtab %}
{% endtabs %}
