IBM Cloud Docs
Updating secret metadata

Updating secret metadata

With IBM Cloud® Secrets Manager, you can update an existing secret metadata, such as its name or description, custom metadata and expiration date.
Note that not all secret types support all options.

When changing an IAM credential's or Service crednetial's secret TTL, it will be applied only on the next secret version rotation.

Before you begin

Before you get started, be sure that you have the required level of access. To update secrets, you need the Writer service role or higher.

Updating a secret metadata in the UI

  1. In the row for the secret that you want to update, click the Actions menu Actions icon > Details.
  2. To update a secret's General, Expiration, or Metadata details, click the respective tab.

Updating a secret metadata using CLI

To update a secret's metadata by using the Secrets Manager CLI plug-in, run the ibmcloud secrets-manager secret-metadata-update command. For example, the following command updates a secret's name, description, labels, custom metadata, and expiration date.

ibmcloud secrets-manager secret-metadata-update \
    --id 0b5571f7-21e6-42b7-91c5-3f5ac9793a46 \
    --name updated-arbitrary-secret-name-example \
    --description 'updated Arbitrary Secret description' \
    --labels dev,us-south \
    --custom-metadata '{"anyKey": "anyValue"}' \
    --expiration-date 2033-04-12T23:20:50.520Z

Updating a secret metadata using API

To update a secret's metadata by using the API, execute the following request. In this example the request updates a secret's name, description, labels, custom metadata, and expiration date.

curl -X PATCH --location --header "Authorization: Bearer {iam_token}" \
   --header "Accept: application/json" \
   --header "Content-Type: application/merge-patch+json" \
   --data '{
      "custom_metadata":{
         "metadata_custom_key": "metadata_custom_value"
      },
      "description": "updated Arbitrary Secret description",
      "labels": ["dev","us-south"],
      "name": "updated-arbitrary-secret-name-example",
      "expiration_date": "2023-10-05T11:49:42Z"
   }' \  
   "https://{instance_ID}.{region}.secrets-manager.appdomain.cloud/api/v2/secrets/{id}/metadata"

When you call the API, replace the region, secret id variables and IAM token with the values that are specific to your Secrets Manager instance.