PutSecretValue
Stores a new version of a secret value for a generic secret.
Operation description
-
For details about the access policy that must be granted to a Resource Access Management (RAM) user or RAM role to call this API operation, see Access control.
-
Only generic secrets support this API operation. Each generic secret can store up to 10 secret versions. If the limit is exceeded, KMS automatically deletes the earliest secret version.
-
By default, a newly stored secret value is marked with ACSCurrent, and the previous version marked with ACSCurrent is marked with ACSPrevious. You can override this default behavior by specifying the VersionStages parameter.
-
This API operation is used to store a new version of a secret value, not to modify the secret value of an existing version. When you store a new version, you must specify a version ID. KMS performs operations based on the following rules:
If the version ID does not exist in the secret: A new version is created and the secret value is stored.
If the version ID already exists in the secret: If the secret value in the request is the same as the secret value corresponding to the version ID in the secret, the request is ignored and a success response is returned (the request is idempotent). If the secret values are different, the request is rejected and a failure response is returned.
This topic provides an example of storing a new version of a secret value for the secret named secret001. The version ID VersionId of the new secret version is v3, and the secret value SecretData is importantdata.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
kms:PutSecretValue |
update |
*Secret
|
None |
|
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| VersionId |
string |
Yes |
The version ID of the secret. The version ID must be unique within the secret. |
v3 |
| SecretName |
string |
Yes |
The name or Alibaba Cloud Resource Name (ARN) of the secret. Note
When you access a secret that belongs to another Alibaba Cloud account, you must specify the ARN of the secret. The ARN of a secret is in the |
secret001 |
| SecretData |
string |
Yes |
The secret value. The secret value is encrypted and stored in the specified new version. |
importantdata |
| SecretDataType |
string |
No |
The type of the secret value. Valid values:
|
text |
| VersionStages |
string |
No |
The version stages that are attached to the secret version when it is stored. If you do not specify this parameter, KMS attaches ACSCurrent to the new version by default. |
["ACSCurrent","ACSNext"] |
For more information about common request parameters, see Common parameters.
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| RequestId |
string |
The ID of the request. The ID is a unique identifier generated by Alibaba Cloud for the request and can be used for troubleshooting. |
f94ec9d3-2d10-4922-9a5c-5dcd5ebcb5e8 |
| SecretName |
string |
The name of the secret. |
secret001 |
| VersionId |
string |
The version ID of the secret. |
v3 |
| VersionStages |
object |
||
| VersionStage |
array |
The version stage of the secret. |
|
|
string |
The version stage of the secret. |
{ "VersionStage": [ "ACSCurrent", "ACSNext" ] } |
Examples
Success response
JSON format
{
"RequestId": "f94ec9d3-2d10-4922-9a5c-5dcd5ebcb5e8",
"SecretName": "secret001",
"VersionId": "v3",
"VersionStages": {
"VersionStage": [
"{ \"VersionStage\": [ \"ACSCurrent\", \"ACSNext\" ] }"
]
}
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | InvalidParameter | some of the specified parameters "\" is not valid | |
| 400 | Rejected.LimitExceeded | exceed secret limits error | |
| 500 | InternalFailure | Internal Failure | |
| 403 | Forbidden.NoPermission | This operation is forbidden by permission system | |
| 404 | Forbidden.ResourceNotFound | Resource not found | |
| 409 | Rejected.ResourceExist | The request was rejected becasue key already exsit |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.