Binding an Application Key
Function
This API is used to bind the generated API key to a specified service. It is applicable to the scenario where an application needs to call a specific service. Before calling this API, ensure that the service instances have been created and a valid API key has been obtained. After the binding is successful, the API key is used as the identity authentication credential for service calls to ensure that only authorized users can access the service. If you attempt to bind an invalid API key, an error message will be displayed, prompting you to check the validity and binding status of the API key.
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:apiKey:bind
Write
apiKey *
-
-
-
service *
-
URI
POST /v2/{project_id}/services/{service_id}/api-keys/{key_id}/bind
| 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 |
| service_id | Yes | 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 |
| key_id | Yes | 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 |
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 |
|---|---|---|
| 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
Bind an API key to a service.
POST https://{endpoint}/v2/{project_id}/services/{service_id}/api-keys/{key_id}/bind Example Responses
Status code: 200
The API key is bound to the service.
{
"create_time" : 1743228962325,
"description" : "test",
"domain_id" : "04f258c83e00d5a50f38****example",
"key_id" : "8a0e4a2d95e088ea0195e08****example",
"name" : "test",
"project_id" : "04f258c84780d5a52f3bc0****example",
"scope" : "SERVICE",
"services" : [ {
"id" : "bd689f90-bbf5-4638-a96b-f3af****example",
"name" : "test-infer-raw1234567"
} ],
"workspace_id" : "0"
} Status Codes
| Status Code | Description |
|---|---|
| 200 | The API key is bound to the service. |
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