To send an SMS from Perl, POST a JSON body to https://api.tryready.com/v1/messages with HTTP::Tiny, your key in an X-API-Key header and an Idempotency-Key header. The body holds to, body and consent_attested. A 2xx status means the text was accepted.

Perl still runs a great deal of glue code: cron jobs, log watchers, billing scripts and old monitoring tools. Those scripts know when something needs a human, and a text is one HTTPS request away. Both modules below ship with core Perl, so there's nothing to install. We make Ready, and the example uses only the request shape we document.

Before you start

  • An API key from Ready, read from the environment so it never lands in the script or in version control.
  • A card on file and a number of your own, which is $2 a month.
  • A record that the recipient agreed to texts. consent_attested is your statement that they did.

A text costs $0.0075 per segment plus a $0.0045 carrier fee. The pricing page has the full list.

The script

use strict;
use warnings;
use HTTP::Tiny;
use JSON::PP qw(encode_json);

sub send_text {
    my ($to, $body, $idem) = @_;
    my $http = HTTP::Tiny->new(timeout => 15);
    my $res = $http->post(
        'https://api.tryready.com/v1/messages',
        {
            headers => {
                'Content-Type'    => 'application/json',
                'X-API-Key'       => $ENV{READY_API_KEY},
                'Idempotency-Key' => $idem,
            },
            content => encode_json({
                to               => $to,
                body             => $body,
                consent_attested => JSON::PP::true,
            }),
        },
    );
    return $res->{status};   # 2xx accepted; 599 means a network error
}

my $status = send_text('+12125550199', 'Backup job finished.', 'backup-2026-11-22');
print "status $status\n";

HTTP::Tiny needs IO::Socket::SSL and Net::SSLeay for HTTPS, which most Linux distributions include. Use E.164 numbers such as +12125550199. Let encode_json build the body, since hand-written JSON breaks on a quote.

Reading the status

StatusMeaningWhat the script does
2xxAcceptedLog it and exit 0
409 QUIET_HOURS_BLOCKRecipient in quiet hours, window more than 6 hours awayTry again after the window opens
403 api_consent_attested_requiredAttestation missingFix the body
599 or 5xxNetwork or server troubleRetry with the same key

Opted-out numbers are refused up front and not charged, so treat that refusal as final. The error codes docs list every refusal.

Cron-safe habits

Cron jobs run twice by accident more often than anyone admits. Build the idempotency key from the job name and date, as above, so a second run of the same job can't send a second text. Put a lock file around the script, and send nothing if the alert condition has cleared by the time the script runs. For lists, POST /v1/messages/bulk takes at most 100 numbers per call. The retries and failure handling post has a decision table.

Frequently asked questions

Do I need a CPAN module for Ready? No. HTTP::Tiny and JSON::PP are enough, and both are in core.

Can I use LWP::UserAgent instead? Yes. Any HTTP client that can set headers and send JSON works.

How do I get replies? Replies arrive as webhooks to an endpoint you host. See receiving SMS through inbound webhooks.

Next step

Run the script against your own phone, then run it twice and confirm only one text arrives. The API quickstart shows how to create a key. If you prefer a shell one-liner, see sending SMS with curl.

Accounts opened before November 12, 2026 keep their signup prices, shown under Billing.