Send your first text from code with the phone you already own
Create a key, POST one JSON body, follow the status until it's final. curl, Node and Python examples for Simline's SMS API, plus idempotency, picking the SIM and handling limits.
Simline sends SMS from an Android phone you already own. Your code calls an HTTPS API, the phone sends the text from its SIM on your normal plan, and you get every status change back. This post goes from zero to a delivered text in curl, Node and Python, then covers the parts that matter in production: idempotency keys, choosing which SIM sends, and what to do when the API says no.
Everything below was tested on 28 November 2026 against Simline’s API (a local build of the current code) with a simulated test phone that reports sent and delivered like a real one. No real carrier was involved, so your delivery times will be slower than ours.
Before you start
You need three things:
- A Simline workspace. Sign in at app.simline.dev.
- A paired Android phone. In the dashboard, open Devices → Pair device and scan the QR code with the Simline app (or type the 6-character code; it expires after 5 minutes). The Android app is in Google Play review right now, so it isn’t public yet.
- An API key. Open Developers → API keys → Create key, give it a name (“Production backend”), keep both scopes (
sendandread), and copy the key. It starts withsl_live_and is shown once. Simline stores only a hash.
Put the key in an environment variable rather than in your code:
export SIMLINE_API_KEY=sl_live_...
One key per app is a good habit: you can revoke one without breaking the others.
Send a text with curl
curl https://api.simline.dev/v1/messages \
-H "Authorization: Bearer $SIMLINE_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-1042-ready" \
-d '{"to": "+12125550142", "body": "Hi Maya, your order #1042 is ready for pickup."}'
The answer comes back right away with HTTP 202 and the stored message:
{
"id": "msg_4e03f88dc3ae3e703ee205e19b5ad9c7",
"direction": "outbound",
"status": "dispatched",
"finalStatus": false,
"channel": "sms",
"contact": "+12125550142",
"deviceId": "dev_local",
"simSlot": 1,
"idempotencyKey": "order-1042-ready",
...
}
to must be in E.164 format: a plus sign, the country code, then the number, digits only. 2125550142 without the +1 is a 400. The body can be 1 to 1,600 characters; long texts are split into several SMS parts by the phone and reported as one message.
status is dispatched here because the phone was online and the message was handed to it. If the phone is asleep or offline, you’ll see queued, and the message waits for it.
Read the status until it’s final
A text moves through queued → dispatched → accepted → sent → delivered, or ends at failed with an errorCode. We explain each state in what actually happens when Simline sends a text. The field to watch is finalStatus: it turns true once the status can’t change any more.
curl https://api.simline.dev/v1/messages/msg_4e03f88dc3ae3e703ee205e19b5ad9c7 \
-H "Authorization: Bearer $SIMLINE_API_KEY"
The response includes events, the timeline with one entry per state and attempt:
"status": "delivered",
"finalStatus": true,
"events": [
{ "state": "queued", "attempt": 1, "at": "2026-11-28T09:13:57.390Z" },
{ "state": "dispatched", "attempt": 1, "at": "2026-11-28T09:13:57.395Z" },
{ "state": "accepted", "attempt": 1, "at": "2026-11-28T09:13:57.401Z" },
{ "state": "sent", "attempt": 1, "at": "2026-11-28T09:13:57.696Z", "parts": 1 },
{ "state": "delivered", "attempt": 1, "at": "2026-11-28T09:13:57.997Z", "parts": 1 }
]
Polling is fine for a script. For an app, let Simline call you instead: every status and every reply can arrive as a signed webhook.
Node (built-in fetch)
Node 18 and later have fetch built in, so there’s nothing to install. Save this as send.mjs and run node send.mjs:
const API = "https://api.simline.dev"
const headers = {
Authorization: `Bearer ${process.env.SIMLINE_API_KEY}`,
"Content-Type": "application/json"
}
async function sendText(to, body, idempotencyKey) {
const res = await fetch(`${API}/v1/messages`, {
method: "POST",
headers,
body: JSON.stringify({ to, body, idempotencyKey })
})
const data = await res.json()
if (!res.ok) throw new Error(`${res.status} ${data.error}: ${data.message}`)
return data // 202 for a new message, 200 if this key was already used
}
async function waitForFinalStatus(id, { everyMs = 2000, timeoutMs = 120_000 } = {}) {
const deadline = Date.now() + timeoutMs
while (Date.now() < deadline) {
const res = await fetch(`${API}/v1/messages/${id}`, { headers })
const message = await res.json()
if (message.finalStatus) return message
await new Promise((r) => setTimeout(r, everyMs))
}
throw new Error(`message ${id} not final after ${timeoutMs / 1000} s`)
}
const sent = await sendText("+12125550142", "Hi Maya, your order #1042 is ready for pickup.", "order-1042-ready")
console.log(sent.id, sent.status)
const final = await waitForFinalStatus(sent.id)
console.log(final.status, final.errorCode ?? "", final.events.map((e) => e.state).join(" → "))
Our run printed:
msg_4e03f88dc3ae3e703ee205e19b5ad9c7 dispatched
delivered queued → dispatched → accepted → sent → delivered
Python (requests)
import os
import time
import requests
API = "https://api.simline.dev"
session = requests.Session()
session.headers["Authorization"] = f"Bearer {os.environ['SIMLINE_API_KEY']}"
def send_text(to: str, body: str, idempotency_key: str) -> dict:
r = session.post(
f"{API}/v1/messages",
json={"to": to, "body": body, "idempotencyKey": idempotency_key},
timeout=15,
)
data = r.json()
if not r.ok:
raise RuntimeError(f"{r.status_code} {data['error']}: {data['message']}")
return data
def wait_for_final_status(message_id: str, every: float = 2, timeout: float = 120) -> dict:
deadline = time.monotonic() + timeout
while time.monotonic() < deadline:
message = session.get(f"{API}/v1/messages/{message_id}", timeout=15).json()
if message["finalStatus"]:
return message
time.sleep(every)
raise TimeoutError(f"message {message_id} not final after {timeout} s")
sent = send_text("+12125550142", "Hi Maya, your order #1042 is ready for pickup.", "order-1042-ready")
print(sent["id"], sent["status"])
final = wait_for_final_status(sent["id"])
print(final["status"], final["errorCode"] or "", " → ".join(e["state"] for e in final["events"]))
We ran it with Python 3.13 and requests 2.34 straight after the Node script, with the same idempotency key. It printed the same message id and sent nothing new, which is exactly the point of the next section.
Idempotency keys: send once, even if you retry
Networks fail in the worst place: after the server stored your message but before you got the answer. If you retry blindly, the customer gets two texts.
Pass an idempotency key, either as idempotencyKey in the body or as an Idempotency-Key header. If the same key arrives again within 24 hours, Simline doesn’t send anything; it answers 200 with the original message and the header Idempotent-Replayed: true.
Two things we checked that are worth knowing:
- The key is the whole identity. A repeat with the same key and a different body still returns the first message. Build keys from what makes a text unique in your system, like
order-1042-readyorappointment-77-reminder-24h, not from a random value made at send time. - Keys are scoped to your workspace. Nobody else’s keys clash with yours, but two of your own apps can, so prefix keys with the app’s name if several apps send.
Choosing which phone and SIM sends
Leave from out (or send "auto") and Simline picks a connected phone on its default SIM. When you want a specific line, from takes:
from |
Sends from |
|---|---|
"auto" |
An online phone, on its default sender SIM |
"dev_…" |
That phone, on its default sender SIM |
"sim_…" |
That exact SIM |
"+33 6 00 00 00 02" |
The SIM you gave that number to in the dashboard (any formatting) |
{"deviceId": "dev_…", "simSlot": 1} |
That phone’s second slot |
Android doesn’t let the app read a SIM’s own number, so you type it once next to each SIM in the dashboard. After that, sending “from my shop number” is a one-line change. If you have a dual-SIM phone, pick the sending number per text explains labels, the default sender and turning a SIM off.
When the API says no
Errors are JSON with a machine-readable error and a sentence in message. These are the ones to handle:
| Status | error |
What to do |
|---|---|---|
400 |
bad_request |
Fix the input: a number without +, an empty body, an unknown or switched-off SIM in from. |
401 / 403 |
Wrong key, or a key without the send scope. |
|
402 |
plan_limit_texts |
This month’s texts on your plan are used up. The body names the plan that lifts it. |
409 |
no_device |
No paired phone can send. Pair one, or turn sending back on for a SIM. |
409 |
contact_opted_out |
The person texted STOP. Don’t retry; they opt back in by texting START. |
429 |
usage_limit |
The workspace’s daily cap (10,000 texts per UTC day by default). Retry-After says how many seconds until midnight UTC. |
503 |
dispatch_failed |
The phone’s session couldn’t take the message, and it was stored as failed. Try again after Retry-After seconds, with a new idempotency key. |
Here’s the shape we use in Node:
async function trySend(message) {
const res = await fetch("https://api.simline.dev/v1/messages", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.SIMLINE_API_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify(message)
})
const data = await res.json()
if (res.ok) return { ok: true, message: data }
switch (data.error) {
case "usage_limit": // 429: the workspace's daily cap, resets at 00:00 UTC
case "dispatch_failed": // 503: the phone's session couldn't take it; stored as failed
return { ok: false, retryAfterSeconds: Number(res.headers.get("Retry-After")), reason: data.message }
case "contact_opted_out": // 409: they texted STOP; never retry
case "plan_limit_texts": // 402: this month's texts are used up
case "no_device": // 409: no paired phone can send right now
default:
return { ok: false, retryAfterSeconds: null, reason: `${res.status} ${data.error}: ${data.message}` }
}
}
To see the 429 for real, we started the API with a daily cap of 10 and sent an eleventh text. The answer was 429 with Retry-After: 52662 (the seconds left until midnight UTC) and the message “Daily send limit of 10 messages reached for this workspace; it resets at 00:00 UTC”. A 429 here is not a per-second rate limit, so don’t retry it in a tight loop: queue the text for tomorrow or tell a person.
What it can’t do
Being honest about the limits saves you a bad week later.
- Volume. One phone sends at phone speed. The app paces itself at 20 texts a minute by default, and carriers notice when a personal line suddenly sends thousands. Simline is for the texts a business actually exchanges with people: confirmations, reminders, replies. More phones add capacity, but it’s not a bulk platform.
- Marketing blasts. Many countries require prior consent for promotional texts, and carriers’ terms for personal plans usually forbid bulk commercial traffic. If you text customers in France or elsewhere in the EU, read our notes on consent, STOP and sending hours first.
- Short codes and sender names. Recipients always see your SIM’s number.
- MMS. Text only, up to 1,600 characters. Accents and emoji change how many SMS parts that takes: here’s why one accent can double a text.
- Delivery reports from every network.
deliveredneeds the carrier to send a report. If it doesn’t, the text can end atsent.
Next steps
- Get incoming texts as signed webhooks instead of polling.
- Let an AI agent text people, with your approval.
- The full OpenAPI spec is at api.simline.dev/v1/openapi.json.
FAQ
- Do I need a special phone number or sender ID?
- No. Texts go out from the SIM in your Android phone, so recipients see your normal number. Simline doesn't offer short codes or alphanumeric sender names.
- Which status means the text arrived?
- delivered means the carrier's delivery report came back for every part. Stop polling when finalStatus is true: the status won't change after that.
- What happens if I send the same request twice?
- With the same idempotency key within 24 hours, the API returns the first message with HTTP 200 and an Idempotent-Replayed header, and nothing is sent again.
- Can I send marketing campaigns this way?
- It isn't built for that. A personal SIM sends at phone speed, carriers watch for bulk traffic, and marketing texts need prior consent in many countries.