How to Send an SMS with curl
To send an SMS with curl, POST a JSON body with to and body to https://smsnet.net/api/v1/messages/send with your API key in the X-API-Key header. The response returns a message_id and your remaining quota, and the text leaves from your connected Android phone. No SDK or library is needed.
Every command below runs as written in a shell with SMSNET_API_KEY exported. Nothing beyond curl is required.
What do I need before the first call?
Two things: a connected phone and an API key. Install the SMSNET Gateway app on any Android 8.0 or newer phone with a SIM, sign in, and copy the key from the last setup screen. The Android gateway guide shows every screen. Then export it:
export SMSNET_API_KEY="paste-your-key-here"
The free plan is enough to build against: 300 messages a month, 20 a day, and replies are never counted. Numbers go in E.164 format (+15551234567).
How do I send an SMS with curl?
curl -X POST https://smsnet.net/api/v1/messages/send \
-H "X-API-Key: $SMSNET_API_KEY" \
-H "Content-Type: application/json" \
-d '{"to": "+15551234567", "body": "Your table is ready. Reply STOP to opt out."}'
For a message the recipient is waiting on right now, such as a login code, add "transactional": true to the JSON body. It skips the pacing gap and quiet hours and typically reaches the handset in about a second:
curl -X POST https://smsnet.net/api/v1/messages/send \
-H "X-API-Key: $SMSNET_API_KEY" \
-H "Content-Type: application/json" \
-d '{"to": "+15551234567", "body": "Your code is 481516.", "transactional": true}'
The same call in code is in Send an SMS from Python and Send an SMS from Node.js.
How do I read the quota in the response?
A successful send returns the remaining allowance inline, so a script can check it without a second call:
{
"ok": true,
"message_id": "msg_01j9x8k2...",
"conversation_id": "conv_01j9x8k2...",
"device_id": "dev_01j9x8k2...",
"quota": {
"month": { "used": 13, "limit": 300 },
"day": { "used": 4, "limit": 20 }
}
}
quota.day counts against the daily ceiling of 20 and quota.month against the monthly allowance of 400. Once you are in the headroom band above the limit, the response carries "grace": true with a note. Full endpoint reference is in What Is an SMS API and How to Use One.
How do I poll for replies with curl?
Polling needs no public URL. The first call lists the latest messages; each response carries a next_cursor that you pass back as since, so nothing is missed or repeated:
curl -H "X-API-Key: $SMSNET_API_KEY" \
"https://smsnet.net/api/v1/messages?direction=inbound&limit=20"
curl -H "X-API-Key: $SMSNET_API_KEY" \
"https://smsnet.net/api/v1/messages?direction=inbound&limit=100&since=$SINCE"
Set SINCE to the next_cursor from the previous call. Repeat the second command on a timer, every 10 seconds or so when idle, and after each page check whether the response says there are more pages before sleeping.
How do I register and test a webhook with curl?
Register your HTTPS endpoint once and keep the secret from the response for signature verification:
curl -X PUT https://smsnet.net/api/v1/webhooks \
-H "X-API-Key: $SMSNET_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com/sms"}'
Before any real traffic exists, send yourself a test event:
curl -X POST https://smsnet.net/api/v1/webhooks/test \
-H "X-API-Key: $SMSNET_API_KEY"
SMSNET POSTs message.received and message.status events to the registered URL, signs each one with HMAC-SHA256 over the timestamp and raw body, and retries nine times over about three days if your endpoint is down. Verification code is in the Python and Node.js guides.
The curl lifecycle in four steps: send, poll, register, test.
What errors will curl show?
| Status | When | What to do |
|---|---|---|
| 400 | Missing to or body, or no phone connected to the account | Fix the request, or connect a phone |
| 401 | Missing or wrong key; the error says whether the key was rotated | Export the right key, rotate if needed |
| 403 | The recipient opted out; the error names the date and the words they used | Do not retry; remove them from your list |
| 429 | Monthly or daily allowance reached, including the headroom | Wait for the window, or upgrade the plan |
Add -i to any command to see the status line above the JSON error body, which names the exact cause. Everything here runs on the free plan.
FAQ
How do I send an SMS with curl?
POST JSON with to and body to https://smsnet.net/api/v1/messages/send, with your key in the X-API-Key header and Content-Type application/json. The response returns a message_id and your remaining quota. No SDK or library is needed.
How do I know the message was accepted?
A send that returns ok true with a message_id is queued for delivery. The same response shows quota used and limit for the day and month, so you can confirm headroom without a second call.
How do I read SMS replies with curl?
Call GET /api/v1/messages?direction=inbound and pass the next_cursor from each response back as since on the next call. Repeat on a timer, or register a webhook and receive message.received events instead.
How do I register a webhook with curl?
PUT JSON with url to https://smsnet.net/api/v1/webhooks and keep the secret from the response for signature verification. Then POST to https://smsnet.net/api/v1/webhooks/test to send a test event before real traffic exists.
What are the free plan limits?
The free plan covers 300 messages a month with a daily ceiling of 20, and replies are never counted. A 14 day Growth trial is available when you need more headroom. Current prices are on the pricing page.
Do I need an SDK to use the SMS API?
No. curl plus an API key covers sending, polling, and webhook management. When the prototype grows into an app, the same calls map directly to the Python and Node.js guides.
Related guides
This is a spoke of What Is an SMS API and How to Use One. Siblings: Send an SMS from Python and Send an SMS from Node.js. The phone comes from Turn Your Android Phone into an SMS Gateway; the agent route is What Is an MCP Server for SMS?.
Send your first message today
Free plan, no card: 400 messages a month from your own number, with the API, webhooks and MCP included.
Get the app See pricing