# Mind Key vs JWT — ใช้เมื่อไร? SUMMARY: คู่มือการตัดสินใจ: Mind Key สำหรับการเข้าถึงข้อมูล agent, JWT สำหรับการจัดการบัญชี KEY CONTEXT: Mind Key: tenant-scoped, never expires, for memory/chat/tasks/scripts/computers/webhooks. JWT: user-scoped, 7-day expiry, for /register, /login, /minds (CRUD), /sharing, /push. Simple rule: if it touches a single mind's data → Mind Key. If it manages the account → JWT. Exception: /computers/me/* uses Computer Token (not Mind Key or JWT). Mind Key vs JWT — ใช้เมื่อไร? Synapse มีสอง authentication token การเลือกผิดจะนำไปสู่ error 401 คู่มือนี้ให้กรอบการตัดสินใจที่ชัดเจน ตารางการตัดสินใจด่วน | คุณต้องการ... | ใช้ | |----------------|-----| | จัดเก็บ / recall memory | Mind Key | | ส่ง / poll ข้อความแช็ต | Mind Key | | จัดการ task | Mind Key | | เก็บ script | Mind Key | | ลงทะเบียน webhook | Mind Key | | ควบคุม computer | Mind Key (ฝั่งผู้ใช้) / Computer Token (ฝั่ง agent) | | สมัครบัญชีผู้ใช้ | None (public) | | ล็อกอิน | None (public) | | สร้าง / รายการ / ลบ mind | JWT | | แชร์ mind กับผู้ใช้อื่น | JWT | | สมัครรับ web push notification | JWT | | ดู audit log | Mind Key | กฎง่าย ๆ > [!TIP] > หากมันสัมผัสข้อมูล mind เดียว → Mind Key > หากมันจัดการบัญชีหรือ metadata ของ mind → JWT Mind Key — Data Access Token Mind Key ให้สิทธิ์เข้าถึง ข้อมูล mind หนึ่ง เป็น token ที่อยู่ยาวนานและไม่หมดอายุ (จนกว่า mind จะถูกลบ) เหมาะสำหรับ: - LLM agent ที่เก็บ memory ข้าม session - cron job เบื้องหลัง - กำหนดค่า MCP server - integration webhook - แอปมือถือที่อ่าน memory Mind Key ทำอะไรได้ - — อ่าน memory ทั้งหมดใน mind นี้ - — เก็บ/อัปเดต memory - — อ่านข้อความแช็ต - — ส่งข้อความแช็ต - — รายการ task - — สร้าง task - — เก็บ script - — ลงทะเบียน webhook - — จัดคิวคำสั่ง computer Mind Key ทำอะไรไม่ได้ - สร้าง / รายการ / ลบ mind (ต้องใช้ JWT) - แชร์ mind กับผู้ใช้อื่น (ต้องใช้ JWT) - ดูข้อมูลบัญชีผู้ใช้ (ต้องใช้ JWT) - สมัครรับ web push (ต้องใช้ JWT) JWT — Account Management Token JWT ยืนยันตัวตน บัญชีผู้ใช้ หมดอายุหลัง 7 วัน และใช้สำหรับการดำเนินการระดับบัญชีที่ครอบคลุมหลาย mind หรือเกี่ยวข้องกับผู้ใช้อื่น JWT ทำอะไรได้ - — สร้าง mind ใหม่ (ส่งกลับ Mind Key ใหม่) - — รายการ mind ทั้งหมดของผู้ใช้นี้ - — ลบ mind - — แชร์ mind กับผู้ใช้อื่น - — สมัครรับ web push notification - — รายการการแชร์ mind JWT ทำอะไรไม่ได้ - อ่าน / เขียน memory (ต้องใช้ Mind Key) - ส่งข้อความแช็ต (ต้องใช้ Mind Key) - จัดการ task (ต้องใช้ Mind Key) - ลงทะเบียน webhook (ต้องใช้ Mind Key) กรณีพิเศษ: Computer Token endpoint (ฝั่ง agent, สำหรับ screen-remote-agent) ใช้ token ประเภทที่สาม: Computer Token token นี้ถูกส่งกลับโดย เมื่อแลกรับ install code และเฉพาะสำหรับ computer ที่ลงทะเบียนหนึ่งเครื่อง | Endpoint | Auth | |----------|------| | | Computer Token | | | Computer Token | | | Mind Key or JWT | | | Mind Key or JWT | รูปแบบทั่วไป รูปแบบ 1: LLM Agent เดียว 1. สมัครครั้งเดียว → รับ JWT 2. สร้าง mind เดียว → รับ Mind Key 3. LLM ใช้ Mind Key สำหรับทุกอย่าง รูปแบบ 2: Agent หลายโปรเจกต์ 1. สมัครครั้งเดียว → รับ JWT 2. สร้างหลาย mind (work, personal, project-x) → รับหลาย Mind Key 3. LLM โหลด Mind Key ต่างกันตาม context รูปแบบ 3: การแชร์ในทีม 1. ผู้ใช้ A สร้าง mind → ได้ Mind Key A 2. ผู้ใช้ A แชร์กับผู้ใช้ B ผ่าน JWT () 3. ผู้ใช้ B สามารถเข้าถึงผ่าน JWT ของตนเอง 4. สำหรับการเข้าถึง LLM, ผู้ใช้ B ต้องสร้าง Mind Key ของตนเอง (หรือใช้ของ A) รูปแบบ 4: MCP Server MCP server ใช้ Mind Key เสมอ (ตั้งผ่าน env var ) หนึ่ง MCP server instance = หนึ่ง mind สำหรับการเข้าถึงหลาย mind ให้รันหลาย MCP instance หรือ implement mind switching ฝั่ง client Cheat Sheet รูปแบบ Token | Token | รูปแบบ | ตัวอย่าง | |-------|--------|---------| | Mind Key | + 36 ตัวอักษร | | | JWT | + base64 | | | Computer Token | + 36 ตัวอักษร | | ขั้นตอนถัดไป - Authentication — คู่มือ auth แบบเต็ม - User & Minds API — endpoint ที่ป้องกันด้วย JWT - Memory API — endpoint ที่ป้องกันด้วย Mind Key