{"title":"Computer Control API","slug":"computers","category":"api","summary":"ควบคุม computer ที่ลงทะเบียนจากระยะไกล — จัดคิวคำสั่ง, จับภาพ screenshot, รันสคริปต์บนเครื่องระยะไกล","audience":["human","llm"],"tags":["api","computers","remote-control","automation"],"difficulty":"advanced","updated":"2026-06-27","word_count":241,"read_minutes":1,"llm_context":"Two sides: user-facing (Mind Key/JWT) and agent-facing (Computer Token)\nRegister agent: POST /computers/register { install_code } → returns computer_token\nList: GET /computers/list (Mind Key or JWT)\nQueue command: POST /computers/:id/commands { type, payload }\nCommand types: screenshot, click, move, type, key, scroll, drag\nAgent poll: GET /computers/me/poll?wait=5 (Computer Token)\nAgent result: POST /computers/me/commands/:cid/result (Computer Token)\nOne-shot screenshot: GET /computers/:id/screenshot (waits 30s for result)\nPattern: register agent on remote machine → user queues commands → agent polls and executes\n","lang":"th","translated":true,"requested_lang":"th","content_markdown":"\n# Computer Control API\n\nComputer Control API ช่วยให้คุณควบคุม computer ที่ลงทะเบียนจากระยะไกล agent ตัวเล็ก ๆ (`screen-remote-agent`) รันบนเครื่องเป้าหมาย, poll หาคำสั่ง, ปฏิบัติตามคำสั่ง, และส่งผลลัพธ์กลับ ทำให้สามารถทำ GUI automation ที่ขับเคลื่อนด้วย LLM ได้\n\n## Architecture\n\n```\n┌─────────────┐  queue cmd   ┌──────────┐  poll   ┌─────────────────┐\n│ LLM Agent   │ ───────────▶ │ Synapse  │ ◀───── │ screen-remote   │\n│ (user-side) │              │  Server  │ ──────▶│ (on target PC)  │\n└─────────────┘              └──────────┘ result  └─────────────────┘\n                                     ▲\n                                     │\n                              ┌─────────────┐\n                              │  Human UI   │\n                              │ (browser)   │\n                              └─────────────┘\n```\n\n## User-Facing Endpoints (Mind Key or JWT)\n\n### GET /computers/list\n\nรายการ computer ที่ลงทะเบียนทั้งหมด\n\n```bash\ncurl -H \"Authorization: Bearer YOUR_MIND_KEY\" \\\n     https://synapse.schaefer.zone/computers/list\n```\n\n### GET /computers/:id\n\nดึงรายละเอียดของ computer เครื่องเดียว\n\n```bash\ncurl -H \"Authorization: Bearer YOUR_MIND_KEY\" \\\n     https://synapse.schaefer.zone/computers/comp_001\n```\n\n### POST /computers/install-code\n\nสร้าง install code สำหรับลงทะเบียน computer เครื่องใหม่\n\n```bash\ncurl -X POST https://synapse.schaefer.zone/computers/install-code \\\n  -H \"Authorization: Bearer YOUR_MIND_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"computer_name\": \"office-mac\"}'\n```\n\nResponse: `{ \"install_code\": \"ic_xyz789\", \"expires_at\": \"...\" }`\n\n### POST /computers/:id/commands\n\nจัดคิวคำสั่งให้ remote agent ปฏิบัติ\n\n```bash\ncurl -X POST https://synapse.schaefer.zone/computers/comp_001/commands \\\n  -H \"Authorization: Bearer YOUR_MIND_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"type\": \"screenshot\",\n    \"payload\": {}\n  }'\n```\n\nResponse: `{ \"command_id\": \"cmd_001\", \"status\": \"queued\" }`\n\n### GET /computers/:id/command (via query)\n\nจัดคิวคำสั่งผ่าน GET (สำหรับกรณีง่าย ๆ)\n\n```bash\ncurl -H \"Authorization: Bearer YOUR_MIND_KEY\" \\\n     \"https://synapse.schaefer.zone/computers/comp_001/command?type=screenshot\"\n```\n\n### GET /computers/:id/commands\n\nรายการคำสั่งล่าสุดของ computer\n\n```bash\ncurl -H \"Authorization: Bearer YOUR_MIND_KEY\" \\\n     \"https://synapse.schaefer.zone/computers/comp_001/commands?limit=50\"\n```\n\n### GET /computers/:id/commands/:cid\n\nดึงสถานะ + ผลลัพธ์ของคำสั่งเฉพาะ\n\n```bash\ncurl -H \"Authorization: Bearer YOUR_MIND_KEY\" \\\n     https://synapse.schaefer.zone/computers/comp_001/commands/cmd_001\n```\n\n### GET /computers/:id/screenshot\n\nแบบ one-shot: จัดคิวคำสั่ง screenshot และรอผลลัพธ์สูงสุด 30 วินาที\n\n```bash\ncurl -H \"Authorization: Bearer YOUR_MIND_KEY\" \\\n     https://synapse.schaefer.zone/computers/comp_001/screenshot > screenshot.png\n```\n\n### POST /computers/:id/disable\n\nปิดใช้งาน computer (เพิกถอน token แต่เก็บ record ไว้เพื่อ audit)\n\n```bash\ncurl -X POST -H \"Authorization: Bearer YOUR_MIND_KEY\" \\\n     https://synapse.schaefer.zone/computers/comp_001/disable\n```\n\n### DELETE /computers/:id\n\nลบ computer อย่างถาวร\n\n```bash\ncurl -X DELETE -H \"Authorization: Bearer YOUR_MIND_KEY\" \\\n     https://synapse.schaefer.zone/computers/comp_001\n```\n\n## Agent-Facing Endpoints (Computer Token)\n\nendpoint เหล่านี้ใช้โดย `screen-remote-agent` ที่รันอยู่บนเครื่องเป้าหมาย ใช้ Computer Token (ส่งกลับโดย `/computers/register`) ไม่ใช่ Mind Key\n\n### POST /computers/register\n\nแลกรับ install code เพื่อรับ Computer Token\n\n```bash\ncurl -X POST https://synapse.schaefer.zone/computers/register \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"code\": \"ic_xyz789\",\n    \"computer_name\": \"office-mac\",\n    \"platform\": \"darwin\",\n    \"platform_release\": \"14.5.0\",\n    \"python\": \"3.12.4\"\n  }'\n```\n\nResponse: `{ \"computer_id\": \"comp_001\", \"computer_token\": \"ct_...\" }`\n\n> [!CRITICAL]\n> บันทึก `computer_token` ไว้ — แสดงเพียงครั้งเดียวและต้องใช้สำหรับ endpoint ฝั่ง agent ทั้งหมด\n\n### GET /computers/me/poll\n\nLong-poll หาคำสั่งใหม่ agent เรียกสิ่งนี้ในลูป\n\n```bash\ncurl -H \"Authorization: Bearer ct_YOUR_COMPUTER_TOKEN\" \\\n     \"https://synapse.schaefer.zone/computers/me/poll?wait=30\"\n```\n\nส่งกลับทันทีหากมีคำสั่งรออยู่ หรือหลังจาก `wait` วินาที หากไม่มี\n\n### POST /computers/me/commands/:cid/result\n\nส่งผลลัพธ์การปฏิบัติคำสั่ง\n\n```bash\ncurl -X POST https://synapse.schaefer.zone/computers/me/commands/cmd_001/result \\\n  -H \"Authorization: Bearer ct_YOUR_COMPUTER_TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"status\": \"done\",\n    \"result\": { \"screenshot_b64\": \"iVBORw0KG...\" }\n  }'\n```\n\n## ประเภทคำสั่ง\n\n| Type | Payload | คำอธิบาย |\n|------|---------|-------------|\n| `screenshot` | `{}` | จับภาพหน้าจอเป็น PNG (base64) |\n| `click` | `{x, y}` | คลิกที่พิกัด |\n| `move` | `{x, y}` | เลื่อนเมาส์ไปยังพิกัด |\n| `type` | `{text}` | พิมพ์ข้อความที่ตำแหน่งเคอร์เซอร์ |\n| `key` | `{keys: [\"Ctrl\",\"c\"]}` | กดปุ่มผสม |\n| `scroll` | `{deltaX, deltaY}` | เลื่อน scroll wheel |\n| `drag` | `{fromX, fromY, toX, toY}` | ลากและวาง |\n\n## รูปแบบทั่วไป: LLM-Driven GUI Automation\n\n```python\n# LLM agent workflow\n1. List computers: GET /computers/list\n2. Take screenshot: GET /computers/:id/screenshot\n3. Analyze screenshot (vision model)\n4. Queue click: POST /computers/:id/commands {type:\"click\", payload:{x,y}}\n5. Wait for result: GET /computers/:id/commands/:cid\n6. Take new screenshot to verify\n7. Repeat until task done\n```\n\n## ขั้นตอนถัดไป\n\n- [Browser Proxy](/docs/api/browser) — service แยกต่างหากสำหรับ browser automation\n- [Self-Hosted Agents Guide](/docs/guides/self-hosted-agents)\n","content_html":"<h1>Computer Control API</h1>\n<p>Computer Control API ช่วยให้คุณควบคุม computer ที่ลงทะเบียนจากระยะไกล agent ตัวเล็ก ๆ (<code>screen-remote-agent</code>) รันบนเครื่องเป้าหมาย, poll หาคำสั่ง, ปฏิบัติตามคำสั่ง, และส่งผลลัพธ์กลับ ทำให้สามารถทำ GUI automation ที่ขับเคลื่อนด้วย LLM ได้</p>\n<h2>Architecture</h2>\n<pre><code class=\"hljs language-plaintext\">┌─────────────┐  queue cmd   ┌──────────┐  poll   ┌─────────────────┐\n│ LLM Agent   │ ───────────▶ │ Synapse  │ ◀───── │ screen-remote   │\n│ (user-side) │              │  Server  │ ──────▶│ (on target PC)  │\n└─────────────┘              └──────────┘ result  └─────────────────┘\n                                     ▲\n                                     │\n                              ┌─────────────┐\n                              │  Human UI   │\n                              │ (browser)   │\n                              └─────────────┘</code></pre><h2>User-Facing Endpoints (Mind Key or JWT)</h2>\n<h3>GET /computers/list</h3>\n<p>รายการ computer ที่ลงทะเบียนทั้งหมด</p>\n<pre><code class=\"hljs language-bash\">curl -H <span class=\"hljs-string\">&quot;Authorization: Bearer YOUR_MIND_KEY&quot;</span> \\\n     https://synapse.schaefer.zone/computers/list</code></pre><h3>GET /computers/:id</h3>\n<p>ดึงรายละเอียดของ computer เครื่องเดียว</p>\n<pre><code class=\"hljs language-bash\">curl -H <span class=\"hljs-string\">&quot;Authorization: Bearer YOUR_MIND_KEY&quot;</span> \\\n     https://synapse.schaefer.zone/computers/comp_001</code></pre><h3>POST /computers/install-code</h3>\n<p>สร้าง install code สำหรับลงทะเบียน computer เครื่องใหม่</p>\n<pre><code class=\"hljs language-bash\">curl -X POST https://synapse.schaefer.zone/computers/install-code \\\n  -H <span class=\"hljs-string\">&quot;Authorization: Bearer YOUR_MIND_KEY&quot;</span> \\\n  -H <span class=\"hljs-string\">&quot;Content-Type: application/json&quot;</span> \\\n  -d <span class=\"hljs-string\">&#x27;{&quot;computer_name&quot;: &quot;office-mac&quot;}&#x27;</span></code></pre><p>Response: <code>{ &quot;install_code&quot;: &quot;ic_xyz789&quot;, &quot;expires_at&quot;: &quot;...&quot; }</code></p>\n<h3>POST /computers/:id/commands</h3>\n<p>จัดคิวคำสั่งให้ remote agent ปฏิบัติ</p>\n<pre><code class=\"hljs language-bash\">curl -X POST https://synapse.schaefer.zone/computers/comp_001/commands \\\n  -H <span class=\"hljs-string\">&quot;Authorization: Bearer YOUR_MIND_KEY&quot;</span> \\\n  -H <span class=\"hljs-string\">&quot;Content-Type: application/json&quot;</span> \\\n  -d <span class=\"hljs-string\">&#x27;{\n    &quot;type&quot;: &quot;screenshot&quot;,\n    &quot;payload&quot;: {}\n  }&#x27;</span></code></pre><p>Response: <code>{ &quot;command_id&quot;: &quot;cmd_001&quot;, &quot;status&quot;: &quot;queued&quot; }</code></p>\n<h3>GET /computers/:id/command (via query)</h3>\n<p>จัดคิวคำสั่งผ่าน GET (สำหรับกรณีง่าย ๆ)</p>\n<pre><code class=\"hljs language-bash\">curl -H <span class=\"hljs-string\">&quot;Authorization: Bearer YOUR_MIND_KEY&quot;</span> \\\n     <span class=\"hljs-string\">&quot;https://synapse.schaefer.zone/computers/comp_001/command?type=screenshot&quot;</span></code></pre><h3>GET /computers/:id/commands</h3>\n<p>รายการคำสั่งล่าสุดของ computer</p>\n<pre><code class=\"hljs language-bash\">curl -H <span class=\"hljs-string\">&quot;Authorization: Bearer YOUR_MIND_KEY&quot;</span> \\\n     <span class=\"hljs-string\">&quot;https://synapse.schaefer.zone/computers/comp_001/commands?limit=50&quot;</span></code></pre><h3>GET /computers/:id/commands/:cid</h3>\n<p>ดึงสถานะ + ผลลัพธ์ของคำสั่งเฉพาะ</p>\n<pre><code class=\"hljs language-bash\">curl -H <span class=\"hljs-string\">&quot;Authorization: Bearer YOUR_MIND_KEY&quot;</span> \\\n     https://synapse.schaefer.zone/computers/comp_001/commands/cmd_001</code></pre><h3>GET /computers/:id/screenshot</h3>\n<p>แบบ one-shot: จัดคิวคำสั่ง screenshot และรอผลลัพธ์สูงสุด 30 วินาที</p>\n<pre><code class=\"hljs language-bash\">curl -H <span class=\"hljs-string\">&quot;Authorization: Bearer YOUR_MIND_KEY&quot;</span> \\\n     https://synapse.schaefer.zone/computers/comp_001/screenshot &gt; screenshot.png</code></pre><h3>POST /computers/:id/disable</h3>\n<p>ปิดใช้งาน computer (เพิกถอน token แต่เก็บ record ไว้เพื่อ audit)</p>\n<pre><code class=\"hljs language-bash\">curl -X POST -H <span class=\"hljs-string\">&quot;Authorization: Bearer YOUR_MIND_KEY&quot;</span> \\\n     https://synapse.schaefer.zone/computers/comp_001/disable</code></pre><h3>DELETE /computers/:id</h3>\n<p>ลบ computer อย่างถาวร</p>\n<pre><code class=\"hljs language-bash\">curl -X DELETE -H <span class=\"hljs-string\">&quot;Authorization: Bearer YOUR_MIND_KEY&quot;</span> \\\n     https://synapse.schaefer.zone/computers/comp_001</code></pre><h2>Agent-Facing Endpoints (Computer Token)</h2>\n<p>endpoint เหล่านี้ใช้โดย <code>screen-remote-agent</code> ที่รันอยู่บนเครื่องเป้าหมาย ใช้ Computer Token (ส่งกลับโดย <code>/computers/register</code>) ไม่ใช่ Mind Key</p>\n<h3>POST /computers/register</h3>\n<p>แลกรับ install code เพื่อรับ Computer Token</p>\n<pre><code class=\"hljs language-bash\">curl -X POST https://synapse.schaefer.zone/computers/register \\\n  -H <span class=\"hljs-string\">&quot;Content-Type: application/json&quot;</span> \\\n  -d <span class=\"hljs-string\">&#x27;{\n    &quot;code&quot;: &quot;ic_xyz789&quot;,\n    &quot;computer_name&quot;: &quot;office-mac&quot;,\n    &quot;platform&quot;: &quot;darwin&quot;,\n    &quot;platform_release&quot;: &quot;14.5.0&quot;,\n    &quot;python&quot;: &quot;3.12.4&quot;\n  }&#x27;</span></code></pre><p>Response: <code>{ &quot;computer_id&quot;: &quot;comp_001&quot;, &quot;computer_token&quot;: &quot;ct_...&quot; }</code></p>\n<div class=\"callout callout-critical\">บันทึก `computer_token` ไว้ — แสดงเพียงครั้งเดียวและต้องใช้สำหรับ endpoint ฝั่ง agent ทั้งหมด</div><h3>GET /computers/me/poll</h3>\n<p>Long-poll หาคำสั่งใหม่ agent เรียกสิ่งนี้ในลูป</p>\n<pre><code class=\"hljs language-bash\">curl -H <span class=\"hljs-string\">&quot;Authorization: Bearer ct_YOUR_COMPUTER_TOKEN&quot;</span> \\\n     <span class=\"hljs-string\">&quot;https://synapse.schaefer.zone/computers/me/poll?wait=30&quot;</span></code></pre><p>ส่งกลับทันทีหากมีคำสั่งรออยู่ หรือหลังจาก <code>wait</code> วินาที หากไม่มี</p>\n<h3>POST /computers/me/commands/:cid/result</h3>\n<p>ส่งผลลัพธ์การปฏิบัติคำสั่ง</p>\n<pre><code class=\"hljs language-bash\">curl -X POST https://synapse.schaefer.zone/computers/me/commands/cmd_001/result \\\n  -H <span class=\"hljs-string\">&quot;Authorization: Bearer ct_YOUR_COMPUTER_TOKEN&quot;</span> \\\n  -H <span class=\"hljs-string\">&quot;Content-Type: application/json&quot;</span> \\\n  -d <span class=\"hljs-string\">&#x27;{\n    &quot;status&quot;: &quot;done&quot;,\n    &quot;result&quot;: { &quot;screenshot_b64&quot;: &quot;iVBORw0KG...&quot; }\n  }&#x27;</span></code></pre><h2>ประเภทคำสั่ง</h2>\n<table>\n<thead>\n<tr>\n<th>Type</th>\n<th>Payload</th>\n<th>คำอธิบาย</th>\n</tr>\n</thead>\n<tbody><tr>\n<td><code>screenshot</code></td>\n<td><code>{}</code></td>\n<td>จับภาพหน้าจอเป็น PNG (base64)</td>\n</tr>\n<tr>\n<td><code>click</code></td>\n<td><code>{x, y}</code></td>\n<td>คลิกที่พิกัด</td>\n</tr>\n<tr>\n<td><code>move</code></td>\n<td><code>{x, y}</code></td>\n<td>เลื่อนเมาส์ไปยังพิกัด</td>\n</tr>\n<tr>\n<td><code>type</code></td>\n<td><code>{text}</code></td>\n<td>พิมพ์ข้อความที่ตำแหน่งเคอร์เซอร์</td>\n</tr>\n<tr>\n<td><code>key</code></td>\n<td><code>{keys: [&quot;Ctrl&quot;,&quot;c&quot;]}</code></td>\n<td>กดปุ่มผสม</td>\n</tr>\n<tr>\n<td><code>scroll</code></td>\n<td><code>{deltaX, deltaY}</code></td>\n<td>เลื่อน scroll wheel</td>\n</tr>\n<tr>\n<td><code>drag</code></td>\n<td><code>{fromX, fromY, toX, toY}</code></td>\n<td>ลากและวาง</td>\n</tr>\n</tbody></table>\n<h2>รูปแบบทั่วไป: LLM-Driven GUI Automation</h2>\n<pre><code class=\"hljs language-python\"><span class=\"hljs-comment\"># LLM agent workflow</span>\n<span class=\"hljs-number\">1.</span> <span class=\"hljs-type\">List</span> computers: GET /computers/<span class=\"hljs-built_in\">list</span>\n<span class=\"hljs-number\">2.</span> Take screenshot: GET /computers/:<span class=\"hljs-built_in\">id</span>/screenshot\n<span class=\"hljs-number\">3.</span> Analyze screenshot (vision model)\n<span class=\"hljs-number\">4.</span> Queue click: POST /computers/:<span class=\"hljs-built_in\">id</span>/commands {<span class=\"hljs-built_in\">type</span>:<span class=\"hljs-string\">&quot;click&quot;</span>, payload:{x,y}}\n<span class=\"hljs-number\">5.</span> Wait <span class=\"hljs-keyword\">for</span> result: GET /computers/:<span class=\"hljs-built_in\">id</span>/commands/:cid\n<span class=\"hljs-number\">6.</span> Take new screenshot to verify\n<span class=\"hljs-number\">7.</span> Repeat until task done</code></pre><h2>ขั้นตอนถัดไป</h2>\n<ul>\n<li><a href=\"/docs/api/browser\">Browser Proxy</a> — service แยกต่างหากสำหรับ browser automation</li>\n<li><a href=\"/docs/guides/self-hosted-agents\">Self-Hosted Agents Guide</a></li>\n</ul>\n","urls":{"html":"/docs/api/computers","text":"/docs/api/computers?format=text","json":"/docs/api/computers?format=json","llm":"/docs/api/computers?format=llm"},"translations_available":["en","zh","hi","es","fr","ar","pt","ru","ja","de","it","ko","nl","pl","tr","sv","vi","th","id","uk"]}