How to send your data (format)

Note: If you want to learn how WP Webhooks works, please click here.

In this article, we want to explain you more in detail what content types can be used by our plugin and how you set them up correctly.
If you want to learn more about how you can send your data to a webhook, please check this video:

EARLY ACCESS: We currently opened our first Zapier extension for public testing. You can check it out here:

In general we have five different content types you can send:

  1. application/json
  2. application/xml
  3. application/x-www-form-urlencoded
  4. text/plain
  5. text/html

1. application/json

The first one we are going to look at is the content type JSON. This one is pretty easy, since it is supported by most of the third party service providers. To set it up properly, you create an array with the settings as keys and the data as values.
Here is an example:

  "action": "delete_post",
  "post_id": "333"

In case you use a third party service provider like Zapier or, the integration is very easy. For Zapier you can either use the Custom Request webhook or for the easier way the POST webhook to make your integrations within Zapiers optimized UI. For an example, you can check this video.

2. application/xml

The second content type is xml. This one get sent via the body of your request and it contains a flattened model, with not more than two layers. To show you this in an example, I included one down below:

<?xml version="1.0"?>

We simply use data as a wrapper and include all of our single settings into it.
Please note: When you use Zapier for setting up the XML data, please use under Webhooks for Zapier the Custom Request action and set the content type header to application/xml

For testing purposes, I recommend you the following tool (External Link) for creating demo XML data:

3. application/x-www-form-urlencoded

The easiest way of setting up URL encoded data is using Zapier. There you can easily choose the POST request and set your data directly within the Zapier UI. Here is a video that shows how this works: Click here to go to Youtube

If you want to set it up by yourself, you have to send the data as a query string within your body of the request. Here is an example of how the data should look like:


4 & 5. text/plain & text/html

We also support raw text and html as a content type – both work exactly the same and are a neat way to send data within a document, email, site or whatever else you parse to it.

It works by using our custom tag engine which converts specific notations into data values. To give you an example, we pretend do delete a user from one of our WordPress sites.
To do so, we need to define at least two values:
1. the user id
2. the action

We would therefore need to define somehow these relations:
action = delete_post
post_id = 12345

Here is how we do it:

This is just some random content that can contain anything you want.

The code above defines our action. To make the definition, we set
the key (action) in between two "@" and extend the word by either
a "-start" or a "-end", depending if the value starts or ends.


It also doesn't matter if these values are in between the content,
in an order or at the beginning or the end.
Everything that matters is that the
value itself is right in between these tags.

As you can see within the example, it is very simple to define what values
you can extract out of your content.
With this logic you can nearly do everything with any kind of content in it.

Updated on August 13, 2020

Was this article helpful?

Related Articles