Documentation

Get started with your own restdb.io database.


Webhooks

Webhooks are "user-defined HTTP callbacks" from a restdb.io database to any other system.

restdb.io calls an URL when an event occurs in the database. An event is triggered when you/api:

  • Create a data record
  • Update a data record
  • Delete one or many data records

Example

Lets say that you created a collection with Article data in RestDB and you want to notify some other system when a new Article is created in your database. In order to set up a Webhook you must know or control the URL endpoint you wish to connect to. An URL endpoint looks something like:

https://myservice.org/customerdata

restdb.io will POST an event JSON object from the database to the URL endpoint each time a record event occurs.

Example event JSON object sent to the URL endpoint when a PUT trigger is called:

    {
      "event": {
        "db": "rdb-nocms",
        "collection": "articles",
        "method": "PUT",
        "payload": [
          {
            "_id": "5660473aa389c34a0000035e",
            "title": "Suite 108",
            "_version": 2,
            "_created": "2015-12-03T13:44:26.034Z",
            "_createdby": "jones",
            "body": "Some text ...",
            "_changed": "2015-12-11T09:23:52.695Z",
            "_changedby": "jones@restdb.io"
          }
        ]
      }
    }

Creating a Webhook

To create a Webhook, activate Developer mode (top right corner), navigate to a Collection and click on the Webhook tab.

Enter the URL endpoint for the Webhook, check which event you want to trigger and check the Active checkbox. That's all there is to it. restdb.io will now call this URL each time one of the events occurs.

screenshot

Errors

If restdb.io gets an error while calling a Webhook this is logged and displayed. Subsequent errors will disable the Webhook, i.e. the Active checkbox is turned off. When you locate the error, activate the Webhook again.

screenshot

Tip

Create an URL endpoint for testing your Webhooks: http://requestb.in. This shows you all the data that are posted from restdb.io to that URL endpoint.

Read more about Webhooks at Wikipedia.