Open APIs & Webhooks to embed customer service into your systems
X-API-Key) in your console under Settings → Open Platform.
All API requests require your API Key and tenant ID:
X-API-Key: <your-api-key>
X-Company-Id: <tenant-id>
Content-Type: application/json
Create and revoke keys anytime in Console → Settings → Open Platform. All endpoints use HTTPS and return JSON.
Send a customer message and get the AI reply (synchronous). For custom chat entry points and in-app conversations.
{
"session_id": "sess_xxxx", // optional, auto-created if omitted
"content": "Do you have a plan with WeChat Pay?",
"source": "app",
"user_id": "u_10001" // optional business user ID
}
Paginated message history with intent and handover metadata.
Create a session with an optional bot (bot_id), channel and user tags.
Paginated Q&A list with keyword and status filters.
Batch add Q&A (with similar phrasings) to auto-sync FAQs and product data.
{
"questions": [
{ "question": "How do I request a refund?",
"answer": "Go to your order and click 'Apply for refund'…",
"category": "After-sales",
"similar": ["How to refund", "Refund process"] }
]
}Soft-delete a Q&A (restorable in console).
User profile and session history summary.
Paginated sessions, filterable by status, time, channel and bot.
Create a ticket (auto-assigned, SLA starts).
Update ticket status with history.
Operation KPIs: sessions, AI resolution, CSAT, etc.
BI multi-dimension: trends, channels, bots, handover reasons, top misses, agent performance.
Configure your callback URL and subscribe to events (delivered with signature verification):
| Event | Description |
|---|---|
session.created | New session created |
message.received | Customer message received |
message.ai_replied | AI replied |
transfer.created | Human handover triggered (with reason) |
ticket.created / updated | Ticket created / updated |
rating.submitted | CSAT submitted |
knowledge.miss | Unresolved question (drives KB optimization) |
Signature: X-TianKey-Signature = HMAC-SHA256(Webhook Secret, raw body). Verify before processing.
Query order status by order number / phone. AI answers logistics and after-sales directly. Supports Taobao, JD, Pinduoduo, Douyin.
{
"platform": "douyin",
"order_no": "DY202608270001",
"query": "Has my order shipped?"
}Python: chat API
import requests
API = "https://api.tiankeyun.com"
resp = requests.post(f"{API}/api/v1/chat/message",
headers={"X-API-Key": "your-key", "X-Company-Id": "1001"},
json={"session_id": "sess_1001", "content": "Do you support WeChat Pay?", "source": "app"})
print(resp.json()["reply"]) # AI reply
print(resp.json()["intent"]) # detected intent
JavaScript: webhook verification
const crypto = require("crypto");
const sig = crypto
.createHmac("sha256", process.env.WEBHOOK_SECRET)
.update(rawBody)
.digest("hex");
if (req.headers["x-tiankey-signature"] !== sig) return res.status(401).end();
// handle event…