Creating an Application Key
Function
This API is used to create an API key in the system. It is applicable to scenarios where access credentials need to be generated for users or applications. Before calling this API, ensure that you have the creation permission and provide necessary parameters, such as the user ID or application ID. After the creation is successful, the system generates a unique API key and returns the detailed information about the API key, including the API key value and creation time. If the provided parameter is invalid or the same API key already exists in the system, an exception message is returned, prompting you to check the validity of the input data.
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::createApiKey
Write
-
-
modelarts:apiKey:create
-
URI
POST /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 |
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 | No | String | Definition Message body type or format. Constraints N/A Range Default Value N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| name | Yes | String | Definition API key name, which is customized when you create an API key. Constraints The API key name must be unique. Range The value can contain 1 to 64 characters. Only letters, digits, hyphens (-), and underscores (_) are allowed. Default Value N/A |
| description | No | String | Definition API key description. Constraints N/A Range The value can contain at most 256 characters. The following special characters are not allowed: !><=&'" Default Value This parameter is left blank by default. |
| scope | Yes | String | Definition Scope of the API key. Constraints N/A Range
Default Value N/A |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| - | File | Application key file. |
Example Requests
This API is used to create an application key.
https://{endpoint}/v2/{project_id}/services/api-keys
{
"name" : "apikey_test",
"scope" : "SERVICE"
} Example Responses
Status code: 200
Application key file.
id,api_key,scope,workspace_id,create_time,domain_id,project_id 2c9080f097****example,******,SERVICE,0,2025-05-28T10:04:53.272696578,e57495061d744****example,b33fd65d96474****example
Status Codes
| Status Code | Description |
|---|---|
| 200 | Application key file. |
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