POST with a JSON body, authenticated by a shared secret you choose. This guide walks an AI coding agent through wiring that endpoint into a Next.js App Router project and rendering the articles as a blog.
One-prompt setup
Paste this into your AI coding agent (Cursor, Claude Code, v0, Windsurf, …) inside your Next.js project. It has everything the agent needs to do the whole integration.prompt
What you’re building
A shared secret
An env var both TryRoki and your endpoint know, so you can reject anyone else.
A webhook route
An App Router route handler at
/api/tryroki that receives and stores each article.A blog
/blog and /blog/[slug] pages that render the articles TryRoki sends.Prerequisites
- A Next.js project using the App Router (
app/directory). - A TryRoki account.
- A publicly reachable HTTPS URL for your site (your production deploy, or a tunnel like
ngrok/cloudflaredfor local testing).
There is no API key to request and nothing to
npm install. The only credential is a secret you generate — it goes in your app’s env and in the webhook’s custom headers.Step 1 — Add a shared secret
Generate a long random string and add it to your environment. Anything unguessable works:terminal
.env.local
Step 2 — Create the webhook route handler
Createapp/api/tryroki/route.ts. It authenticates the request, parses the article, stores it, and responds 2xx quickly.
app/api/tryroki/route.ts
Step 3 — Store the article
Createapp/lib/articles.ts. This example uses an in-memory Map so you can run it instantly — swap the bodies for your real database (Prisma, Drizzle, Postgres, a CMS, etc.) before deploying.
app/lib/articles.ts
Step 4 — Render the blog
TryRoki sendscontent_html already rendered, so the article pages are thin.
app/blog/page.tsx
app/blog/[slug]/page.tsx
content_html comes from a source you authenticate with your secret, so rendering it directly is fine. If you also expose user-submitted content, sanitize HTML with a library such as rehype-sanitize or DOMPurify.Step 5 — Register the webhook in TryRoki
1
Open the webhook settings
In the TryRoki dashboard go to Integrations → Webhooks and click Add webhook.
2
Set the endpoint URL
Enter your route’s public URL, e.g.
https://yourdomain.com/api/tryroki.3
Choose events
Tick On create (
article.created) and On update (article.updated).4
Add the secret header
In Custom headers, paste a JSON object with your secret:This must match
TRYROKI_WEBHOOK_SECRET from Step 1 exactly.5
Save
Save the webhook. TryRoki will POST to your endpoint on the next publish.
Step 6 — Test it
Simulate a delivery withcurl (replace the domain and use the same secret):
terminal
{"ok":true}. Open /blog and you’ll see the post; /blog/hello-from-tryroki renders the body. A 401 means the Authorization header doesn’t match your env secret.
Payload reference
ThePOST body is identical for article.created and article.updated. Full field table, event semantics, delivery timeouts, and security notes live in the webhook documentation.
Production checklist
- Idempotency — upsert by
id; the same article can arrive more than once. - HTTPS only — the secret rides in a header; never expose the endpoint over plain HTTP.
- Fast response — return
2xxin under 15s; queue heavy work. - Real storage — replace the in-memory demo store with your database.
- Revalidation — call
revalidatePath(shown above) or use on-demand revalidation so new posts appear immediately.
