IntroductionGetting StartedAuthenticationRequestsResponses
Entities
WebhooksEventsCreating an EndpointExamplesIntegration Test

Webhooks

walrus.ai offers the ability to receive webhook requests at a URL of your choosing when a number of events occur. Subscribing to these events can be helpful for a variety of reasons:

  • Carrying out any setup logic before a test is run (e.g., provisioning a test account)
  • Carrying out any teardown logic once a test is complete (e.g., tearing down that test account)
  • Alerting on test failures (walrus.ai also offers a Slack integration!)
Head to your Integrations Settings to specify your webhooks URL.

Events

Event TypeDescription
test_receivedwalrus.ai has received the test and execution is pending.
test_completedThe test has been completed and returned.

test_received

FieldDescription
eventType: 'test_received'
data: object
data.integrationTest: IntegrationTestThe created IntegrationTest.
POSThttps://your-app.com/walrus-webhook
1{
2 "eventType": "test_received",
3 "data": {
4 "integrationTest": {
5 "createdAt": "2019-11-19T21:17:58.226Z",
6 "name": "Amazon Checkout",
7 "url": "https://amazon.com"
8 }
9 }
10}

test_completed

FieldDescription
eventType: 'test_completed'
data: object
data.integrationTest: IntegrationTestThe completed IntegrationTest.
data.success: booleanWhether or not the test passed successfully.
data.video: stringThe URL of the test recording and results.
POSThttps://your-app.com/walrus-webhook
1{
2 "eventType": "test_completed",
3 "data": {
4 "integrationTest": {
5 "completedAt": "2019-11-19T21:19:58.226Z",
6 "createdAt": "2019-11-19T21:17:58.226Z",
7 "name": "Amazon Checkout",
8 "url": "https://amazon.com"
9 },
10 "success": true,
11 "video": "https://app.walrus.ai/integration-test/b43211c1-3af0-4b3d-8281-66042b55e653"
12 }
13}

Creating an Endpoint

In order to register for webhook events and begin handling them, you're going to have to create an API endpoint on your end.

This endpoint is what you'll specify in Integrations Settings.

Below is an example of an endpoint for handling walrus.ai webhook events. Note that the eventType parameter should be used to determine if and how to handle the event.

1// This example uses Express to receive webhooks
2const app = require('express')();
3
4// Use body-parser to retrieve the raw body as a buffer
5const bodyParser = require('body-parser');
6
7// Match the raw body to content type application/json
8app.post('/walrus-webhook', bodyParser.raw({ type: 'application/json' }), (request, response) => {
9 let event;
10
11 try {
12 event = JSON.parse(request.body);
13 } catch (err) {
14 response.status(400).send(`Webhook Error: ${err.message}`);
15 }
16
17 // Handle the event
18 switch (event.eventType) {
19 case 'test_received':
20 handleTestReceived(event.data);
21 break;
22 case 'test_completed':
23 handleTestCompleted(event.data);
24 break;
25 default:
26 // Unexpected event type
27 return response.status(400).end();
28 }
29
30 // Return a response to acknowledge receipt of the event
31 response.json({ received: true });
32});
33
34app.listen(3000, () => console.log('Running on port 3000'));