Configure Webhooks for PDF embedding
1.xWebhooks allow you to receive notifications about the success or failure of the PDF generation process. You can configure them via a single array or by using pre-defined configurations from your YAML settings.
Using a configuration name
If you have a webhook configuration defined in your Symfony configuration file, use webhookConfiguration() to apply it.
Manual Webhook Configuration
webhook(array $webhook): Set success, error, and event URLs in one array.webhookUrl(string $url, ?string $method): Set the success URL and optional HTTP method (POST,PUT, orPATCH).webhookErrorUrl(string $url, ?string $method): Set the error URL and optional HTTP method.webhookRoute(string $route, array $parameters, ?string $method): Set a Symfony route for success.webhookErrorRoute(string $route, array $parameters, ?string $method): Set a Symfony route for errors.webhookEventsUrl(string $url): Set a URL to receive structured JSON event callbacks (e.g.,webhook.success,webhook.error).webhookEventsRoute(string $route, array $parameters): Set a Symfony route for event callbacks.
// Using a named configuration from config files
return $gotenberg
->webhookConfiguration('my_webhook_config')
->generate()
->stream();
// Manual configuration
return $gotenberg
->webhook([
'config_name' => 'my_config',
'success' => ['url' => 'https://my.webhook.url/success', 'method' => 'POST'],
'error' => ['route' => 'my_route_error', 'method' => 'POST'],
'events' => ['url' => 'https://my.webhook.url/events']
])
->generate()
->stream();