Create Key
Create a new API key for your application. Each application can create multiple keys for different business scenarios or environments (such as development, testing, production).
This interface requires authentication, please refer to Platform Token.
¶ Interface Description
- Request Method: POST
- Request URL:
https://platform.acedata.cloud/api/v1/credentials/ - Request Headers:
- accept:
application/json - content-type:
application/json - authorization:
Bearer {token}
- accept:
¶ Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
application_id |
string | Yes | Application ID (UUID) |
host |
string | No | Bound domain, restricts the key to be called only from the specified domain |
limited_amount |
number | No | Limit usage amount, null means unlimited |
expired_at |
string | No | Expiration time (ISO 8601 format), null means never expires |
¶ CURL Request Example
Create a basic key:
curl -X POST \
-H "accept: application/json" \
-H "content-type: application/json" \
-H "authorization: Bearer {token}" \
-d '{"application_id": "107f8d0f-e465-4a7e-a49e-d633d26f7aa2"}' \
"https://platform.acedata.cloud/api/v1/credentials/"
Create a key with usage limit:
curl -X POST \
-H "accept: application/json" \
-H "content-type: application/json" \
-H "authorization: Bearer {token}" \
-d '{"application_id": "107f8d0f-e465-4a7e-a49e-d633d26f7aa2", "limited_amount": 100}' \
"https://platform.acedata.cloud/api/v1/credentials/"
¶ Response Example
{
"id": "c1d2e3f4-a5b6-7890-cdef-1234567890ab",
"user_id": "b87f67c1-b04f-4332-99a1-7a5e651331c6",
"application_id": "107f8d0f-e465-4a7e-a49e-d633d26f7aa2",
"type": "Token",
"token": "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"username": null,
"password": null,
"host": null,
"limited_amount": null,
"used_amount": 0,
"expired_at": null,
"created_at": "2024-08-01T10:00:00.000000Z",
"updated_at": "2024-08-01T10:00:00.000000Z"
}
¶ Notes
- After the key is created, the
tokenvalue is automatically generated and cannot be customized. - For regular API services, the key type is
Token, using thetokenvalue as the Bearer Token. - For Proxy services, the key type is
Identity, which will generate bothusernameandpassword. - Please keep the key safe after creation, as key leakage may lead to consumption of the quota.
¶ Code Example
Python:
import requests
url = "https://platform.acedata.cloud/api/v1/credentials/"
headers = {
"accept": "application/json",
"content-type": "application/json",
"authorization": "Bearer {token}"
}
data = {
"application_id": "107f8d0f-e465-4a7e-a49e-d633d26f7aa2"
}
response = requests.post(url, json=data, headers=headers)
credential = response.json()
print(f"New Key: {credential['token']}")
