Notifications (Email, SMS, and Webhook)
You can get notifications from RapidAPI Testing through email, SMS, or webhook. Below we will discuss how you can get them set up.
Email + SMS Notifications
In order to enable email notifications, head over to the “Settings” page of your API, and scroll down to the “Alerts” section. Then, click the “+” button, and enter your email address.
There are a few more settings that can help you control when you get notifications.
On Error
You will most likely want to get notified when a test fails, and this is that alert. It is by default toggled on.
- Start sending alerts after X consecutive test failures (including retries). If you don’t want notifications on failures, you can toggle this off. In addition, you can (along with the retries setting) set it up so that you only get notified after X consecutive failures. For example, you may notice that there are transient failures with your tests (API network issues, etc.), and you only want to get notified if the original test + the retry fails. In that case, you can set it up so that you only get notified after 2 consecutive failures.
- Don't send me additional alerts within X minutes of the previous alert. A test failure may alert you of an issue with your APIs, which requires some work to fix it. Once you are aware of the issue, it may add to the stress if you keep on getting notifications of the same failures while you are working to fix the issue. This setting helps reduce those notifications. You can set it up so that you only get one alert within an X minutes period.
On Recovery
You may also want to get notified if a test that has previously failed is now successful. If that is the case, toggle this setting on.
SMS notifications work in exactly the same way, except that you will provide a phone number as opposed to an email address.
Webhook Notification
Webhook notification is helpful if you want to integrate RapidAPI Testing notifications with your existing tools, such as Slack, DataDog, PagerDuty, etc. Unlike email + SMS notifications, you can get alerts on successful test executions as well with webhook notifications. This can help you keep a pulse on your test executions, gather data, etc.
First, head over to the Webhooks tab of the Alert section where you can enter a name for the alert and select the appropriate environment.
Then, we can set up the webhook detail + its contents. For this, click the “Edit request” button (marked as number 3). You will now see a modal, which we will use to set up the webhook.
Hit “Custom Request”, and you will see something similar to an API client. Here, you can define what you want included in the webhook alert (HTTP method, URL, headers, body, etc.). In the body of the webhook, you can include information about the test by using the {{}} nomenclature. See below for more details on variables that you can use.
Once you have specified the contents, hit “Send” to make a test request. This helps you ensure that the URL is correct, etc. If the request is successful, and you are ready to save the webhook, click “Create Webhook”.
You will see the webhook information added on the Settings page. At this point, you can set up additional webhooks for success + recovery case, or if you are done, don’t forget to hit Submit to save your webhook definition. And you are done!
Webhook Content Variables
- apiName. Name of the API.
- test.id. ID of the test.
- test.name. Name of the test.
- test.api. ID of the API.
- test.code. Code representation of the test.
- testExecution.id. Test execution ID.
- testExecution.status. Test execution status (completed, pending).
- testExecution.environment. Environment ID of the test execution.
- testExecution.location. Location of the test execution.
- testExecution.executionTime. The time it took to execute the test.
- testExecution.successful. Boolean on whether the test execution is successful.
- testExecution.computedStatus. Human-readable status of test execution.
- testExecution.executed. The time at which the test was executed.
- learnMoreUrl. URL to the Testing app containing detailed test execution report.
As an example, if you put the following in the body.
{
"text": "{{test.name}} in {{apiName}} API has failed after {{testExecution.executionTime}} ms. This test was executed in {{testExecution.location}} location."
}
You will get the following in the webhook.
{
"text": "Get Products Test in MyStore API has failed after 534 ms. This test was executed in Hong Kong location."
}
Updated about 3 years ago