# User & Minds API La User & Minds API gestisce la gestione dell'account. Questi endpoint usano l'autenticazione JWT (non Mind Key) perché operano a livello di account, non di mente. ## Endpoint di autenticazione ### POST /register Crea un nuovo account utente. ```bash curl -X POST https://synapse.schaefer.zone/register \ -H "Content-Type: application/json" \ -d '{ "email": "you@example.com", "password": "your-secure-password", "display_name": "Michael" }' ``` Risposta: ```json { "jwt": "eyJhbGci...", "user": { "id": "u_abc123", "email": "you@example.com", "display_name": "Michael", "created_at": "2026-06-27T..." } } ``` ### POST /login Accede a un account esistente. ```bash curl -X POST https://synapse.schaefer.zone/login \ -H "Content-Type: application/json" \ -d '{ "email": "you@example.com", "password": "your-secure-password" }' ``` Risposta: uguale a `/register`. ## Endpoint delle menti ### POST /minds Crea una nuova mente. Restituisce la Mind Key — **la salvi immediatamente**, viene mostrata una sola volta. ```bash curl -X POST https://synapse.schaefer.zone/minds \ -H "Authorization: Bearer YOUR_JWT" \ -H "Content-Type: application/json" \ -d '{ "name": "Work Mind", "description": "Job-related memories" }' ``` Risposta: ```json { "id": "m_xyz789", "name": "Work Mind", "description": "Job-related memories", "mind_key": "mk_aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789", "created_at": "2026-06-27T..." } ``` > [!CRITICAL] > La `mind_key` viene mostrata una sola volta. Se la perde, non può recuperarla — > deve eliminare la mente e crearne una nuova (perdendo tutte le memorie salvate). ### GET /minds Elenca tutte le menti dell'utente corrente. ```bash curl -H "Authorization: Bearer YOUR_JWT" \ https://synapse.schaefer.zone/minds ``` Risposta: ```json { "minds": [ { "id": "m_xyz789", "name": "Work Mind", "description": "Job-related memories", "created_at": "2026-06-27T...", "memory_count": 142, "last_activity": "2026-06-27T..." } ] } ``` ### DELETE /minds/:id Elimina una mente permanentemente. ```bash curl -X DELETE -H "Authorization: Bearer YOUR_JWT" \ https://synapse.schaefer.zone/minds/m_xyz789 ``` > [!WARNING] > L'eliminazione di una mente è **irreversibile**. Tutte le memorie, le > attività, la cronologia chat e gli script in quella mente vengono persi > definitivamente. Esporti prima tramite `GET /memory/mind-export` se ha bisogno > di un backup. ## Modello multi-mente La maggior parte degli utenti beneficia di più menti per mantenere i contesti isolati: ```bash # Create minds for different contexts curl -X POST .../minds -d '{"name": "work", "description": "Job"}' # → mind_key: mk_work... curl -X POST .../minds -d '{"name": "personal", "description": "Personal life"}' # → mind_key: mk_personal... curl -X POST .../minds -d '{"name": "project-synapse", "description": "Synapse dev"}' # → mind_key: mk_synapse... ``` Usi Mind Key diverse in sessioni LLM diverse per mantenere i contesti isolati. ## Sicurezza dell'account ### Requisiti della password - Minimo 6 caratteri - Nessun massimo (usi un password manager) - Salvata come hash bcrypt (mai in chiaro) ### Scadenza JWT I JWT scadono dopo **7 giorni**. Quando scadono, chiami semplicemente `/login` nuovamente. ### Sicurezza della Mind Key Le Mind Key non scadono mai. Se una Mind Key viene compromessa: 1. Crei una nuova mente tramite `POST /minds` 2. Aggiorni la configurazione LLM con la nuova Mind Key 3. Elimini la mente compromessa tramite `DELETE /minds/:id` ## Prossimi passi - [Autenticazione](/docs/getting-started/authentication) — guida auth completa - [Mind Key vs JWT](/docs/getting-started/mind-key-vs-jwt) — guida decisionale - [API Sharing](/docs/api/user) — condivida menti con altri utenti