When you configure a cloud product with sensitive credentials — such as API keys or AccessKey pairs — the product can automatically store those credentials as a KMS secret on your behalf. These are called default secrets. The cloud product manages the secret's lifecycle; you control who can access it.
How it works
Default secrets can only be created by the cloud product that manages them. You cannot create, update, or delete them directly through KMS APIs.
You submit credentials to a cloud product (such as AI Gateway or API Gateway), or the product generates credentials automatically.
The cloud product assumes a RAM role and creates a KMS secret to store those credentials securely.
The secret is accessible to your applications and developers through standard KMS access methods, subject to the permissions you configure.
Default secrets follow the naming format <ProductCode>!<SecretIdentifier>. For example:
bailian!secret-123— created by Alibaba Cloud Model Studioaigw!secret-abc— created by AI Gateway
To find all default secrets for a specific product, filter by the product code prefix. In the KMS console, enter the prefix (for example, aigw!) in the secret name filter.
Choose a hosting mode
Default secrets are available in free and paid hosting modes. The supported mode varies by cloud product.
When to use paid mode: Choose paid mode when you need control over the encryption key, cross-account authorization via secret policies, dedicated gateway throughput, or detailed SLS audit logs.
Free | Paid | |
Cost | Free. No KMS instance required. | Requires a purchased KMS instance, billed by instance type. |
Quota | Limited per cloud product. | Determined by the KMS instance type; supports on-demand scale-out. |
Lifecycle management | Delete or modify only from the cloud product. In KMS, you can only read them. | Delete or modify only from the cloud product. In KMS, you can only read them. |
Encryption key | Alibaba Cloud managed key (not visible or controllable by you). | Customer managed key (CMK). You have full control. Create a key in KMS before using paid mode. |
Access policies | Identity-based policies only. | Identity-based policies and secret policies. |
Security audit | ActionTrail only. | ActionTrail and Simple Log Service (SLS) logs of the KMS instance. |
Access gateway | Shared gateway only. | Shared gateway or dedicated gateway. |
Set up access to a default secret
Step 1: Confirm the cloud product has created the secret
Trigger the secret creation from within the cloud product — for example, by creating a key in AI Gateway or API Gateway. The cloud product assumes a RAM role to create the secret in KMS automatically.
Supported products
Product | Secret type | Quota | Reference |
Model Studio (MCP) | Free credentials | 20 | Integrate with Alipay MCP Server to add payment collection to your agent application |
Alibaba Cloud Model Studio (API key) | Free credentials | 100 | None |
AI Gateway | Payment credentials | KMS instance quota applies. | |
API Gateway | Payment credentials | KMS instance quota applies. |
Step 2: Grant access permissions
Grant a RAM user or RAM role permission to read the secret. Two policy types are available.
Identity-based policy — attach to a RAM user or RAM role. Supported in both free and paid modes.
The following sample policy grants read access to all default secrets created by Alibaba Cloud Model Studio (product code: mcp):
{
"Version": "1",
"Statement": [{
"Effect": "Allow",
"Action": [
"kms:List*",
"kms:Describe*",
"kms:GetSecretValue"
],
"Resource": "acs:kms:${region}:${account}:secret/mcp!*"
}]
}If the secret uses a customer managed key (paid mode), the identity must also have kms:Decrypt permission on the encryption key. The following complete policy grants both secret access and key decryption:
{
"Version": "1",
"Statement": [
{
"Effect": "Allow",
"Action": [
"kms:List*",
"kms:Describe*",
"kms:GetSecretValue"
],
"Resource": "acs:kms:${region}:${account}:secret/mcp!*"
},
{
"Effect": "Allow",
"Action": "kms:Decrypt",
"Resource": "acs:kms:${region}:${account}:key/${key-id}"
}
]
}Secret policy (paid mode only) — attach directly to the secret resource. Use this for cross-account authorization.
The following sample policy allows the RAM user key_ramuser3 from another Alibaba Cloud account (190325303126****) to retrieve the secret value:
{
"Version": "1",
"Statement": [{
"Effect": "Allow",
"Action": [
"kms:List*",
"kms:Describe*",
"kms:GetSecretValue"
],
"Principal": {
"RAM": [
"acs:ram::190325303126****:user/key_ramuser3"
]
},
"Resource": [
"acs:kms:cn-hangzhou:123456789012****:secret/ai-gateway!secret-name"
]
}]
}For more information on policy configuration, see Grant permissions.
Step 3: Retrieve the secret
Retrieve the secret value using any of the following methods:
RAM role (for cloud products): Grant the cloud product's RAM role permission to call the secret. The product retrieves the secret automatically.
Alibaba Cloud SDK: Call GetSecretValue through the Alibaba Cloud SDK.
Secrets Manager Client: Integrate the secret client into your application for automatic caching and rotation-aware retrieval.
KMS Agent: Use the KMS Agent as a sidecar to retrieve secrets without SDK integration.
Free default secrets are accessible only through a shared gateway. Paid default secrets are accessible through either a shared or dedicated gateway.
API reference
The cloud product handles all write operations on your behalf. The APIs available to you are read operations and access policy management.
Operation | API | Cloud product | You |
Secret management | |||
— | |||
— | — | ||
Retrieve secret |
FAQ
How do I identify a default secret in the console or in code?
Default secrets follow the format <ProductCode>!<SecretIdentifier>, where the product code identifies the managing service. For example, bailian!secret-123 belongs to Alibaba Cloud Model Studio and aigw!secret-abc belongs to AI Gateway. In the KMS console, filter the secret list by this prefix to find all secrets for a given product.
My application failed to retrieve a default secret. How do I troubleshoot?
Check the following in order:
Permissions: Confirm the RAM role or RAM user running the application has an identity-based policy granting
kms:GetSecretValueon the target secret.Encryption key permissions: If the secret uses a CMK (paid mode), the same identity must also have
kms:Decrypton the key.Secret status: In the KMS console, verify the secret is in Normal state and not scheduled for deletion.
Network connectivity: If using a dedicated gateway, verify the VPC where your application runs can reach the KMS dedicated gateway endpoint.
Is there a QPS limit for retrieving default secrets?
Yes. GetSecretValue through a shared gateway is limited to 450 QPS. Through a dedicated gateway, the limit is determined by the instance type you purchase. For details, see Performance metrics.