# Webhooks

When using the `async` render mode from **RenderPDF.io**, your content will be rendered in the background and once it has been rendered, we'll send a webhook notification to your registered endpoints.

### Authenticate our Request

After adding your Webhook URL, we will give you a unique key.&#x20;

Every time we **send** a Webhook Request to your endpoint, that key **will be included** in the `Authorization` header (as a **Bearer Token**)

So you just simply check the Authorization header with the given key to validate the requests 😎.

#### Example (PHP)

```php
public function webhook(Request $request): Response
{
    $token = $request->bearerToken(); 
    if ($token !== config('services.render-pdf-io.webhook-token')) {
        return new Response(400);
    }
    
    // handle my logic
    // ...
    
    return new Response('ok');
}
```

### User-Agent

To ensure your firewall doesn't block our requests, add our User-Agent to the allow list:

```
RenderPdfIoHTTP/1
```

### Request Body

We'll always send you `POST` with JSON body (`Content-Type: Application/JSON`)

The base structure:

```json
{
    type: "EVENT_NAME",
    payload: {
        // vary based on EVENT
    }
}
```

### Available Events

#### PDF\_RENDERED

```typescript
{
    type: "PDF_RENDERED",
    payload: {
        id: string; // your unique identifier ID that you gave to RenderPDF.io
        url: string; // downloadable URL
    }
}
```

#### RENDER\_PDF\_FAILED

```typescript
{
    type: "RENDER_PDF_FAILED",
    payload: {
        id: string; // your unique identifier ID that you gave to RenderPDF.io
    }
}
```
