Webhooks allow your application to receive real-time notifications from TextUs as soon as a specific event occurs. Details about the event are sent via an HTTPS POST request to an endpoint URL that you specify.
How are webhooks different from APIs?
While webhooks and APIs are similar in what they can do for you, they serve different purposes and operate in different ways. Both are designed to send data between an application and a server; however, the way in which they operate differs in the following ways:
Webhooks are event-driven, which means that webhooks automatically send one-way data from one application to another as soon as an event occurs. In this way, webhooks act as a messenger that “listens” for specific system events, and then transfers the data in real-time to a designated endpoint.
APIs, on the other hand, rely on manual requests to retrieve or modify data and allow for two-way communication between software applications. As a result, APIs can update a server or application periodically when a request is made, but they don’t receive real-time data as soon as an immediate change occurs.
Should I use a webhook or an API when integrating my application with TextUs?
Ultimately, webhooks and APIs serve similar functions, but the better choice between the two depends on your specific needs. In some cases, you may find it beneficial to use both methods to transfer data between two systems: a webhook to receive real-time updates from TextUs, and an API call to push the data to your system.
The section below provides more information on some of the most common use cases for using TextUs webhooks and APIs in an integration.
When to use a webhook
If you want to receive real-time updates or notifications about events that happen in your TextUs messaging account, webhooks might be the simplest option. Here are a few examples of when you may want to use webhooks in your TextUs integration:
Receive real-time notifications in your application when a message in TextUs is sent to a contact and successfully delivered, or when you receive a message from a contact.
Sync and update opt out records in your application as soon as a contact opts out of receiving text messages from your organization in TextUs.
Send a contact record to your application every time a new contact is added to your TextUs account.
When to use an API
If your integration with TextUs requires on-demand access to data, or you plan to modify the data rather than simply push notifications, an API call is probably the better choice. Here are some examples of when you might want to use the TextUs APIs in your integration:
Retrieve data from your TextUs messaging account, such as a list of all your contacts, then add the data to your application.
Update or create new data in your TextUs account, such as a contact’s information, without manually entering data via the TextUs apps.