Contact support:
Contact support
Select Language Русский English

    Quick Start

    To connect the ChatApp API, you need to perform a few simple steps. Let’s go through them step by step:

    Step 1. Registration in the personal account

    Step 2. Purchase or request a demo license

    Step 3. Create an appId in the personal account

    To register an appId, go to the page for its creation.

    Step 4. Obtaining access tokens

    Let’s look at an example of a request to obtain access tokens using the v1.tokens.make method.

    Note: All request examples are provided in PHP using the Guzzle HTTP client.

    $client = new GuzzleHttpClient();
    try {
        $response = $client->post(
            'https://api.chatapp.online/v1/tokens',
            [
                'headers' => [
                    'Content-Type' => 'application/json',
                ],
                'json' => [
                    'email' => 'test@test.test', // email from the personal account
                    'password' => '123456', // password from the personal account
                    'appId' => 'app_4556_1', // appId from the personal account
                ],
            ]
        );
        $body = $response->getBody();
        echo '<pre>';
        print_r(json_decode((string)$body));
    } catch (Exception $e) {
        echo '<pre>';
        print_r([$e->getCode(), $e->getMessage()]);
    }

    In response to this request, you will receive two tokens: refreshToken and accessToken. However, for subsequent requests you will only need one of them — the accessToken.

    Step 5. Sending a message

    Let’s look at an example of sending a text message using the v1.messages.send.text method:

    $client = new GuzzleHttpClient();
    $licenseId = 12345;
    $messengerType = 'grWhatsApp';
    $chatId = '70000000000'; // phone or chatId
    $accessToken = '$2y$10$loFiiY4XsYIDv5lfuJ9qROnpfxe000fsvjR/F1qWYiTgJEXaDiMfa';
    
    try {
        $response = $client->post(
            "https://api.chatapp.online/v1/licenses/$licenseId/messengers/$messengerType/chats/$chatId/messages/text",
            [
                'headers' => [
                    'Authorization' => $accessToken,
                ],
                'json' => [
                    'text' => 'Hello world!',
                ],
            ]
        );
        $body = $response->getBody();
        echo '<pre>';
        print_r(json_decode((string)$body));
    } catch (Exception $e) {
        echo '<pre>';
        print_r([$e->getCode(), $e->getMessage()]);
    }

    Detailed description of working with access tokens.