View API Keys

Updated at:

This topic shows you how to view the metadata of API Keys for a specific RAM user or all API Keys in your Alibaba Cloud account. You can view them in the RAM console or by calling an OpenAPI operation.

These operations return only API Key metadata, not the secret. If you lose the secret, delete the API Key and create a new one.

View in the RAM console

  1. Log on to the RAM console.

  2. In the left-side navigation pane, choose Identities > Users. Click the logon name of the target RAM user.

  3. On the user details page, click the Credentials tab, and then navigate to the API Keys section.

  4. The list shows the following information for the RAM user's API Keys:

    Column

    Description

    Cloud service

    The identifier of the cloud service that the API Key is bound to, such as ak.aliyuncs.com. The list displays the full service identifier, whereas the creation dialog box and the filter above the list use a shortened version.

    ID

    The service credential ID (ServiceCredentialId), which has the SC prefix.

    Name

    A user-friendly name. You can click the edit icon on the right to modify it.

    Status

    The current status: Active / Inactive / Expired.

    Creation time

    The credential creation time. You can click the column header to sort the entries in ascending or descending order.

    Expiration time

    The credential expiration time. For an API Key that never expires, this column displays Never Expires.

    Actions

    The available actions, such as Disable/Enable and Delete, depend on the key's current status. For an active key, the Delete button is disabled. You must first disable the key before you can delete it.

  5. You can use the Cloud Service (All / specific cloud service) and Status (All / Active / Inactive / Expired) drop-down filters above the list to find a specific API Key.

List API keys via API

Call ListServiceCredentials to list all API Keys for a specified RAM user or the current Alibaba Cloud account.

Request parameters

Parameter

Type

Description

AllUsers

Boolean

Specifies whether to query the API Keys for all RAM users. When this parameter is set to true, you cannot specify UserPrincipalName, and administrator permissions are required.

UserPrincipalName

String

The RAM user logon name. If you omit this parameter, the operation queries the API Keys of the current caller identity by default.

ServiceName

String

Filters the results by cloud service. If you omit this parameter, the operation returns the API Keys for all services.

NextToken

String

The pagination token. You do not need to specify this parameter for the first call. For subsequent calls, use the NextToken value from the previous response to paginate.

MaxResults

Integer

The maximum number of entries to return per page. Valid values: 1 to 100. Default value: 10.

Example

Query the API Keys bound to the ak.aliyuncs.com service for all RAM users in the current Alibaba Cloud account:

aliyun ims ListServiceCredentials \
  --AllUsers true \
  --ServiceName ak.aliyuncs.com \
  --MaxResults 50

Sample response:

{
  "RequestId": "B3C5E2A1-1234-5678-90AB-EXAMPLE0000",
  "ServiceCredentials": [
    {
      "ServiceName": "ak.aliyuncs.com",
      "UserPrincipalName": "alice@1234567890.onaliyun.com",
      "ServiceCredentialName": "ak_apikey_for_alice",
      "ServiceCredentialId": "SCCfgu2GXci1qwcS****",
      "CreateTime": "2026-05-18T03:55:32Z",
      "ExpirationTime": "2026-06-17T03:55:32Z",
      "Status": "Active"
    }
  ]
}

Get an API key via API

Call GetServiceCredential to retrieve the metadata of a single API Key by its credential ID.

Query the metadata of a specific API Key by its service credential ID and the RAM user's logon name:

aliyun ims GetServiceCredential \
  --ServiceCredentialId <ServiceCredentialId> \
  --UserPrincipalName <UserPrincipalName>

Request parameters

Parameter

Type

Required

Description

ServiceCredentialId

String

Yes

The service credential ID.

UserPrincipalName

String

Yes

The RAM user logon name.

Returns a ServiceCredential object. The fields are the same as those in ListServiceCredentials, but ServiceCredentialSecret is not returned.