How to send SMS from a GoIP / Ejoin gateway over HTTP
A GoIP or Ejoin gateway holds real SIM cards and can send SMS from them. Besides its web panel it has an HTTP API, so your own software can queue messages without anyone logging in. This guide shows the request, how the gateway reports back, and what usually goes wrong.
1. Queue a message
POST a JSON task list to goip_post_sms.html on the gateway, with the panel username and password in the query string:
POST http://<gateway-address>/goip_post_sms.html?version=1.1&username=<user>&password=<pass>
Content-Type: application/json;charset=utf-8
{
"type": "send-sms",
"task_num": 1,
"sr_url": "https://your-server.example/sms-report",
"tasks": [
{ "tid": 1001, "from": "1", "to": "<number>", "sms": "Your code is 123456", "sdr": 1, "fdr": 1 }
]
}tidis your own task id. Make it unique: you need it to check on or cancel the task later.fromis the port (SIM slot) that sends. Choosing it yourself is how you spread load across SIMs.sr_urlis where the gateway posts the result;sdrandfdrask for a report on success and on failure.
The reply lists one status per tid. A status starting with 0 means the gateway accepted the task. It does not mean the SMS was sent yet.
2. Status codes worth handling
0: accepted and queued.2Invalid Port: the port number doesn't exist on this gateway.4Pending USSD: the port is busy with a USSD session; retry on another port.5SIM Unregistered: the SIM isn't on the network (no signal, no credit, blocked). Take that SIM out of rotation instead of retrying it.- Login or server errors say nothing about the SIM. Treat them as a gateway problem, not a SIM problem.
3. Know when it was really sent
Accepted is not sent. The gateway posts the final result to your sr_url when the SIM has sent the message or failed. Build your own handling for the case where no report ever arrives: ask the gateway whether the task is still queued (goip_get_tasks.html) before you assume it failed, otherwise you can send the same message twice.
To take a task back out of the queue, call goip_remove_sms.html with the tid. Never call it with an empty list: that removes every queued task on the gateway.
4. Mistakes that cost the most time
- Number format. The API and the web panel can expect different formats (with or without the
+). Test one message by hand and copy the format that arrives. - One SIM, many failures. A SIM that fails repeatedly should be paused for a while, not retried on every message.
- Long texts. One SMS is 160 characters, or 70 if it contains a character outside the basic GSM alphabet (an emoji, or a letter like ș). Longer text is split into parts, and every part is a message.
- Panel password. The API sends the password in the URL. Change the default one, and prefer HTTPS or a private network.
Don't want to run this yourself?
SMS Send does all of the above for you: a web panel and a single API call, a status for every message, an automatic retry on another SIM, and automatic refunds for failures. See the API or create an account.