# v1 Webhooks (deprecated)

## Overview

By setting a `webhook` URL in the request to [#upload-image](https://doc.celantur.com/api-endpoints#upload-image "mention"), a HTTPS POST request will be sent to the specified URL, as soon as the submitted file has finished processing.

<pre class="language-python" data-overflow="wrap"><code class="lang-python">url = 'https://api.celantur.com/v1/file?method=blur&#x26;face=True&#x26;webhook=<a data-footnote-ref href="#user-content-fn-1">https://example.com/webhook/dev?sender=celantur%26approve=always</a>'

response = requests.post(
      url, 
      data=image, 
      headers={'Authorization': auth_token}
    )
</code></pre>

The payload sent to the webhook URL looks like this:

```json
{
    customer_id={customer_id}
    file_id={file_id}
    file_status="done"
    original_link="https://api.celantur.com/v1/file/{file_id}/original"
    anonymized_link="https://api.celantur.com/v1/file/{file_id}/anonymized"
    binary_mask_link="https://api.celantur.com/v1/file/{file_id}/binary-mask"
    instance_mask_link="https://api.celantur.com/v1/file/{file_id}/instance-mask"
    metadata_link="https://api.celantur.com/v1/file/{file_id}/metadata"
}
```

{% hint style="info" %}
Webhooks are especially useful to trigger the download of a file, right after it has finished processing. See [#get-anonymized-file](https://doc.celantur.com/api-endpoints#get-anonymized-file "mention")
{% endhint %}

## Prerequisites for webhooks

* [ ] Make sure you have a publicly available HTTPS endpoint (URL) on your server.
* [ ] Set the `webhook` URL in the [#upload-image](https://doc.celantur.com/api-endpoints#upload-image "mention") request's URL parameter.
* [ ] [#encode-the-webhook-url-correctly](#encode-the-webhook-url-correctly "mention")

## Encode the webhook URL correctly

The webhook URL needs to be encoded correctly, in order to not interfere with the [#upload-image](https://doc.celantur.com/api-endpoints#upload-image "mention") endpoint URL:

{% code overflow="wrap" %}

```python
import requests

...

webhook_url = 'https://example.com/webhook/dev?sender=celantur&approve=always'

# encode the URL you want to send the webhook to
# returns 'https://example.com/webhook/dev?sender=celantur%26approve=always'
webhook_url_encoded = webhook_url.encode()

# set webhook in the POST request
response = requests.post('https://api.celantur.com/v1/file?method=blur&face=True&webhook=' + webhook_url_encoded, 
      data=image, 
      headers={'Authorization': auth_token}
    )

```

{% endcode %}

[^1]: URL needs to be encoded: [#encode-the-webhook-url-correctly](#encode-the-webhook-url-correctly "mention")
