انتقل إلى المحتوى الرئيسي

Sending Whatsapp Messages

Textly also allows you to send text messages via whatsapp to one or more targets which you can do by dispatching a post request to /api/v1/client/whatsapp/send_plain

const myApiToken = await getApiToken(); // See authentication guide to learn how to get a token

const response = await fetch(
"https://api.textly.ly/api/v1/client/whatsapp/send_plain",
{
method: "POST",
headers: new Headers({
"Content-Type": "application/json",
Authorization: `Bearer ${myApiToken}`,
}),
body: JSON.stringify({
target_numbers: ["09100000"],
content: "Hello world",
wait_for_send: true,
}),
}
);

As we can see from the code snippet the /api/v1/client/whatsapp/send_plain expects a json body that contains

{
"target_numbers": ["09100000"],
"content": "4501",
"wait_for_send": true
}
  • Target_numbers: an array of phone numbers which the message will be sent to (must contain at least one number)
  • content: is the content of the text message
  • wait_for_send: whether or not to immediately send the message or have it be scheduled to send 3 to 5 seconds (optional)