{"title":"User & Minds API","slug":"user","category":"api","summary":"การจัดการบัญชี — สมัคร, ล็อกอิน, สร้าง mind, รายการ mind, ลบ mind ป้องกันด้วย JWT","audience":["human","llm"],"tags":["api","user","account","minds","jwt"],"difficulty":"beginner","updated":"2026-06-27","word_count":191,"read_minutes":1,"llm_context":"Auth: JWT (from /register or /login)\nRegister: POST /register { email, password, display_name? } → returns JWT\nLogin: POST /login { email, password } → returns JWT\nCreate mind: POST /minds { name, description? } → returns mind_key (shown once!)\nList minds: GET /minds\nDelete mind: DELETE /minds/:id (irreversible — deletes all memories!)\nJWT expires after 7 days. Mind Key never expires.\nMind Key is shown only once at creation — save it permanently.\n","lang":"th","translated":true,"requested_lang":"th","content_markdown":"\n# User & Minds API\n\nUser & Minds API จัดการบัญชี endpoint เหล่านี้ใช้ JWT authentication (ไม่ใช่ Mind Key) เพราะทำงานในระดับบัญชี ไม่ใช่ระดับ mind\n\n## Endpoint ยืนยันตัวตน\n\n### POST /register\n\nสร้างบัญชีผู้ใช้ใหม่\n\n```bash\ncurl -X POST https://synapse.schaefer.zone/register \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"email\": \"you@example.com\",\n    \"password\": \"your-secure-password\",\n    \"display_name\": \"Michael\"\n  }'\n```\n\nResponse:\n\n```json\n{\n  \"jwt\": \"eyJhbGci...\",\n  \"user\": {\n    \"id\": \"u_abc123\",\n    \"email\": \"you@example.com\",\n    \"display_name\": \"Michael\",\n    \"created_at\": \"2026-06-27T...\"\n  }\n}\n```\n\n### POST /login\n\nล็อกอินเข้าสู่บัญชีที่มีอยู่\n\n```bash\ncurl -X POST https://synapse.schaefer.zone/login \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"email\": \"you@example.com\",\n    \"password\": \"your-secure-password\"\n  }'\n```\n\nResponse: เหมือนกับ `/register`\n\n## Minds Endpoints\n\n### POST /minds\n\nสร้าง mind ใหม่ ส่งกลับ Mind Key — **บันทึกทันที** แสดงเพียงครั้งเดียว\n\n```bash\ncurl -X POST https://synapse.schaefer.zone/minds \\\n  -H \"Authorization: Bearer YOUR_JWT\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"name\": \"Work Mind\",\n    \"description\": \"Job-related memories\"\n  }'\n```\n\nResponse:\n\n```json\n{\n  \"id\": \"m_xyz789\",\n  \"name\": \"Work Mind\",\n  \"description\": \"Job-related memories\",\n  \"mind_key\": \"mk_aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789\",\n  \"created_at\": \"2026-06-27T...\"\n}\n```\n\n> [!CRITICAL]\n> `mind_key` แสดงเพียงครั้งเดียว หากคุณสูญเสียจะดึงคืนไม่ได้ — ต้องลบ mind และสร้างใหม่ (ซึ่งจะสูญเสีย memory ที่จัดเก็บไว้ทั้งหมด)\n\n### GET /minds\n\nรายการ mind ทั้งหมดของผู้ใช้ปัจจุบัน\n\n```bash\ncurl -H \"Authorization: Bearer YOUR_JWT\" \\\n     https://synapse.schaefer.zone/minds\n```\n\nResponse:\n\n```json\n{\n  \"minds\": [\n    {\n      \"id\": \"m_xyz789\",\n      \"name\": \"Work Mind\",\n      \"description\": \"Job-related memories\",\n      \"created_at\": \"2026-06-27T...\",\n      \"memory_count\": 142,\n      \"last_activity\": \"2026-06-27T...\"\n    }\n  ]\n}\n```\n\n### DELETE /minds/:id\n\nลบ mind อย่างถาวร\n\n```bash\ncurl -X DELETE -H \"Authorization: Bearer YOUR_JWT\" \\\n     https://synapse.schaefer.zone/minds/m_xyz789\n```\n\n> [!WARNING]\n> การลบ mind **เป็นการกระทำที่ย้อนกลับไม่ได้** memory, task, chat history และ script ทั้งหมดใน mind นั้นจะสูญหายอย่างถาวร export ก่อนผ่าน `GET /memory/mind-export` หากคุณต้องการสำรองข้อมูล\n\n## รูปแบบ Multi-Mind\n\nผู้ใช้ส่วนใหญ่ได้ประโยชน์จากหลาย mind เพื่อแยก context:\n\n```bash\n# Create minds for different contexts\ncurl -X POST .../minds -d '{\"name\": \"work\", \"description\": \"Job\"}'\n# → mind_key: mk_work...\n\ncurl -X POST .../minds -d '{\"name\": \"personal\", \"description\": \"Personal life\"}'\n# → mind_key: mk_personal...\n\ncurl -X POST .../minds -d '{\"name\": \"project-synapse\", \"description\": \"Synapse dev\"}'\n# → mind_key: mk_synapse...\n```\n\nใช้ Mind Key ต่างกันใน LLM session ต่างกันเพื่อแยก context\n\n## ความปลอดภัยบัญชี\n\n### ข้อกำหนดรหัสผ่าน\n\n- ขั้นต่ำ 6 ตัวอักษร\n- ไม่จำกัดความยาวสูงสุด (ใช้ password manager)\n- เก็บเป็น bcrypt hash (ไม่เก็บ plaintext เด็ดขาด)\n\n### การหมดอายุของ JWT\n\nJWT หมดอายุหลัง **7 วัน** เมื่อหมดอายุเรียก `/login` อีกครั้ง\n\n### ความปลอดภัยของ Mind Key\n\nMind Key ไม่มีวันหมดอายุ หาก Mind Key ถูกโจมตี:\n\n1. สร้าง mind ใหม่ผ่าน `POST /minds`\n2. อัปเดต config ของ LLM ด้วย Mind Key ใหม่\n3. ลบ mind ที่ถูกโจมตีผ่าน `DELETE /minds/:id`\n\n## ขั้นตอนถัดไป\n\n- [Authentication](/docs/getting-started/authentication) — คู่มือ auth แบบเต็ม\n- [Mind Key vs JWT](/docs/getting-started/mind-key-vs-jwt) — คู่มือการตัดสินใจ\n- [Sharing API](/docs/api/user) — แชร์ mind กับผู้ใช้อื่น\n","content_html":"<h1>User &amp; Minds API</h1>\n<p>User &amp; Minds API จัดการบัญชี endpoint เหล่านี้ใช้ JWT authentication (ไม่ใช่ Mind Key) เพราะทำงานในระดับบัญชี ไม่ใช่ระดับ mind</p>\n<h2>Endpoint ยืนยันตัวตน</h2>\n<h3>POST /register</h3>\n<p>สร้างบัญชีผู้ใช้ใหม่</p>\n<pre><code class=\"hljs language-bash\">curl -X POST https://synapse.schaefer.zone/register \\\n  -H <span class=\"hljs-string\">&quot;Content-Type: application/json&quot;</span> \\\n  -d <span class=\"hljs-string\">&#x27;{\n    &quot;email&quot;: &quot;you@example.com&quot;,\n    &quot;password&quot;: &quot;your-secure-password&quot;,\n    &quot;display_name&quot;: &quot;Michael&quot;\n  }&#x27;</span></code></pre><p>Response:</p>\n<pre><code class=\"hljs language-json\"><span class=\"hljs-punctuation\">{</span>\n  <span class=\"hljs-attr\">&quot;jwt&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;eyJhbGci...&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;user&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">{</span>\n    <span class=\"hljs-attr\">&quot;id&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;u_abc123&quot;</span><span class=\"hljs-punctuation\">,</span>\n    <span class=\"hljs-attr\">&quot;email&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;you@example.com&quot;</span><span class=\"hljs-punctuation\">,</span>\n    <span class=\"hljs-attr\">&quot;display_name&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;Michael&quot;</span><span class=\"hljs-punctuation\">,</span>\n    <span class=\"hljs-attr\">&quot;created_at&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;2026-06-27T...&quot;</span>\n  <span class=\"hljs-punctuation\">}</span>\n<span class=\"hljs-punctuation\">}</span></code></pre><h3>POST /login</h3>\n<p>ล็อกอินเข้าสู่บัญชีที่มีอยู่</p>\n<pre><code class=\"hljs language-bash\">curl -X POST https://synapse.schaefer.zone/login \\\n  -H <span class=\"hljs-string\">&quot;Content-Type: application/json&quot;</span> \\\n  -d <span class=\"hljs-string\">&#x27;{\n    &quot;email&quot;: &quot;you@example.com&quot;,\n    &quot;password&quot;: &quot;your-secure-password&quot;\n  }&#x27;</span></code></pre><p>Response: เหมือนกับ <code>/register</code></p>\n<h2>Minds Endpoints</h2>\n<h3>POST /minds</h3>\n<p>สร้าง mind ใหม่ ส่งกลับ Mind Key — <strong>บันทึกทันที</strong> แสดงเพียงครั้งเดียว</p>\n<pre><code class=\"hljs language-bash\">curl -X POST https://synapse.schaefer.zone/minds \\\n  -H <span class=\"hljs-string\">&quot;Authorization: Bearer YOUR_JWT&quot;</span> \\\n  -H <span class=\"hljs-string\">&quot;Content-Type: application/json&quot;</span> \\\n  -d <span class=\"hljs-string\">&#x27;{\n    &quot;name&quot;: &quot;Work Mind&quot;,\n    &quot;description&quot;: &quot;Job-related memories&quot;\n  }&#x27;</span></code></pre><p>Response:</p>\n<pre><code class=\"hljs language-json\"><span class=\"hljs-punctuation\">{</span>\n  <span class=\"hljs-attr\">&quot;id&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;m_xyz789&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;name&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;Work Mind&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;description&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;Job-related memories&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;mind_key&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;mk_aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;created_at&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;2026-06-27T...&quot;</span>\n<span class=\"hljs-punctuation\">}</span></code></pre><div class=\"callout callout-critical\">`mind_key` แสดงเพียงครั้งเดียว หากคุณสูญเสียจะดึงคืนไม่ได้ — ต้องลบ mind และสร้างใหม่ (ซึ่งจะสูญเสีย memory ที่จัดเก็บไว้ทั้งหมด)</div><h3>GET /minds</h3>\n<p>รายการ mind ทั้งหมดของผู้ใช้ปัจจุบัน</p>\n<pre><code class=\"hljs language-bash\">curl -H <span class=\"hljs-string\">&quot;Authorization: Bearer YOUR_JWT&quot;</span> \\\n     https://synapse.schaefer.zone/minds</code></pre><p>Response:</p>\n<pre><code class=\"hljs language-json\"><span class=\"hljs-punctuation\">{</span>\n  <span class=\"hljs-attr\">&quot;minds&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">[</span>\n    <span class=\"hljs-punctuation\">{</span>\n      <span class=\"hljs-attr\">&quot;id&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;m_xyz789&quot;</span><span class=\"hljs-punctuation\">,</span>\n      <span class=\"hljs-attr\">&quot;name&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;Work Mind&quot;</span><span class=\"hljs-punctuation\">,</span>\n      <span class=\"hljs-attr\">&quot;description&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;Job-related memories&quot;</span><span class=\"hljs-punctuation\">,</span>\n      <span class=\"hljs-attr\">&quot;created_at&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;2026-06-27T...&quot;</span><span class=\"hljs-punctuation\">,</span>\n      <span class=\"hljs-attr\">&quot;memory_count&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-number\">142</span><span class=\"hljs-punctuation\">,</span>\n      <span class=\"hljs-attr\">&quot;last_activity&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;2026-06-27T...&quot;</span>\n    <span class=\"hljs-punctuation\">}</span>\n  <span class=\"hljs-punctuation\">]</span>\n<span class=\"hljs-punctuation\">}</span></code></pre><h3>DELETE /minds/:id</h3>\n<p>ลบ mind อย่างถาวร</p>\n<pre><code class=\"hljs language-bash\">curl -X DELETE -H <span class=\"hljs-string\">&quot;Authorization: Bearer YOUR_JWT&quot;</span> \\\n     https://synapse.schaefer.zone/minds/m_xyz789</code></pre><div class=\"callout callout-warn\">การลบ mind **เป็นการกระทำที่ย้อนกลับไม่ได้** memory, task, chat history และ script ทั้งหมดใน mind นั้นจะสูญหายอย่างถาวร export ก่อนผ่าน `GET /memory/mind-export` หากคุณต้องการสำรองข้อมูล</div><h2>รูปแบบ Multi-Mind</h2>\n<p>ผู้ใช้ส่วนใหญ่ได้ประโยชน์จากหลาย mind เพื่อแยก context:</p>\n<pre><code class=\"hljs language-bash\"><span class=\"hljs-comment\"># Create minds for different contexts</span>\ncurl -X POST .../minds -d <span class=\"hljs-string\">&#x27;{&quot;name&quot;: &quot;work&quot;, &quot;description&quot;: &quot;Job&quot;}&#x27;</span>\n<span class=\"hljs-comment\"># → mind_key: mk_work...</span>\n\ncurl -X POST .../minds -d <span class=\"hljs-string\">&#x27;{&quot;name&quot;: &quot;personal&quot;, &quot;description&quot;: &quot;Personal life&quot;}&#x27;</span>\n<span class=\"hljs-comment\"># → mind_key: mk_personal...</span>\n\ncurl -X POST .../minds -d <span class=\"hljs-string\">&#x27;{&quot;name&quot;: &quot;project-synapse&quot;, &quot;description&quot;: &quot;Synapse dev&quot;}&#x27;</span>\n<span class=\"hljs-comment\"># → mind_key: mk_synapse...</span></code></pre><p>ใช้ Mind Key ต่างกันใน LLM session ต่างกันเพื่อแยก context</p>\n<h2>ความปลอดภัยบัญชี</h2>\n<h3>ข้อกำหนดรหัสผ่าน</h3>\n<ul>\n<li>ขั้นต่ำ 6 ตัวอักษร</li>\n<li>ไม่จำกัดความยาวสูงสุด (ใช้ password manager)</li>\n<li>เก็บเป็น bcrypt hash (ไม่เก็บ plaintext เด็ดขาด)</li>\n</ul>\n<h3>การหมดอายุของ JWT</h3>\n<p>JWT หมดอายุหลัง <strong>7 วัน</strong> เมื่อหมดอายุเรียก <code>/login</code> อีกครั้ง</p>\n<h3>ความปลอดภัยของ Mind Key</h3>\n<p>Mind Key ไม่มีวันหมดอายุ หาก Mind Key ถูกโจมตี:</p>\n<ol>\n<li>สร้าง mind ใหม่ผ่าน <code>POST /minds</code></li>\n<li>อัปเดต config ของ LLM ด้วย Mind Key ใหม่</li>\n<li>ลบ mind ที่ถูกโจมตีผ่าน <code>DELETE /minds/:id</code></li>\n</ol>\n<h2>ขั้นตอนถัดไป</h2>\n<ul>\n<li><a href=\"/docs/getting-started/authentication\">Authentication</a> — คู่มือ auth แบบเต็ม</li>\n<li><a href=\"/docs/getting-started/mind-key-vs-jwt\">Mind Key vs JWT</a> — คู่มือการตัดสินใจ</li>\n<li><a href=\"/docs/api/user\">Sharing API</a> — แชร์ mind กับผู้ใช้อื่น</li>\n</ul>\n","urls":{"html":"/docs/api/user","text":"/docs/api/user?format=text","json":"/docs/api/user?format=json","llm":"/docs/api/user?format=llm"},"translations_available":["en","zh","hi","es","fr","ar","pt","ru","ja","de","it","ko","nl","pl","tr","sv","vi","th","id","uk"]}