Obtaining an Application Key
Function
This API is used to query the API key list in the current system. This API is applicable to the scenario where the administrator or user needs to view and manage API keys. Before calling this API, ensure that you have the corresponding query permission. The returned list contains the basic information about each API key, such as the API key value, creation time, and bound service. If there is no API key in the system, an empty list or corresponding exception information is returned, prompting you to check the search criteria.
Debugging
You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.
Authorization Information
Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.
- If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
- If you are using identity policy-based authorization, the following identity policy-based permissions are required.
Action
Access Level
Resource Type (*: required)
Condition Key
Alias
Dependencies
modelarts::listApiKey
List
-
-
modelarts:apiKey:list
-
URI
GET /v2/{project_id}/services/api-keys
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | Yes | String | Definition Project ID. For details, see Obtaining a Project ID and Name. Constraints N/A Range Project ID. Default Value N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| scope | No | String | Definition The options are USER and SERVICE. Constraints N/A Range
Default Value N/A |
| service_id | No | String | Definition Service ID, which can be obtained from the response body during service creation or by obtaining services owned by the current user. The service_id field is the service ID. Constraints N/A Range Service ID. Default Value N/A |
| name | No | String | Definition API key name. Obtain the API key of the current user by querying the API key list. The name field is the API key name. Constraints N/A Range apikey_name Default Value N/A |
| service_name | No | String | Definition Service name, which is customized when you create a service. Constraints The service name must be unique. Range The value can contain 1 to 128 characters, including letters, digits, hyphens (-), and underscores (_). Default Value N/A |
| key_id | No | String | Definition API key ID, which can be obtained from the response body when you create an API key or by querying the API keys. The key_id field in the response body is the API key ID. Constraints N/A Range The API key ID can only contain lowercase letters and digits. The length of the API key ID is 32 characters. Default Value N/A |
| limit | No | Integer | Definition Maximum number of records that can be returned. Constraints N/A Range [1,500] Default Value 10. |
| offset | No | Integer | Definition Offset of the pagination list query. Constraints The value must be an integral multiple of limit. Range N/A Default Value 0. |
| workspace_id | No | String | Definition Workspace ID. Constraints N/A Range N/A Default Value N/A |
| with_user_scope | No | Boolean | Definition Specifies whether to query the API keys whose authentication scope is of the USER type. If service_id is specified, all API keys that can be accessed by the service are queried. Constraints N/A Range N/A Default Value false |
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| X-Auth-Token | Yes | String | Definition User token. It can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token. For details about how to obtain the token, see Obtaining a User Token Through Password Authentication. Constraints N/A Range N/A Default Value N/A |
| Content-Type | Yes | String | Definition Message body type or format. Constraints N/A Range Default Value N/A |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| data | Array of ApiKeyResponseV2 objects | Definition API key data. |
| current | Integer | Definition Current page number, starting from 0. Range N/A |
| pages | Integer | Definition Total number of pages, which is calculated based on the limit field and the total number of data records. For example, if the total number of records is 10 and the value of limit (maximum number of records on a page) is 3, the number of pages is 4. Range N/A |
| size | Integer | Definition Current page size. Range N/A |
| total | Integer | Definition Total number of records. Range N/A |
| Parameter | Type | Description |
|---|---|---|
| key_id | String | Definition API key ID, which can be obtained from the response body when you create an API key or by obtaining API keys. The id field in the response body is the API key ID. Range The value is in UUID format. |
| name | String | Definition Name of the API key, which you can edit when creating the API key. Range The value can contain 1 to 64 characters. Only letters, digits, hyphens (-), and underscores (_) are allowed. |
| description | String | Definition Description of the API key, which you can edit when creating the API key. Range The value can contain 1 to 256 characters, including letters, digits, hyphens (-), and underscores (_). |
| create_time | String | Definition Time when the API key is created, which is automatically generated based on the creation time. Range Millisecond-level timestamp, which is a 13-digit number, for example, 1609459200000. |
| scope | String | Definition Scope of the API key. Range |
| domain_id | String | Definition Domain ID. For details about how to obtain the value, see Obtaining the Account Name and Account ID. Range Account ID |
| project_id | String | Definition Project ID. For details, see Obtaining a Project ID and Name. Range Project ID of the account. |
| services | Array of ServiceIdName objects | Definition List of real-time services bound to the API key. |
| workspace_id | String | Definition Workspace ID. Range Workspace ID. |
Example Requests
This API is used to obtain the API key list.
GET https://{endpoint}/v2/{project_id}/services/api-keys Example Responses
Status code: 200
The API key list is obtained.
{
"current" : 0,
"data" : [ {
"create_time" : 1743494875405,
"description" : "test",
"domain_id" : "04f258c83e00d5****example",
"key_id" : "8a0e847095f063aa0****example",
"name" : "api-keys-name-test",
"project_id" : "04f258c84780d5a52f3****example",
"scope" : "SERVICE",
"services" : [ ]
}, {
"create_time" : 1743228962325,
"description" : "test",
"domain_id" : "04f258c83e00d5a50f38c****example",
"key_id" : "8a0e4a2d95e088ea0195e0****example",
"name" : "test",
"project_id" : "04f258c84780d5a52f3bc****example",
"scope" : "SERVICE",
"services" : [ ]
}, {
"create_time" : 1743228957659,
"description" : "test",
"domain_id" : "04f258c83e00d5a****example",
"key_id" : "8a0e4a2d95e088ea01****example",
"name" : "test123123",
"project_id" : "04f258c84780d5a****example",
"scope" : "SERVICE",
"services" : [ ]
} ],
"pages" : 1,
"size" : 10,
"total" : 3
} Status Codes
| Status Code | Description |
|---|---|
| 200 | The API key list is obtained. |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank 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