Update User By ID
Update a user's basic profile data.
Authentication
This endpoint requires a bearer access token for the System API.
Endpoint
PUT /api/v1/users/{userId}
Authorization: Bearer YOUR_ACCESS_TOKEN
Content-Type: application/json
Request
Headers
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer token for a System API client |
Content-Type | Yes | Must be application/json |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
userId | integer | Yes | User identifier |
Query Parameters
This endpoint does not accept query parameters.
Request Body
{
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]",
"triggerWebhook": true
}
Request Fields
| Field | Type | Required | Description |
|---|---|---|---|
firstName | string | Yes | User first name. Maximum length: 50. |
lastName | string | Yes | User last name. Maximum length: 50. |
email | string | Yes | User email address. Must be a valid email address. |
triggerWebhook | boolean | No | When true, the API triggers the user-updated webhook flow. Default: false. |
Validation Rules
firstNameis required and must not exceed50characterslastNameis required and must not exceed50charactersemailmust be a valid email address
Response
204 No Content
The user was updated successfully.
This endpoint does not return a response body on success.
Errors
| Status | When it happens |
|---|---|
400 Bad Request | The request body is invalid |
401 Unauthorized | The bearer token is missing, invalid, or expired |
403 Forbidden | The token is valid but does not have access to this endpoint |
404 Not Found | No user exists with the provided userId |
404 Example
User not found
Behavior
- The API trims
firstNameandlastName - The API trims and lowercases the email address before storing it
- When
triggerWebhookistrue, the user-updated webhook flow is triggered
Example
cURL
curl -X PUT "https://your-tenant.guardhouse.cloud/api/v1/users/101" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]",
"triggerWebhook": true
}'
.NET SDK
using Guardhouse.SDK.Models.Users;
using Guardhouse.SDK.Services;
// Assumes AddGuardhouseClientWithApiClients(...) is already configured.
app.MapPut("/example/users/{userId:int}", async (int userId, IGuardhouseUsersClient usersClient) =>
{
var updated = await usersClient.UpdateUserAsync(userId, new UpdateUserRequest
{
FirstName = "John",
LastName = "Doe",
Email = "[email protected]",
TriggerWebhook = true
});
return updated ? Results.NoContent() : Results.NotFound();
});
Python SDK
# SDK support is in development.
# Use raw HTTP for now.
#
# Example shape:
# response = requests.put(
# "https://your-tenant.guardhouse.cloud/api/v1/users/101",
# headers={
# "Authorization": "Bearer YOUR_ACCESS_TOKEN",
# "Content-Type": "application/json",
# },
# json={
# "firstName": "John",
# "lastName": "Doe",
# "email": "[email protected]",
# "triggerWebhook": True,
# },
# )
Notes
- Use Get User By ID after updating if you need the latest stored record.
- Use Change User Password for password changes.