API Reference
หน้านี้แสดงรายการ API Endpoint ทั้งหมดสำหรับการเชื่อมต่อจากบุคคลที่สาม
การยืนยันตัวตน
หัวข้อที่มีชื่อว่า “การยืนยันตัวตน”การเชื่อมต่อจากบุคคลที่สามใช้ API Key ที่ส่งผ่านหัวข้อ x-api-key:
curl -H "x-api-key: dpk_YOUR_API_KEY" https://app.dailyplay.ai/api/...Endpoint สำหรับจัดการจากแดชบอร์ดใช้ Clerk Bearer Token แทน:
curl -H "Authorization: Bearer <clerk_token>" https://app.dailyplay.ai/api/...Session Endpoints
หัวข้อที่มีชื่อว่า “Session Endpoints”Endpoint เหล่านี้ใช้สำหรับการเชื่อมต่อจากบุคคลที่สามในการสร้างและจัดการเซสชันโทเค็นแบบใช้ครั้งเดียว
สร้างเซสชัน
หัวข้อที่มีชื่อว่า “สร้างเซสชัน”สร้างเซสชันโทเค็นแบบใช้ครั้งเดียวสำหรับเกมหรือสตรีม
POST /api/org-api-keys?action=create-sessionHeaders:
| Header | ค่า |
|---|---|
Content-Type | application/json |
x-api-key | API Key (dpk_...) |
Body:
{ "game_id": 42, "stream_id": null, "external_ref": "user-12345", "metadata": { "campaign": "summer-promo" }, "expires_in_minutes": 60}| ฟิลด์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
game_id | number | * | Game ID เป้าหมาย |
stream_id | number | * | Stream ID เป้าหมาย |
external_ref | string | ไม่ | อ้างอิงสำหรับติดตาม |
metadata | object | ไม่ | ข้อมูล JSON ตามต้องการ |
expires_in_minutes | number | ไม่ | ระยะเวลาหมดอายุ (ค่าเริ่มต้น: 1440) |
* ต้องระบุ game_id หรือ stream_id อย่างน้อย 1 อย่าง
Response 200:
{ "success": true, "data": { "token": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "stream_id": null, "game_id": 42, "expires_at": "2026-02-17T12:00:00.000Z", "external_ref": "user-12345" }}ตรวจสอบเซสชัน
หัวข้อที่มีชื่อว่า “ตรวจสอบเซสชัน”ตรวจสอบว่าเซสชันโทเค็นยังใช้ได้หรือไม่โดยไม่ใช้โทเค็น
GET /api/org-api-keys?action=validate-session&token=<uuid>Query Parameters:
| พารามิเตอร์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
token | string (UUID) | ใช่ | เซสชันโทเค็นที่ต้องการตรวจสอบ |
Response 200:
{ "success": true, "data": { "valid": true, "status": "active", "stream_id": null, "game_id": 42, "expires_at": "2026-02-17T12:00:00.000Z", "external_ref": "user-12345", "metadata": { "campaign": "summer-promo" } }}ใช้เซสชัน
หัวข้อที่มีชื่อว่า “ใช้เซสชัน”ใช้เซสชันโทเค็นแบบ atomic ทำให้ไม่สามารถใช้ซ้ำ
POST /api/org-api-keys?action=consume-sessionHeaders:
| Header | ค่า |
|---|---|
Content-Type | application/json |
Body:
{ "token": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "player_uuid": "player-uuid-here"}| ฟิลด์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
token | string (UUID) | ใช่ | เซสชันโทเค็นที่ต้องการใช้ |
player_uuid | string | ไม่ | UUID สำหรับระบุผู้เล่น |
Response 200:
{ "success": true, "data": { "session_id": 1, "org_id": 5, "stream_id": null, "game_id": 42, "external_ref": "user-12345", "metadata": { "campaign": "summer-promo" } }}Response 410 (ใช้แล้ว/หมดอายุ):
{ "success": false, "error": "Session is invalid, already consumed, or expired"}API Key Management Endpoints
หัวข้อที่มีชื่อว่า “API Key Management Endpoints”Endpoint เหล่านี้ต้องใช้ Clerk Bearer Token และใช้สำหรับจัดการ API Keys จากแดชบอร์ด DailyPlay
แสดงรายการ API Keys
หัวข้อที่มีชื่อว่า “แสดงรายการ API Keys”GET /api/org-api-keys?org_id=<id>แสดง API Keys ทั้งหมดขององค์กรที่ระบุ
สร้าง API Key
หัวข้อที่มีชื่อว่า “สร้าง API Key”POST /api/org-api-keysBody:
{ "org_id": 1, "name": "Production CRM", "description": "CRM ใช้สำหรับออกลิงก์เกม", "allowed_game_ids": [42, 43], "rate_limit_per_minute": 60, "rate_limit_per_day": 10000, "expires_at": "2027-01-01T00:00:00Z"}