Adding a New Password ​
POST /winapi/passwords
Adding a new Password object can be achieved by making a POST request on the URL, with appropriate fields forming the HTTP message body. Only the fields provided in the data block will be updated; any unspecified fields will be posted as Null values.
This method returns the new Password object as described above, as well as the URL location in the HTTP Headers where the Password object can be retrieved from.
Note: You can either specify the AccountType or AccountTypeID if needed when adding password records. Account Types and their ID values can be seen on the screen Administration -> Passwordstate Administration -> Images and Account Types, and click on the 'Toggle ID Column Visibility' button to determine the appropriate value.
Powershell
# PowerShell Request
#JSON data for the object
$Body = @{
PasswordListID = $PasswordListID
Title = "North American Core Router 1"
UserName = "narouter1"
Password = "StenS-Lun#3$2^yc"
}
$jsonData = $Body | ConvertTo-Json
$PasswordstateUrl = 'https://passwordstate/winapi/passwords'
$result = Invoke-Restmethod -Method Post -Uri $PasswordstateUrl -ContentType "application/json" -Body $jsonData -UseDefaultCredentialsJson
# Response
HTTP/1.1 200
[
{
"PasswordID": 47401,
"Title": "North American Core Router 1",
"UserName": "narouter1",
"Description": "",
"GenericField1": "",
"GenericField2": "",
"GenericField3": "",
"GenericField4": "",
"GenericField5": "",
"GenericField6": "",
"GenericField7": "",
"GenericField8": "",
"GenericField9": "",
"GenericField10": "",
"GenericFieldInfo": [],
"AccountTypeID": 0,
"Notes": "",
"URL": "",
"Password": "StenS-Lun#3$2^yc",
"ExpiryDate": "",
"AllowExport": true,
"AccountType": "",
"OTP": "",
"WebUser_ID": "",
"WebPassword_ID": "",
"WebOTP_ID": "",
"WebGenericField1_ID": "",
"WebGenericField2_ID": "",
"WebGenericField3_ID": "",
"WebGenericField4_ID": "",
"WebGenericField5_ID": "",
"WebGenericField6_ID": "",
"WebGenericField7_ID": "",
"WebGenericField8_ID": "",
"WebGenericField9_ID": "",
"WebGenericField10_ID": ""
}
]In addition to specifying each of the fields manually for the Password object, there are also a couple of options which can be used to perform certain actions:
| Heading | Data Type | Description |
|---|---|---|
| GeneratePassword | Boolean | If set to true, a newly generated random password will be created based on the Password Generator options associated with the Password List. If the Password List is set to use the user's Password Generator options, the Default Password Generator options will be used instead. |
| GenerateGenFieldPassword | Boolean | If set to true, any 'Generic Fields' which you have set to be of type 'Password' will have a newly generated random password assigned to it. If the Password List or Generic Field is set to use the user's Password Generator options, the Default Password Generator options will be used instead. |
| PasswordResetEnabled | Boolean | This option will enable the account to perform Password Resets. To do this, the Password List the password record belongs to, must also have this option set. |
| EnablePasswordResetSchedule | Boolean | If you want to specify a regular scheduled for automatically resetting the value of the Password, you need to enable this option. |
| PasswordResetSchedule | String | This field allows you to set the schedule for automatic password changes. Specify values in the format of 23:10, or 04:00, etc. |
| AddDaysToExpiryDate | Integer | Provides the default value for adding (x) number of days to the ExpiryDate field for all new password records added to the Password List. Note: This field has been deprecated. Please use the fields AddToExpiryDate and AddToExpiryDateInterval below instead. |
| AddToExpiryDate | Integer | Provides the default value for adding (x) number of days or months to the ExpiryDate field for all new password records added to the Password List. Use the field AddToExpiryDateInterval below to specify Days or Months. |
| AddToExpiryDateInterval | String | Specify Days (default) or Months in conjunction with the field AddToExpiryDate above, to add the require time interval to the Expiry Date field once a password reset has occurred. |
| ScriptID | Integer | To configure an account to perform password resets, a Password Reset Script must be assigned to them. To look up the values of the ScriptID's, this can be done by using the 'Toggle ID Column Visibility' button on the Password Reset Scripts screens in Passwordstate. |
| PrivilegedAccountID | Integer | Some Password Reset Scripts also require a Privileged Account Credential to be associated with the Password record, to initiate connection and perform the reset. Requirements for Privileged Accounts are documented in the User Manual, under the KB Article section. To look up the value of PrivilegedAccountID's, this can be done on the screen Administration -> Passwordstate Administration -> Privileged Account Credentials. |
| HeartbeatEnabled | Boolean | If you want to enable the record to perform regular account heartbeat status update, then set this field to True. |
| HeartbeatSchedule | String | This field allows you to set the schedule for the account heartbeat status update. Specify values in the format of 23:10, or 04:00, etc. |
| ValidationScriptID | Integer | When enabling Account Heartbeat, you must associate the correct Password Validation Script to the record (all account types require a Validation Script to be selected). To look up the values of the ValidationScriptID's, this can be done by using the 'Toggle ID Column Visibility' button on the Password Validation Scripts screens in Passwordstate. |
| HostName | String | If the record relates to account on a Host, then you must specify the Host Name here, as it is stored on the Hosts screen in Passwordstate. |
| ADDomainNetBIOS | String | If the record relates to an Active Directory account, then you must specify the Active Directory NetBIOS value here, as it is stored on the Administration -> Passwordstate Administration -> Active Directory Domains screen in Passwordstate. |
| ValidatewithPrivAccount | Boolean | This field is only used for Linux accounts, and when set to True, the Privileged Account Credential will be used for Authentication when performing Account Heartbeats - useful for accounts like root which generally are not allowed to be used for SSH. |
| OTPUri | String (NA) | A valid URi for an OTP field e.g. otpauth://totp/Example:alice@google.com?secret=XBSW23DPAHPK3PXP&issuer=Example |