cURL
curl --request POST \ --url https://api.example.com/api/v1/api-keys \ --header 'Authorization: <authorization>' \ --header 'Content-Type: application/json' \ --data ' { "name": "聊天API专用密钥", "description": "用于访问聊天和文件上传API的密钥", "expires_at": "2024-12-31T23:59:59Z", "permissions": [ "chat", "upload" ] } '
{ "id": "68b6a40ed572df01e4ee12e9", "name": "聊天API专用密钥", "description": "用于访问聊天和文件上传API的密钥", "key_prefix": "ccb37996", "created_at": "2025-09-02T16:00:14.803179", "expires_at": "2025-12-31T23:59:59", "last_used_at": null, "permissions": [ "chat", "upload" ], "is_active": true, "created_by": "68b69f1367bdaff96386c4e6", "full_key": "ccb37996e5582ccebda2f91f7146eef8e8349c5d562caa4b26d286afddf52968" }
Bearer your_access_token
curl -X POST 'https://your-domain.com/api/v1/api-keys' \\ -H 'Authorization: Bearer your_access_token' \\ -H 'Content-Type: application/json' \\ -d '{ "name": "聊天API专用密钥", "description": "用于访问聊天和文件上传API的密钥", "expires_at": "2024-12-31T23:59:59Z", "permissions": ["chat", "upload"] }'
{ "id": "key_789012", "name": "聊天API专用密钥", "description": "用于访问聊天和文件上传API的密钥", "expires_at": "2024-12-31T23:59:59Z", "permissions": ["chat", "upload"], "is_active": true, "created_by": "user_123456", "full_key": "ccb37996e5582ccebda2f91f7146eef8e8349c5d562caa4b26d286afddf52968" }
["chat"]
["chat", "upload"]
["chat", "upload", "admin"]
full_key
-H 'Authorization: Bearer your_api_key'