> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.templated.io/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# Webhook Integration

# Webhook Integration

Receive notifications when users interact with the embedded editor.

## Embedded Editor Webhooks

Configure in your [Embed Settings](https://app.templated.io/embed):

1. Enter your **Webhook URL**
2. Events are sent when users **create**, **save**, or **download**

## Webhook Actions

### Create Action
Triggered when a user creates a new template or clones an existing one:

```json
{
  "action": "create",
  "templateId": "template-uuid",
  "metadata": {
    "userId": "user-123",
    "customField": "value"
  }
}
```

### Save Action
Triggered when a user saves a template:

```json
{
  "action": "save",
  "templateId": "template-uuid",
  "metadata": {
    "userId": "user-123",
    "customField": "value"
  }
}
```

### Download Action
Triggered when a user downloads/renders a template:

```json
{
  "action": "download",
  "templateId": "template-uuid",
  "renderId": "render-uuid",
  "renderUrl": "https://templated-assets.s3.amazonaws.com/...",
  "metadata": {
    "userId": "user-123",
    "customField": "value"
  }
}
```

## Setting Up Your Endpoint

```javascript
// Express.js example
app.post('/webhook', (req, res) => {
  const { action, templateId, renderId, renderUrl, metadata } = req.body;
  
  console.log(`Received ${action} for template ${templateId}`);
  
  if (action === 'download') {
    console.log(`Render URL: ${renderUrl}`);
  }
  
  // Process the webhook...
  
  res.status(200).send('OK');
});
```

## Passing Metadata

Pass custom data to your webhooks using URL parameters:

```
https://app.templated.io/editor/TEMPLATE_ID?embed=CONFIG_ID&metadata=eyJ1c2VySWQiOiIxMjMifQ==
```

The metadata is Base64 encoded JSON that gets included in all webhook payloads.

## Security

* Verify webhooks originate from Templated
* Use HTTPS endpoints
* Respond with 200 OK quickly
* Process asynchronously if needed

Documentation: [https://templated.io/docs/embed/webhooks/](https://templated.io/docs/embed/webhooks/)