Chat operations



Introduction

Once you have the token, you can start sending requests to the API.


Operations

Register a "Chat"

The first interaction you have to do with the API is to create a "Chat".

HTTP Request

POST /api/v1/private/chats

With the following information provided as JSON:

{
        "title": "Title of the chat",
        "createdBy": "example created by",
        "description": "example description"
    }

Request body parameters

Parameter Mandatory Datatype Description
title yes string A title for the "Chat".
createdBy no string(50) The creator of the "Chat".
description no string(255) The description of the "Chat"

As response, you will get

202 "Chat" created and the ID of the "Chat"

"Chat" detail

To be able to get the detailed information of a "Chat"

HTTP Request

GET /api/v1/private/chats/{chatId}

As response, you will get the following JSON object:


                {
    "id": "9a983789-1709-4543-aa31-a02867680017",
    "isActive": true,
    "service": "telegram",
    "registeredAt": "2024-12-11T08:54:03.000Z",
    "createdBy": "4279566b-ee1b-49ed-bda7-046bd68c11d1",
    "title": [
        {
            "value": "Chat día 11 XXII",
            "contentType": "text/plain",
            "capturedAt": "2024-12-11T08:54:21.898Z"
        }
    ],
    "participants": [
        {
            "id": "5a9b042b-36ca-4aab-ba50-7ceda030d33f",
            "userProperties": {
                "firstname": "Flood_wait_bot",
                "username": "Flood_wait_bot"
            },
            "participations": [
                {
                    "isActive": true,
                    "joinedAt": "2024-12-11T08:54:12.000Z",
                    "invitedBy": "ba2cc0a8-841c-49d3-9c30-418e955f06ff"
                }
            ]
        },
        {
            "id": "ba2cc0a8-841c-49d3-9c30-418e955f06ff",
            "userProperties": {
                "username": "JorgeOiz"
            },
            "participations": [
                {
                    "isActive": true,
                    "joinedAt": "2024-12-11T08:54:21.898Z"
                }
            ]
        }
    ]
}

Where:

HTTP Response parameters

Parameter Datatype Description
id UUID An identification for the "Chat". UUID V4
isActive bool If the Chat is active or not
service string(255) The provider used to create the "Chat"
registeredAt string(50) The timestamp of the creation of the Chat.
createdBy string(50) The creator of the "Chat"
title array An array with the different titles that the "Chat" has had.
participants array An array with the different participants that the "Chat" has had.<

"Chat" list

To be able to get the list of "Chats"

HTTP Request

GET /api/v1/private/chats/

These call can be paged. This is specially usefull when you have to retrieve a big amount of elements.

By default, the size of the page is 20 elements, and you can put a maximum size of 200 elements. The response shows a list of resources to make the paged calls, basically you can set the page, the size, and the field you want to sort the list by.

These call can be filtered. The filters are made by QueryParams. The filters can be: "isActive", "id", "fromDate" and "toDate"

As response, you will get the same information as in the "Chat" detail but with an array. Following JSON object:


                {
    "records": [
        {
            "id": "9a983789-1709-4543-aa31-a02867680017",
            "isActive": true,
            "service": "telegram",
            "createdBy": "4279566b-ee1b-49ed-bda7-046bd68c11d1",
            "registeredAt": "2024-12-11T08:54:03",
            "title": [
                {
                    "value": "Chat día 11 XXII",
                    "contentType": "text/plain",
                    "capturedAt": "2024-12-11T08:54:21.898Z"
                }
            ],
            "participants": [
                {
                    "id": "5a9b042b-36ca-4aab-ba50-7ceda030d33f",
                    "userProperties": {
                        "firstname": "Flood_wait_bot",
                        "username": "Flood_wait_bot"
                    },
                    "participations": [
                        {
                            "isActive": true,
                            "joinedAt": "2024-12-11T08:54:12.000Z",
                            "invitedBy": "ba2cc0a8-841c-49d3-9c30-418e955f06ff"
                        }
                    ]
                },
                {
                    "id": "ba2cc0a8-841c-49d3-9c30-418e955f06ff",
                    "userProperties": {
                        "username": "JorgeOiz"
                    },
                    "participations": [
                        {
                            "isActive": true,
                            "joinedAt": "2024-12-11T08:54:21.898Z"
                        }
                    ]
                }
            ]
        },
        {
            "id": "3322d043-4f3c-4a85-92fc-4c6876cd9442",
            "isActive": true,
            "service": "telegram",
            "createdBy": "4279566b-ee1b-49ed-bda7-046bd68c11d1",
            "registeredAt": "2024-12-11T07:56:03",
            "title": [
                {
                    "value": "Chat día 11 XXI",
                    "contentType": "text/plain",
                    "capturedAt": "2024-12-11T07:56:22.004Z"
                }
            ],
            "participants": [
                {
                    "id": "5a9b042b-36ca-4aab-ba50-7ceda030d33f",
                    "userProperties": {
                        "firstname": "Flood_wait_bot",
                        "username": "Flood_wait_bot"
                    },
                    "participations": [
                        {
                            "isActive": true,
                            "joinedAt": "2024-12-11T07:56:12.000Z",
                            "invitedBy": "ba2cc0a8-841c-49d3-9c30-418e955f06ff"
                        }
                    ]
                },
                {
                    "id": "ba2cc0a8-841c-49d3-9c30-418e955f06ff",
                    "userProperties": {
                        "username": "JorgeOiz"
                    },
                    "participations": [
                        {
                            "isActive": true,
                            "joinedAt": "2024-12-11T07:56:22.004Z"
                        }
                    ]
                }
            ]
        },
		...
    ],
    "_metadata": {
        "currentPage": 0,
        "totalPages": 42,
        "pageSize": 20,
        "totalRecords": 831
    }
}

Delete user from a "Chat"

If you want to delete a user from a "Chat", you can make the following requests:

HTTP Request

DELETE /api/v1/private/chats/{chatId}/participants/{participantId}

As response, you will get

202 Participant removed and the ID of the "Chat"

If you want get the invitation link of the "Chat", you can make the following requests:

HTTP Request

GET /api/v1/private/chats/{chatId}/invitation

As response, you will get the invitation link as follows:

{
    "service": "telegram",
    "invitation": "https://t.me/xxxxxxxx"
            }