What Are Webhooks?
Webhooks are a powerful method for web applications to communicate in real-time. Unlike traditional APIs that require constant polling for updates, webhooks use a push mechanism to send data immediately when specific events occur. When an event is triggered, a webhook sends an HTTP request to a pre-configured URL in another system, containing a payload with information about the event. This allows the receiving system to process the data and take necessary actions promptly.
Why Should I Use Webhooks?
The main advantages of webhooks include reduced latency and bandwidth usage, as they eliminate the need for frequent polling. They are especially useful for scenarios requiring immediate data synchronization, such as payment processing, real-time messaging, and automated workflows. By enabling instant interactions between web applications, webhooks enhance efficiency and responsiveness in modern web architectures.
Webhook Fields
These are the fields we sent in the Webhook:
-
event
: a string identifying the event (user_create
,user_delete
, etc.) -
activity_fields
: an object containing the following fields:- id: Activity ID
- action: a string describing the action that triggered the Webhook (publish, create, etc.)
- trackable_type: a string indicating what was affected (a User, for example)
- trackable_id: the ID of the affected model (the ID of the User that was created, for example)
- owner_type: a string indicating the type of who did this activity (usually this is the User that performed the action)
- owner_id: the ID of who was responsible for generating this activity (the ID of the User that created the article, for example)
- created_at: timestamp indicating when the activity was performed.
- extra: a JSON object that contains extra information about the activity.
- published_activity_id: ID of the activity publication. This is something that Helpjuice uses to track the activity internally.
- automatic: if the article was automatically published/expired.
-
activity
: a string containing theactivity_fields
object serialized.
Webhook Events
The available events for webhooks are:
Event Name | Description |
user_create |
Called when a user is created. |
user_update |
Called when a user is updated. |
user_delete |
Called when a user is deleted. |
question_create |
Called when an article is created. |
question_update |
Called when an article is updated. |
question_delete |
Called when an article is deleted. |
question_archive |
Called when an article is archived. |
question_publish |
Called when an article is published. |
comment_create |
Called when a comment is created. |
comment_update |
Called when a comment is updated. |
comment_delete |
Called when a comment is deleted. |
category_create |
Called when a category is created. |
category_update |
Called when a category is updated. |
category_delete |
Called when a category is deleted. |
API Endpoints
We have API V3 endpoints available for managing webhooks all through our API. You can find more information about each endpoint below. For more information on how our API V3 works, check this article.
Retrieve all webhooks
URL
GET https://<your-account>.helpjuice.com/api/v3/webhooks
RESPONSE raw
{
"meta": {
"current": 1,
"limit": 25,
"total_pages": 1,
"total_count": 2
},
"articles": [
{
"id": 3,
"url": "<URL>",
"event": "user_delete",
"last_response_code": null,
"account_id": 6,
"created_by_id": 6,
"enabled_at": "2023-05-09T19:12:03.224Z",
"created_at": "2023-05-09T19:12:03.224Z",
"updated_at": "2023-05-09T19:12:03.224Z"
},
{
"id": 4,
"url": "<URL>",
"event": "category_create",
"last_response_code": null,
"account_id": 6,
"created_by_id": 6,
"enabled_at": "2023-05-09T19:12:31.289Z",
"created_at": "2023-05-09T19:12:31.289Z",
"updated_at": "2023-05-09T19:12:42.020Z"
}
]
}
Retrieve a webhook
URL
GET https://<your-account>.helpjuice.com/api/v3/webhooks/:id
RESPONSE raw
{
"id": 3,
"url": <URL>,
"event": "user_delete",
"last_response_code": null,
"account_id": 6,
"created_by_id": 6,
"enabled_at": "2023-05-09T19:12:03.224Z",
"created_at": "2023-05-09T19:12:03.224Z",
"updated_at": "2023-05-09T19:12:03.224Z"
}
Create a webhook
URL
POST https://<your-account>.helpjuice.com/api/v3/webhooks
BODY raw
{
"id": 3,
"url": <URL>,
"event": "user_delete",
"last_response_code": null,
"account_id": 6,
"created_by_id": 6,
"enabled_at": "2023-05-09T19:12:03.224Z",
"created_at": "2023-05-09T19:12:03.224Z",
"updated_at": "2023-05-09T19:12:03.224Z"
}
Field | Type | Description |
---|---|---|
url |
String | URL to post the activity to. |
event |
String |
Event type |
Update a webhook
URL
PUT https://<your-account>.helpjuice.com/api/v3/webhooks/:id
BODY raw
{
"id": 3,
"url": <URL>,
"event": "user_delete",
"last_response_code": null,
"account_id": 6,
"created_by_id": 6,
"enabled_at": "2023-05-09T19:12:03.224Z",
"created_at": "2023-05-09T19:12:03.224Z",
"updated_at": "2023-05-09T19:12:03.224Z"
}
Field | Type | Description |
---|---|---|
url |
String | URL to post the activity to. |
event |
String |
Event type |
Toggle a webhook
URL
PUT https://<your-account>.helpjuice.com/api/v3/webhooks/:id/toggle
BODY raw
{
"id": 3,
"url": <URL>,
"event": "user_delete",
"last_response_code": null,
"account_id": 6,
"created_by_id": 6,
"enabled_at": "2023-05-09T19:12:03.224Z",
"created_at": "2023-05-09T19:12:03.224Z",
"updated_at": "2023-05-09T19:12:03.224Z"
}
Test a webhook
URL
POST https://<your-account>.helpjuice.com/api/v3/webhooks/:id/test
BODY raw
{
"id": 3,
"url": <URL>,
"event": "user_delete",
"last_response_code": 200,
"account_id": 6,
"created_by_id": 6,
"enabled_at": "2023-05-09T19:12:03.224Z",
"created_at": "2023-05-09T19:12:03.224Z",
"updated_at": "2023-05-09T19:12:03.224Z"
}
Delete a webhook
URL
DELETE https://<your-account>.helpjuice.com/api/v3/webhooks/:id