Developer guide
Last updated 19 November 2026
Most websites don't need any code: your blog appears on your site through the connection in your dashboard. This guide is for custom-built websites and apps that want to load posts themselves (the Read API) or be told the moment a post changes (webhooks).
Quick start
- In your dashboard, open your site's Settings → API & webhooks and create an API key. Copy it: it is shown only once.
- Send the key with every request, as
Authorization: Bearer <key>(orX-API-Key: <key>). - Keep the key on your server when you can. It can only read published posts, so it is safe if it leaks, but you can revoke it any time and create a new one.
curl https://plugyourblog.com/api/v1/site \
-H "Authorization: Bearer pyb_live_YOUR_KEY"List published posts
GET https://plugyourblog.com/api/v1/posts returns published posts, newest first.
limit: posts per page, 1 to 50 (default 20).page: page number, from 1.categoryortag: only posts in that category or with that tag.updated_since: only posts changed after this time (ISO date, for example2026-11-01T00:00:00Z). Handy for syncing.
{
"data": [
{
"id": "539ff929-…",
"slug": "teeth-whitening-cost",
"url": "https://yoursite.com/blog/teeth-whitening-cost",
"title": "Teeth Whitening Cost in 2026",
"excerpt": "…",
"language": "en",
"published_at": "2026-11-11T14:39:00.000Z",
"updated_at": "2026-11-12T09:02:41.118Z",
"author": "Dr. Sarah Lee",
"category": "Cosmetic",
"tags": ["whitening"],
"image": { "url": "https://…/cover.webp", "alt": "…" },
"seo": { "title": "…", "description": "…", "canonical_url": "https://yoursite.com/blog/teeth-whitening-cost", "noindex": false }
}
],
"pagination": { "page": 1, "limit": 20, "total": 42, "pages": 3, "has_more": true }
}Get one post
GET https://plugyourblog.com/api/v1/posts/{slug} returns everything above, plus:
html: the article body, cleaned and safe to place in your page.tldr(summary points),faq(question,answer),sources,cta.json_ld: ready-made structured data. Put it in a<script type="application/ld+json">tag on the post page so Google understands it.
Use seo.title, seo.description and seo.canonical_url for the page's title, meta description and canonical link. If a post's address changed, you get status 301 with moved_to (the new slug): redirect your old page there.
const res = await fetch("https://plugyourblog.com/api/v1/posts/teeth-whitening-cost", {
headers: { Authorization: `Bearer ${process.env.PLUGYOURBLOG_KEY}` },
});
if (res.status === 404) return notFound();
const { data: post } = await res.json();
// post.title, post.html, post.seo.description, post.json_ld …Errors and limits
- Errors look like
{ "error": { "code": "invalid_key", "message": "…" } }. 401missing or invalid key (revoked, or the site is paused) ·404no published post with that slug ·429too many requests.- Up to 120 requests a minute per key. Cache responses on your side and use webhooks to know when to refresh.
- Responses allow any origin (CORS), so browser code can call the API too.
Webhooks
Add your website's address in Settings → API & webhooks and pick the events. We send a POST with a JSON body when a post goes live (post.published), a live post changes (post.updated), or a post is unpublished or deleted (post.unpublished). Scheduled posts send post.published when they go live. Send test sends a ping.
{
"event": "post.updated",
"site_id": "c41b955f-…",
"sent_at": "2026-11-19T10:15:02.123+00:00",
"post": {
"id": "539ff929-…",
"slug": "teeth-whitening-cost-2027",
"previous_slug": "teeth-whitening-cost",
"title": "Teeth Whitening Cost in 2027",
"url": "https://yoursite.com/blog/teeth-whitening-cost-2027",
"status": "published",
"published_at": "…",
"updated_at": "…"
}
}- Answer with any
2xxstatus within 5 seconds. Do slow work (like fetching the full post) after you answer. - Messages are sent once. If your site was down, fetch recent posts with
updated_sinceto catch up. - Unpublished or deleted posts have
statusdraft,archivedordeleted: remove them from your site. - Headers:
X-PlugYourBlog-Event(the event) andX-PlugYourBlog-Signature.
Check the signature
Every webhook is signed with the secret you saw when you added it, so you know it came from us. The header looks like t=1763547302,v1=5257a869e7…. To check it:
- Take
tand the raw request body, exactly as received (don't parse and re-encode the JSON first). - Compute HMAC-SHA256 of
<t>.<raw body>with your secret, as lowercase hex. - Compare it with
v1using a constant-time comparison, and reject messages wheretis more than 5 minutes old.
import { createHmac, timingSafeEqual } from "node:crypto";
export function isFromPlugYourBlog(rawBody, header, secret) {
const parts = Object.fromEntries(header.split(",").map((p) => p.split("=")));
const t = Number(parts.t);
if (!t || Math.abs(Date.now() / 1000 - t) > 300) return false;
const expected = createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
const a = Buffer.from(expected), b = Buffer.from(parts.v1 || "");
return a.length === b.length && timingSafeEqual(a, b);
}
// Next.js route handler: app/api/plugyourblog/route.js
export async function POST(request) {
const raw = await request.text();
if (!isFromPlugYourBlog(raw, request.headers.get("x-plugyourblog-signature") || "", process.env.PLUGYOURBLOG_WEBHOOK_SECRET)) {
return new Response("bad signature", { status: 401 });
}
const { event, post } = JSON.parse(raw);
// e.g. revalidatePath(`/blog/${post.slug}`)
return new Response("ok");
}$raw = file_get_contents('php://input');
parse_str(str_replace(',', '&', $_SERVER['HTTP_X_PLUGYOURBLOG_SIGNATURE'] ?? ''), $sig);
$expected = hash_hmac('sha256', ($sig['t'] ?? '') . '.' . $raw, getenv('PLUGYOURBLOG_WEBHOOK_SECRET'));
if (abs(time() - (int)($sig['t'] ?? 0)) > 300 || !hash_equals($expected, $sig['v1'] ?? '')) {
http_response_code(401); exit;
}
$event = json_decode($raw, true);Need help?
Email admin@nexrtechnologies.com with your site name and what you're building. Never send us your API key or webhook secret.