> For the complete documentation index, see [llms.txt](https://docs.ionos.com/cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ionos.com/cloud/api-reference/databases/mongodb/users-1/patch-a-mongodb-user-by-id.md).

# Patch a MongoDB User by ID

Patches a MongoDB user specified by its ID.

```json
{"openapi":"3.0.3","info":{"title":"IONOS DBaaS MongoDB REST API","version":"1.0.0"},"tags":[{"name":"Users","description":"How to manage users of a database cluster."}],"servers":[{"url":"https://api.ionos.com/databases/mongodb","description":"Production"}],"security":[{"basicAuth":[]},{"tokenAuth":[]}],"components":{"securitySchemes":{"basicAuth":{"type":"http","scheme":"basic","description":"For 'Basic' authentication, take your credentials by first combining the username and password with a colon (``username:password``) and then encoding the resulting string in base64 (``YWxhZGRpbjpvcGVuc2VzYW1l``).\n\n**Example Request Header**\n\n``Authorization: Basic YWxhZGRpbjpvcGVuc2Vzl``\n\nMore details: https://en.wikipedia.org/wiki/Basic_access_authentication\n"},"tokenAuth":{"type":"apiKey","in":"header","name":"Authorization","description":"Authorization is granted when a valid proof of identity is provided along with an API request for data. This proof of identity is in the form of a JSON web access token, a unique string that identifies a user.\n\n**Example Request Header**\n\n``Authorization: Bearer ACCESS_TOKEN``\n"}},"parameters":{"ClusterIdPath":{"name":"clusterId","in":"path","description":"The unique ID of the cluster.","required":true,"schema":{"type":"string"}},"UsernamePath":{"name":"username","in":"path","description":"The authentication username.","required":true,"schema":{"type":"string"}}},"schemas":{"PatchUserRequest":{"description":"MongoDB database user patch request.","properties":{"metadata":{"$ref":"#/components/schemas/UserMetadata"},"properties":{"$ref":"#/components/schemas/PatchUserProperties"}}},"UserMetadata":{"description":"The metadata of the resource.","properties":{"createdDate":{"type":"string","format":"date-time","description":"The date the resource was created."},"createdBy":{"type":"string","description":"The user who created the resource."},"createdByUserId":{"type":"string","description":"The ID of the user who created the resource."}}},"PatchUserProperties":{"description":"MongoDB database user patch request properties.","properties":{"password":{"type":"string","writeOnly":true,"minLength":10},"roles":{"type":"array","items":{"$ref":"#/components/schemas/UserRoles"}}}},"UserRoles":{"description":"a list of mongodb user role.","properties":{"role":{"type":"string","enum":["read","readWrite","dbAdmin","clusterMonitor","readAnyDatabase","readWriteAnyDatabase","dbAdminAnyDatabase","enableSharding"]},"database":{"type":"string"}},"type":"object"},"User":{"description":"MongoDB database user.","properties":{"type":{"allOf":[{"$ref":"#/components/schemas/ResourceType"}]},"metadata":{"$ref":"#/components/schemas/UserMetadata"},"properties":{"$ref":"#/components/schemas/UserProperties"}},"type":"object"},"ResourceType":{"description":"The resource type.","type":"string","enum":["collection","cluster","user","snapshot","template"]},"UserProperties":{"description":"Mongodb user properties.","required":["username"],"properties":{"username":{"type":"string"},"roles":{"type":"array","items":{"$ref":"#/components/schemas/UserRoles"}}}},"ErrorResponse":{"properties":{"httpStatus":{"type":"integer","description":"The HTTP status code of the operation."},"messages":{"type":"array","items":{"$ref":"#/components/schemas/ErrorMessage"}}},"type":"object"},"ErrorMessage":{"properties":{"errorCode":{"type":"string","description":"Application internal error code.\n"},"message":{"type":"string","description":"A human readable explanation specific to this occurrence of the\nproblem.\n"}},"type":"object"}},"responses":{"ApiError":{"description":"Any erroneous status code: 400 (parse error), 401 (authorization error),\n402 (trial access), 403 (insufficient permissions), 404 (not found),\n405 (unsupported HTTP method), 415 (unsupported content type),\n422 (validation error), 429 (request rate limit exceeded),\n500 (server error), 503 (maintenance)\n","headers":{"Content-Type":{"description":"The content type of the response.","schema":{"type":"string","default":"application/problem+json"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"paths":{"/clusters/{clusterId}/users/{username}":{"patch":{"operationId":"clustersUsersPatch","summary":"Patch a MongoDB User by ID","description":"Patches a MongoDB user specified by its ID.","tags":["Users"],"parameters":[{"$ref":"#/components/parameters/ClusterIdPath"},{"$ref":"#/components/parameters/UsernamePath"}],"requestBody":{"description":"Part of the MongoDB user which should be modified.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PatchUserRequest"}}},"required":true},"responses":{"200":{"description":"The user identified by the username and database parameters will be patched.\n","content":{"application/json":{"schema":{"$ref":"#/components/schemas/User"}}}},"default":{"$ref":"#/components/responses/ApiError"}}}}}}
```


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.ionos.com/cloud/api-reference/databases/mongodb/users-1/patch-a-mongodb-user-by-id.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
