Quickstart
What you'll need
- An EZ Texting account. Sign up if you don't have one.
- Your EZ Texting username and password, the same ones you use to log in.
- A phone number to send a test message to. Use your own.
- The account holder's login or an Admin teammate's; Operator and Agent logins get
403. The plan must include API access, and the account must be verified (until it is, sends return400"Additional Account Verification Needed"). - A number on the account to send from. The text goes out from the account's default number; an account with no default number gets
From number is required.
Test messages use credits like any other message.
1. Put your credentials in environment variables
export EZTEXTING_USERNAME="[email protected]"
export EZTEXTING_PASSWORD="your-password"$env:EZTEXTING_USERNAME = "[email protected]"
$env:EZTEXTING_PASSWORD = "your-password"This quickstart uses HTTP Basic Auth. You may want to switch to OAuth 2.0 tokens for production. Authentication covers both.
2. Send a text
Call POST /v1/messages with the recipient's number and your message. Replace 15551234567 with your own phone number (country code first, 11 digits is the preferred format).
Each tab is a complete program. Python needs pip install requests. Node.js needs version 18 or later and runs as an ES module: save it as send.mjs and run node send.mjs. Java needs version 15 or later, and C# needs .NET 7 or later. Each example gives up after 30 seconds; if a send times out, check whether it was accepted before sending it again (Idempotency & retries).
curl -X POST https://a.eztexting.com/v1/messages \
--max-time 30 \
-u "$EZTEXTING_USERNAME:$EZTEXTING_PASSWORD" \
-H "Content-Type: application/json" \
-d '{
"toNumbers": ["15551234567"],
"message": "Hello from the EZ Texting API!"
}'$pair = "$($env:EZTEXTING_USERNAME):$($env:EZTEXTING_PASSWORD)"
$auth = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($pair))
$body = @{
toNumbers = @("15551234567")
message = "Hello from the EZ Texting API!"
} | ConvertTo-Json
try {
$response = Invoke-RestMethod -Method Post -Uri "https://a.eztexting.com/v1/messages" `
-Headers @{ Authorization = "Basic $auth" } `
-ContentType "application/json" -Body $body -TimeoutSec 30
# {"id":"128443910003"}
$response | ConvertTo-Json -Compress
} catch {
# the HTTP status and the API's error details
"$([int]$_.Exception.Response.StatusCode) $($_.ErrorDetails.Message)"
}import os
import requests
response = requests.post(
"https://a.eztexting.com/v1/messages",
auth=(os.environ["EZTEXTING_USERNAME"], os.environ["EZTEXTING_PASSWORD"]),
json={
"toNumbers": ["15551234567"],
"message": "Hello from the EZ Texting API!",
},
timeout=30,
)
# 201 {"id":"128443910003"}, or the status and the API's error details
print(response.status_code, response.text)const credentials = Buffer.from(
`${process.env.EZTEXTING_USERNAME}:${process.env.EZTEXTING_PASSWORD}`
).toString("base64");
const response = await fetch("https://a.eztexting.com/v1/messages", {
method: "POST",
headers: {
Authorization: `Basic ${credentials}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
toNumbers: ["15551234567"],
message: "Hello from the EZ Texting API!",
}),
signal: AbortSignal.timeout(30_000),
});
// 201 {"id":"128443910003"}, or the status and the API's error details
console.log(response.status, await response.text());<?php
$ch = curl_init("https://a.eztexting.com/v1/messages");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_USERPWD => getenv("EZTEXTING_USERNAME") . ":" . getenv("EZTEXTING_PASSWORD"),
CURLOPT_HTTPHEADER => ["Content-Type: application/json"],
CURLOPT_POSTFIELDS => json_encode([
"toNumbers" => ["15551234567"],
"message" => "Hello from the EZ Texting API!",
]),
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
// 201 {"id":"128443910003"}
echo "$status $body\n";require "net/http"
require "json"
uri = URI("https://a.eztexting.com/v1/messages")
request = Net::HTTP::Post.new(uri, "Content-Type" => "application/json")
request.basic_auth(ENV.fetch("EZTEXTING_USERNAME"), ENV.fetch("EZTEXTING_PASSWORD"))
request.body = {
toNumbers: ["15551234567"],
message: "Hello from the EZ Texting API!"
}.to_json
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true, read_timeout: 30) { |http| http.request(request) }
# 201 {"id":"128443910003"}
puts "#{response.code} #{response.body}"// Java 15+ (uses a text block for the JSON body)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
import java.util.Base64;
public class SendSms {
public static void main(String[] args) throws Exception {
String credentials = System.getenv("EZTEXTING_USERNAME") + ":" + System.getenv("EZTEXTING_PASSWORD");
String basicAuth = Base64.getEncoder().encodeToString(credentials.getBytes());
String json = """
{"toNumbers": ["15551234567"], "message": "Hello from the EZ Texting API!"}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://a.eztexting.com/v1/messages"))
.header("Authorization", "Basic " + basicAuth)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.timeout(Duration.ofSeconds(30))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
// 201 {"id":"128443910003"}
System.out.println(response.statusCode() + " " + response.body());
}
}using System.Net.Http.Headers;
using System.Text;
var credentials = Convert.ToBase64String(Encoding.UTF8.GetBytes(
$"{Environment.GetEnvironmentVariable("EZTEXTING_USERNAME")}:{Environment.GetEnvironmentVariable("EZTEXTING_PASSWORD")}"));
using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", credentials);
var json = """{"toNumbers": ["15551234567"], "message": "Hello from the EZ Texting API!"}""";
var response = await client.PostAsync(
"https://a.eztexting.com/v1/messages",
new StringContent(json, Encoding.UTF8, "application/json"));
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");
// 201 {"id":"128443910003"}package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
"time"
)
func main() {
body := []byte(`{"toNumbers": ["15551234567"], "message": "Hello from the EZ Texting API!"}`)
req, _ := http.NewRequest("POST", "https://a.eztexting.com/v1/messages", bytes.NewBuffer(body))
req.SetBasicAuth(os.Getenv("EZTEXTING_USERNAME"), os.Getenv("EZTEXTING_PASSWORD"))
req.Header.Set("Content-Type", "application/json")
client := &http.Client{Timeout: 30 * time.Second}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
respBody, _ := io.ReadAll(resp.Body)
// 201 {"id":"128443910003"}
fmt.Println(resp.StatusCode, string(respBody))
}3. Check the response
{
"id": "128443910003"
}A 201 means EZ Texting accepted the message. Your phone should buzz within a few seconds. Hold on to the id. It's how you look up delivery status, reports, and details later.
401: username or password is wrong, or theAuthorizationheader is missing.400: the request was rejected, for example an invalid field or a number that has opted out. Readerrors[].message; it says why.201but no text: the number may be disconnected or unable to receive texts (for example, a landline). Send, track & receive shows how to check the delivery report.
More in Troubleshooting.
That's it
You've sent a text with the EZ Texting API. Where next depends on what you're building:
Or go straight to the API Reference and try any endpoint from the browser.
Try Troubleshooting, check status.eztexting.com, or contact support.
Updated about 18 hours ago