# demote \[DISABLED]

#### api.demote

`api.demote(userid: string or number)`: table

| Argument | Type             | Description               |
| -------- | ---------------- | ------------------------- |
| userid   | string or number | The roblox players userid |

Returns a table including status and rank data.

#### Return table

```lua
{
  status = boolean,
  code = number,
  error = string,
  data = {
    newRole = { 
      id = number, 
      name = string, 
      rank = number, 
      memberCount = number
    },
    oldRole: {
      id = number,
      name = string,
      rank = number,
      memberCount = number
    }
  }
}
```

<table><thead><tr><th width="150">Table</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>status</td><td>boolean</td><td>True if request went though, False if request didn't go through</td></tr><tr><td>code</td><td>number</td><td>The status code of the request</td></tr><tr><td>error</td><td>string</td><td>This tells you what went wrong. Only will be given if status is false.</td></tr><tr><td>data.newRole.id</td><td>number</td><td>rolesetid of users new rank</td></tr><tr><td>data.newRole.name</td><td>string</td><td>Name of users new rank</td></tr><tr><td>data.newRole.rank</td><td>number</td><td>rankid of users new rank</td></tr><tr><td>data.newRole.membercount</td><td>number</td><td> How many users are in the new rank</td></tr><tr><td>data.oldRole.id</td><td>number</td><td>rolesetid of users old rank</td></tr><tr><td>data.oldRole.name</td><td>string</td><td>Name of users old rank</td></tr><tr><td>data.oldRole.rank</td><td>number</td><td>rankid of users old rank</td></tr><tr><td>data.oldRole.membercount</td><td>number</td><td> How many users are in the old rank</td></tr></tbody></table>

#### Possible Errors

```lua
{
  status = false,
  code = 429,
  error = "Too Many Requests"
}
{
  status = false,
  code = 403,
  error = "The bot does not have permissions to rank this user"
}
{
  status = false,
  code = 402,
  error = "The user you provided is not in the group"
}
{
  status = false,
  code = 405,
  error =  "The user is invalid or does not exist"
}
{
  status = false,
  code = 0,
  error = "Error not found"
}
```

#### Example

```lua
local API = require(10005387312)({key = "Key Here", beta = false}) 

game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:Connect(function()
		if player.UserId == 123445 then
			local success, rank = pcall(function()
				return API.demote(player.UserId)
			end)
			if not success then return error(rank) end
			if rank.status then
				print(player.Name .. ' was demoted to ' ..rank.data.newRole.name)
			else
				error('EasyRanks '.. tostring(rank.code) .. ': ' .. rank.error)
			end
		end	
	end)
end)
```

This example demotes someone with the userid 123445 to rankid 2. This shows you how to demote someone when they join your game, hopefully you can take this and make more out of it.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.easyranks.tech/reference/api-reference/demote-disabled.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
