---
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

## Changes

- **2025-05-29** `2deb154b9766` — 3 info
  - added the non-success response with the status `403`
  - added the non-success response with the status `404`
  - added the optional property `message` to the response with the `200` status
- **2025-05-28** `d03e8c66c195` — 1 warning, 2 info
  - removed the optional property `message` from the response with the `200` status
  - removed the non-success response with the status `403`
  - removed the non-success response with the status `404`

[Change history](https://skmtc.dev/microfox-ai/apis/microfox-discord-sdk-api/changes/addRoleToUser/post.md)

---

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