Create your first HTTP receiver
An iHook receiver provides an iHook hosted API endpoint that allows you to receive HTTP requests, and send email/Slack notifications whenever those requests happen. An iHook receiver is a handy tool to accept webhooks from web services such as SendGrid and Okta. Or you can simply use it to test and inspect HTTP requests.
In this tutorial, we will show you how to set up an iHook receiver that sends out email notification when it receives an HTTP request.
1. Create receiver
After signing into iHook dashboard, go to the Receiver
tab, and click the CREATE RECEIVER
button at the top left corner:
A new receiver will be created:
Under the Receiver Settings
section, you can see your receiver's unique URL, which you can use to receive HTTP requests from external resources. The endpoint can receive GET
and POST
requests.
Click the EDIT
button at the top right corner of the Receiver Settings
section, and provide the following values:
Field | Value | Description |
---|---|---|
Name | HTTP request receiver | The name of the receiver. |
Status Code | 200 | The response status code of the endpoint. |
Content Type | application/json | The response content type of the endpoint. The value will appear in response header content-type |
Response Body | {"message": "Hello World", "requestUserAgent": "${requestHeaders.user-agent}"} | The response body of the receiver. You may customize the response body by adding built-in variables such as ${requestBody} and ${requestHeaders} . Variables support JSON path for property value extraction. |
Then click SAVE
. With the new settings, the receiver will respond to HTTP callers with a 200
status code, and a JSON formatted response body.
Note that in the response body, we use the built-in variable ${requestHeaders.user-agent} to access the user agent info of the HTTP request. The expression follows JSON path syntax, for more information about built-in variables and JSON path expression, see here.
At this point, you should be able to see the receiver in action. In your web browser, visit your receiver URL: https://ihook.us/receivers/{receiverId}
, then you will see the response:
{
"message": "Hello World",
"requestUserAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"
}
Congratulations, your receiver has been configured properly and is actively accepting HTTP requests.
2. Setup notification
Next let us set up an email notification, so we can be notified whenever the receiver gets called.
Under the Notification
section, click on ADD
button next to Email
label:
Then a notification setup dialog will show up:
Enter your email address, and click SAVE
, you will see the new notification appear under the Notification
section.
3. Test task
In your browser, enter your receiver URL again, shortly you should receive an email triggered by the receiver:
4. Check request history
If you go to the History
tab, you can see a history of all HTTP requests that your receiver received:
Here you can check the request details such as request timestamp, request/response body, and request/response headers.
Congratulations! You've successfully set up your first iHook receiver that accepts HTTP requests publicly, with email notification enabled!