This method allows sending a file to a recipient via the specified communication channel. The file must be accessible via a public link on the internet. The method is convenient for sending documents, images, videos, and other file types to clients without the need to upload them directly to the WAMM.chat server.


Supported Messengers

The API method for sending files in a message is available for the following messengers: WhatsApp, MAX Personal, Telegram Personal, Telegram Bot.


Request Example:

GET https://wamm.chat/api2/file_to/{token}/?phone={phone}&url={url}

or

GET https://wamm.chat/api2/file_to/{token}/{phone}/{url}

Request Parameters
ParameterTypeRequiredDescription
tokenstringYesAPI token obtained in the settings
phonestringYesPhone number in international format (e.g., 79001234567). For Telegram, you can specify a chat ID or username instead of a number; for MAX - a chat ID
urlstringYesPublic link to the file (accessible on the Internet without authorization, HTTP Code 200), encoded with the urlencode function
quote_msg_idintegerNoID of the message being replied to

Success Response
{"err":0,"msg_id":1234567}

Possible Errors
Error CodeDescription
token failToken error
acc not authorizedConnection not authorized
phone failPhone number error
no WhatsApp on the numberNo WhatsApp associated with this number
no Account on the numberNo account with this number for other channels (Telegram...)
phone not checked for WhatsApp, please retryNumber not checked for WhatsApp presence
phone not checked, please retryNumber not checked for account presence
url failEmpty link or missing http / https in it
quote_msg_id fail, not foundMessage for reply not found

Usage Examples
curl -X GET "https://wamm.chat/api2/file_to/YOUR_TOKEN/?phone=79001234567&url=https://example.com/files/document.pdf"

function sendFile($token, $phone, $fileUrl) {
    // Prepare the request URL
    $url = "https://wamm.chat/api2/file_to/$token/?phone=$phone&url=" . urlencode($fileUrl);

    // Execute the request
    $response = file_get_contents($url);

    // Process the response
    if ($response !== false) {
        // Convert the response to an array
        $json_response = json_decode($response, true);

        // Check for errors
        if (isset($json_response['err'])) {
            if ($json_response['err'] == 0 && isset($json_response['msg_id'])) {
                echo "File sent successfully, message ID: " . $json_response['msg_id'];
            } else {
                echo "Error: " . $json_response['err'];
            }
        } else {
            echo "Failed to process the server response";
        }
    } else {
        echo "Failed to execute the request to the server";
    }
}

// Use the function to send a file
$token = "YOUR_TOKEN";
$phone = "79001234567";
$fileUrl = "https://example.com/files/document.pdf";

sendFile($token, $phone, $fileUrl);