Querying the API Key List
Function
The query API provides a comprehensive view for API Key asset inventory and security auditing. Administrators can use this API to retrieve a list of all keys associated with the current account, along with their detailed metadata, including creation time, source, permission scope, and current status.
API constraints:
-
Authentication: Requests to this API must include a valid IAM token in the request header (X-Auth-Token) and have the corresponding fine-grained permission: modelarts:apiKey:list for query.
-
Only records that are not deleted are returned. The api_key plaintext is not returned. Only the masked string is returned.
URI
GET /v2/{project_id}/maas/api-auth/api-keys
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | Yes | String | Definition: Project ID, which uniquely identifies tenant resources in Huawei Cloud and is associated with a specific region. It is used to locate the project space to which the resources belong when calling Huawei Cloud APIs. You can obtain the value by calling the API for obtaining a project ID and name. Constraints: N/A Range: N/A Default Value: N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| offset | No | Integer | Definition: Offset. Constraints: The value must be greater than or equal to 0. Range: The value must be greater than or equal to 0. Default Value: 0 |
| limit | No | Integer | Definition: Maximum number of records on each page. Constraints: The minimum value is 1. Range: an integer greater than or equal to 1. Default Value: 30. |
| order | No | String | Definition: Sorting rule of the API key list. Constraints: N/A Range: Default Value: desc |
| sort_by | No | String | Definition: Field used for sorting by default. Constraints: N/A Range: Fields that exist in the data Default Value: create_at |
Request Parameters
None
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| api_key_list | ListApiKeysRespPage object | Definition: API keys on the current page. Range: N/A |
| user_api_key_quota | Integer | Definition: Maximum number of API keys that can be created. Range: Positive integers |
| Parameter | Type | Description |
|---|---|---|
| items | Array of ApiKeyInfo objects | Definition: All existing API keys. Range: N/A |
| total | Integer | Definition: Total number of API keys. Range: An integer greater than or equal to 0. |
| count | Integer | Definition: Number of current pages. Range: Integer greater than 0. |
| default_sort_by | String | Definition: Field used for sorting by default. Range: empty |
| default_order | String | Definition: Specifies whether the sorting order is ascending or descending. Range: |
| Parameter | Type | Description |
|---|---|---|
| id | String | Definition: Unique ID of an API key. Range: N/A |
| api_key | String | Definition: Masked authentication information, which is encrypted using SHA-256 for storage. Range: N/A |
| label | String | Definition: API key tag. Range: The tag can contain 0 to 100 characters, including letters, digits, underscores (_), and hyphens (-). |
| description | String | Definition: Description of the API key. Range: a string of up to 100 characters. |
| mask | String | Definition: Masked authentication information. Range: N/A |
| allow_all | Boolean | Definition: Specifies whether access to all resources is allowed. The value can be true (yes) or false (no). Range: |
| ip_whitelist | Array of strings | Definition: The API key IP address whitelist is a security feature in Huawei Cloud Model as a Service (MaaS) that restricts the use of an API key to specified IP addresses when calling model services. This helps prevent unauthorized use if the API key is compromised. Format: IP address validation rules: Validation of individual IP segments: Each IPv4 octet must be a valid decimal integer between 0 and 255. IP address format and subnet mask validation:
Special rule: The subnet mask prefix length must be greater than or equal to the position of the rightmost 1 bit in the 32-bit binary representation of the IP address (that is, the mask must not truncate the IP address's significant bits). IP address comparison rule: To compare two IP addresses, compare their numerical values segment by segment from left to right (most significant to least significant) to determine their relative order. IP range validation: A valid IP range must contain exactly two IP addresses. Both addresses must pass the format and subnet mask validation rules described above, and the starting IP address must be less than or equal to the ending IP address. |
| resident_model_version_whitelist | Definition: Whitelist of resident model versions, which restricts the resident model versions that can be accessed. | |
| endpoint_whitelist | EndpointWhitelist object | Definition: Whitelist of endpoints, which restricts the endpoints that can be accessed. |
| create_at | Integer | Definition: Time when the API key is created. The value is a timestamp, in milliseconds. Example: 1773065452790. Range: N/A |
| channel | String | Definition: Channel type, which can be either maas or a channel-specific API key. Range: |
| Parameter | Type | Description |
|---|---|---|
| overall | String | Definition: Model service scope (including the model services and their versions) where the API key takes effect. Range: |
| whitelist | Array of Whitelist objects | Definition: Whitelist of resident model versions. Each entry specifies a resident model and its version that can be accessed. Range: Whitelist object array. For details, see the field breakdown below. |
| Parameter | Type | Description |
|---|---|---|
| resident_model_id | String | Definition: Resident model ID. The following uses the Chrome browser as an example to describe how to obtain the resident model ID: On the Real-Time Inference > Built-in Services page in the MaaS console, press F12 to open DevTools. Choose the Network tab and search for query. Click the entry whose name starts with query?business_type=payment. In the Response tab, search for the desired model name, such as DeepSeek-V4.1-Flash. The value of the resident_model_id parameter is the resident model ID. Range: N/A |
| version_whitelist | String | Definition: Whitelisted versions of the resident model that can be accessed. Separate multiple versions with commas (,). The following uses the Chrome browser as an example to describe how to obtain the resident model version name: On the Real-Time Inference > Built-in Services page in the MaaS console, press F12 to open DevTools. Choose the Network tab and search for query. Click the entry whose name starts with query?business_type=payment. In the Response tab, search for the desired model name, such as DeepSeek-V4.1-Flash. The ID of the data whose version_name is DeepSeek-V4.1-Flash under version_list is the resident model version. Range: N/A |
| Parameter | Type | Description |
|---|---|---|
| overall | String | Definition: Overall bypass policy. Range: The value "all" indicates that all requests are allowed to bypass. An empty string indicates that the overall bypass function is disabled. |
| whitelist | Array of strings | Definition: Whitelist of endpoint IDs. Only the endpoints in the whitelist can be accessed. You can obtain the ID by calling the API for querying endpoints. |
Example Requests
GET https://{endpoint}/v2/{project_id}/maas/api-auth/api-keys?offset=0&limit=30&order=desc&sort_by=create_at Example Responses
Status code: 200
{
"user_api_key_quota" : 30,
"api_key_list" : {
"total" : 19,
"count" : 10,
"default_order" : "desc",
"items" : [ {
"id" : "145528d0-5afe-468e-80ad-e1091e323fdf",
"label" : "xsxs",
"description" : "xsxs",
"create_at" : 1773065452790,
"mask" : "pL2v******AhoQ",
"allow_all" : true,
"ip_whitelist" : [ ],
"resident_model_version_whitelist" : {
"overall" : "",
"whitelist" : [ {
"resident_model_id" : "ce15e584-bb43-46ff-a215-febb27501353",
"version_whitelist" : "all"
}, {
"resident_model_id" : "1a848aa4-6493-4da0-bd5a-e1e918fad55f",
"version_whitelist" : "all"
} ]
},
"endpoint_whitelist" : {
"overall" : "",
"whitelist" : [ "d8d76767-637a-4040-8835-39bdc39b79b6", "6a9cba80-3594-4611-a8c0-a5a1fd34985d" ]
},
"channel" : "maas"
}, {
"id" : "6d088782-609a-4db5-b7c8-a7028858c0c7",
"label" : "asdfasd",
"description" : "asfdasdf",
"create_at" : 1787911404440,
"mask" : "Q-Kw******KsOg",
"allow_all" : true,
"ip_whitelist" : [ ],
"resident_model_version_whitelist" : {
"overall" : "",
"whitelist" : null
},
"endpoint_whitelist" : {
"overall" : "",
"whitelist" : null
},
"channel" : "maas"
} ]
}
} Status Codes
| Status Code | Description |
|---|---|
| 200 | The API key authentication information list is successfully obtained. |
Error Codes
See Error Codes.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot