---
title: "Adds a role to a user in a Discord guild."
method: POST
path: "/addRoleToUser"
---

# Adds a role to a user in a Discord guild.

`POST /addRoleToUser`

This function assigns a specific role to a user within a Discord guild. It takes the guild ID, user ID, and role ID as required parameters, with an optional reason for audit log purposes. The function returns a Promise that resolves when the role is successfully added to the user.

## Request body

- object
  - `body` object — Body of the addRoleToUser sls call
    - `arguments` unknown[], required
      - unknown
    - `auth` object — Authentication object
      - `strategy` 'apikey' — Authentication strategy
      - `variables` unknown[] — Variables for the authentication strategy
        - unknown
    - `packageName` string — @microfox/discord

## Response `200`

Role successfully added to the user

- object
  - `success` boolean — Indicates if the role was successfully added
  - `message` string — A message confirming the role addition

## Other responses

- `400` — Bad Request - Invalid input parameters
- `403` — Forbidden - Insufficient permissions to add the role
- `404` — Not Found - Guild, user, or role not found
- `500` — Internal Server Error

---

[API](https://skmtc.net/microfox-ai/apis/microfox-discord-sdk-api.md) · [All operations](https://skmtc.net/microfox-ai/apis/microfox-discord-sdk-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/microfox-ai/microfox-discord-sdk-api/versions/7cb5b64ae924/schema)
