To send an SMS from Delphi, use TNetHTTPClient to POST a JSON body to https://api.tryready.com/v1/messages with an X-API-Key header. The body has to, body and consent_attested. Add an Idempotency-Key header so a retry never sends a second text.
Delphi still runs a lot of billing, clinic-scheduling, logistics and shop-floor software. Those programs already know when someone needs a message, and a text is one HTTPS request away. We make Ready, so this guide uses only the request shape we document, and nothing in it needs a third-party component.
Before you start
- An API key from Ready, read from config or an environment variable.
- A card on file and a number of your own ($2 a month).
- Consent you can show for each recipient, since
consent_attested: trueis your promise they agreed. - Delphi 10.3 or newer for
System.Net.HttpClientandSystem.JSON.
Cost is $0.0075 per segment plus a $0.0045 carrier fee. See the pricing page.
The code
uses
System.SysUtils, System.Classes, System.JSON, System.Net.HttpClient,
System.Net.URLClient, System.NetEncoding;
function SendText(const ToNumber, Msg, IdemKey: string): Integer;
var
Http: THTTPClient;
Body: TJSONObject;
Stream: TStringStream;
Resp: IHTTPResponse;
begin
Http := THTTPClient.Create;
Body := TJSONObject.Create;
try
Body.AddPair('to', ToNumber);
Body.AddPair('body', Msg);
Body.AddPair('consent_attested', TJSONBool.Create(True));
Stream := TStringStream.Create(Body.ToJSON, TEncoding.UTF8);
try
Http.ConnectionTimeout := 10000;
Http.ResponseTimeout := 15000;
Http.CustomHeaders['X-API-Key'] := GetEnvironmentVariable('READY_API_KEY');
Http.CustomHeaders['Idempotency-Key'] := IdemKey;
Http.ContentType := 'application/json';
Resp := Http.Post('https://api.tryready.com/v1/messages', Stream);
Result := Resp.StatusCode;
finally
Stream.Free;
end;
finally
Body.Free;
Http.Free;
end;
end; Build the JSON with TJSONObject as above, never by joining strings, so quotes and line breaks in a message can't break the request. Use E.164 numbers like +12125550199.
Reading the status
| Status | What it means | What to do |
|---|---|---|
| 2xx | Accepted | Mark the row sent |
409 QUIET_HOURS_BLOCK | Recipient in quiet hours, window more than 6 hours off | Send again when it opens |
403 api_consent_attested_required | No attestation on the send | Fix the body |
| Timeout or 5xx | Transient | Retry, same key |
A number that opted out is refused up front and isn't charged. Treat that as final. The error codes docs list every refusal.
Keep the UI alive
Run the call in TTask.Run or a worker thread. A blocking request on the main thread freezes the form for the length of the timeout. Store the idempotency key in your database before you call, and reuse it if the app restarts and tries the same row again. That's the cheapest way to avoid a double text. The idempotency guide explains why.
Frequently asked questions
Do I need Indy or a third-party library? No. The built-in System.Net.HttpClient handles HTTPS and headers.
Does this work on FireMonkey mobile apps? It does, but don't ship the API key inside a mobile app. Have the app call your own server, and keep the key there. See sending SMS from a mobile app backend.
How do I send to a list? Use POST /v1/messages/bulk, which takes a list of numbers, with up to 100 numbers per call.
Next step
Text your own phone, then repeat the call with the same key and check that only one message arrives. The API quickstart shows how to create a key.
Accounts opened before November 12, 2026 keep their signup prices, shown under Billing.