Webhooks v2

Version 2 push subscriptions are signed, can carry several events, and can be listed, tested and inspected. Version 1 subscriptions (one event, {resource_url} payload, used by Zapier) keep working unchanged.

Status: v2 subscriptions are live: events are delivered as they happen, signed, with retries for about a day. push/test sends a signed test.ping on demand.

Create a subscription

curl -sS https://api.mailshake.com/2017-04-01/push/create \
  -H "Authorization: Bearer $MAILSHAKE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"version": 2, "targetUrl": "https://example.com/mailshake-hook", "events": ["email.bounced", "reply.received"]}'

The answer includes secret once. Store it: it verifies every delivery. The target must be https. At most 50 subscriptions per team.

Events: email.sent, email.opened, link.clicked, reply.received, email.bounced, reply.out_of_office, recipient.unsubscribed, lead.created, lead.status_changed, lead.assigned, sender.quota_hit, task.created, task.completed, call.completed, sender.needs_reauth, campaign.paused, campaign.resumed, sender.auto_action. A "campaign completed" event isn't offered yet: Mailshake doesn't mark a campaign as completed today.

An optional filter of {"campaignID": 123} (and, for message events, campaignMessageID) limits a subscription to one campaign.

Payload and headers

{"id": "evt_…", "type": "email.bounced", "created": 1794351600, "teamID": 123, "data": {"object": "recipient-action", "id": 456, "recipientID": 789, "campaignID": 12, "campaignMessageID": 34, "integrationID": 5, "actionDate": "…", "resourceUrl": "https://api.mailshake.com/2017-04-01/activity/…"}}

data holds the ids of what changed and, for email, reply and lead events, a resourceUrl you can GET for the full record. This is by design: the body never carries a full copy of the record, so fetch resourceUrl (with your API key) when you need the details.

Retries and failures

Verify a delivery (Node)

const crypto = require('crypto');

function verifyMailshake(rawBody, header, secret, toleranceSecs = 300) {
  const parts = header.split(',').map((p) => p.split('='));
  const t = Number((parts.find((p) => p[0] === 't') || [])[1]);
  const expected = crypto.createHmac('sha256', secret).update(`${t}.${rawBody}`).digest('hex');
  const match = parts.some((p) => p[0] === 'v1' && p[1].length === expected.length
    && crypto.timingSafeEqual(Buffer.from(p[1]), Buffer.from(expected)));
  return match && Math.abs(Date.now() / 1000 - t) <= toleranceSecs;
}

Verify a delivery (Python)

import hashlib, hmac, time

def verify_mailshake(raw_body: bytes, header: str, secret: str, tolerance_secs: int = 300) -> bool:
    parts = [p.split("=", 1) for p in header.split(",")]
    t = int(next(v for k, v in parts if k == "t"))
    expected = hmac.new(secret.encode(), f"{t}.".encode() + raw_body, hashlib.sha256).hexdigest()
    ok = any(k == "v1" and hmac.compare_digest(v, expected) for k, v in parts)
    return ok and abs(time.time() - t) <= tolerance_secs

Always verify against the raw request body, before parsing it.

Manage

Operation What it does
push/list The team's subscriptions (never their secrets).
push/get {id} One subscription.
push/test {id} Sends a signed test.ping now and records the delivery.
push/rotate-secret {id} A new secret, shown once; the old one keeps working for 24 hours. Only the most recent old secret is kept: a second rotation within those 24 hours ends the first old secret at once.
push/deliveries {id} The latest 100 delivery attempts.
push/delete {id} Deletes the subscription.

All need the webhooks:manage scope. Another team's subscription answers 404 not_found.

Version 1 Replied events

A v1 Replied push can be a reply, a bounce, an out-of-office or a delay notice: read type from the fetched reply. Version 2 names them separately (reply.received, email.bounced, reply.out_of_office).