The short answer: any script that already watches something (a website, a server, stock levels, a backup) can text your team with one request to our API. SMS reaches people even with mobile data switched off, which makes it a good fit for alerts that cannot wait.
What you need
| 1 |
SMS activated on the SMS page in Meu Interweb, with credits in the balance.
|
|
| 2 |
An API key with only the sms:write permission, created on the API page in Meu Interweb. If the script always runs from the same server, restrict the key to its IP.
|
|
| 3 |
Your team's numbers, written with or without the country code, because the system can tell the country from the first digit: 841234567 goes to Mozambique and 923456789 to Angola. So +258 84 123 4567 and 258841234567 are the same number as 841234567.
|
|
A minimal script
This example sends an alert to two numbers. Keep the key in an environment variable, never in the file itself:
#!/bin/sh
# alert.sh: sends the text in the 1st argument to each number on the team
for N in 841234567 ANOTHER_NUMBER; do
curl -s https://api.interweb.co.mz/v1/sms/messages \
-H "Authorization: Bearer $RLX_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"number\": \"$N\", \"text\": \"ALERT: $1\"}"
done
Run it like this: ./alert.sh "the website has not answered since 14:38". With a sandbox_ key the request is validated but nothing is sent and no credits are used: test with it, then switch to the prod_ key. For many numbers at once there is the batch send.
When to fire
| What you watch |
When it alerts |
| Website or server |
When it stops answering, and again when it is back |
| Stock |
When a product drops below the minimum you set |
| Backups and scheduled jobs |
When a job fails or does not run |
| Disk space or quotas |
When usage passes a threshold of yours |
To run the script on its own at regular intervals, see cron schedule examples. To watch a website, an alert when your site goes down.
|
Alert once per problem, not once per minute. A script that runs every minute and texts every time it sees the fault burns credits and hits the account's daily sending limit. Write down in a file that you already alerted, and only send again when the problem changes or ends.
|
|
Start the text with ALERT and name the system, the problem and the time. Whoever is on duty understands at a glance.
|
|
Want your team to know straight away when something stops? See the API page and create your first key.
See the API page
|
RECOMMENDED PRODUCT Web hosting with cPanel Domain and SSL included, daily backups and the panel you already know. from 321,75 MT/mo (3-year plan, with coupon) See plans |