Webhooks
Celantur Cloud API uses webhooks to notify your application when a file has been processed.
By setting a
webhook
URL in the request to Upload image, a HTTPS POST request will be sent to the specified URL, as soon as the submitted file has finished processing.url = 'https://api.celantur.com/v1/file?method=blur&face=True&webhook=https://example.com/webhook/dev?sender=celantur%26approve=always'
response = requests.post(
url,
data=image,
headers={'Authorization': auth_token}
)
The payload sent to the webhook URL looks like this:
{
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"
}
Webhooks are especially useful to trigger the download of a file, right after it has finished processing. See Get anonymized file
- Make sure you have a publicly available HTTPS endpoint (URL) on your server.
The webhook URL needs to be encoded correctly, in order to not interfere with the Upload image endpoint URL:
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}
)
Last modified 12d ago