Logo White

Webhooks

Webhooks notify your external applications in real time when events occur in a BlogHunch publication—such as posts being published or approved, new subscribers joining, comments being moderated, or orders completing.


Supported event types

  • Name
    all
    Type
    wildcard
    Description

    Subscribe to all publication events.

  • Name
    Posts
    Type
    events
    Description

    post.created, post.published, post.approved, post.updated

  • Name
    Pages
    Type
    events
    Description

    page.created, page.published, page.updated

  • Name
    Audience & Newsletters
    Type
    events
    Description

    email.subscribed, member.signup, member.update, newsletter.created, newsletter.updated

  • Name
    Comments
    Type
    events
    Description

    comment.posted, comment.approved, comment.rejected

  • Name
    Products & Orders
    Type
    events
    Description

    order.created, order.updated, course.published, course.updated, ebook.published, ebook.updated, digital_product.published, digital_product.updated


GET/v1/webhooks

List webhooks

Retrieve a paginated list of configured webhooks for the publication. Requires webhooks:read.

Request

curl https://api.bloghunch.com/v1/webhooks \
  -H "Authorization: Bearer {token}"

Response

{
  "data": [
    {
      "id": 12,
      "publication_id": 3696,
      "url": "https://hooks.agency.com/bloghunch",
      "description": "Production CRM sync",
      "source": "api_v1",
      "events": ["post.published", "post.approved", "email.subscribed"],
      "has_secret": true,
      "created_at": "2026-11-24T10:00:00.000Z",
      "updated_at": "2026-11-24T10:00:00.000Z"
    }
  ],
  "meta": {
    "total": 1,
    "per_page": 20,
    "current_page": 1,
    "last_page": 1,
    "has_more": false
  }
}

POST/v1/webhooks

Create a webhook

Registers a webhook endpoint and returns a signing secret (whsec_...) once upon creation. Requires webhooks:write.

  • Name
    url
    Type
    string
    Description

    Required. Public HTTPS endpoint URL.

  • Name
    events
    Type
    array
    Description

    Required. Non-empty array of event strings (e.g., ["post.published", "email.subscribed"]).

  • Name
    description
    Type
    string
    Description

    Optional human-readable description.

Request

curl -X POST https://api.bloghunch.com/v1/webhooks \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://hooks.agency.com/bloghunch",
    "description": "Production CRM sync",
    "events": ["post.published", "post.approved", "email.subscribed"]
  }'

Response

{
  "data": {
    "id": 12,
    "publication_id": 3696,
    "url": "https://hooks.agency.com/bloghunch",
    "events": ["post.published", "post.approved", "email.subscribed"],
    "has_secret": true,
    "secret": "whsec_9a8b7c6d5e4f3a2b1c0d9e8f7a6b5c4d"
  }
}

Test, rotate secret & delivery logs

  • Send test event: POST /v1/webhooks/{id}/test dispatches a webhook.test event immediately.
  • Inspect delivery attempts: GET /v1/webhooks/{id}/deliveries returns status codes, latency (duration_ms), retry attempts, and error messages.
  • Rotate signing secret: POST /v1/webhooks/{id}/rotate-secret generates a new whsec_... secret.
  • Update / Delete: PATCH /v1/webhooks/{id} and DELETE /v1/webhooks/{id}.

Verifying webhook signatures

Every webhook delivery includes the following headers:

  • X-BlogHunch-Event: Event name (e.g., post.published)
  • X-BlogHunch-Timestamp: ISO-8601 timestamp string
  • X-BlogHunch-Delivery-Id: Unique delivery identifier (wh_...)
  • X-BlogHunch-Signature: sha256=<hex_digest> computed over ${timestamp}.${JSON.stringify(body)} using your webhook secret

Verifying X-BlogHunch-Signature

import crypto from 'crypto'

const timestamp = req.headers['x-bloghunch-timestamp']
const signature = req.headers['x-bloghunch-signature']
const expected =
  'sha256=' +
  crypto
    .createHmac('sha256', process.env.BLOGHUNCH_WEBHOOK_SECRET)
    .update(`${timestamp}.${JSON.stringify(req.body)}`)
    .digest('hex')

const isValid = crypto.timingSafeEqual(
  Buffer.from(signature),
  Buffer.from(expected)
)