Pike13 For Developers
Get Started
Authentication
Core API
Reporting API
Webhooks API
Announcements

Webhooks API Documentation

Get Started

Follow these simple steps to register your app and get started with the Pike13 Webhooks API. Only OAuth2 tokens registered to those with the role of owner or higher can access the Webhooks API.

API access is included only with the Pike13 Premium plan. If you need to upgrade your plan, contact us at sales@pike13.com.

API Description

The purpose of the Webhooks API is to automatically notify you and your services of changes within your business. Remember, only staff members with the role of owner or higher have access to the API. For example, when a new client signs up for your business, we'll automatically send you a JSON payload.

Interaction with the Webhooks API is two parts: subscribing to topics and receiving notifications.

Subscribing

Subscribe using the REST API endpoint. Note that it conforms to JSON API version 1.0. Choose what kinds of notifications should be sent based on available topics.

Receiving

Receive notifications through POST requests. The payload is automatically POSTed to the target server when a change corresponding to a webhook happens.

Example Flow

Once you have an OAuth2 token for an owner of your business, you can subscribe to an available topic.

Let's create a webhook that triggers whenever a new person is created in your business:

SUBSCRIPTION REQUEST
curl -X POST https://mybiz.pike13.com/api/v3/webhooks \
-H 'Authorization: Bearer XXXXXX' \
-H 'Content-Type: application/vnd.api+json' \
-d '{
  "data": {
    "type": "webhooks",
      "attributes": {
        "target": "https://target.example.com",
        "topic": "person.created"
        }
      }
    }'

The target attribute specifies the endpoint to which we will send a notification.

SUBSCRIPTION RESPONSE
HTTP/1.1 201 Created
Content-Type: application/vnd.api+json

{
  "data": {
    "id": "1",
    "type": "webhooks",
    "links": {
      "self": "https://subdomain.pike13.com/api/v3/webhooks/1"
    },
    "attributes": {
      "account_id": 1,
      "business_id": 1,
      "topic": "person.created",
      "target": "https://target.example.com/",
      "name": null,
      "description": null
    }
  }
}

After this successful subscription, if a person is created for the business, a server on https://target.example.com/ will receive a message like this:

NOTIFICATION PAYLOAD
POST https://target.example.com/
Content-Type: application/json

{
  "topic": "person.created",
  "webhook_id": 1,
  "business_id": 1,
  "data": {
    "people": [
      {
        "id": 10,
        "address": null,
        "birthdate": null,
        "business_id": 1,
        "deleted_at": null,
        "dependents": [],
        "email": null,
        "pronoun": null,
        "first_name": "John",
        "guardian_email": null,
        "guardian_name": "Nathan Doe",
        "hidden_at": null,
        "is_member": false,
        "joined_at": "2019-02-19T23:24:02Z",
        "last_name": "Doe",
        "location": {
          "id": 30742,
          "name": "Example Business",
          "slug": "example-business"
        },
        "middle_name": null,
        "name": "John Doe",
        "phone": "123 456 7890",
        "primary_staff_member": {
          "id": 2,
          "name": "Joseph Cremin"
        },
        "providers": [],
        "secondary_info_field": "No Membership",
        "timezone": "America/Los_Angeles",
        "updated_at": "2019-02-19T23:24:02Z"
      }
    ]
  }
}

Once you have received this payload, you must respond with a 200 status code within 10 seconds, or else it is considered an error on our end.

The data field shows the most up to date status of the resource, in this case a person. It is not identical to the json returned by the person desk endpoint If you require more fields about a person, access the corresponding Core API endpoint upon receiving a webhook:
/api/v2/desk/people/:id

POST bodies

Notifications are sent within HTTP POST bodies. The common format for notifications hitting target servers is

NOTIFICATION PAYLOAD
POST https://target.example.com/
Content-Type: application/json

{
  "topic": "person.created",
  "data": { <topic fields> },
  "target_url": "https://target.example.com",
  "webhook_id": 1
}
Where the supported fields are documented for each topic. If the webhook is a <resource>.updated topic:
TOPIC FIELDS (previous exists only on *.updated topics)
{
  ...Supported fields for the topic,
  "previous": {<previous values of the changed fields>}
}
A full example of a person.updated payload illustrates that the previous name for a person was "John" but was updated to "Gary":
EXAMPLE: person.updated payload
{
  "topic": "person.updated",
  "data": {
    "people": [
      {
        "id": 1,
        "first_name": "Gary",
        "middle_name": null,
        "last_name": "Turcotte",
        "email": "turcotte_raegan@pike13.com",
        "account_id": null,
        "created_at": "2012-09-03T09:05:00.468-07:00",
        "updated_at": "2012-09-03T09:08:53.337-07:00",
        "business_id": 1,
        "is_client": true,
        "address": null,
        "phone": "(534)052-5044",
        "location_id": null,
        ... (truncated for clarity)
      }
    ],
    "previous": {
      "first_name": "John",
      "updated_at": "2012-09-03T09:08:53.337-07:00"
    }
  },
  "webhook_id": 1,
  "business_id": 1
}

The indicated topic fields within data is similar to the json that Core API would return for the endpoint corresponding to the person.created topic. If you need other fields on the resource, you would make your own api call to the resource's corresponding Core API endpoint.

Requirements

  • The target url specified when creating a webhook must be be https.
  • Servers must respond with a 200 (Success) status code upon receiving a notification within 10 seconds.
  • Opening a connection to servers will timeout if it takes longer than 10 seconds.
  • If a target url server responds with a 410 (Gone) status code the webhook will be deleted.

Notification Lifetime

Generally, a notification will reach target servers within minutes and likely sooner. In the event that notification destinations are unavailable when POSTing, the notification will be retried based on the response status code returned. However, notifications may expire if the target server does not respond with a 200 after 20 retries.

Retry Status Codes
429
500-599

All other status codes returned by servers will result in the dropping the notification immediately. To help with debugging, use the trigger sample notification endpoint to receive a notification.

Retry Intervals

Retries are done with jittered exponential backoff. We will retry sending a notification 20 times over the next 4 days.

Automated Unsubscription

By default a webhook will continue to receive notifications indefinitely. However, when the user who created the webhook is no longer an owner of the business or the user has been removed from the business, all of their webhooks are unsubscribed automatically. Additionally, when the business has chosen to disable the webhooks feature, all of its webhooks will be unsubscribed automatically.

Debugging Notifications

Trigger sample notification.

POST /api/v3/webhooks/:webhook_id/trigger_sample_notification

Sends a sample notification to a webhook's target URL. Does not make a real data change.

Show curl example

REQUEST
$ curl -X POST https://mybiz.pike13.com/api/v3/webhooks/1/trigger_sample_notification \
  -H "Authorization: Bearer XXXXXXXXXXXXXXX"

RESPONSE
HTTP/1.1 202 Accepted