Developers

Webhooks

A webhook lets Varf publish to any site or CMS. When an article is published, Varf sends it as signed JSON to an HTTPS address you choose, and your code creates or updates the post.

Set up

An admin sets up the webhook in Settings › Publishing connector.

  1. 1

    Enter your endpoint

    Choose Webhook and enter the HTTPS address that will receive articles.
  2. 2

    Set the secret

    Enter a secret of at least 16 characters, or leave it empty and Varf generates one and shows it once. Store it on your server; it signs every request.
  3. 3

    Save and test

    Varf sends a ping event and saves the connector only if your endpoint answers with a 2xx status.
  4. 4

    Publish

    From then on, every published article arrives as a content.publish event, whether you publish it yourself or your autonomy level does.

If Varf generates the secret, the first ping is signed with a secret your endpoint doesn’t know yet. Answer every ping with 2xx, or enter your own secret so you can verify from the start.

Events and body

There are two events. Each is a POST with a JSON body; the event name is in the body and in the x-varf-event header.

EventWhen it is sent
pingWhen the connector is saved or tested. It isn’t retried; its result decides whether the save or test succeeds.
content.publishWhen an article is published: by you, at its scheduled time, or automatically under your autonomy level. Publishing a new version sends it again, with the same contentId.
ping body
{
  "event": "ping",
  "sentAt": "2026-11-27T09:30:00.000Z",
  "workspace": "example"
}
content.publish body
{
  "event": "content.publish",
  "sentAt": "2026-11-27T09:30:00.000Z",
  "content": {
    "contentId": "5d2f0c4e-8a17-4f3b-9c62-1e7a9b0d4f85",
    "version": 3,
    "title": "Espresso makinesi nasıl seçilir?",
    "slug": "espresso-makinesi-nasil-secilir",
    "metaDescription": "Kazan tipi, basınç ve öğütücü: espresso makinesi seçerken nelere bakmalı?",
    "keyword": "espresso makinesi",
    "html": "<p>…</p>\n<h2>…</h2>\n<p>…</p>",
    "doc": { "type": "doc", "content": [] },
    "lang": "tr",
    "status": "publish",
    "categories": [],
    "tags": ["espresso"],
    "image": "https://example.com/images/espresso.jpg",
    "remoteId": null
  }
}

Fields of content

FieldTypeMeaning
contentIdstring (UUID)Varf’s ID for the article. It stays the same across versions; use it to find the post again.
versionintegerThe version being published.
titlestringThe article’s title.
slugstringThe URL slug.
metaDescriptionstringThe meta description.
keywordstringThe target keyword.
htmlstringThe body as HTML, without the title.
docobjectThe body as structured JSON (ProseMirror format), if you prefer to render it yourself.
langstringThe article’s language code, for example tr.
status"draft" | "publish"draft or publish: how the post should appear on your site.
categoriesnumber[]Category IDs from the publish options. Usually empty for webhooks.
tagsstring[]Tags from the publish options.
imagestring | nullThe featured image’s URL, or null. Varf doesn’t download it for webhooks.
remoteIdstring | nullThe id your endpoint returned last time for this article, or null on the first delivery.

Headers

Every request carries these headers:

HeaderValue
content-typeAlways application/json.
x-varf-eventThe event: ping or content.publish.
x-varf-signatureThe timestamp and the signature, as t=…,v1=….
user-agentVarf’s user agent.

Verify the signature

The x-varf-signature header has two parts: t, the Unix time in seconds when the request was sent, and v1, the HMAC-SHA256 of the string t.body with your secret as the key, in lowercase hex.

  1. Read the raw request body before parsing it as JSON.
  2. Split the header into t and v1.
  3. Reject the request if t is more than 5 minutes away from your clock.
  4. Compute the HMAC-SHA256 of t, a dot and the raw body, and compare it with v1 in constant time.
Node.js
import { createHmac, timingSafeEqual } from "node:crypto";

// rawBody: the request body as received, before JSON.parse.
export function verify(rawBody, header, secret, tolerance = 300) {
  const m = /^t=(\d+),v1=([0-9a-f]{64})$/.exec(header ?? "");
  if (!m || Math.abs(Date.now() / 1000 - Number(m[1])) > tolerance) return false;
  const want = createHmac("sha256", secret).update(`${m[1]}.${rawBody}`).digest("hex");
  return timingSafeEqual(Buffer.from(want), Buffer.from(m[2]));
}

Every attempt, a retry included, is signed again with a new timestamp.

Your response

Answer with any 2xx status to confirm the delivery. Other statuses count as failures (see below).

