> For the complete documentation index, see [llms.txt](https://support.attackforge.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://support.attackforge.com/app/modules/ai-mcp-and-skills/patch-user.md).

# Patch User

#### Description <a href="#description" id="description"></a>

Partially updates an existing AttackForge user. This is a **write** operation: it updates the user record, and may also move the user to a different role or block them. Only the keys supplied in `args` are changed; omitted keys are left untouched.

The shape of `args` is declared inline (see Building args for Write Tools), so no preparatory call is needed.

Who may patch what:

* **Administrators** may patch any user and any key.
* **Any other caller** may patch only their own record, and only the keys not marked **Administrators only** below. Supplying an administrator-only key is refused rather than silently dropped.

A deleted user cannot be patched. The last remaining active administrator cannot be blocked, expired, or moved off the `admin` role. On success the patched user id is returned.

#### How To Enable <a href="#how-to-enable" id="how-to-enable"></a>

1. Go to `Users`
2. Select the user you would like to provide access to this tool
3. Click on `Access > MCP`
4. Click on `Add Tools`
5. Select the tool `patch_user` and click `Add`

#### Example Prompts <a href="#example-prompts" id="example-prompts"></a>

* *Block Jane Smith's account.*
* *Unblock user X.*
* *Make Bob a project operator.*
* *Set my job title to Senior Penetration Tester and add OSCP to my certifications.*
* *Force user X to change their password at next login.*
* *Expire the contractor accounts at the end of the month.*
* *Clear the account expiry on user X.*
* *Update the Department custom field on user X to "Security".*

#### Parameters <a href="#parameters" id="parameters"></a>

| Parameter | Type   | Required | Description                                  |
| --------- | ------ | -------- | -------------------------------------------- |
| `args`    | object | Yes      | The user-patch payload - see the keys below. |

**`args` keys:**

| Key                               | Type           | Required | Description                                                                                                                                                                                                                                                                                                         |
| --------------------------------- | -------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `user_id`                         | string         | Yes      | Id (24-hex) of the user to patch. Source: `find_users`. A caller who is not an administrator may only pass their own user id.                                                                                                                                                                                       |
| `first_name`                      | string         | No       | First name.                                                                                                                                                                                                                                                                                                         |
| `last_name`                       | string         | No       | Last name.                                                                                                                                                                                                                                                                                                          |
| `email`                           | string         | No       | Email address. Must not already be in use by another user. **Administrators only.**                                                                                                                                                                                                                                 |
| `username`                        | string         | No       | The username the user signs in with. Must not already be in use by another user. **Administrators only.**                                                                                                                                                                                                           |
| `role`                            | string         | No       | One of `'admin'`, `'projectoperator'`, `'librarymod'`, `'consultant'`, `'client'`. Every role other than `'client'` consumes a user licence, so moving a user off `'client'` fails once the licence is exhausted. Moving the only remaining active administrator off `'admin'` is refused. **Administrators only.** |
| `status`                          | string         | No       | `'Active'` unblocks the account and clears any expiry; `'Blocked'` blocks it and signs the user out of every session. Blocking the only remaining active administrator is refused. **Administrators only.**                                                                                                         |
| `mfa_enabled`                     | boolean        | No       | Whether multi-factor authentication is required for this user. **Administrators only.**                                                                                                                                                                                                                             |
| `force_password_change`           | boolean        | No       | Whether the user must change their password at next sign-in. **Administrators only.**                                                                                                                                                                                                                               |
| `exempt_global_inactivity_policy` | boolean        | No       | Whether the user is exempt from the global inactivity policy. **Administrators only.**                                                                                                                                                                                                                              |
| `account_expiry`                  | string or null | No       | ISO-8601 datetime of when the account expires. Pass `null` to clear an existing expiry; omit to leave it unchanged. Expiring the only remaining active administrator is refused. **Administrators only.**                                                                                                           |
| `job_title`                       | string         | No       | Profile job title.                                                                                                                                                                                                                                                                                                  |
| `organization`                    | string         | No       | Profile organization.                                                                                                                                                                                                                                                                                               |
| `business_group`                  | string         | No       | Profile business group.                                                                                                                                                                                                                                                                                             |
| `office_location`                 | string         | No       | Profile office location.                                                                                                                                                                                                                                                                                            |
| `about_me`                        | string         | No       | Profile free-text biography.                                                                                                                                                                                                                                                                                        |
| `tags`                            | array          | No       | String tags on the profile. **Replaces** the existing tags when supplied.                                                                                                                                                                                                                                           |
| `certifications`                  | array          | No       | Certifications. **Replaces** the existing certifications when supplied.                                                                                                                                                                                                                                             |
| `education`                       | array          | No       | Education history, each `{ qualification, institute, completed }`. **Replaces** the existing history when supplied.                                                                                                                                                                                                 |
| `employment`                      | array          | No       | Employment history, each `{ role, company, duration, description }`. `duration` is one of `'0+ Years'`, `'1-2 Years'`, `'2-3 Years'`, `'3-5 Years'`, `'5-10 Years'`, `'10+ Years'`. **Replaces** the existing history when supplied.                                                                                |
| `custom_fields`                   | array          | No       | Custom field values, each `{ key, value }`. Supplying a custom field replaces its current value; supplying `null` clears it. Discover keys via `get_field_structure(model="user")`. A caller who is not an administrator may set these on their own record, subject to the same per-field access.                   |

> Supplying `status` together with `account_expiry` applies both: `'Active'` clears the existing expiry and the supplied `account_expiry` then sets a new one.

#### Example Response

```json
{
  "user_id": "65a440c08cade68ca7bc7192"
}
```


---

# 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, and the optional `goal` query parameter:

```
GET https://support.attackforge.com/app/modules/ai-mcp-and-skills/patch-user.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
