TextMaster's Developer Documentation
HomeApp
  • Welcome!
  • Quick Start
    • Postman
    • OpenAPI
  • Overview
    • Resources in the REST API
    • Authentication
    • Troubleshooting
    • Filters
    • Workflow
    • File uploads
    • Loop
  • Guides
    • Integrator best practices
  • Apps
    • About OAuth Apps
    • Building OAuth Apps
      • Creating an OAuth App
      • Authorizing OAuth Apps
      • Scopes for OAuth Apps
    • Managing OAuth Apps
      • Modifying an OAuth App
      • Deleting an OAuth App
  • Webhooks & Events
    • Webhooks
      • Creating webhooks
      • Configuring your server for webhooks
      • Securing webhooks
      • Troubleshooting webhooks
    • Events
  • Integrations
    • Akeneo
      • Getting Started
      • Configuration
      • Usage
      • Monitoring
      • Troubleshooting
    • Salesforce Commerce Cloud
      • Getting Started
      • Configuration
      • Usage
      • Monitoring
      • Troubleshooting
  • Reference
    • Abilities
    • Authors
    • Documents
    • Categories
    • Countries
    • Expertises
    • Glossaries
    • Languages
    • Levels
    • Locales
    • Preferred Authors
    • Projects
    • Project Templates
    • Negotiated Contracts
    • Support Messages
    • Transactions
    • Uploads
    • Users
    • Work Templates
Powered by GitBook
On this page
  • Exposing localhost to the internet
  • Setting up a webhook

Was this helpful?

  1. Webhooks & Events
  2. Webhooks

Creating webhooks

Learn to build a webhook, choosing the events your webhook will listen for on TextMaster and how to set up a server to receive and manage the webhook payload.

PreviousWebhooksNextConfiguring your server for webhooks

Last updated 3 years ago

Was this helpful?

Now that you understand , let's go through the process of building out our own webhook-powered integration. In this tutorial, we'll create a webhook defined at the user level that will be responsible for receiving a notification every time word count has been computed on a new document.

Creating a webhook is a two-steps process. You'll first need to set up how you want your webhook to behave through TextMaster: which events it should listen to. After that, you'll set up your server to receive and manage the payload.

The REST API allows you to manage webhooks. You can use it to list configured webhooks and change their configuration. For example, you can modify their payload URL and/or associated events.

Exposing localhost to the internet

For the purposes of this tutorial, we're going to use a local server to receive messages from TextMaster. First of all, we need to expose our local development environment to the internet. We'll use ngrok to do this. ngrok is available, free of charge, for all major operating systems. For more information, see .

After installing ngrok, you can expose your localhost by running ./ngrok http 4567 on the command line. 4567 is the port number on which our server will listen for messages. You should see a line that looks something like this:

$ Forwarding    http://7e9ea9dc.ngrok.io -> 127.0.0.1:4567

Make a note of the *.ngrok.io URL. We'll use it to set up our webhook later.

Setting up a webhook

You can set up webhooks either globally, on your user account or on a specific resource. In this tutorial, we'll set up a global webhook.

You can use the following cURL query to create/update webhooks set up on your user account.

curl "https://api.textmaster.com/v1/clients/users/USER_ID" \
     -X PUT \
     -H "Authorization: Bearer ACCESS_TOKEN" \
     -H "Content-Type: application/json" \
     -d '
     {
       "user": {
         "callback": {
           "word_count_finished": {
             "url": "http://7e9ea9dc.ngrok.io/payload"
           }
         }
       }
     }
     '

You'll need to replace USER_ID with your own user id and ACCESS_TOKEN with a valid OAuth2 access token.

Notice the payload URL is the URL of the server that will receive the webhook POST requests. Since we're developing locally for our tutorial, we've set it to the *.ngrok.io URL, followed by /payload.

the basics of webhooks
the ngrok download page
About OAuth Apps