Batch Binding Application Keys
Function
This API is used to bind multiple generated apikeys to specified services in batches for accessing them. 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 or an API key that has been bound to the current service, an exception message is returned, 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/batch-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 |
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 |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| key_ids | Yes | Array of key_ids objects | Definition Array of API key IDs to be bound in batches. Constraints The number of API key IDs to be bound in batches cannot exceed 10. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| 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 |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| total | Integer | Definition Number of API keys that are requested to be bound. Range N/A |
| success_count | Integer | Definition Number of API keys that are successfully bound. Range N/A |
| success_items | Array of ApiKeyResponseV2 objects | Definition List of API keys that are successfully bound. |
| failure_count | Integer | Definition Number of API keys that fail to be bound. Range N/A |
| failure_items | Array of ApiKeyFailureResponse objects | Definition List of API keys that fail to be bound. |
| 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. |
| Parameter | Type | Description |
|---|---|---|
| id | String | Definition Service ID. Range Service ID. |
| name | String | Definition Service name. Range The value can contain 1 to 128 characters, including letters, digits, hyphens (-), and underscores (_). |
| 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. |
| error_code | String | Definition ModelArts error code. Range N/A |
| error_msg | String | Definition Error message. Range N/A |
Example Requests
Batch bind multiple API keys to a service.
POST /v2/{project_id}/services/{service_id}/api-keys/batch-bind Example Responses
Status code: 200
The API key is bound to the service.
{
"total" : 2,
"success_count" : 1,
"success_items" : [ {
"create_time" : 1743228962325,
"description" : "test",
"domain_id" : "04f258c83e00d5a50f3****example",
"key_id" : "8a0e4a2d95e088ea0195e0****example",
"name" : "test66",
"project_id" : "04f258c84780d5a52f3bc****example",
"scope" : "SERVICE",
"services" : [ {
"id" : "bd689f90-bbf5-4638-a96b-f3a****example",
"name" : "test-infer-raw1234567"
} ],
"workspace_id" : "eab57afd5e8a4fc9a66d68****example"
} ],
"failure_count" : 1,
"failure_items" : [ {
"key_id" : "8a0e4a2d95e088ea0****example",
"error_code" : "ModelArts.8024",
"error_msg" : "bd689f90-bbf5-4638-a96b-f3a****example service not found"
} ]
} 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