{"title":"Mind Key vs JWT — ใช้เมื่อไร?","slug":"mind-key-vs-jwt","category":"getting-started","summary":"คู่มือการตัดสินใจ: Mind Key สำหรับการเข้าถึงข้อมูล agent, JWT สำหรับการจัดการบัญชี","audience":["human","llm"],"tags":["auth","mind-key","jwt","decision-guide"],"difficulty":"beginner","updated":"2026-06-27","word_count":553,"read_minutes":3,"llm_context":"Mind Key: tenant-scoped, never expires, for memory/chat/tasks/scripts/computers/webhooks.\nJWT: user-scoped, 7-day expiry, for /register, /login, /minds (CRUD), /sharing, /push.\nSimple rule: if it touches a single mind's data → Mind Key. If it manages the account → JWT.\nException: /computers/me/* uses Computer Token (not Mind Key or JWT).\n","lang":"th","translated":true,"requested_lang":"th","content_markdown":"\n# Mind Key vs JWT — ใช้เมื่อไร?\n\nSynapse มีสอง authentication token การเลือกผิดจะนำไปสู่ error 401 คู่มือนี้ให้กรอบการตัดสินใจที่ชัดเจน\n\n## ตารางการตัดสินใจด่วน\n\n| คุณต้องการ... | ใช้ |\n|----------------|-----|\n| จัดเก็บ / recall memory | Mind Key |\n| ส่ง / poll ข้อความแช็ต | Mind Key |\n| จัดการ task | Mind Key |\n| เก็บ script | Mind Key |\n| ลงทะเบียน webhook | Mind Key |\n| ควบคุม computer | Mind Key (ฝั่งผู้ใช้) / Computer Token (ฝั่ง agent) |\n| สมัครบัญชีผู้ใช้ | None (public) |\n| ล็อกอิน | None (public) |\n| สร้าง / รายการ / ลบ mind | JWT |\n| แชร์ mind กับผู้ใช้อื่น | JWT |\n| สมัครรับ web push notification | JWT |\n| ดู audit log | Mind Key |\n\n## กฎง่าย ๆ\n\n> [!TIP]\n> **หากมันสัมผัสข้อมูล mind เดียว → Mind Key**\n> **หากมันจัดการบัญชีหรือ metadata ของ mind → JWT**\n\n## Mind Key — Data Access Token\n\nMind Key ให้สิทธิ์เข้าถึง **ข้อมูล mind หนึ่ง** เป็น token ที่อยู่ยาวนานและไม่หมดอายุ (จนกว่า mind จะถูกลบ) เหมาะสำหรับ:\n\n- LLM agent ที่เก็บ memory ข้าม session\n- cron job เบื้องหลัง\n- กำหนดค่า MCP server\n- integration webhook\n- แอปมือถือที่อ่าน memory\n\n### Mind Key ทำอะไรได้\n\n- `GET /memory/recall` — อ่าน memory ทั้งหมดใน mind นี้\n- `POST /memory` — เก็บ/อัปเดต memory\n- `GET /chat/poll` — อ่านข้อความแช็ต\n- `POST /chat/reply` — ส่งข้อความแช็ต\n- `GET /mind/tasks` — รายการ task\n- `POST /mind/task` — สร้าง task\n- `POST /script` — เก็บ script\n- `POST /webhooks` — ลงทะเบียน webhook\n- `POST /computers/:id/commands` — จัดคิวคำสั่ง computer\n\n### Mind Key ทำอะไรไม่ได้\n\n- สร้าง / รายการ / ลบ mind (ต้องใช้ JWT)\n- แชร์ mind กับผู้ใช้อื่น (ต้องใช้ JWT)\n- ดูข้อมูลบัญชีผู้ใช้ (ต้องใช้ JWT)\n- สมัครรับ web push (ต้องใช้ JWT)\n\n## JWT — Account Management Token\n\nJWT ยืนยันตัวตน **บัญชีผู้ใช้** หมดอายุหลัง 7 วัน และใช้สำหรับการดำเนินการระดับบัญชีที่ครอบคลุมหลาย mind หรือเกี่ยวข้องกับผู้ใช้อื่น\n\n### JWT ทำอะไรได้\n\n- `POST /minds` — สร้าง mind ใหม่ (ส่งกลับ Mind Key ใหม่)\n- `GET /minds` — รายการ mind ทั้งหมดของผู้ใช้นี้\n- `DELETE /minds/:id` — ลบ mind\n- `POST /sharing` — แชร์ mind กับผู้ใช้อื่น\n- `POST /push/subscribe` — สมัครรับ web push notification\n- `GET /sharing` — รายการการแชร์ mind\n\n### JWT ทำอะไรไม่ได้\n\n- อ่าน / เขียน memory (ต้องใช้ Mind Key)\n- ส่งข้อความแช็ต (ต้องใช้ Mind Key)\n- จัดการ task (ต้องใช้ Mind Key)\n- ลงทะเบียน webhook (ต้องใช้ Mind Key)\n\n## กรณีพิเศษ: Computer Token\n\nendpoint `/computers/me/*` (ฝั่ง agent, สำหรับ screen-remote-agent) ใช้ token ประเภทที่สาม: **Computer Token** token นี้ถูกส่งกลับโดย `POST /computers/register` เมื่อแลกรับ install code และเฉพาะสำหรับ computer ที่ลงทะเบียนหนึ่งเครื่อง\n\n| Endpoint | Auth |\n|----------|------|\n| `GET /computers/me/poll` | Computer Token |\n| `POST /computers/me/commands/:cid/result` | Computer Token |\n| `GET /computers/list` | Mind Key or JWT |\n| `POST /computers/:id/commands` | Mind Key or JWT |\n\n## รูปแบบทั่วไป\n\n### รูปแบบ 1: LLM Agent เดียว\n\n1. สมัครครั้งเดียว → รับ JWT\n2. สร้าง mind เดียว → รับ Mind Key\n3. LLM ใช้ Mind Key สำหรับทุกอย่าง\n\n### รูปแบบ 2: Agent หลายโปรเจกต์\n\n1. สมัครครั้งเดียว → รับ JWT\n2. สร้างหลาย mind (work, personal, project-x) → รับหลาย Mind Key\n3. LLM โหลด Mind Key ต่างกันตาม context\n\n### รูปแบบ 3: การแชร์ในทีม\n\n1. ผู้ใช้ A สร้าง mind → ได้ Mind Key A\n2. ผู้ใช้ A แชร์กับผู้ใช้ B ผ่าน JWT (`POST /sharing`)\n3. ผู้ใช้ B สามารถเข้าถึงผ่าน JWT ของตนเอง\n4. สำหรับการเข้าถึง LLM, ผู้ใช้ B ต้องสร้าง Mind Key ของตนเอง (หรือใช้ของ A)\n\n### รูปแบบ 4: MCP Server\n\nMCP server ใช้ Mind Key เสมอ (ตั้งผ่าน env var `SYNAPSE_MIND_KEY`) หนึ่ง MCP server instance = หนึ่ง mind สำหรับการเข้าถึงหลาย mind ให้รันหลาย MCP instance หรือ implement mind switching ฝั่ง client\n\n## Cheat Sheet รูปแบบ Token\n\n| Token | รูปแบบ | ตัวอย่าง |\n|-------|--------|---------|\n| Mind Key | `mk_` + 36 ตัวอักษร | `mk_aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789` |\n| JWT | `eyJ` + base64 | `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...` |\n| Computer Token | `ct_` + 36 ตัวอักษร | `ct_xYzAbCdEfGhIjKlMnOpQrStUvWxYz0123456789` |\n\n## ขั้นตอนถัดไป\n\n- [Authentication](/docs/getting-started/authentication) — คู่มือ auth แบบเต็ม\n- [User & Minds API](/docs/api/user) — endpoint ที่ป้องกันด้วย JWT\n- [Memory API](/docs/api/memory) — endpoint ที่ป้องกันด้วย Mind Key\n","content_html":"<h1>Mind Key vs JWT — ใช้เมื่อไร?</h1>\n<p>Synapse มีสอง authentication token การเลือกผิดจะนำไปสู่ error 401 คู่มือนี้ให้กรอบการตัดสินใจที่ชัดเจน</p>\n<h2>ตารางการตัดสินใจด่วน</h2>\n<table>\n<thead>\n<tr>\n<th>คุณต้องการ...</th>\n<th>ใช้</th>\n</tr>\n</thead>\n<tbody><tr>\n<td>จัดเก็บ / recall memory</td>\n<td>Mind Key</td>\n</tr>\n<tr>\n<td>ส่ง / poll ข้อความแช็ต</td>\n<td>Mind Key</td>\n</tr>\n<tr>\n<td>จัดการ task</td>\n<td>Mind Key</td>\n</tr>\n<tr>\n<td>เก็บ script</td>\n<td>Mind Key</td>\n</tr>\n<tr>\n<td>ลงทะเบียน webhook</td>\n<td>Mind Key</td>\n</tr>\n<tr>\n<td>ควบคุม computer</td>\n<td>Mind Key (ฝั่งผู้ใช้) / Computer Token (ฝั่ง agent)</td>\n</tr>\n<tr>\n<td>สมัครบัญชีผู้ใช้</td>\n<td>None (public)</td>\n</tr>\n<tr>\n<td>ล็อกอิน</td>\n<td>None (public)</td>\n</tr>\n<tr>\n<td>สร้าง / รายการ / ลบ mind</td>\n<td>JWT</td>\n</tr>\n<tr>\n<td>แชร์ mind กับผู้ใช้อื่น</td>\n<td>JWT</td>\n</tr>\n<tr>\n<td>สมัครรับ web push notification</td>\n<td>JWT</td>\n</tr>\n<tr>\n<td>ดู audit log</td>\n<td>Mind Key</td>\n</tr>\n</tbody></table>\n<h2>กฎง่าย ๆ</h2>\n<div class=\"callout callout-ok\">**หากมันสัมผัสข้อมูล mind เดียว → Mind Key**\n**หากมันจัดการบัญชีหรือ metadata ของ mind → JWT**</div><h2>Mind Key — Data Access Token</h2>\n<p>Mind Key ให้สิทธิ์เข้าถึง <strong>ข้อมูล mind หนึ่ง</strong> เป็น token ที่อยู่ยาวนานและไม่หมดอายุ (จนกว่า mind จะถูกลบ) เหมาะสำหรับ:</p>\n<ul>\n<li>LLM agent ที่เก็บ memory ข้าม session</li>\n<li>cron job เบื้องหลัง</li>\n<li>กำหนดค่า MCP server</li>\n<li>integration webhook</li>\n<li>แอปมือถือที่อ่าน memory</li>\n</ul>\n<h3>Mind Key ทำอะไรได้</h3>\n<ul>\n<li><code>GET /memory/recall</code> — อ่าน memory ทั้งหมดใน mind นี้</li>\n<li><code>POST /memory</code> — เก็บ/อัปเดต memory</li>\n<li><code>GET /chat/poll</code> — อ่านข้อความแช็ต</li>\n<li><code>POST /chat/reply</code> — ส่งข้อความแช็ต</li>\n<li><code>GET /mind/tasks</code> — รายการ task</li>\n<li><code>POST /mind/task</code> — สร้าง task</li>\n<li><code>POST /script</code> — เก็บ script</li>\n<li><code>POST /webhooks</code> — ลงทะเบียน webhook</li>\n<li><code>POST /computers/:id/commands</code> — จัดคิวคำสั่ง computer</li>\n</ul>\n<h3>Mind Key ทำอะไรไม่ได้</h3>\n<ul>\n<li>สร้าง / รายการ / ลบ mind (ต้องใช้ JWT)</li>\n<li>แชร์ mind กับผู้ใช้อื่น (ต้องใช้ JWT)</li>\n<li>ดูข้อมูลบัญชีผู้ใช้ (ต้องใช้ JWT)</li>\n<li>สมัครรับ web push (ต้องใช้ JWT)</li>\n</ul>\n<h2>JWT — Account Management Token</h2>\n<p>JWT ยืนยันตัวตน <strong>บัญชีผู้ใช้</strong> หมดอายุหลัง 7 วัน และใช้สำหรับการดำเนินการระดับบัญชีที่ครอบคลุมหลาย mind หรือเกี่ยวข้องกับผู้ใช้อื่น</p>\n<h3>JWT ทำอะไรได้</h3>\n<ul>\n<li><code>POST /minds</code> — สร้าง mind ใหม่ (ส่งกลับ Mind Key ใหม่)</li>\n<li><code>GET /minds</code> — รายการ mind ทั้งหมดของผู้ใช้นี้</li>\n<li><code>DELETE /minds/:id</code> — ลบ mind</li>\n<li><code>POST /sharing</code> — แชร์ mind กับผู้ใช้อื่น</li>\n<li><code>POST /push/subscribe</code> — สมัครรับ web push notification</li>\n<li><code>GET /sharing</code> — รายการการแชร์ mind</li>\n</ul>\n<h3>JWT ทำอะไรไม่ได้</h3>\n<ul>\n<li>อ่าน / เขียน memory (ต้องใช้ Mind Key)</li>\n<li>ส่งข้อความแช็ต (ต้องใช้ Mind Key)</li>\n<li>จัดการ task (ต้องใช้ Mind Key)</li>\n<li>ลงทะเบียน webhook (ต้องใช้ Mind Key)</li>\n</ul>\n<h2>กรณีพิเศษ: Computer Token</h2>\n<p>endpoint <code>/computers/me/*</code> (ฝั่ง agent, สำหรับ screen-remote-agent) ใช้ token ประเภทที่สาม: <strong>Computer Token</strong> token นี้ถูกส่งกลับโดย <code>POST /computers/register</code> เมื่อแลกรับ install code และเฉพาะสำหรับ computer ที่ลงทะเบียนหนึ่งเครื่อง</p>\n<table>\n<thead>\n<tr>\n<th>Endpoint</th>\n<th>Auth</th>\n</tr>\n</thead>\n<tbody><tr>\n<td><code>GET /computers/me/poll</code></td>\n<td>Computer Token</td>\n</tr>\n<tr>\n<td><code>POST /computers/me/commands/:cid/result</code></td>\n<td>Computer Token</td>\n</tr>\n<tr>\n<td><code>GET /computers/list</code></td>\n<td>Mind Key or JWT</td>\n</tr>\n<tr>\n<td><code>POST /computers/:id/commands</code></td>\n<td>Mind Key or JWT</td>\n</tr>\n</tbody></table>\n<h2>รูปแบบทั่วไป</h2>\n<h3>รูปแบบ 1: LLM Agent เดียว</h3>\n<ol>\n<li>สมัครครั้งเดียว → รับ JWT</li>\n<li>สร้าง mind เดียว → รับ Mind Key</li>\n<li>LLM ใช้ Mind Key สำหรับทุกอย่าง</li>\n</ol>\n<h3>รูปแบบ 2: Agent หลายโปรเจกต์</h3>\n<ol>\n<li>สมัครครั้งเดียว → รับ JWT</li>\n<li>สร้างหลาย mind (work, personal, project-x) → รับหลาย Mind Key</li>\n<li>LLM โหลด Mind Key ต่างกันตาม context</li>\n</ol>\n<h3>รูปแบบ 3: การแชร์ในทีม</h3>\n<ol>\n<li>ผู้ใช้ A สร้าง mind → ได้ Mind Key A</li>\n<li>ผู้ใช้ A แชร์กับผู้ใช้ B ผ่าน JWT (<code>POST /sharing</code>)</li>\n<li>ผู้ใช้ B สามารถเข้าถึงผ่าน JWT ของตนเอง</li>\n<li>สำหรับการเข้าถึง LLM, ผู้ใช้ B ต้องสร้าง Mind Key ของตนเอง (หรือใช้ของ A)</li>\n</ol>\n<h3>รูปแบบ 4: MCP Server</h3>\n<p>MCP server ใช้ Mind Key เสมอ (ตั้งผ่าน env var <code>SYNAPSE_MIND_KEY</code>) หนึ่ง MCP server instance = หนึ่ง mind สำหรับการเข้าถึงหลาย mind ให้รันหลาย MCP instance หรือ implement mind switching ฝั่ง client</p>\n<h2>Cheat Sheet รูปแบบ Token</h2>\n<table>\n<thead>\n<tr>\n<th>Token</th>\n<th>รูปแบบ</th>\n<th>ตัวอย่าง</th>\n</tr>\n</thead>\n<tbody><tr>\n<td>Mind Key</td>\n<td><code>mk_</code> + 36 ตัวอักษร</td>\n<td><code>mk_aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789</code></td>\n</tr>\n<tr>\n<td>JWT</td>\n<td><code>eyJ</code> + base64</td>\n<td><code>eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...</code></td>\n</tr>\n<tr>\n<td>Computer Token</td>\n<td><code>ct_</code> + 36 ตัวอักษร</td>\n<td><code>ct_xYzAbCdEfGhIjKlMnOpQrStUvWxYz0123456789</code></td>\n</tr>\n</tbody></table>\n<h2>ขั้นตอนถัดไป</h2>\n<ul>\n<li><a href=\"/docs/getting-started/authentication\">Authentication</a> — คู่มือ auth แบบเต็ม</li>\n<li><a href=\"/docs/api/user\">User &amp; Minds API</a> — endpoint ที่ป้องกันด้วย JWT</li>\n<li><a href=\"/docs/api/memory\">Memory API</a> — endpoint ที่ป้องกันด้วย Mind Key</li>\n</ul>\n","urls":{"html":"/docs/getting-started/mind-key-vs-jwt","text":"/docs/getting-started/mind-key-vs-jwt?format=text","json":"/docs/getting-started/mind-key-vs-jwt?format=json","llm":"/docs/getting-started/mind-key-vs-jwt?format=llm"},"translations_available":["en","zh","hi","es","fr","ar","pt","ru","ja","de","it","ko","nl","pl","tr","sv","vi","th","id","uk"]}