Creating a Temporary Application Key
Function
This API is used to create a temporary API key in the system. It is applicable to scenarios where temporary 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 temporary API key value and creation time. If the provided parameter is invalid, an exception message is returned, prompting you to check the validity of the input data.
How to use a temporary API key:
Add two headers to the prediction API:
X-Api-Key-Type=temp
Authorization=Temporary API key
Range
Default Value
normal
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::createTempApikey
Write
-
-
-
-
URI
POST /v2/{project_id}/services/api-keys/temp
| 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, 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 |
|---|---|---|---|
| expire_time | No | Long | Definition Expiration time. Constraints The value cannot be a decimal. Range The value ranges from 1 hour to 24 hours. Default Value N/A |
| workspace_id | No | String | Definition: Workspace ID. If no workspaces are available, the default value is 0. If a workspace is created and used, use the actual value. Constraints: N/A Range: N/A Default Value: N/A |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| api_key | String | Definition: Temporary API key. Range: N/A |
| expire_time | Long | Definition: Timeout interval of the temporary API key. Range: N/A |
| create_time | Long | Definition: Time when the temporary API key was created. Range: N/A |
Example Requests
Create a temporary application key.
https://{endpoint}/v2/{project_id}/services/api-keys/temp
{
"expire_time" : 1783044280635,
"workspace_id" : 0
} Example Responses
Status code: 200
Application key file.
{
"api_key" : "eyJkb21haW5faWQiOiIwNGYyNThjODN****example",
"create_time" : 1783044280635,
"expire_time" : 1783051480635
} Status Codes
| Status Code | Description |
|---|---|
| 200 | Application key file. |
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