Update a user by ID
PUT/users/:userId
This request is useful for modifying user information when changes need to be made to a user's account or access level. Additionally, the "isActive" key can be used to temporarily suspend or disable a user's account, without permanently deleting it.
Request
Path Parameters
The ID of the user to retrieve, update or delete
- application/json
Body
required
Possible values: >= 3 characters and <= 50 characters
Possible values: >= 5 characters and <= 255 characters
A Unique email address of the user
Possible values: [developer, admin, user]
Responses
- 200
- 400
- 401
- 403
- 404
- 500
User updated
- application/json
- Schema
- Example (from schema)
Schema
Possible values: >= 3 characters and <= 50 characters
Possible values: >= 5 characters and <= 255 characters
Possible values: [developer, admin, user]
createdBy object
The user who created this user
updatedBy object
The user who last updated this user
The date and time this user was created
The date and time this user was last updated
{
"_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"name": "string",
"email": "user@example.com",
"isActive": true,
"role": "developer",
"createdBy": {
"_id": "string",
"name": "string",
"email": "user@example.com"
},
"updatedBy": {
"_id": "string",
"name": "string",
"email": "user@example.com"
},
"createdAt": "2024-12-03T13:26:27.369Z",
"updatedAt": "2024-12-03T13:26:27.369Z"
}
Bad Request due to validation errors in the request body
- application/json
- Schema
- Example (from schema)
- Example
Schema
- any
{
"message": "Validation failed.",
"errors": [
{
"field": "name",
"message": "Name is required."
},
{
"field": "email",
"message": "Email must be a valid email address."
}
]
}
{
"message": "Validation failed.",
"errors": [
{
"field": "name",
"message": "Name is required."
},
{
"field": "email",
"message": "Email must be a valid email address."
}
]
}
Unauthorized.
- application/json
- Schema
- Example (from schema)
- Example
Schema
- any
{
"message": "Authentication token not provided."
}
{
"message": "Authentication token not provided."
}
Forbidden.
- application/json
- Schema
- Example (from schema)
- Example
Schema
- any
{
"message": "Access to this resource is forbidden."
}
{
"message": "Access to this resource is forbidden."
}
Resource not found.
- application/json
- Schema
- Example (from schema)
- Example
Schema
- any
{
"message": "Resource not found."
}
{
"message": "Resource not found."
}
Internal Server Error
- application/json
- Schema
- Example (from schema)
- Example
Schema
- any
{
"message": "Internal Server Error. Please try again later."
}
{
"message": "Internal Server Error. Please try again later."
}