Getting Started

To take advantage of Webhook payload templates, login to the Meraki Dashboard and navigate to the Network-wide --> Alerts page.

When defining an HTTPS server to receive the webhook alert, you have an option to select a payload template. This will shape the data for the selected service.

Each service will have a set of requirements to complete the setup. This typically involves enabling the 3rd party service and collecting API keys and resource IDs.

Explore the Webhook Integrations section for more details.

A Webhook HTTPS Receiver can have a Payload template assigned to it, which will be applied to each alert sent to the configured URL.

alt

Webhook Template Editor

-- In Beta -- The following editor features are available to our Early Access members.

Meraki Dashboard → Network-wide → Alerts

Click on the Add or edit webhook templates to begin.

A list of included or custom templates allows you to perform common actions. To make changes to an exisisting template, select Edit from the Actions menu. Or, create a new one by pressing the Create template button.

Webhook payload templates can be managed and devoloped using the editor within Dashboard.

Liquid Body

This section will contain the Liquid template, which can be modified when in edit mode. The template must be written in a way that it renders to valid JSON RFC8259.

Editor Commands

Press F1 or (right click on a PC / control + click if on a Mac) in the Edit area to open up additional command options.

Generate Preview

When the "Generate Preview" button is pressed, the values for these properties are set by Meraki and are based on real values in your system. Any JSON & Liquid syntax errors will be caught when generating the preview.

Tip: If there are missing values, check to ensure your network or alert type is expected to have this information.

Liquid Headers

Liquid Headers can be added to any message by defining a name/value pair for each. The value supports the Liquid syntax and can use the keys available from the webhook data or sharedSecret property.

In this example, a Basic authorization header is formed by using the base64_encode Liquid filter with the sharedSecret property and setting this value for the Authorization key.

Basic {{ sharedSecret | base64_encode }}

Webhook Data

The Webhook Data section allows you to see an example JSON structure of the default webhook, based on the selected sample alert data. The Shared Secret input allows you to mock the sharedSecret property, which is provide with the webhook HTTPS receiver.

With this information, you can write templates that use these property names as {{variables}} in the Liquid Body or Liquid Headers section.

In this example, you could use the property name alertType and use it in your template with the {{alertType}} syntax, which would then render to the value of: Power supply went down

Toolbox

The Toolbox provides several helpful resources to explore different templates and alert data.

Sample Templates

See how other templates are written to help start your next creation.

Sample Data Types (Alerts)

Test the template against different alerts to preview and validate your code.

Test Webhook

Enter the HTTPS URL address for the webhook receiever. The rendered template will be sent to this destination address, including the sample alert data and user specified sharedSecret

In this example, a test webhook was sent to the free test service, webhook.site, where we can examine the final results.

REST API

Using the Dashboard API, the templates can be uploaded, managed, tested and applied. The following sections highlight the related API operations and the first steps to get started.

Payload Templates

get /networks/{networkId}/webhooks/payloadTemplates getNetworkWebhooksPayloadTemplates
post /networks/{networkId}/webhooks/payloadTemplates createNetworkWebhooksPayloadTemplate
get /networks/{networkId}/webhooks/payloadTemplates/{payloadTemplateId} getNetworkWebhooksPayloadTemplate
delete /networks/{networkId}/webhooks/payloadTemplates/{payloadTemplateId} deleteNetworkWebhooksPayloadTemplate
put /networks/{networkId}/webhooks/payloadTemplates/{payloadTemplateId} updateNetworkWebhooksPayloadTemplate

Create a Webhook Template

Name the template and upload a *.liquid headersFile and bodyFile as form-data or optionally the headers and body params can be used for stringified versions of the templates.

Postman Example

Create Template

Python Example

import requests

url = "https://api.meraki.com/api/v1/networks/{{networkId}}/webhooks/payloadTemplates"
payload={'name': 'My Event Service'}
files=[('headersFile',('customTemplate.headers.liquid',open('/customTemplate.headers.liquid','rb'),'application/octet-stream')),('bodyFile',('customTemplate.body.liquid',open('/customTemplate.body.liquid','rb'),'application/octet-stream'))]

headers = {
 'X-Cisco-Meraki-API-Key': '{{apiKey}}'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text)

Webhook Tests

post /networks/{networkId}/webhooks/webhookTests createNetworkWebhooksWebhookTest
get /networks/{networkId}/webhooks/webhookTests/{webhookTestId} getNetworkWebhooksWebhookTest

Test the Webhook Template

Try using the new template by providing a url, sharedSecret and the payloadTemplateId that was just created or modified.

Postman Example

test webhook

Python Example

import requests
import json

url = "https://api.meraki.com/api/v1/networks/{{networkId}}/webhooks/webhookTests"
payload = json.dumps({
 "url": "https://someservice.com/api/events",
 "sharedSecret": "secret123123",
 "payloadTemplateId": "wpt_1000"
})
headers = {
 'X-Cisco-Meraki-API-Key': '{{apiKey}}',
 'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Webhook HTTP Servers

get /networks/{networkId}/webhooks/httpServers getNetworkWebhooksHttpServers
post /networks/{networkId}/webhooks/httpServers createNetworkWebhooksHttpServer
get /networks/{networkId}/webhooks/httpServers/{httpServerId} getNetworkWebhooksHttpServer
put /networks/{networkId}/webhooks/httpServers/{httpServerId} updateNetworkWebhooksHttpServer
delete /networks/{networkId}/webhooks/httpServers/{httpServerId} deleteNetworkWebhooksHttpServer

Apply Template to HTTP Server

Create or update an HTTP server and add the payloadTemplateId.

Postman Example

image_tooltip

Python Example

import requests
import json

url = "https://api.meraki.com/api/v1/networks/{{networkId}}/webhooks/httpServers"

payload = json.dumps({
 "name": "My Logging Service",
 "url": "http://someservice.com/api/events",
 "sharedSecret": "secret123123",
 "payloadTemplate": {
   "payloadTemplateId": "wpt_9999"
 }
})
headers = {
 'X-Cisco-Meraki-API-Key': '{{apiKey}}',
 'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)

Assign Alerts

get /networks/{networkId}/alerts/settings getNetworkAlertsSettings
put /networks/{networkId}/alerts/settings updateNetworkAlertsSettings

The webhook can be assigned to various Dashboard alerts by applying the httpServerId to the respective alert.

Webhook Logs & Samples

get /organizations/{organizationId}/webhooks/alertTypes getOrganizationWebhooksAlertTypes
get /organizations/{organizationId}/webhooks/logs getOrganizationWebhooksLogs

Get a listing of sample alertTypes to anticipate the data and use as a reference for the webhook logs.