Référence REST
REST · Messages et conversations
Historique, recherche, modification, réactions, groupes, épinglage et archives.
L’envoi d’un message se fait en temps réel (message:send, voir Évènements client) pour profiter de la diffusion instantanée ; le REST sert à lire l’historique, rechercher, modifier et gérer les conversations. L’identifiant d’un MP est dm_<idA>_<idB> (les deux UUID triés).
Messages
Historique d'un message privé (`recipientId`) ou d'une conversation (`conversationId`), paginé (`limit`, `before`).
GET https://gateway.alfychat.app/api/messages
Erreurs
- 403Accès non autorisé
Succès : 200
curl -X GET "https://gateway.alfychat.app/api/messages" \
-H "Authorization: Bearer $ACCESS_TOKEN"Enregistre un message (appel interne du gateway ; les clients passent par Socket.IO).
POST https://gateway.alfychat.app/api/messages
Corps JSON
| id | UUID | facultatif |
| conversationId | texte · NotEmpty | obligatoire |
| senderId | UUID | obligatoire |
| content | NotEmpty · longueur 0–131072 | obligatoire |
| senderContent | texte · longueur 0–131072 | facultatif |
| e2eeType | ToInt · ∈ {1, 3, 4} | facultatif |
| replyToId | UUID | facultatif |
Erreurs
- 403Accès interdit — réservé aux services internes
curl -X POST "https://gateway.alfychat.app/api/messages" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"conversationId":"…","senderId":"…","content":"…"}'Recherche plein texte dans ses conversations.
GET https://gateway.alfychat.app/api/messages/search
Paramètres de requête
| conversationId | texte · NotEmpty | obligatoire |
| q | texte · longueur 1–200 | obligatoire |
| limit | MinMax | facultatif |
| before | date ISO 8601 | facultatif |
Erreurs
- 403Accès non autorisé
curl -X GET "https://gateway.alfychat.app/api/messages/search" \
-H "Authorization: Bearer $ACCESS_TOKEN"Messages d'une conversation, du plus récent au plus ancien.
GET https://gateway.alfychat.app/api/messages/conversation/{conversationId}
Paramètres de requête
| limit | MinMax | facultatif |
| before | date ISO 8601 | facultatif |
Erreurs
- 403Accès non autorisé
curl -X GET "https://gateway.alfychat.app/api/messages/conversation/<conversationId>" \
-H "Authorization: Bearer $ACCESS_TOKEN"Détail d'un message.
GET https://gateway.alfychat.app/api/messages/{messageId}
Erreurs
- 404Message non trouvé
Succès : 200
curl -X GET "https://gateway.alfychat.app/api/messages/<messageId>" \
-H "Authorization: Bearer $ACCESS_TOKEN"Modifie le contenu d'un de ses messages.
PATCH https://gateway.alfychat.app/api/messages/{messageId}
Corps JSON
| content | NotEmpty · longueur 0–131072 | obligatoire |
| senderContent | texte · longueur 0–131072 | facultatif |
| e2eeType | ToInt · ∈ {1, 3, 4} | facultatif |
Erreurs
- 404Message non trouvé ou non autorisé
Succès : 200
curl -X PATCH "https://gateway.alfychat.app/api/messages/<messageId>" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"content":"…","senderContent":"…","e2eeType":"…"}'Supprime un de ses messages.
DELETE https://gateway.alfychat.app/api/messages/{messageId}
Erreurs
- 404Message non trouvé ou non autorisé
Succès : 200
curl -X DELETE "https://gateway.alfychat.app/api/messages/<messageId>" \
-H "Authorization: Bearer $ACCESS_TOKEN"Ajoute une réaction (émoji).
POST https://gateway.alfychat.app/api/messages/{messageId}/reactions
Corps JSON
| emoji | texte · longueur 1–50 | obligatoire |
Succès : 200
curl -X POST "https://gateway.alfychat.app/api/messages/<messageId>/reactions" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"emoji":"…"}'Retire sa réaction.
DELETE https://gateway.alfychat.app/api/messages/{messageId}/reactions/{emoji}
Succès : 200
curl -X DELETE "https://gateway.alfychat.app/api/messages/<messageId>/reactions/<emoji>" \
-H "Authorization: Bearer $ACCESS_TOKEN"Marque la conversation comme lue.
POST https://gateway.alfychat.app/api/messages/conversation/{conversationId}/read
Succès : 200
curl -X POST "https://gateway.alfychat.app/api/messages/conversation/<conversationId>/read" \
-H "Authorization: Bearer $ACCESS_TOKEN"Envoie un message vocal (audio enregistré).
POST https://gateway.alfychat.app/api/messages/voice
Erreurs
- 400Fichier audio requis
- 400conversationId requis
- 403Accès non autorisé
Succès : 201, 500
curl -X POST "https://gateway.alfychat.app/api/messages/voice" \
-H "Authorization: Bearer $ACCESS_TOKEN"Supprime tous les messages d'un utilisateur (RGPD / modération).
DELETE https://gateway.alfychat.app/api/messages/user/{userId}/all
Erreurs
- 403Non autorisé
Succès : 200
curl -X DELETE "https://gateway.alfychat.app/api/messages/user/<userId>/all" \
-H "Authorization: Bearer $ACCESS_TOKEN"Conversations et groupes
Liste ses conversations (messages privés et groupes) avec le dernier message.
GET https://gateway.alfychat.app/api/conversations
Erreurs
- 401Non authentifié
Succès : 200
curl -X GET "https://gateway.alfychat.app/api/conversations" \
-H "Authorization: Bearer $ACCESS_TOKEN"Crée un groupe de discussion.
POST https://gateway.alfychat.app/api/conversations
Corps JSON
| type | ∈ {dm, group} | obligatoire |
| participantIds | tableau | obligatoire |
| participantIds.* | texte | obligatoire |
| name | texte · longueur 0–100 | facultatif |
| avatarUrl | texte | facultatif |
Erreurs
- 400Au moins deux participants sont requis
- 400Un MP compte exactement deux participants
- 400Un groupe compte au plus 100 participants
- 401Non authentifié
Succès : 201
curl -X POST "https://gateway.alfychat.app/api/conversations" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"type":"…","participantIds":"…"}'Ouvre (ou récupère) un message privé avec un utilisateur.
POST https://gateway.alfychat.app/api/conversations/dm
Corps JSON
| recipientId | texte | obligatoire |
Erreurs
- 401Non authentifié
Succès : 200
curl -X POST "https://gateway.alfychat.app/api/conversations/dm" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"recipientId":"…"}'Conversations d'un utilisateur (usage interne et administration).
GET https://gateway.alfychat.app/api/conversations/user/{userId}
Erreurs
- 403Accès non autorisé
Succès : 200
curl -X GET "https://gateway.alfychat.app/api/conversations/user/<userId>" \
-H "Authorization: Bearer $ACCESS_TOKEN"Conversations épinglées.
GET https://gateway.alfychat.app/api/conversations/pinned
Succès : 200
curl -X GET "https://gateway.alfychat.app/api/conversations/pinned" \
-H "Authorization: Bearer $ACCESS_TOKEN"Détail d'une conversation et de ses participants.
GET https://gateway.alfychat.app/api/conversations/{conversationId}
Erreurs
- 401Non authentifié
- 403Accès non autorisé
- 404Conversation non trouvée
Succès : 200
curl -X GET "https://gateway.alfychat.app/api/conversations/<conversationId>" \
-H "Authorization: Bearer $ACCESS_TOKEN"Modifie le nom, l'avatar ou l'ouverture d'un groupe.
PATCH https://gateway.alfychat.app/api/conversations/{conversationId}
Corps JSON
| name | texte · longueur 0–100 | facultatif |
| avatarUrl | texte | facultatif |
Erreurs
- 403Accès non autorisé
- 403Seul le propriétaire peut ouvrir ou fermer le groupe
Succès : 200
curl -X PATCH "https://gateway.alfychat.app/api/conversations/<conversationId>" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name":"…","avatarUrl":"…"}'Participants d'une conversation (appel interne).
GET https://gateway.alfychat.app/api/conversations/{conversationId}/participants
Erreurs
- 403Accès interdit — réservé aux services internes
curl -X GET "https://gateway.alfychat.app/api/conversations/<conversationId>/participants" \
-H "Authorization: Bearer $ACCESS_TOKEN"Vérifie qu'un utilisateur participe à la conversation (appel interne).
GET https://gateway.alfychat.app/api/conversations/{conversationId}/participants/{userId}/check
Erreurs
- 403Accès interdit — réservé aux services internes
curl -X GET "https://gateway.alfychat.app/api/conversations/<conversationId>/participants/<userId>/check" \
-H "Authorization: Bearer $ACCESS_TOKEN"Ajoute un participant à un groupe.
POST https://gateway.alfychat.app/api/conversations/{conversationId}/participants
Corps JSON
| userId | texte | obligatoire |
Erreurs
- 400Seuls les groupes acceptent de nouveaux membres
- 400Un groupe compte au plus 100 participants
- 400userId invalide
- 403Accès non autorisé
- 403Ce groupe est fermé. Seul le propriétaire peut ajouter des membres.
- 403Impossible d'ajouter cet utilisateur
Succès : 200
curl -X POST "https://gateway.alfychat.app/api/conversations/<conversationId>/participants" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"userId":"…"}'Retire un participant d'un groupe.
DELETE https://gateway.alfychat.app/api/conversations/{conversationId}/participants/{userId}
Erreurs
- 403Accès non autorisé
- 403Permissions insuffisantes
Succès : 200
curl -X DELETE "https://gateway.alfychat.app/api/conversations/<conversationId>/participants/<userId>" \
-H "Authorization: Bearer $ACCESS_TOKEN"Quitte un groupe (la propriété est transférée si besoin).
POST https://gateway.alfychat.app/api/conversations/{conversationId}/leave
Succès : 200
curl -X POST "https://gateway.alfychat.app/api/conversations/<conversationId>/leave" \
-H "Authorization: Bearer $ACCESS_TOKEN"Supprime un groupe (propriétaire).
DELETE https://gateway.alfychat.app/api/conversations/{conversationId}
Erreurs
- 403Seul le propriétaire peut supprimer le groupe
Succès : 200
curl -X DELETE "https://gateway.alfychat.app/api/conversations/<conversationId>" \
-H "Authorization: Bearer $ACCESS_TOKEN"Épingle la conversation.
POST https://gateway.alfychat.app/api/conversations/{conversationId}/pin
Succès : 200
curl -X POST "https://gateway.alfychat.app/api/conversations/<conversationId>/pin" \
-H "Authorization: Bearer $ACCESS_TOKEN"Désépingle la conversation.
DELETE https://gateway.alfychat.app/api/conversations/{conversationId}/pin
Succès : 200
curl -X DELETE "https://gateway.alfychat.app/api/conversations/<conversationId>/pin" \
-H "Authorization: Bearer $ACCESS_TOKEN"Archives
État de l'archivage pair-à-pair d'une conversation.
GET https://gateway.alfychat.app/api/archive/status/{conversationId}
Erreurs
- 403Accès non autorisé
curl -X GET "https://gateway.alfychat.app/api/archive/status/<conversationId>" \
-H "Authorization: Bearer $ACCESS_TOKEN"Statistiques d'archivage d'une conversation.
GET https://gateway.alfychat.app/api/archive/stats/{conversationId}
Erreurs
- 403Accès non autorisé
curl -X GET "https://gateway.alfychat.app/api/archive/stats/<conversationId>" \
-H "Authorization: Bearer $ACCESS_TOKEN"Quota de messages conservés côté serveur.
GET https://gateway.alfychat.app/api/archive/quota/{conversationId}
Erreurs
- 403Accès non autorisé
curl -X GET "https://gateway.alfychat.app/api/archive/quota/<conversationId>" \
-H "Authorization: Bearer $ACCESS_TOKEN"Confirme qu'un client a reçu et stocké des messages archivés.
POST https://gateway.alfychat.app/api/archive/confirm
Corps JSON
| conversationId | texte · NotEmpty | obligatoire |
| archiveLogId | texte · NotEmpty | obligatoire |
Erreurs
- 403Accès non autorisé
Succès : 200
curl -X POST "https://gateway.alfychat.app/api/archive/confirm" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"conversationId":"…","archiveLogId":"…"}'Récupère un message archivé depuis le cache serveur.
GET https://gateway.alfychat.app/api/archive/message/{messageId}
Succès : 200
curl -X GET "https://gateway.alfychat.app/api/archive/message/<messageId>" \
-H "Authorization: Bearer $ACCESS_TOKEN"Met en cache des messages fournis par un pair (appel interne).
POST https://gateway.alfychat.app/api/archive/cache
Corps JSON
| messages | tableau | obligatoire |
Erreurs
- 403Accès interdit — réservé aux services internes
curl -X POST "https://gateway.alfychat.app/api/archive/cache" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"messages":"…"}'Tâche de maintenance de l'archive (appel interne).
POST https://gateway.alfychat.app/api/archive/maintenance
Erreurs
- 403Accès interdit — réservé aux services internes
curl -X POST "https://gateway.alfychat.app/api/archive/maintenance" \
-H "Authorization: Bearer $ACCESS_TOKEN"Configuration de la base de données externe de l'utilisateur.
GET https://gateway.alfychat.app/api/archive/external-db
Succès : 200
curl -X GET "https://gateway.alfychat.app/api/archive/external-db" \
-H "Authorization: Bearer $ACCESS_TOKEN"Enregistre une base de données externe pour y archiver ses messages.
POST https://gateway.alfychat.app/api/archive/external-db
Erreurs
- 400Connexion impossible avec ces paramètres
- 400Hôte refusé — une adresse publique est requise
- 429Trop de tentatives, réessayez plus tard
Succès : 200
curl -X POST "https://gateway.alfychat.app/api/archive/external-db" \
-H "Authorization: Bearer $ACCESS_TOKEN"Teste la connexion à la base externe.
POST https://gateway.alfychat.app/api/archive/external-db/test
Erreurs
- 429Trop de tentatives, réessayez plus tard
Succès : 200, 400
curl -X POST "https://gateway.alfychat.app/api/archive/external-db/test" \
-H "Authorization: Bearer $ACCESS_TOKEN"Lit les messages archivés dans la base externe.
GET https://gateway.alfychat.app/api/archive/external-db/messages
Erreurs
- 400conversationId requis
- 403Accès non autorisé
Succès : 200
curl -X GET "https://gateway.alfychat.app/api/archive/external-db/messages" \
-H "Authorization: Bearer $ACCESS_TOKEN"Supprime la configuration de la base externe.
DELETE https://gateway.alfychat.app/api/archive/external-db
Succès : 200
curl -X DELETE "https://gateway.alfychat.app/api/archive/external-db" \
-H "Authorization: Bearer $ACCESS_TOKEN"