Référence REST
REST · Comptes et sessions
Inscription, connexion, 2FA, QR code, sessions, e-mail, mot de passe et droits RGPD.
Le détail du fonctionnement (durée des jetons, renouvellement, QR code) est dans Authentification. Ci-dessous, toutes les routes.
Authentification — /api/auth
Règles d'inscription en vigueur (ouverture, invitation requise, captcha).
GET https://gateway.alfychat.app/api/auth/register/settings
Succès : 200
curl -X GET "https://gateway.alfychat.app/api/auth/register/settings"Crée un compte et renvoie les jetons d'accès.
POST https://gateway.alfychat.app/api/auth/register
Corps JSON
| obligatoire | ||
| username | texte · longueur 3–32 · format imposé | obligatoire |
| password | texte · longueur 8–128 | obligatoire |
| displayName | texte · longueur 0–64 | facultatif |
| inviteCode | texte | facultatif |
| turnstileToken | texte | facultatif |
| publicKey | texte | facultatif |
| encryptedPrivateKey | texte | facultatif |
| keySalt | texte · longueur 0–64 | facultatif |
Succès : 201, 403
curl -X POST "https://gateway.alfychat.app/api/auth/register" \
-H "Content-Type: application/json" \
-d '{"email":"…","username":"…","password":"…"}'Connexion par e-mail ou nom d'utilisateur et mot de passe ; demande le 2FA si activé.
POST https://gateway.alfychat.app/api/auth/login
Corps JSON
| obligatoire | ||
| password | texte · longueur 1–128 | obligatoire |
| turnstileToken | — | facultatif |
Succès : 200, 403
curl -X POST "https://gateway.alfychat.app/api/auth/login" \
-H "Content-Type: application/json" \
-d '{"email":"…","password":"…","turnstileToken":"…"}'Termine la connexion avec le code d'authentification à deux facteurs.
POST https://gateway.alfychat.app/api/auth/2fa/login
Corps JSON
| twoFactorToken | texte | obligatoire |
| code | texte · longueur 6–8 | obligatoire |
Erreurs
- 400Données manquantes
Succès : 200
curl -X POST "https://gateway.alfychat.app/api/auth/2fa/login" \
-H "Content-Type: application/json" \
-d '{"twoFactorToken":"…","code":"…"}'Échange un refresh token contre un nouveau jeton d'accès (rotation du refresh token).
POST https://gateway.alfychat.app/api/auth/refresh
Corps JSON
| refreshToken | texte | obligatoire |
Erreurs
- 400Refresh token requis
Succès : 200
curl -X POST "https://gateway.alfychat.app/api/auth/refresh" \
-H "Content-Type: application/json" \
-d '{"refreshToken":"…"}'Ferme la session courante.
POST https://gateway.alfychat.app/api/auth/logout
Corps JSON
| refreshToken | — | facultatif |
Succès : 200
curl -X POST "https://gateway.alfychat.app/api/auth/logout" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"refreshToken":"…"}'Ferme toutes les sessions du compte.
POST https://gateway.alfychat.app/api/auth/logout-all
Erreurs
- 401Non authentifié
Succès : 200
curl -X POST "https://gateway.alfychat.app/api/auth/logout-all" \
-H "Authorization: Bearer $ACCESS_TOKEN"Vérifie la validité du jeton d'accès et renvoie l'identité associée.
GET https://gateway.alfychat.app/api/auth/verify
Succès : 200
curl -X GET "https://gateway.alfychat.app/api/auth/verify" \
-H "Authorization: Bearer $ACCESS_TOKEN"Démarre une connexion par QR code : renvoie un code à afficher.
POST https://gateway.alfychat.app/api/auth/remote/init
Corps JSON
| ephemeralPublicKey | texte · longueur 1–2048 | obligatoire |
Erreurs
- 400Clé éphémère requise
- 400Impossible de générer le code
Succès : 200
curl -X POST "https://gateway.alfychat.app/api/auth/remote/init" \
-H "Content-Type: application/json" \
-d '{"ephemeralPublicKey":"…"}'Interroge l'état d'une connexion par QR code (en attente, approuvée, refusée).
GET https://gateway.alfychat.app/api/auth/remote/poll
Erreurs
- 400Paramètres manquants
Succès : 200
curl -X GET "https://gateway.alfychat.app/api/auth/remote/poll"Un appareil déjà connecté lit le QR code.
POST https://gateway.alfychat.app/api/auth/remote/claim
Corps JSON
| deviceCode | texte · longueur 32–32 | obligatoire |
Erreurs
- 400Code requis
- 401Authentification requise
- 410Ce code a déjà été utilisé
- 410Code inconnu ou expiré
Succès : 200
curl -X POST "https://gateway.alfychat.app/api/auth/remote/claim" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"deviceCode":"…"}'Approuve la connexion de l'autre appareil.
POST https://gateway.alfychat.app/api/auth/remote/approve
Corps JSON
| deviceCode | texte · longueur 32–32 | obligatoire |
| encryptedKeyPayload | texte · longueur 0–8192 | facultatif |
Erreurs
- 400Code requis
- 401Authentification requise
- 410Ce code appartient à une autre session
- 410Ce code doit d’abord être scanné
- 410Charge de clé trop volumineuse
- 410Code inconnu ou expiré
- 410Utilisateur introuvable
Succès : 200
curl -X POST "https://gateway.alfychat.app/api/auth/remote/approve" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"deviceCode":"…","encryptedKeyPayload":"…"}'Refuse la connexion de l'autre appareil.
POST https://gateway.alfychat.app/api/auth/remote/deny
Corps JSON
| deviceCode | texte · longueur 32–32 | obligatoire |
Erreurs
- 400Code requis
- 401Authentification requise
- 410Ce code a déjà été approuvé
- 410Ce code appartient à une autre session
- 410Code inconnu ou expiré
Succès : 200
curl -X POST "https://gateway.alfychat.app/api/auth/remote/deny" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"deviceCode":"…"}'POST https://gateway.alfychat.app/api/auth/sso/code
Corps JSON
| returnUrl | texte · longueur 1–2048 | obligatoire |
Erreurs
- 400URL de retour invalide
- 401Authentification requise
- 403Origine non autorisée
Succès : 200
curl -X POST "https://gateway.alfychat.app/api/auth/sso/code" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"returnUrl":"…"}'POST https://gateway.alfychat.app/api/auth/sso/exchange
Corps JSON
| code | texte · longueur 64–64 | obligatoire |
Erreurs
- 401Lien de connexion invalide ou expiré
- 401Utilisateur introuvable
Succès : 200
curl -X POST "https://gateway.alfychat.app/api/auth/sso/exchange" \
-H "Content-Type: application/json" \
-d '{"code":"…"}'Valide l'adresse e-mail avec le jeton reçu par courriel.
GET https://gateway.alfychat.app/api/auth/verify-email
Erreurs
- 400Token manquant
Succès : 200
curl -X GET "https://gateway.alfychat.app/api/auth/verify-email"Renvoie l'e-mail de vérification du compte connecté.
POST https://gateway.alfychat.app/api/auth/resend-verification
Erreurs
- 401Non authentifié
Succès : 200
curl -X POST "https://gateway.alfychat.app/api/auth/resend-verification" \
-H "Authorization: Bearer $ACCESS_TOKEN"Renvoie l'e-mail de vérification à une adresse donnée.
POST https://gateway.alfychat.app/api/auth/resend-verification-email
Corps JSON
| obligatoire |
Erreurs
- 400Email requis
Succès : 200
curl -X POST "https://gateway.alfychat.app/api/auth/resend-verification-email" \
-H "Content-Type: application/json" \
-d '{"email":"…"}'Envoie un lien de réinitialisation du mot de passe.
POST https://gateway.alfychat.app/api/auth/forgot-password
Corps JSON
| obligatoire |
Erreurs
- 400Email requis
Succès : 200
curl -X POST "https://gateway.alfychat.app/api/auth/forgot-password" \
-H "Content-Type: application/json" \
-d '{"email":"…"}'Définit un nouveau mot de passe avec le jeton reçu par courriel.
POST https://gateway.alfychat.app/api/auth/reset-password
Corps JSON
| token | texte · longueur ≥ 1 | obligatoire |
| password | texte · longueur 8–128 | obligatoire |
Erreurs
- 400Le mot de passe doit comporter au moins 8 caractères
- 400Token et mot de passe requis
Succès : 200
curl -X POST "https://gateway.alfychat.app/api/auth/reset-password" \
-H "Content-Type: application/json" \
-d '{"token":"…","password":"…"}'Indique si le 2FA est activé.
GET https://gateway.alfychat.app/api/auth/2fa/status
Erreurs
- 401Non authentifié
Succès : 200
curl -X GET "https://gateway.alfychat.app/api/auth/2fa/status" \
-H "Authorization: Bearer $ACCESS_TOKEN"Génère le secret TOTP et le QR code d'activation du 2FA.
POST https://gateway.alfychat.app/api/auth/2fa/setup
Erreurs
- 401Non authentifié
- 404Utilisateur non trouvé
Succès : 200
curl -X POST "https://gateway.alfychat.app/api/auth/2fa/setup" \
-H "Authorization: Bearer $ACCESS_TOKEN"Active le 2FA après vérification d'un premier code.
POST https://gateway.alfychat.app/api/auth/2fa/enable
Corps JSON
| code | texte · longueur 6–6 | obligatoire |
Erreurs
- 400Code requis
- 401Non authentifié
Succès : 200
curl -X POST "https://gateway.alfychat.app/api/auth/2fa/enable" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"code":"…"}'Désactive le 2FA (code ou mot de passe requis).
POST https://gateway.alfychat.app/api/auth/2fa/disable
Corps JSON
| code | texte · longueur 6–8 | obligatoire |
Erreurs
- 400Code requis
- 401Non authentifié
Succès : 200
curl -X POST "https://gateway.alfychat.app/api/auth/2fa/disable" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"code":"…"}'Récupère ses clés de chiffrement stockées.
GET https://gateway.alfychat.app/api/auth/keys
Erreurs
- 401Non authentifié
Succès : 200
curl -X GET "https://gateway.alfychat.app/api/auth/keys" \
-H "Authorization: Bearer $ACCESS_TOKEN"Enregistre ses clés de chiffrement.
PATCH https://gateway.alfychat.app/api/auth/keys
Corps JSON
| publicKey | texte | obligatoire |
| encryptedPrivateKey | texte | obligatoire |
| keySalt | texte · longueur 0–64 | obligatoire |
| password | — | facultatif |
Erreurs
- 400Données manquantes
- 401Non authentifié
Succès : 200
curl -X PATCH "https://gateway.alfychat.app/api/auth/keys" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"publicKey":"…","encryptedPrivateKey":"…","keySalt":"…","password":"…"}'Profil du compte connecté (alias de GET /users/me).
GET https://gateway.alfychat.app/api/auth/me
Erreurs
- 401Non authentifié
- 404Utilisateur non trouvé
Succès : 200
curl -X GET "https://gateway.alfychat.app/api/auth/me" \
-H "Authorization: Bearer $ACCESS_TOKEN"Liste des sessions actives (appareil, IP, dernière activité).
GET https://gateway.alfychat.app/api/auth/sessions
Erreurs
- 401Non authentifié
Succès : 200
curl -X GET "https://gateway.alfychat.app/api/auth/sessions" \
-H "Authorization: Bearer $ACCESS_TOKEN"Révoque une session.
DELETE https://gateway.alfychat.app/api/auth/sessions/{id}
Erreurs
- 401Non authentifié
Succès : 200
curl -X DELETE "https://gateway.alfychat.app/api/auth/sessions/<id>" \
-H "Authorization: Bearer $ACCESS_TOKEN"Données personnelles — /api/rgpd
Export, consentements, suppression (30 jours de délai de rétractation) et anonymisation. Les variantes avec {userId} sont historiques : préférez celles sans identifiant, qui agissent sur le compte connecté.
Exporte toutes ses données personnelles.
GET https://gateway.alfychat.app/api/rgpd/export
Succès : 200
curl -X GET "https://gateway.alfychat.app/api/rgpd/export" \
-H "Authorization: Bearer $ACCESS_TOKEN"Demande une exportation des données personnelles.
POST https://gateway.alfychat.app/api/rgpd/export
Succès : 200
curl -X POST "https://gateway.alfychat.app/api/rgpd/export" \
-H "Authorization: Bearer $ACCESS_TOKEN"Programme la suppression du compte (délai de rétractation).
POST https://gateway.alfychat.app/api/rgpd/delete
Succès : 200
curl -X POST "https://gateway.alfychat.app/api/rgpd/delete" \
-H "Authorization: Bearer $ACCESS_TOKEN"Annule la suppression programmée du compte.
DELETE https://gateway.alfychat.app/api/rgpd/delete
Succès : 200
curl -X DELETE "https://gateway.alfychat.app/api/rgpd/delete" \
-H "Authorization: Bearer $ACCESS_TOKEN"Consentements enregistrés.
GET https://gateway.alfychat.app/api/rgpd/consents
Succès : 200
curl -X GET "https://gateway.alfychat.app/api/rgpd/consents" \
-H "Authorization: Bearer $ACCESS_TOKEN"Met à jour un consentement.
PUT https://gateway.alfychat.app/api/rgpd/consents
Corps JSON
| type | ∈ {necessary, analytics, marketing} | obligatoire |
| granted | booléen | obligatoire |
| consentType | ∈ {necessary, analytics, marketing} | obligatoire |
Succès : 200
curl -X PUT "https://gateway.alfychat.app/api/rgpd/consents" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"type":"…","granted":"…","consentType":"…"}'Anonymise le compte immédiatement.
POST https://gateway.alfychat.app/api/rgpd/anonymize
Succès : 200
curl -X POST "https://gateway.alfychat.app/api/rgpd/anonymize" \
-H "Authorization: Bearer $ACCESS_TOKEN"Variante historique avec identifiant explicite (export).
GET https://gateway.alfychat.app/api/rgpd/{userId}/export
Succès : 200
curl -X GET "https://gateway.alfychat.app/api/rgpd/<userId>/export" \
-H "Authorization: Bearer $ACCESS_TOKEN"Variante historique avec identifiant explicite (suppression).
POST https://gateway.alfychat.app/api/rgpd/{userId}/delete
Succès : 200
curl -X POST "https://gateway.alfychat.app/api/rgpd/<userId>/delete" \
-H "Authorization: Bearer $ACCESS_TOKEN"Variante historique avec identifiant explicite (annulation).
DELETE https://gateway.alfychat.app/api/rgpd/{userId}/delete
Succès : 200
curl -X DELETE "https://gateway.alfychat.app/api/rgpd/<userId>/delete" \
-H "Authorization: Bearer $ACCESS_TOKEN"Variante historique avec identifiant explicite (consentements).
GET https://gateway.alfychat.app/api/rgpd/{userId}/consents
Succès : 200
curl -X GET "https://gateway.alfychat.app/api/rgpd/<userId>/consents" \
-H "Authorization: Bearer $ACCESS_TOKEN"Variante historique avec identifiant explicite (mise à jour).
PATCH https://gateway.alfychat.app/api/rgpd/{userId}/consents
Corps JSON
| type | ∈ {necessary, analytics, marketing} | obligatoire |
| granted | booléen | obligatoire |
| consentType | ∈ {necessary, analytics, marketing} | obligatoire |
Succès : 200
curl -X PATCH "https://gateway.alfychat.app/api/rgpd/<userId>/consents" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"type":"…","granted":"…","consentType":"…"}'Variante historique avec identifiant explicite (anonymisation).
POST https://gateway.alfychat.app/api/rgpd/{userId}/anonymize
Succès : 200
curl -X POST "https://gateway.alfychat.app/api/rgpd/<userId>/anonymize" \
-H "Authorization: Bearer $ACCESS_TOKEN"