> For the complete documentation index, see [llms.txt](https://developer.leaderos.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.leaderos.net/users/roles.md).

# Roles

## Get all roles of a user

<mark style="color:blue;">`GET`</mark> `https://yourwebsite.com/api/users/<user_id>/roles`

#### Path Parameters

| Name                                       | Type    | Description |
| ------------------------------------------ | ------- | ----------- |
| user\_id<mark style="color:red;">\*</mark> | numeric | User's ID   |

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

```json
[
    {
        "id": "2",
        "discordRoleID": "673855784005795840",
        "name": "Admin",
        "slug": "admin",
        "priority": "99",
        "expiryDate": "1000-01-01 00:00:00", // Permanent role
    },
    {
        "id": "3",
        "discordRoleID": "673855784005795841",
        "name": "VIP",
        "slug": "vip",
        "priority": "5",
        "expiryDate": "2023-09-03 12:30:45", // Temporary role
    }
]
```

{% endtab %}

{% tab title="404: Not Found User not found" %}

```json
{
    "status": false,
    "error": "USER_NOT_FOUND",
    "message": "User not found!"
}
```

{% endtab %}
{% endtabs %}

## Add role to user

<mark style="color:green;">`POST`</mark> `https://yourwebsite.com/api/users/<user_id>/roles`

#### Path Parameters

| Name                                       | Type    | Description |
| ------------------------------------------ | ------- | ----------- |
| user\_id<mark style="color:red;">\*</mark> | numeric | User's ID   |

#### Request Body

| Name                                     | Type    | Description |
| ---------------------------------------- | ------- | ----------- |
| roleID<mark style="color:red;">\*</mark> | numeric |             |
| expiryDate                               | string  |             |

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

```json
[
    {
        "id": "2",
        "discordRoleID": "673855784005795840",
        "name": "Admin",
        "slug": "admin",
        "priority": "99",
        "expiryDate": "1000-01-01 00:00:00", // Permanent role
    },
    {
        "id": "3",
        "discordRoleID": "673855784005795841",
        "name": "VIP",
        "slug": "vip",
        "priority": "5",
        "expiryDate": "2023-09-03 12:30:45", // Temporary role
    }
]
```

{% endtab %}

{% tab title="404: Not Found User not found" %}

```json
{
    "status": false,
    "error": "USER_NOT_FOUND",
    "message": "User not found!"
}
```

{% endtab %}
{% endtabs %}

## Update user roles

<mark style="color:purple;">`PATCH`</mark> `https://yourwebsite.com/api/users/<user_id>/roles/<role>`

#### Path Parameters

| Name                                       | Type    | Description |
| ------------------------------------------ | ------- | ----------- |
| user\_id<mark style="color:red;">\*</mark> | numeric | User's ID   |
| role                                       | string  | Role ID     |

#### Request Body

| Name                                     | Type    | Description |
| ---------------------------------------- | ------- | ----------- |
| roleID<mark style="color:red;">\*</mark> | numeric |             |
| expiryDate                               | string  |             |

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

```json
[
    {
        "id": "2",
        "discordRoleID": "673855784005795840",
        "name": "Admin",
        "slug": "admin",
        "priority": "99",
        "expiryDate": "1000-01-01 00:00:00", // Permanent role
    },
    {
        "id": "3",
        "discordRoleID": "673855784005795841",
        "name": "VIP",
        "slug": "vip",
        "priority": "5",
        "expiryDate": "2023-09-03 12:30:45", // Temporary role
    }
]
```

{% endtab %}

{% tab title="404: Not Found User not found" %}

```json
{
    "status": false,
    "error": "USER_NOT_FOUND",
    "message": "User not found!"
}
```

{% endtab %}
{% endtabs %}

## Remove role from user

<mark style="color:red;">`DELETE`</mark> `https://yourwebsite.com/api/users/<user_id>/roles/<role>`

#### Path Parameters

| Name                                       | Type    | Description |
| ------------------------------------------ | ------- | ----------- |
| user\_id<mark style="color:red;">\*</mark> | numeric | User's ID   |
| role<mark style="color:red;">\*</mark>     | string  | Role ID     |

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

```json
[
    {
        "id": "2",
        "discordRoleID": "673855784005795840",
        "name": "Admin",
        "slug": "admin",
        "priority": "99",
        "expiryDate": "1000-01-01 00:00:00", // Permanent role
    },
    {
        "id": "3",
        "discordRoleID": "673855784005795841",
        "name": "VIP",
        "slug": "vip",
        "priority": "5",
        "expiryDate": "2023-09-03 12:30:45", // Temporary role
    }
]
```

{% endtab %}

{% tab title="404: Not Found User not found" %}

```json
{
    "status": false,
    "error": "USER_NOT_FOUND",
    "message": "User not found!"
}
```

{% endtab %}
{% endtabs %}
