> For AI agents: [llms.txt](https://docs.trustedauth.com/llms.txt) provides a Markdown index of this documentation.

# Set a user password

`PUT /api/web/v1/users/{userid}/passwords`

Set a user password for the specified user. Caller requires the USERPASSWORDS:EDIT permission.

## Parameters

| Name | In | Required | Type | Description |
| --- | --- | --- | --- | --- |
| userid | path | Yes | string | The UUID of the user whose password is to be created or modified. |

## Request Body

Required.

### application/json

Schema

```json
{
  "type": "object",
  "properties": {
    "clearPasswordHistory": {
      "type": "boolean",
      "description": "If set to true, this flag indicates existing password history is cleared before the new password is created."
    },
    "currentPassword": {
      "type": "string",
      "description": "A value for the current password when changing the AD-User password. "
    },
    "emailPassword": {
      "type": "boolean",
      "description": "A flag indicating whether to email a new password to the user.  It defaults to true."
    },
    "expiryTime": {
      "type": "string",
      "description": "The date at which the password will expire.",
      "format": "date-time",
      "example": "2019-02-19T13:15:27Z"
    },
    "forceUpdate": {
      "type": "boolean",
      "description": "If set to true, this value indicates the user will be forced to change their password upon next password authentication."
    },
    "generatePassword": {
      "type": "boolean",
      "description": "A flag indicating whether a new random password is generated. It defaults to false."
    },
    "namedPasswordId": {
      "type": "string",
      "description": "The ID of the named password."
    },
    "password": {
      "type": "string",
      "description": "A value for the new password when setting the user password. This value is ignored if generatePassword is set to true."
    },
    "passwordFormat": {
      "type": "string",
      "description": "Define the password format of new password, it's BCRYPT when importing BCrypted password, it's GETACCESS when importing GetAccess password,it defaults to CLEARTEXT if not provided.When passwordFormat is BCRYPT or GETACCESS, the following restrictions must be enforced:<ul><li>1.the user must be an IDaaS local user.</li><li>2.currentPassword must be null.</li><li>3.generatePassword must be false.</li><li>4.emailPassword must be false.</li><li>5.returnPassword must be false.</li></ul>",
      "enum": [
        "CLEARTEXT",
        "BCRYPT",
        "GETACCESS"
      ],
      "default": "CLEARTEXT"
    },
    "returnPassword": {
      "type": "boolean",
      "description": "A flag indicating if a password generated by IDaaS should be returned to the caller. This flag is ignored  if the password is passed from the client.  It defaults to false."
    }
  },
  "description": "Parameters specifying how the password is to be modified. This value may include an actual password or arguments specifying that the service should create a random password.",
  "title": "UserPasswordParms"
}
```

## Responses

### 200

Successful

#### application/json

Schema

```json
{
  "type": "object",
  "properties": {
    "compromised": {
      "type": "boolean",
      "description": "Indicates if the user's password has been found in a data breach."
    },
    "expiryNotificationDate": {
      "type": "string",
      "description": "The date at which the next password expiry notification will be sent.",
      "format": "date-time",
      "example": "2019-02-19T13:15:27Z"
    },
    "expiryTime": {
      "type": "string",
      "description": "The date at which the password will expire.",
      "format": "date-time",
      "example": "2019-02-19T13:15:27Z"
    },
    "forceUpdate": {
      "type": "boolean",
      "description": "Indicates if the user will be forced to change their password the next time the user authenticates with it."
    },
    "id": {
      "type": "string",
      "description": "The ID of the user password."
    },
    "lastChangedTime": {
      "type": "string",
      "description": "The last time the password was changed.",
      "format": "date-time",
      "example": "2019-02-19T13:15:27Z"
    },
    "lastCompromisedCheckTime": {
      "type": "string",
      "description": "The date and time of the last Have I Been Pwned api call performed on this password.",
      "format": "date-time",
      "example": "2019-02-19T13:15:27Z"
    },
    "namedPasswordId": {
      "type": "string",
      "description": "The named password associated to the user."
    },
    "newPassword": {
      "type": "string",
      "description": "The value of the new password generated by IDaaS if requested by the client."
    },
    "present": {
      "type": "boolean",
      "description": "A flag that indicates if the user has a password."
    }
  },
  "description": "Information returned when a user password is queried.",
  "title": "UserPassword"
}
```

### 400

Bad Request

#### application/json

Schema

```json
{
  "type": "object",
  "properties": {
    "errorCode": {
      "type": "string",
      "description": "Error Codes specific to cause of failure.",
      "example": "invalid_user_response"
    },
    "errorMessage": {
      "type": "string",
      "description": "Additional Error Message describing the error.",
      "example": "Application id cannot be null"
    },
    "parameters": {
      "type": "array",
      "description": "Optional additional error information.",
      "items": {
        "type": "object",
        "description": "Optional additional error information."
      }
    }
  },
  "description": "Object containing information about errors reported by services.",
  "title": "ErrorInfo"
}
```

### 401

Access denied

#### application/json

Schema

```json
{
  "type": "object",
  "properties": {
    "errorCode": {
      "type": "string",
      "description": "Error Codes specific to cause of failure.",
      "example": "invalid_user_response"
    },
    "errorMessage": {
      "type": "string",
      "description": "Additional Error Message describing the error.",
      "example": "Application id cannot be null"
    },
    "parameters": {
      "type": "array",
      "description": "Optional additional error information.",
      "items": {
        "type": "object",
        "description": "Optional additional error information."
      }
    }
  },
  "description": "Object containing information about errors reported by services.",
  "title": "ErrorInfo"
}
```

### 403

Forbidden

#### application/json

Schema

```json
{
  "type": "object",
  "properties": {
    "errorCode": {
      "type": "string",
      "description": "Error Codes specific to cause of failure.",
      "example": "invalid_user_response"
    },
    "errorMessage": {
      "type": "string",
      "description": "Additional Error Message describing the error.",
      "example": "Application id cannot be null"
    },
    "parameters": {
      "type": "array",
      "description": "Optional additional error information.",
      "items": {
        "type": "object",
        "description": "Optional additional error information."
      }
    }
  },
  "description": "Object containing information about errors reported by services.",
  "title": "ErrorInfo"
}
```

### 404

Not Found

#### application/json

Schema

```json
{
  "type": "object",
  "properties": {
    "errorCode": {
      "type": "string",
      "description": "Error Codes specific to cause of failure.",
      "example": "invalid_user_response"
    },
    "errorMessage": {
      "type": "string",
      "description": "Additional Error Message describing the error.",
      "example": "Application id cannot be null"
    },
    "parameters": {
      "type": "array",
      "description": "Optional additional error information.",
      "items": {
        "type": "object",
        "description": "Optional additional error information."
      }
    }
  },
  "description": "Object containing information about errors reported by services.",
  "title": "ErrorInfo"
}
```

### 409

Conflict

#### application/json

Schema

```json
{
  "type": "object",
  "properties": {
    "errorCode": {
      "type": "string",
      "description": "Error Codes specific to cause of failure.",
      "example": "invalid_user_response"
    },
    "errorMessage": {
      "type": "string",
      "description": "Additional Error Message describing the error.",
      "example": "Application id cannot be null"
    },
    "parameters": {
      "type": "array",
      "description": "Optional additional error information.",
      "items": {
        "type": "object",
        "description": "Optional additional error information."
      }
    }
  },
  "description": "Object containing information about errors reported by services.",
  "title": "ErrorInfo"
}
```

## Security

Requirements

```json
[
  {
    "AdminAPIAuthentication": [
      "USERPASSWORDS:EDIT"
    ]
  }
]
```
