Skip to main content

Sending SMS

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

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/send_sms", {
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/send_sms 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)