How do I get embed events server-side?
Receive template events on your own endpoint instead of in the browser.
Updated
Get real-time notifications when templates are created, updated or deleted. Use them to sync data, send notifications or trigger workflows. Webhooks are available on Grow and Scale.
Overview#
Webhooks send HTTP POST requests to your specified endpoint whenever:
- A template is created (
template.create) - A template is updated (
template.update) - A template is deleted (
template.delete)
Webhooks fire for template changes anywhere in the workspace: in the embed, in your own Studio and through the API. Templates saved by an embed user carry template.embed_user_id. Use it to tell your users' templates apart.
Every request has User-Agent: Orshot-Webhook/1.0. Verify the signature to trust it.
Who is user_id?#
The top-level user_id is your Orshot account ID (the workspace owner), not your end user. Your end user appears only as template.embed_user_id, a hashed ID that starts with eui_. Match it with the IDs on the Your Users tab. A template deleted through the API has no user_id.
Setup#
1. Configure Webhook URL#
In your embed settings, add your webhook endpoint:
https://yourapp.com/api/studio-webhook2. Handle Webhook Events#
Create an endpoint that accepts POST requests:
// Next.js API Route
export async function POST(request) {
try {
const body = await request.json();
// Process the webhook
console.log("Webhook received:", body);
return Response.json({ success: true });
} catch (error) {
console.error("Webhook error:", error);
return Response.json({ error: error.message }, { status: 500 });
}
}Event Types#
template.create#
Fired when a template is created:
{
"event_type": "template.create",
"template": {
"id": "abc123",
"name": "My New Design",
"workspace_id": "workspace_789",
"user_id": "user_456",
"embed_user_id": "eui_3f9a1c2b7d4e8f60",
"canvas_data": {...},
"canvas_width": 1080,
"canvas_height": 1080,
"thumbnail_url": "https://...",
"description": "Template description",
"pages_data": [
{
"id": "page_1",
"name": "Page 1",
"thumbnail_url": "https://...",
"canvas_data": {...}
}
],
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
},
"workspace_id": "workspace_789",
"user_id": "user_456",
"timestamp": "2024-01-15T10:30:00Z"
}template.update#
Fired when changes to a template are saved:
{
"event_type": "template.update",
"template": {
"id": "abc123",
"name": "My Updated Design",
"workspace_id": "workspace_789",
"user_id": "user_456",
"canvas_data": {...},
"canvas_width": 1080,
"canvas_height": 1350,
"thumbnail_url": "https://...",
"description": "Updated template description",
"pages_data": [
{
"id": "page_1",
"name": "Page 1",
"thumbnail_url": "https://...",
"canvas_data": {...}
},
{
"id": "page_2",
"name": "Page 2",
"thumbnail_url": "https://...",
"canvas_data": {...}
}
],
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T11:45:00Z"
},
"workspace_id": "workspace_789",
"user_id": "user_456",
"timestamp": "2024-01-15T11:45:00Z"
}template.delete#
Fired when a template is deleted. The payload is lighter since the template data is no longer available. When the template is deleted through the API, user_id is left out:
{
"event_type": "template.delete",
"template": {
"id": "abc123",
"name": "My Template",
"workspace_id": "789"
},
"workspace_id": "789",
"user_id": "user_456",
"timestamp": "2024-01-15T12:00:00Z"
}Implementation Examples#
Express.js#
const express = require("express");
const app = express();
app.use(express.json());
app.post("/api/studio-webhook", (req, res) => {
const { event_type, template, workspace_id, user_id } = req.body;
console.log(`Event: ${event_type} for template ${template.id}`);
// Process the event
switch (event_type) {
case "template.create":
handleTemplateCreate(req.body);
break;
case "template.update":
handleTemplateUpdate(req.body);
break;
case "template.delete":
handleTemplateDelete(req.body);
break;
}
res.json({ success: true });
});
function handleTemplateCreate(data) {
// Save to database, send notification, etc.
console.log("New template created:", data.template.name);
console.log("Pages count:", data.template.pages_data?.length || 1);
}
function handleTemplateUpdate(data) {
// Update records, sync changes, etc.
console.log("Template updated:", data.template.name);
console.log(
"Canvas size:",
`${data.template.canvas_width}x${data.template.canvas_height}`,
);
}
function handleTemplateDelete(data) {
// Remove from database, notify users, etc.
console.log("Template deleted:", data.template.id);
}PHP#
<?php
header('Content-Type: application/json');
$input = file_get_contents('php://input');
$data = json_decode($input, true);
$event_type = $data['event_type'];
$template = $data['template'];
$workspace_id = $data['workspace_id'];
$user_id = $data['user_id'];
switch ($event_type) {
case 'template.create':
handleTemplateCreate($data);
break;
case 'template.update':
handleTemplateUpdate($data);
break;
case 'template.delete':
handleTemplateDelete($data);
break;
}
function handleTemplateDelete($data) {
error_log("Template deleted: " . $data['template']['id']);
}
function handleTemplateCreate($data) {
// Database insert, notification, etc.
error_log("New template: " . $data['template']['name']);
error_log("Template ID: " . $data['template']['id']);
}
function handleTemplateUpdate($data) {
// Database update, sync, etc.
error_log("Template updated: " . $data['template']['name']);
}
echo json_encode(['success' => true]);
?>Python (FastAPI)#
from fastapi import FastAPI
from pydantic import BaseModel
from typing import List, Optional, Dict, Any, Union
app = FastAPI()
class PageData(BaseModel):
id: str
name: Optional[str] = None
thumbnail_url: Optional[str] = None
canvas_data: Optional[Dict[str, Any]] = None
# Delete events carry only id, name and workspace_id, so the rest is optional
class Template(BaseModel):
id: str
name: Optional[str] = None
workspace_id: Optional[Union[int, str]] = None
user_id: Optional[str] = None
embed_user_id: Optional[str] = None
canvas_data: Optional[Dict[str, Any]] = None
canvas_width: Optional[int] = None
canvas_height: Optional[int] = None
thumbnail_url: Optional[str] = None
description: Optional[str] = None
pages_data: Optional[List[PageData]] = None
created_at: Optional[str] = None
updated_at: Optional[str] = None
class WebhookPayload(BaseModel):
event_type: str
template: Template
workspace_id: Union[int, str]
user_id: Optional[str] = None
timestamp: str
@app.post("/api/studio-webhook")
async def webhook_handler(payload: WebhookPayload):
print(f"Event: {payload.event_type} for template {payload.template.id}")
if payload.event_type == "template.create":
await handle_template_create(payload)
elif payload.event_type == "template.update":
await handle_template_update(payload)
elif payload.event_type == "template.delete":
await handle_template_delete(payload)
return {"success": True}
async def handle_template_create(data):
# Process new template
print(f"New template created: {data.template.name}")
print(f"Canvas size: {data.template.canvas_width}x{data.template.canvas_height}")
async def handle_template_update(data):
# Process template update
print(f"Template updated: {data.template.name}")
print(f"Pages count: {len(data.template.pages_data) if data.template.pages_data else 1}")
async def handle_template_delete(data):
# Remove template from records
print(f"Template deleted: {data.template.id}")Common Use Cases#
Save to Database#
async function handleTemplateCreate(data) {
await db.templates.create({
id: data.template.id,
name: data.template.name,
embed_user_id: data.template.embed_user_id,
workspace_id: data.workspace_id,
canvas_width: data.template.canvas_width,
canvas_height: data.template.canvas_height,
pages_count: data.template.pages_data?.length || 1,
thumbnail_url: data.template.thumbnail_url,
created_at: data.template.created_at,
updated_at: data.template.updated_at,
});
}Send Notifications#
async function handleTemplateUpdate(data) {
// Find your user by the hashed embed user ID
const user = await findUserByEmbedUserId(data.template.embed_user_id);
if (!user) return;
// Email notification
await sendEmail({
to: user.email,
subject: "Template Updated",
body: `Your template "${data.template.name}" has been updated.`,
});
}Sync with External API#
async function handleTemplateCreate(data) {
// Sync with external design management system
await externalAPI.createDesign({
id: data.template.id,
name: data.template.name,
creator: data.template.embed_user_id,
workspace: data.workspace_id,
thumbnail: data.template.thumbnail_url,
canvas_size: `${data.template.canvas_width}x${data.template.canvas_height}`,
pages: data.template.pages_data?.length || 1,
});
}Full Webhook Payload#
By default, webhook payloads exclude raw element data and modifications to keep payloads lightweight. Full template payload (including all template data) is available on enterprise plans.
Security#
Verify Webhook Signatures#
If your embed has a signing secret (the same secret used for JWT authentication), every webhook carries an X-Orshot-Signature header:
X-Orshot-Signature: t=1760000000,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bdv1 is the hex HMAC-SHA256 of <t>.<raw request body>, keyed with your signing secret. Compute it over the raw body (before JSON parsing) and compare:
import crypto from "crypto";
import express from "express";
app.post(
"/api/studio-webhook",
express.raw({ type: "application/json" }),
(req, res) => {
const header = req.get("X-Orshot-Signature") || "";
const parts = Object.fromEntries(
header.split(",").map((part) => part.split("=")),
);
const expected = crypto
.createHmac("sha256", process.env.ORSHOT_SIGNING_SECRET)
.update(`${parts.t}.${req.body}`)
.digest("hex");
const valid =
parts.v1 &&
parts.v1.length === expected.length &&
crypto.timingSafeEqual(Buffer.from(parts.v1), Buffer.from(expected));
// Reject stale deliveries (here: older than 5 minutes)
const fresh = Math.abs(Date.now() / 1000 - Number(parts.t)) < 300;
if (!valid || !fresh) {
return res.status(401).json({ error: "Invalid signature" });
}
const event = JSON.parse(req.body);
// Process webhook...
res.json({ received: true });
},
);Webhooks are sent server to server, so they carry no Origin or Referer header to check. Embeds without a signing secret receive webhooks without the signature header, exactly as before.
Use HTTPS#
Always use HTTPS endpoints for webhooks in production:
✅ https://yourapp.com/api/studio-webhook
❌ http://yourapp.com/api/studio-webhookValidate Payload#
Check that required fields are present:
function validateWebhook(body) {
const required = ["event_type", "template", "workspace_id", "timestamp"];
for (const field of required) {
if (!body[field]) {
throw new Error(`Missing required field: ${field}`);
}
}
if (
!["template.create", "template.update", "template.delete"].includes(
body.event_type,
)
) {
throw new Error(`Invalid event type: ${body.event_type}`);
}
// Validate template object
if (!body.template.id) {
throw new Error("Missing template field: id");
}
}Error Handling#
No Retries#
Orshot sends each event once and does not retry. A non-2xx answer or a timeout is not sent again. Answer within 15 seconds. Return 2xx right away and do slow work in the background:
app.post("/api/studio-webhook", (req, res) => {
// Answer first, then process
res.json({ success: true });
processWebhook(req.body).catch((error) => {
console.error("Webhook processing failed:", error);
});
});Logging#
Log all webhook events for debugging:
function logWebhook(data) {
console.log(
JSON.stringify({
timestamp: new Date().toISOString(),
event_type: data.event_type,
template_id: data.template?.id,
user_id: data.user_id,
success: true,
}),
);
}Testing#
Local Development#
Use ngrok to expose your local server:
# Install ngrok
npm install -g ngrok
# Expose your local server
ngrok http 3000
# Use the HTTPS URL in your webhook settings
https://abc123.ngrok.io/api/studio-webhookTest Payloads#
Create test webhook payloads for development:
const testPayload = {
event_type: "template.create",
template: {
id: "test_123",
name: "Test Template",
workspace_id: "test_workspace",
user_id: "test_user",
embed_user_id: "eui_0000000000000000",
canvas_data: {},
canvas_width: 1080,
canvas_height: 1080,
thumbnail_url: "https://example.com/thumb.jpg",
description: "Test template description",
pages_data: [
{
id: "page_1",
name: "Page 1",
thumbnail_url: "https://example.com/page1.jpg",
canvas_data: {},
},
],
created_at: new Date().toISOString(),
updated_at: new Date().toISOString(),
},
workspace_id: "test_workspace",
user_id: "test_user",
timestamp: new Date().toISOString(),
};
// Send test webhook
fetch("http://localhost:3000/api/studio-webhook", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(testPayload),
});Troubleshooting#
Webhook Not Firing#
- Check if webhook URL is correctly configured
- Check that your plan is Grow or Scale
- Verify the endpoint is accessible from the internet
- Ensure you're returning a 2xx status code
Payload Issues#
- Log the raw request body to see what's being sent
- Check Content-Type headers
- Verify JSON parsing is working correctly
Timeout Issues#
- Answer within 15 seconds, or the delivery is dropped
- Use background jobs for heavy processing
- Return success response quickly, process asynchronously
Ready to automate?
Start rendering images, PDFs and videos from your templates in under 2 minutes. Free plan, no credit card.
Get your API key- Image, PDF and video generation via API
- Visual editor with AI and smart layouts
- Zapier, Make, MCP and 60+ integrations
- White-label embed for your own app
- 100 free credits a month, no credit card required