Send your first SMS from a Node.js app with a single HTTPS request to the eSMS Africa SMS API. No SDK required - just fetch.
const res = await fetch("https://api.esmsafrica.io/v1/sms/send", {
method: "POST",
headers: {
"Authorization": "Bearer " + process.env.ESMS_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
to: "+254712345678",
from: "MyBrand", // your registered sender ID
message: "Hello from Node.js",
}),
});
const data = await res.json();
console.log(data); // { id, status, ... }Create a free account and copy your API key from the dashboard. Keep it server-side - never ship it in front-end code.
Use the built-in fetch (Node 18+). Recipients must be in international format (e.g. +254... for Kenya).
const res = await fetch("https://api.esmsafrica.io/v1/sms/send", {
method: "POST",
headers: {
"Authorization": "Bearer " + process.env.ESMS_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
to: "+254712345678",
from: "MyBrand", // your registered sender ID
message: "Hello from Node.js",
}),
});
const data = await res.json();
console.log(data); // { id, status, ... }A 2xx response means the message was accepted. Store the returned message id so you can match it to a delivery report later.
if (!res.ok) {
throw new Error(`SMS failed: ${res.status} ${JSON.stringify(data)}`);
}
// data.id -> keep this to reconcile the DLR webhookNo. The API is a plain HTTPS endpoint, so Node 18+ fetch (or axios) is enough. An official Node SDK is also available if you prefer.
International E.164 format, e.g. +254712345678 for Kenya. The API delivers to every African network.