Skip to main content

Change User Password

Change a user's password by user ID.

Authentication

This endpoint requires a bearer access token for the System API.

Endpoint

POST /api/v1/users/{userId}/password
Authorization: Bearer YOUR_ACCESS_TOKEN
Content-Type: application/json

Request

Headers

HeaderRequiredDescription
AuthorizationYesBearer token for a System API client
Content-TypeYesMust be application/json

Path Parameters

ParameterTypeRequiredDescription
userIdintegerYesUser identifier

Query Parameters

This endpoint does not accept query parameters.

Request Body

{
"currentPassword": "CurrentPassword123!",
"newPassword": "NewPassword123!"
}

Request Fields

FieldTypeRequiredDescription
currentPasswordstringNoCurrent password value used by server-side validation when applicable.
newPasswordstringYesNew password value. Must satisfy the current Guardhouse password requirements.

Validation Rules

  • newPassword is required
  • newPassword must satisfy the current Guardhouse password policy
  • Password policy checks are based on the current branding settings, including length and character requirements where configured

Response

204 No Content

The password was changed successfully.

This endpoint does not return a response body on success.

Errors

StatusWhen it happens
400 Bad RequestPassword validation fails or the server rejects the password change
401 UnauthorizedThe bearer token is missing, invalid, or expired
403 ForbiddenThe token is valid but does not have access to this endpoint
404 Not FoundNo user exists with the provided userId

400 Examples

Current password is required
Invalid current password
Failed to change password. Please try again.

404 Example

User not found

Behavior

  • The new password is validated against the current Guardhouse password policy
  • On success, the previous password is removed and the new password is set
  • If the user email is not yet confirmed, a successful password change confirms it

Example

cURL

curl -X POST "https://your-tenant.guardhouse.cloud/api/v1/users/101/password" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"currentPassword": "CurrentPassword123!",
"newPassword": "NewPassword123!"
}'

.NET SDK

using Guardhouse.SDK.Models.Users;
using Guardhouse.SDK.Services;

// Assumes AddGuardhouseClientWithApiClients(...) is already configured.
app.MapPost("/example/users/{userId:int}/password", async (int userId, IGuardhouseUsersClient usersClient) =>
{
var changed = await usersClient.ChangePasswordAsync(userId, new ChangePasswordRequest
{
CurrentPassword = "CurrentPassword123!",
NewPassword = "NewPassword123!"
});

return changed ? Results.NoContent() : Results.NotFound();
});

Python SDK

# SDK support is in development.
# Use raw HTTP for now.
#
# Example shape:
# response = requests.post(
# "https://your-tenant.guardhouse.cloud/api/v1/users/101/password",
# headers={
# "Authorization": "Bearer YOUR_ACCESS_TOKEN",
# "Content-Type": "application/json",
# },
# json={
# "currentPassword": "CurrentPassword123!",
# "newPassword": "NewPassword123!",
# },
# )

Notes

  • Use a password that meets the current tenant policy.
  • Use Get User By ID if you need to inspect the updated user state after the password change.