Launch offer: service fee 10% 4% until 31 Dec, just enough to cover card processing. See pricing

Developers

Webhooks

Hear about asks, yeses, drafts, deals and posts the moment they happen, instead of polling. Every delivery is signed, so you know it came from us.

View as Markdown

Set up an endpoint

  1. Open Settings → Webhooks on yapfactory.com.
  2. Add an https URL and pick the events you want, or all of them (*).
  3. Copy the signing secret. It starts with whsec_ and is shown once.
  4. Press Send test event to get a ping and check your code.

You can have up to 5 endpoints. An event goes to the endpoints of everyone on the deal or campaign it's about: the brand and the creator.

  • The URL must be public https. Addresses on private networks are refused.
  • We don't follow redirects: a 3xx answer counts as a failed try. Give the final URL.
  • Endpoints are set up in Settings for now; there's no API for them yet.

Events

TypeSent toWhen
deal.updatedBoth sidesEvery deal status change (status, previousStatus)
deal.invitedCreatorA brand invited you
invite.acceptedBrandA creator said yes
invite.declinedBrandA creator said no
invite.expiredBoth sidesAn invite ran out
deal.startedBoth sidesThe brand started the deal and payment is secured
draft.submittedBrandA draft or a new version is ready to review
revision.requestedCreatorThe brand sent the draft back
draft.approvedBoth sidesApproved, or approved automatically when the review window ran out
deal.completedBoth sidesThe deal is done
deal.cancelledBoth sidesThe deal was cancelled
ask.receivedBrandA creator asked to join a campaign
message.receivedThe other sideA new message on a deal
campaign.publishedBrandA campaign went live
post.publishedBrandA scheduled post went live (data.postId, data.postUrl)
post.failedBrandA scheduled post stopped and needs the person (data.postId, data.reason)
pingThe endpointA test event from Settings

The payload

Payloads are thin. An event says what changed and carries ids; call the API for the details. A payload never contains a creator's handle or contact details.

{
  "id": "evt_…",
  "type": "deal.updated",
  "createdAt": "2026-12-03T10:00:00.000Z",
  "livemode": true,
  "data": {
    "dealId": "…",
    "campaignId": "…",
    "status": "funded",
    "previousStatus": "accepted",
    "url": "https://yapfactory.com/deals/…"
  }
}
  • id stays the same across retries and replays. Use it to dedupe.
  • livemode is false for events from test sites.
  • data.url is the page on yapfactory.com for the deal, campaign or post.

What `data` carries

Events`data`
deal.updated, invite.accepted, invite.declined, invite.expired, deal.started, revision.requested, draft.approved, deal.completed, deal.cancelleddealId, campaignId, status, previousStatus, url
deal.inviteddealId, campaignId, status (invited), url
draft.submitteddealId, campaignId, status (draft_submitted), version (1 for the first draft), url
message.receiveddealId, campaignId, status, messageId, from (brand or creator), url. The words aren't in the event: read them with get_deal.
ask.receivedcampaignId, status, creatorId, url
campaign.publishedcampaignId, status (live), url
post.publishedpostId, postUrl (the post on TikTok or Instagram, or null), url
post.failedpostId, reason (a sentence for the person), url
pingendpointId, message

One change often sends two events: deal.updated for the status change, and the named one (invite.accepted, deal.started…) for what it means. Subscribe to deal.updated alone to follow every status, or to the named ones to act on moments. The statuses are in Deals and statuses. New fields and event types can be added at any time: ignore what you don't know.

Headers

Each delivery is a POST with Content-Type: application/json and these headers:

HeaderValue
Yap-Event-IdThe event's id, such as evt_….
Yap-Event-TypeThe event's type, such as draft.submitted.
Yap-Signaturet=<unix seconds>,v1=<hex HMAC-SHA256>

Check the signature

  1. Read t and v1 from Yap-Signature.
  2. Reject it if t is more than 5 minutes from now. That stops replays.
  3. Compute HMAC-SHA256 of "<t>.<raw body>" with your secret, as hex.
  4. Compare it with v1 in constant time.

Use the raw body, byte for byte. Parsing the JSON and writing it out again changes it, and the check fails.

import crypto from "node:crypto";

const TOLERANCE_S = 5 * 60;

/** rawBody: the request body exactly as it arrived, before any JSON parsing. */
export function verifyYapSignature(rawBody, header, secret) {
  const parts = Object.fromEntries(header.split(",").map((p) => p.split("=", 2)));
  const t = Number(parts.t);
  if (!Number.isInteger(t) || Math.abs(Date.now() / 1000 - t) > TOLERANCE_S) return false;
  const expected = crypto.createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
  const given = Buffer.from(parts.v1 ?? "", "utf8");
  const want = Buffer.from(expected, "utf8");
  return given.length === want.length && crypto.timingSafeEqual(given, want);
}

// Express: keep the raw body for this route.
app.post("/webhooks/yap", express.raw({ type: "application/json" }), (req, res) => {
  const raw = req.body.toString("utf8");
  if (!verifyYapSignature(raw, req.get("Yap-Signature") ?? "", process.env.YAP_WEBHOOK_SECRET)) {
    return res.status(400).end();
  }
  const event = JSON.parse(raw);
  // Seen event.id before? Answer 200 and stop.
  res.status(200).end();
  queueWork(event); // do the slow part after answering
});

Answer fast

Any 2xx within 10 seconds counts as delivered. Answer first, then do the slow work in the background. Anything else, or no answer, is a failed try.

Retries

A failed delivery is tried again after 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours and 12 hours: 7 tries in about 21 hours. After that it's marked failed.

After 20 deliveries fail in a row, we turn the endpoint off and email you.

Retries can arrive out of order, and the same event can arrive twice. Dedupe on Yap-Event-Id, and read the current state from the API when order matters.

Delivery log, replay and test events

  • Settings → Webhooks shows the last 50 deliveries for each endpoint: status, tries and the response code you sent.
  • Replay any delivery. It's signed again with a fresh t, and keeps the same event id.
  • Send test event sends a ping, to check your endpoint and your signature code.