You may return a JSON object with id and url. Varf stores the id (a string or a number, up to 200 characters) and sends it back as remoteId with the next version of the same article, so you can update the post instead of creating a new one. The url (http or https) is shown in Varf as the post’s address; if you leave it out, the stored address is cleared.

Response
HTTP/1.1 200 OK
content-type: application/json

{ "id": "1234", "url": "https://example.com/blog/espresso-makinesi-nasil-secilir" }

The response body may be at most 64 KB. Varf doesn’t follow redirects.

Failures and retries

Varf retries a delivery once, 60 seconds later, when the failure looks temporary. A permanent failure isn’t retried and shows in Varf with its reason.

Your endpointResult
2xxDelivered.
429, 5xx, timeout after 15 seconds, connection or DNS errorTemporary: one retry after 60 seconds.
Any other 4xx, a redirect, or a body over 64 KBPermanent: no retry.

Deliveries have no separate delivery ID. If your endpoint saved the post but answered too late, the retry delivers the same article again: deduplicate on contentId and version.

Sample receiver

A complete receiver in Node.js with no dependencies: it verifies the signature, answers pings, creates or updates the post and returns its id and URL.

receiver.mjs
import { createServer } from "node:http";
import { createHmac, timingSafeEqual } from "node:crypto";

const SECRET = process.env.VARF_WEBHOOK_SECRET;

function verify(raw, header, tolerance = 300) {
  const m = /^t=(\d+),v1=([0-9a-f]{64})$/.exec(header ?? "");
  if (!m || Math.abs(Date.now() / 1000 - Number(m[1])) > tolerance) return false;
  const want = createHmac("sha256", SECRET).update(`${m[1]}.${raw}`).digest("hex");
  return timingSafeEqual(Buffer.from(want), Buffer.from(m[2]));
}

createServer(async (req, res) => {
  const chunks = [];
  for await (const chunk of req) chunks.push(chunk);
  const raw = Buffer.concat(chunks).toString("utf8");

  // A ping changes nothing, so answer it even before you have the secret.
  if (req.headers["x-varf-event"] === "ping") return res.writeHead(204).end();
  if (req.method !== "POST" || !verify(raw, req.headers["x-varf-signature"])) return res.writeHead(401).end();

  const { content } = JSON.parse(raw);
  // remoteId is the id you returned last time; contentId also catches a retried first delivery.
  const id = content.remoteId ?? (await findPostByContentId(content.contentId));
  const post = id ? await updatePost(id, content) : await createPost(content);

  res.writeHead(200, { "content-type": "application/json" });
  res.end(JSON.stringify({ id: post.id, url: post.url }));
}).listen(8080);

// Replace these with your CMS.
async function findPostByContentId(contentId) {}
async function createPost(content) {}
async function updatePost(id, content) {}

Verification in Python and PHP:

Python
import hashlib, hmac, re, time

def verify(raw_body: bytes, header: str, secret: str, tolerance: int = 300) -> bool:
    m = re.fullmatch(r"t=(\d+),v1=([0-9a-f]{64})", header or "")
    if not m or abs(time.time() - int(m.group(1))) > tolerance:
        return False
    want = hmac.new(secret.encode(), m.group(1).encode() + b"." + raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(want, m.group(2))
PHP
function varf_verify(string $rawBody, string $header, string $secret, int $tolerance = 300): bool {
    if (!preg_match('/^t=(\d+),v1=([0-9a-f]{64})$/', $header, $m)) return false;
    if (abs(time() - (int) $m[1]) > $tolerance) return false;
    $want = hash_hmac('sha256', $m[1] . '.' . $rawBody, $secret);
    return hash_equals($want, $m[2]);
}

// $rawBody = file_get_contents('php://input');
// $header  = $_SERVER['HTTP_X_VARF_SIGNATURE'] ?? '';

Limits

  • The endpoint must use HTTPS and resolve only to public IP addresses.
  • Varf waits up to 15 seconds for the whole response.
  • The response body may be at most 64 KB.
  • Redirects aren’t followed.
  • The address can’t contain a username or password.

Frequently asked questions

How do I verify a Varf webhook?

Compute the HMAC-SHA256 of the timestamp, a dot and the raw body with your secret, and compare it with v1 in the x-varf-signature header in constant time. Reject requests older than 5 minutes.

What if my endpoint is down?

Timeouts, 429 and 5xx responses are retried once after 60 seconds. If that fails too, the article shows the error in Varf and you can publish it again.

How do I update a post instead of creating a new one?

Return the post’s id in your response. Varf sends it back as remoteId with the next version of the same article.

Which events are there?

Two: ping, when the connector is saved or tested, and content.publish, when an article is published.

Put your site on the loop.

Add your site and connect Search Console. Varf starts collecting right away and shows its first findings as soon as the first sync finishes.