Base URL: https://api.shopaikey.com/seller
Introduction
The Seller API is exclusively for ShopAIKey Sellers (Resellers). Through this API, sellers can automate credit management, create and distribute API keys to their end customers.
With the Seller API, you can:
- Check your seller account credit balance.
- Create new API keys (single or bulk) for customers and deduct the corresponding credit.
- Choose a group (channel group) for a key when creating it, or change it later.
- Top up, deduct, or delete keys to refund credit back to your seller account.
- Manage key status and names.
- Top up credit to your seller account via bank transfer.
- View usage statistics and transaction history.
- Integrate into your sales system, Telegram bot, or own website for 24/7 automated operation.
Note: This API is not for end users. Only accounts granted Seller permission can use the endpoints below.
Authentication
Every request requires your seller secret key in a header:
Authorization: Bearer sk-xxx
or:
x-secret-key: sk-xxx
Security warning: The seller secret key can operate directly on your credit balance. Never share it, never commit it to git, and never embed it in client-side code.
Units
When you create or top up a key, the seller wallet is charged the xu equivalent of the USD credit at seller pricing (seller discount applied). When you deduct from or delete a key, the unused credit is converted back to xu at the price actually paid for that key.
Quick Start
1. Check seller account info
curl -X GET https://api.shopaikey.com/seller \
-H "Authorization: Bearer sk-your-seller-secret-key"
2. List available groups
curl -X GET https://api.shopaikey.com/seller/groups \
-H "Authorization: Bearer sk-your-seller-secret-key"
3. Create a new API key for a customer
curl -X POST https://api.shopaikey.com/seller/keys \
-H "Authorization: Bearer sk-your-seller-secret-key" \
-H "Content-Type: application/json" \
-d '{"amount": 10, "name": "Key for customer A"}'
4. List issued keys
curl -X GET "https://api.shopaikey.com/seller/keys?page=1&limit=20" \
-H "Authorization: Bearer sk-your-seller-secret-key"
Endpoints
1. Get seller info
Endpoint: GET /seller
Description: Returns the seller account info: email, wallet balance (xu) and the seller discount currently applied.
Response:
{
"id": 1,
"email": "[email protected]",
"credit": 1500000,
"seller_discount": 0.2
}
2. List groups
Endpoint: GET /seller/groups
Description: Returns the groups that can be assigned to keys, the default group and each group's price ratio. A model's credit price in a group = the model's base price × that group's ratio.
Response:
{
"groups": {
"default": "Default",
"claude": "Claude"
},
"defaultGroups": {
"cheap": "default"
},
"groupRatios": {
"default": 1,
"claude": 1.2
}
}
3. List keys issued by the seller
Endpoint: GET /seller/keys
Query params:
Without page/limit, all keys are returned.
Response:
{
"keys": [
{
"id": 1,
"key": "sk-abc123...",
"name": "Key for customer A",
"type": "cheap",
"balance": 50,
"status": "active",
"created_at": "2026-01-01T00:00:00.000Z",
"refundable": true,
"used": 10,
"remaining": 40,
"tokenName": "Key for customer A",
"tokenGroup": "default"
}
],
"total": 1,
"page": 1,
"limit": 20,
"stats": {
"total": 1,
"active": 1,
"inactive": 0,
"remaining": 40,
"used": 10
}
}
4. Create a key
Endpoint: POST /seller/keys
Body:
Response:
{
"key": "sk-generated-key...",
"balance": 10,
"id": 1
}
5. Create multiple keys at once
Endpoint: POST /seller/keys/bulk-create
Body:
All keys are created in one go; if credit is insufficient, no key is created.
Response:
{
"keys": [
{ "id": 11, "key": "sk-aaa..." },
{ "id": 12, "key": "sk-bbb..." }
],
"totalCostVnd": 52000
}
6. Top up a key
Endpoint: POST /seller/keys/:key_id/topup
Body:
Response:
{
"balance": 30
}
7. Deduct credit from a key (reclaim)
Endpoint: POST /seller/keys/:key_id/deduct
Description: Removes unused USD credit from the key and converts it back to xu in the seller wallet. Not available for keys with refundable: false.
Body:
Response:
{
"keyBalance": 40,
"userCredit": 1526000
}
8. Update key status
Endpoint: PUT /seller/keys/:key_id/status
Body:
Keys in expired status cannot be changed.
Response:
{
"success": true,
"status": "inactive"
}
9. Rename a key
Endpoint: PUT /seller/keys/:key_id/name
Body:
Response:
{
"success": true
}
10. Change a key's group
Endpoint: PUT /seller/keys/:key_id/group
Description: Moves the key to another group. Takes effect on the key's next requests and does not change its credit.
Body:
Response:
{
"success": true
}
11. Delete a key and refund credit
Endpoint: DELETE /seller/keys/:key_id
Response:
{
"refunded": 104000
}
refunded is the xu returned to the seller wallet (0 if the key has refundable: false or is fully used).
Note: Deleted keys cannot be restored. Customers using the key lose access immediately.
12. Delete multiple keys
Endpoint: DELETE /seller/keys/bulk
Body:
Response:
{
"deleted": 3,
"refunded": 312000,
"failures": [
{ "id": 9, "error": "Không tìm thấy key" }
]
}
refunded is the total xu returned to the seller wallet. Keys that fail are listed in failures; the others are still deleted.
13. Create a seller credit top-up order
Endpoint: POST /seller/topup
Description: Creates an order to top up the seller wallet via bank transfer. Minimum 500,000 ₫, in multiples of 1,000 ₫. Once the transfer is received, the seller wallet is credited with exactly the amount transferred (xu).
Body:
Response:
{
"order_id": 123,
"transfer_content": "NP123",
"amount": 385,
"price_vnd": 1000000,
"qrUrl": "https://...",
"bank_info": {
"bankId": "...",
"bankName": "...",
"accountNo": "...",
"accountName": "..."
}
}
14. Get a top-up order
Endpoint: GET /seller/topup/:order_id
Response: Same as POST /seller/topup, plus a status field (draft: awaiting payment, completed: credited, cancelled: cancelled).
15. Top-up history
Endpoint: GET /seller/topup-history
Query params:
Response:
{
"orders": [
{
"id": 123,
"amount": 385,
"price_vnd": 1000000,
"transfer_content": "NP123",
"status": "completed",
"created_at": "2026-04-28T08:00:00.000Z",
"completed_at": "2026-04-28T08:02:10.000Z"
}
],
"total": 1,
"page": 1,
"totalPages": 1
}
16. Cancel an order
Endpoint: PUT /seller/orders/:id
Description: Cancels a top-up order still awaiting payment (draft).
Body:
Response: The order after cancellation.
17. Cancel multiple orders
Endpoint: PUT /seller/orders/bulk
Body:
Only orders in draft are cancelled.
Response:
{
"updated": 2
}
18. Usage statistics
Endpoint: GET /seller/stats
Query params:
Response:
{
"totalSpent": 5000000,
"totalOrders": 10,
"keySpent": 4200000,
"refunded": 150000,
"totalRequests": 12500,
"totalTokenUsed": 3200000,
"spending": [
{ "date": "2026-04-28", "total": 500000, "count": 1 }
],
"topModels": [
{ "modelName": "claude-sonnet-4-5", "requests": 5000, "tokenUsed": 1200000 }
]
}
19. Transaction history
Endpoint: GET /seller/transactions
Query params:
Response:
{
"transactions": [
{
"id": 501,
"type": "key_purchase",
"amount_vnd": -26000,
"description": "Tạo key cheap $10",
"key_id": 1,
"order_id": null,
"created_at": "2026-04-28T08:05:00.000Z"
}
],
"total": 1,
"page": 1,
"totalPages": 1
}
A negative amount_vnd is charged to the wallet, a positive one is credited (xu).
Error Responses
{
"error": "Không đủ credit"
}
Error messages are in Vietnamese.
Seller Workflow Example
Scenario: a seller sells a $50 key to a customer, then the customer buys $30 more.
# 1. Check seller credit
curl -X GET https://api.shopaikey.com/seller \
-H "Authorization: Bearer sk-your-seller-secret-key"
# 2. Create a $50 key for the customer in group "default"
curl -X POST https://api.shopaikey.com/seller/keys \
-H "Authorization: Bearer sk-your-seller-secret-key" \
-H "Content-Type: application/json" \
-d '{"amount": 50, "name": "Customer_JohnDoe", "group": "default"}'
# 3. Customer buys $30 more
curl -X POST https://api.shopaikey.com/seller/keys/1/topup \
-H "Authorization: Bearer sk-your-seller-secret-key" \
-H "Content-Type: application/json" \
-d '{"amount": 30}'
# 4. Customer stops using it; delete the key to reclaim leftover credit
curl -X DELETE https://api.shopaikey.com/seller/keys/1 \
-H "Authorization: Bearer sk-your-seller-secret-key"
Security Notes for Sellers
- Do not share your secret key with customers or third parties.
- Do not commit your secret key to a git repository.
- Always use HTTPS in production.
- Rotate your secret key periodically or immediately if you suspect a leak.
- Use meaningful key names (e.g.
customer_abc_2026_01) for easy reconciliation. - Log every transaction on your side to reconcile with ShopAIKey when needed.