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
| Parameter | Type | Required | Description |
|---|---|---|---|
| token | string | Yes | API token obtained in the settings |
| phone | string | Yes | Phone 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 |
| url | string | Yes | Public link to the file (accessible on the Internet without authorization, HTTP Code 200), encoded with the urlencode function |
| quote_msg_id | integer | No | ID of the message being replied to |
Success Response
{"err":0,"msg_id":1234567} Possible Errors
| Error Code | Description |
|---|---|
| token fail | Token error |
| acc not authorized | Connection not authorized |
| phone fail | Phone number error |
| no WhatsApp on the number | No WhatsApp associated with this number |
| no Account on the number | No account with this number for other channels (Telegram...) |
| phone not checked for WhatsApp, please retry | Number not checked for WhatsApp presence |
| phone not checked, please retry | Number not checked for account presence |
| url fail | Empty link or missing http / https in it |
| quote_msg_id fail, not found | Message 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);