Chat API cURL Documentation

1. Save Message

API URL: POST /chat/save

Use this API to save a new chat message.

curl -X POST https://yourdomain.com/chat/save \
-H "Content-Type: application/json" \
-d '{
    "sender_id": "staff_1",
    "receiver_id": "student_123",
    "group_id": null,
    "message_text": "Hello, how can I help you?",
    "timestamp": "2024-09-10 10:00:00",
    "attachments": [
        {
            "file_path": "/uploads/chat/image1.jpg",
            "file_type": "image/jpeg"
        }
    ]
}'
    

2. List Messages

API URL: POST /chat/list

Use this API to list messages for a user or group.

curl -X POST https://yourdomain.com/chat/list \
-H "Content-Type: application/json" \
-d '{
    "userId": "staff_1",
    "groupId": null,
    "limit": 50,
    "offset": 0
}'
    

3. Sync Chats from Firebase

API URL: POST /chat/sync

Use this API to sync chat data from Firebase to the local database.

curl -X POST https://yourdomain.com/chat/sync \
-H "Content-Type: application/json" \
-d '{
    "firebasePath": "chats/group_123"
}'
    

4. List Group Members

API URL: POST /chat/group/members

Use this API to list the members of a chat group.

curl -X POST https://yourdomain.com/chat/group/members \
-H "Content-Type: application/json" \
-d '{
    "groupId": 123
}'
    

5. Add Group Member

API URL: POST /chat/group/add-member

Use this API to add a user to a chat group.

curl -X POST https://yourdomain.com/chat/group/add-member \
-H "Content-Type: application/json" \
-d '{
    "groupId": 123,
    "userId": "student_456"
}'
    

6. Remove Group Member

API URL: POST /chat/group/remove-member

Use this API to remove a user from a chat group.

curl -X POST https://yourdomain.com/chat/group/remove-member \
-H "Content-Type: application/json" \
-d '{
    "groupId": 123,
    "userId": "student_456"
}'
    

7. Create Group

API URL: POST /chat/group/create

Use this API to create a new chat group.

curl -X POST https://yourdomain.com/chat/group/create \
-H "Content-Type: application/json" \
-d '{
    "groupName": "Class Group",
    "createdBy": "staff_1"
}'
    

8. Delete Group

API URL: POST /chat/group/delete

Use this API to delete a chat group.

curl -X POST https://yourdomain.com/chat/group/delete \
-H "Content-Type: application/json" \
-d '{
    "groupId": 123
}'