SMSNET
Guide

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.

The curl lifecycle: send, poll, register a webhook, test it Four numbered steps from left to right. Step one posts to messages send and gets message_id plus quota. Step two polls messages with a since cursor. Step three registers the webhook with PUT. Step four sends a test event with POST to webhooks test. Four curl calls take you from send to verified webhook Every step runs as written with SMSNET_API_KEY exported. No SDK, just curl. 1 2 3 4 Send Poll Register Test POST .../send GET .../messages PUT .../webhooks POST .../test returns message_id and quota day, month add -i to see status first call lists latest then since = cursor repeat about each 10 s body has your URL keep secret for checks events are signed test before real traffic signed like the real one retry 6 times if down Errors are plain: 400 fix the request, 401 check the key, 403 never retry, 429 wait for the window The same four calls map directly onto the Python and Node.js guides when the prototype grows.
Four step diagram: step one POSTs to messages send and returns message_id plus quota, step two polls messages with a since cursor, step three registers the webhook with PUT, and step four sends a test event to webhooks test.

What errors will curl show?

StatusWhenWhat to do
400Missing to or body, or no phone connected to the accountFix the request, or connect a phone
401Missing or wrong key; the error says whether the key was rotatedExport the right key, rotate if needed
403The recipient opted out; the error names the date and the words they usedDo not retry; remove them from your list
429Monthly or daily allowance reached, including the headroomWait 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.

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

Get it on Google Play

Written by , who builds SMSNET. Product facts on this page are checked against the live pricing page and the running API on the date shown above.