Text or call us at 423-218-0111

Webhooks

In your Text Request account, there are events that occur that you might find interesting. Examples include receiving a new message or when a new contact is created. To let you know when certain events occur, Text Request supports the creation of webhooks. A webhook is a URL that you designate that will be called when an event takes place.

Available Webhook Types

Text Request webhooks are defined per phone number within your account. For example, if your account has the phone numbers 423-218-0111 and 865-902-1468, each of these phone numbers may have its own set of webhooks.

  • A message is received - called whenever your Text Request phone number receives a new message.
  • A message is sent - called whenever your Text Request phone number sends a message.
  • A new contact is created - called whenever a new contact is created in your Text Request phone number’s address book.

Managing Your Account’s Webhooks

Each Text Request number starts life without any webhooks defined. Once you create a Text Request phone number within your account, you can add, list, and delete webhooks. These operations are performed through the v2 API.

The API endpoints for webhook management are documented above. If you have a Text Request account, you can try these endpoints out yourself within our live documentation page.

Webhook Callback Format

When you define a webhook, you provide the URL that should be called via HTTP POST. The body of each webhook callback is as follows:

Message Sent and Message Received

The following JSON is sent in the body for message sent and received webhooks. The only difference between the sent and received webhook body is the messageDirection field.

            
    {
        "account": {
            "id": 1234 //your Text Request account Id.
        },
        "yourPhoneNumber": {
            "id": 7250, //Your Text Request phone number Id.
            "externalPhoneId": null, //The phone number Id that you define.
            "description": "Our demonstration number", //friendly name
            "phoneNumber": "14239309346" //Your Text Request phone number
        },
        "conversation": {
            "id": 42045, //Unique Id for the conversation.
            "date": "2018-10-11T01:28:46.5966126Z", //message timestamp in UTC
            "consumerPhoneNumber": "14232074721", //sender/recipient phone
            "messageDirection": "S", //S for sent messages, R for received
            "message": "This is an outbound message.", //message text
            "consumerFriendlyName": "Check" //friendly name for the customer you are communicating with
        }
    }
                
            

Contact Created

The following body is sent for contact created webhooks.

                
    {
        "ContactId": 3998552, //Unique identifier for the contact.
        "LocationPhoneNumber": "14239309346", //Your Text Request phone
        "ContactPhoneNumber": "19143334444", //contact’s phone number
        "ContactFriendlyName": "James Hoffa" //contact’s friendly name
    }