← Servers, deploying and APIs

Lesson 17 of 20 · Try it · 20 min

3.3 Hands-on: send an SMS from your server

You'll send a real SMS to your own phone, from your server, with Lynk's API.

Steps

  1. In Developer tools, create a key named My server test that can only use sms. Copy it.
  2. Log in to your server. Save the key in a private file:
nano ~/.lynk-key

Paste the key on one line, save and exit, then make the file private:

chmod 600 ~/.lynk-key
  1. Send an SMS to your own number:
curl -X POST https://www.lynkinfra.com/api/v1/sms \
  -H "Authorization: Bearer $(cat ~/.lynk-key)" \
  -H "Content-Type: application/json" \
  -d '{"to": "024XXXXXXX", "message": "Hello from my own server"}'
  1. Read the answer. Your phone gets the text in a few seconds.
  2. Try a mistake on purpose: change one letter of the key in the command (not the file) and run it again. Read the status and the message. That's what your app sees when a key is wrong.

Only to your own number. Never send test messages to other people. Each SMS costs money from your Lynk account.

Check your work: the SMS reached your phone.

Try it in Lynk

Now do it yourself. When you're done, come back here and mark this lesson done.

Sign in to try it
Next lesson

Sign in to save your progress and earn the certificate.

3.2 Lynk's API and your keys