> For the complete documentation index, see [llms.txt](https://docs.vanrothe.com/wranglebot-engine/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.vanrothe.com/wranglebot-engine/api/users.md).

# Users

### Get One User

To retrieve a single user, you can use the following API call:

```javascript
const user_id = "<userid>";
wranglebot.query.users.one(user_id).fetch();
```

Replace `<userid>` with the ID of the user you want to retrieve.

### Get Many Users

To retrieve multiple users based on a set of filters, use the following API call:

```javascript
const filters = {
    $ids: ["<userid>"]
};
wranglebot.query.users.many(filters).fetch();
```

Replace `<userid>` with the ID(s) of the user(s) you want to retrieve. You can also specify other filters such as username or email.

### Update One User

To update a user's information, use the following API call:

```javascript
const user_id = "<userid>";
const changes = {
    email: "hello@example.com",
    password: "plaintext", 
    firstName: "Hans",
    lastName: "Dieter",
}
wranglebot.query.users.one(user_id).put(changes);
```

Replace `<userid>` with the ID of the user you want to update. You can update any of the user's fields, such as their email, password, first name, or last name. Note that the password must meet certain requirements.

### Revoke User Access To Library

To revoke a user's access to a library, use the following API call:

```
const user_id = "<user_id>";
const library_id = "<library_id>";
await wranglebot.query.users.one(user_id).revoke(library_id);
```

Replace `<user_id>` with the ID of the user you want to revoke access from, and `<library_id>` with the ID of the library you want to revoke access to.

> This feature will only work if the library is set to `classified`

### Allow User Access to Library

To grant a user access to a library, use the following API call:

```javascript
const user_id = "<user_id>";
const library_id = "<library_id>";
wranglebot.query.users.one(user_id).allow(library_id);
```

Replace `<user_id>` with the ID of the user you want to grant access to, and `<library_id>` with the ID of the library you want to grant access to.

### Reset User Password

To reset a user's password, use the following API call:

```javascript
const user_id = "<user_id>";
const newPassword = await wranglebot.query.users.one(user_id).reset();
console.log(newPassword) // the password
```

Replace `<user_id>` with the ID of the user whose password you want to reset. The new password will be returned as a string.

### Add One User

To add a new user, use the following API call:

```javascript
wranglebot.query.users.post({
	username: "my-user",  
	password: "plaintext",  
	email: "example@example.com",  
	roles: ["maintainer"],   
	firstName: "Henriette",  
	lastName: "Dietrichs"
});
```

You can specify the user's username, password, email, roles, first name, and last name. Once the user is added, the User will be returned as a reference.

### Remove One User

Currently you can not delete a user via the API. To lock a user out, simply change the password.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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.vanrothe.com/wranglebot-engine/api/users.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.
