Update credential

Updated at:

Rotate a credential's secret or update metadata. The name and networking settings cannot be changed.

Endpoint

Paths are relative to the Base URL. Send Authorization: Bearer $DASHSCOPE_API_KEY on every request. For authentication details, see Authentication.

POST/vaults/{vault_id}/credentials/{credential_id}

Path parameters

vault_idstringRequired

Parent vault ID. Treat it as an opaque ID

credential_idstringRequired

Credential ID. Treat it as an opaque ID

Request body

metadataobjectOptional

Metadata, when omitted, the current value is kept; null returns 400; {} clears it. Up to 16 items; key 1–64 characters, value up to 512 characters

authobjectOptional

Authentication information, when omitted, only metadata is updated; null returns 400

Properties

typestringConditional

Authentication type, fixed as environment_variable

secret_valuestringConditional

New secret value. Cannot be empty or whitespace-only; length and control character limits are the same as on create

Provide at least one of metadata and auth. Omitting both or sending {} returns 400. Updates can only change metadata and rotate secret_value; name, secret_name, and networking cannot be changed, and sending these fields returns 400 unknown_parameter.

metadata is replaced as a whole, not merged. Rotation keeps the existing environment variable name and networking settings. The response does not return secret_value, the key identifier, or injection_location.

Request example

curl -sS -X POST "$BASE_URL/vaults/vlt_xxx/credentials/vcrd_xxx" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "metadata": {"rotation": "2026-11"},
    "auth": {
      "type": "environment_variable",
      "secret_value": "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    }
  }'
import os
import requests

resp = requests.post(
    f"{os.environ['BASE_URL']}/vaults/vlt_xxx/credentials/vcrd_xxx",
    headers={"Authorization": f"Bearer {os.environ['DASHSCOPE_API_KEY']}"},
    json={
        "metadata": {"rotation": "2026-11"},
        "auth": {
            "type": "environment_variable",
            "secret_value": "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        },
    },
)
print(resp.status_code, resp.json())

Response fields

200, returns the updated credential:

idstring

Credential ID

objectstring

Credential object type, fixed as vault.credential

vault_idstring

Parent vault ID

namestring

Display name

created_atinteger

Creation time in Unix seconds

updated_atinteger

Last update time in Unix seconds

metadataobject

Metadata, string key-value pairs; {} when not set

authobject

Authentication settings.

Properties

typestring

Authentication type, fixed as environment_variable

secret_namestring

Environment variable name

networkingobject

Target domain settings.

Properties

typestring

Network access type, limited or unrestricted

allowed_hostsarray

Domains or IPv4 addresses allowed for limited

Response example

{
  "id": "vcrd_xxx",
  "object": "vault.credential",
  "vault_id": "vlt_xxx",
  "name": "crm-token",
  "created_at": 1793941200,
  "updated_at": 1793944800,
  "metadata": {"rotation": "2026-11"},
  "auth": {
    "type": "environment_variable",
    "secret_name": "CRM_TOKEN",
    "networking": {
      "type": "limited",
      "allowed_hosts": ["api.example.com"]
    }
  }
}

Error codes

For the error response structure, see Errors.

HTTP statusError type / codeSolution
400invalid_request_error / unknown_parameterThe request contains an unknown field, such as name, secret_name, or networking
400invalid_request_error / invalid_typeFix the field type as described
400invalid_request_error / invalid_request_errorThe request body is empty, auth.type is invalid, secret_value is blank, or metadata is null
401authentication_error / invalid_api_keySend a valid Authorization: Bearer $DASHSCOPE_API_KEY header
404not_found_error / not_found_errorThe credential does not exist, is deleted, does not belong to the parent vault, or belongs to another workspace
409conflict_error / conflict_errorRetry later. If it keeps failing, submit a ticket with x-request-id
500server_error / server_errorRetry later. If it keeps failing, submit a ticket with x-request-id