Sipgate API: Send SMS via simple Webhook
Anyone who wants to test their systems for availability cannot avoid a type of monitoring. healthchecks.io, for example, is ideal for this use case. Unfortunately Healthchecks.io does not offer a service for Sipgate here, but a possibility to set up a webhook.
Only with this webhook it is possible to send an SMS using the Sipgate API. How to do that, I'll explain in this small blog post.
Sipgate API
- The Sipgate API can be activated free of charge for every Sipgate account. Simply activate the API at: https://app.sipgatebasic.de/feature-store/sipgate.io-s
- An overview of the Sipgate API can be found at: https://api.sipgate.com/v2/doc#/sessions/sendWebSms
- In order to authenticate yourself to the API, you need a so-called personal access token of the Sipgate API. You can set it up at: https://app.sipgate.com/w0/personal-access-token
Method:
- Apply for a personal access token at: https://app.sipgate.com/w0/personal-access-token
- Oauth-2 Scope: sessions:sms:write
- Personal Access Token of the form: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
- Token ID in the overview of the form: token-XXXXXX
he authentication to the API works with Basic-Auth. The Basic-Auth String is just a concatenation of username and password, delimted by :
This token can be generated from password and user name like below in any sophisticated OS:
echo -n "token-0A0AAA:12345678-1234-1234-1234-1234567890ab" | openssl base64
you'll get something like this: dG9rZW4tMEEwQUFBOjEyMzQ1Njc4LTEyMzQtMTIzNC0xMjM0LTEyMzQ1Njc4OTBhYg==
as the Basic-Auth String. This string has to be built in into the header of your request.
Accept: application/json
Authorization: Basic dG9rZW4tMEEwQUFBOjEyMzQ1Njc4LTEyMzQtMTIzNC0xMjM0LTEyMzQ1Njc4OTBhYg==
Content-Type: application/json
Pay attention to the new lines. Always a new line for one header type.
At Healthchecks.io it should look like this:
Webhook healthchecks.io
- URL: POST https://api.sipgate.com/v2/sessions/sms
- Request Body:
{
"smsId": "s0",
"recipient": "+49123456789",
"message": "$NAME went $STATUS at $NOW",
"sendAt": -1
}