🔙 to the home page

In part 1 you learned how to make outgoing API calls, essentially testing how a machine (or an app you might write) to ask for information or perform actions.

Webhooks are the reverse—when something happens in an application, that action might send a message (a webhook) to another system to let it know. Like push notifications, but for machines instead of humans. This type of notification system for APIs is especially useful for processes that do not happen concurrently, like payments!

Option 1: Install ngrok

ngrok is a tool that allows you to create a secure tunnel from the public internet to your computer or “local machine”. This is useful for testing webhooks because it allows external services and APIs to send requests to your code on computer, even when it's running locally.

If you’re unable or would prefer not to install software like this on your computer, skip down to option 2.

Instructions:

  1. Go to ngrok and download the version for your operating system.

  2. Install ngrok by following the setup instructions on their website.

    <aside> 😕

    Trouble installing? We have an alternative!

    It appears that you must signup for a free account to use ngrok 😞 it’s worth it! But if you’d prefer not to, you can use this alternative: pinggy.io which does not require any account signup.

    </aside>

  3. Open your Terminal:

    1. If you installed VS Code, go to Terminal in the menu and then select “New Terminal”
    2. (MacOS) If you did not install VS Code use the Cmd + Space keys and type “Terminal” then hit Enter
    3. If you’re on a windows machine please submit suggestions to update this tutorial to [email protected]
  4. Run the following command to start ngrok on port 8080 (this is the port we’ll use to run our example app):

    ngrok http 8080
    
  5. You should see output that shows a publicly available URL (e.g., https://abcd1234.ngrok.io) which will be labelled forwarding. This URL is now live on the internet and configured as a “forwarding” service to your laptop. So it can be used to receive webhook events from external services!

  6. You’ll also see a url labelled “Web Interface”, it will probably be http://127.0.0.1:4040. Open this link in your web browser and you can see a simple interface that will show information about any incoming webhooks.

Option 2: Use an Online Webhook tool

If you can’t install a terminal-based command line tool like ngrok or pinggy, don’t worry you can use one of these tools below: