Build Webhooks

Write the code that properly handles webhook notifications.

The first step to adding webhooks to your SMSPortal integration is to build your own custom endpoint. Creating a webhook endpoint on your server is no different from creating any page on your website.

Before looking at the code, there are two different versions of webhooks. To learn more about which webhooks version each API or channel uses, and how to set them up with your application, please see the table below. You should also review the best practices.

Channel

Method

REST API

Webhooks V2 (POST)

SFTP Version 7

Webhooks V2 (POST)

Website

Webhooks V1 (GET)

Legacy APIs

Webhooks V1 (GET)

Short Codes

Webhooks V1 (GET)

URL Tracking

Webhooks V1 (GET)

Return a 2xx status code quickly

To acknowledge receipt of an event, your endpoint must return a 2xx HTTP status code to SMSPortal. All response codes outside this range, including 3xx codes, indicate to SMSPortal that you did not receive the event.

If SMSPortal does not receive a 2xx HTTP status code, the notification is retried. After 5 failures to send the notification, SMSPortal marks the event as failed and stops trying to send it to your endpoint.

Because properly acknowledging receipt of the webhook notification is so important, your endpoint should return a 2xx HTTP status code prior to any complex logic that could cause a timeout.

Test that your endpoint works

As your webhook endpoint is used asynchronously, its failures may not be obvious to you until it’s too late. Always test that your endpoint works:

  • Upon initial creation
  • After taking it live
  • After making any changes

The Test Webhooks page explains how to test your endpoint.


Did this page help you?