An ESP8266 or Arduino board can't send a text on its own. It can call an HTTPS endpoint, and something behind that endpoint sends the SMS. The question that matters is which endpoint: ours directly, or a small service you run yourself.

We make Ready, and our answer is the second one. Put your API key on a server you control and let the device call that server. A key flashed into firmware can be read out of the chip by anyone who owns the device, and a leaked key can send texts on your account. This post shows the device side, the proxy side and the limits you'll hit on a small board.

The honest architecture

A texting API is a REST API. Your device makes an HTTPS request, the API hands the message to carriers, and the phone buzzes. There's no radio magic on the board, and no SIM unless you've added a cellular module. A bare ESP8266 has Wi-Fi only.

So the flow has three parts:

  1. The device notices something (a sensor crosses a threshold, a button is pressed) and calls your backend.
  2. Your backend checks the device, decides whether to send and calls POST /v1/messages with the API key.
  3. Ready sends the text and, if you want to know about delivery, calls your webhook later.

Skipping step two is possible. It's also the shortcut that causes trouble, as the next section explains.

Why the key shouldn't live on the device

Anything in a device's flash is readable by someone who holds the device. Dumping the flash of an ESP8266 takes a USB cable and one command. If every unit ships with the same API key, one extracted key exposes the whole fleet, and you can't revoke it without re-flashing every board.

A proxy fixes that:

  • The key stays on your server, where you can rotate it. Our post on API key security and rotation covers the habits.
  • Each device gets its own token, so you can cut off one stolen unit.
  • The server fixes the recipient and the wording. A device can say "door open", but it can't pick any phone number it likes.
  • The server enforces a rate limit, so a stuck sensor loop can't send 4,000 texts overnight.

The tradeoff is real: you run one more small service. A serverless function is enough, and our guide to sending SMS from serverless functions shows the shape.

The device side on an ESP8266

The device's job is to make one small HTTPS POST to your own backend. This sketch uses the ESP8266 Arduino core. The URL and token are placeholders for your own values:

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClientSecure.h>

const char* WIFI_SSID = "your-network";
const char* WIFI_PASS = "your-password";
const char* ALERT_URL = "https://alerts.example.com/device-alert";
const char* DEVICE_TOKEN = "per-device-token-from-your-backend";

bool sendAlert(const char* eventId) {
  BearSSL::WiFiClientSecure client;
  client.setBufferSizes(1024, 512);   // smaller TLS buffers, less heap
  client.setInsecure();               // see the TLS section before shipping

  HTTPClient http;
  http.setTimeout(10000);
  if (!http.begin(client, ALERT_URL)) return false;

  http.addHeader("Content-Type", "application/json");
  http.addHeader("Authorization", String("Bearer ") + DEVICE_TOKEN);

  String body = String("{\"event_id\":\"") + eventId + "\",\"kind\":\"door_open\"}";
  int status = http.POST(body);
  http.end();
  return status == 200;
}

Two details matter. The event_id is generated once per real event and reused on a retry, which lets the backend send one text per event. And the call has a timeout, because a board that blocks forever on a bad network can't do its real job.

Arduino boards with a Wi-Fi module follow the same pattern with their own client class. An older Uno with an Ethernet shield is a harder case, covered below.

The backend side

The backend validates the device, picks the recipient and makes the one request Ready documents for sending. This Node example runs on Node 18 or later, where fetch is built in:

app.post('/device-alert', async (req, res) => {
  const device = lookupDevice(req.headers.authorization);
  if (!device) return res.status(401).end();
  if (tooManyRecently(device)) return res.status(429).end();

  const r = await fetch('https://api.tryready.com/v1/messages', {
    method: 'POST',
    headers: {
      'X-API-Key': process.env.READY_API_KEY,
      'Content-Type': 'application/json',
      'Idempotency-Key': req.body.event_id,
    },
    body: JSON.stringify({
      to: device.ownerPhone,
      body: `Door sensor "${device.name}" opened.`,
      consent_attested: true,
    }),
  });
  res.status(r.ok ? 200 : 502).end();
});

Use a real UUID for the idempotency key. The device generates the event_id, so have it produce a UUID, or build one on the server from the device ID and a counter. If the board retries after a dropped connection, the same key means the owner gets one text, not three. Our post on idempotency keys and duplicate texts explains the retry rules, including what to do after a 5xx.

Set consent_attested: true only when it's true. For an alert to the person who owns the device and asked for alerts, it usually is. For texts to anyone else, you need their consent first. The request shape is in the messages API reference.

Memory and TLS limits on small boards

An ESP8266 has roughly 80 KB of RAM for data, and a TLS session eats a large share of it. That's why alerts from these boards fail in odd ways when the sketch grows. Here's what to plan around.

ConstraintWhat it meansWhat to do
Heap during TLSThe handshake needs tens of KB at onceMake the HTTPS call early, free big buffers first, shrink buffers with setBufferSizes
Certificate checkingsetInsecure() encrypts but doesn't verify who you're talking toPin your backend's certificate or fingerprint, or load a trust anchor, before you ship
ClockCertificate validation needs the correct date, and the board starts with noneSync time over NTP before the request
Certificate expiryA pinned certificate stops working when it renewsPin a CA or plan over-the-air updates
Old boardsAn Arduino Uno has about 2 KB of RAM, too little for modern TLSUse an ESP32, an ESP8266 or a gateway board instead

The honest summary on the last row: if your project is an Uno on a wired shield, don't try to make it speak TLS 1.2. Let it send a plain signal to a gateway on your own network, and let the gateway make the HTTPS call.

The ESP32 has about four times the RAM of an ESP8266 and hardware crypto, so it's the easier choice for a new design. Exact heap figures vary by core version and sketch, so measure with ESP.getFreeHeap() before and during the request.

Limits on what a device should send

A few rules keep a fleet of boards from becoming a spam problem:

  • Alert, don't chat. Devices should send events to people who asked for them: the homeowner, the on-call technician, the shop manager.
  • Rate-limit at the server. A door that bounces open and closed shouldn't produce ten texts a minute.
  • Respect opt-outs. A recipient who replies STOP is opted out, and a send to that number is refused. Keep a plan for what the device does then, such as an email fallback. Our guide to SMS API error codes lists what you'll see.
  • Count segments. Keep the text short. One emoji drops a segment to 70 characters, so a 140-character alert with one becomes 3 segments.

Pricing is one Standard rate of $0.0075 a segment plus a $0.0045 carrier fee on each segment. Accounts opened before 17:55 UTC on November 12, 2026 keep their signup prices, shown under Billing. A sensor that sends a few alerts a month costs almost nothing in segments. A sensor stuck in a loop is where the server-side rate limit pays for itself.

Wrapping up

A microcontroller doesn't send SMS. It asks a server to, over HTTPS. Keep the key on your backend, give each device its own revocable token, rate-limit at the server, and treat TLS on a small board as a design constraint rather than an afterthought.

Build the backend first and test it with a test key and a curl call, as in our send SMS with curl walkthrough. Then point the board at it. When you're ready to try it, sign up and follow the API quickstart.