Guide explains how to manage webhooks using Supervisely SDK and API
Introduction
In this tutorial you will learn how to manage Webhooks using Supervisely SDK and API. Webhooks allow you to receive real-time notifications when certain events occur in your team, such as labeling job completion or labeling queue updates.
Webhooks automation
Import libraries
import osfrom dotenv import load_dotenvimport supervisely as sly
Init API client
Init API for communicating with Supervisely Instance. First, we load environment variables with credentials:
if sly.is_development():load_dotenv(os.path.expanduser("~/supervisely.env"))api = sly.Api.from_env()
Get your Team ID from environment
team_id =123# change to your team ID
Available webhook actions
Supervisely supports the following webhook action types:
sly.LABELING_JOB_COMPLETED - Triggered when a labeling job is completed
sly.LABELING_QUEUE_JOB_COMPLETED - Triggered when a job in labeling queue is completed
sly.LABELING_QUEUE_COMPLETED - Triggered when entire labeling queue is completed
Create a webhook
Create a new webhook that will be triggered when a labeling job is completed:
Create webhook with custom headers
You can add custom headers to your webhook requests, for example for authentication:
Parameters explanation
team_id - ID of your team where the webhook will be active
url - Target URL that will receive webhook POST requests
action - Type of event that triggers the webhook (use constants from sly)
retries_count - Number of retry attempts if webhook delivery fails (default: 5)
retries_delay - Delay in seconds between retry attempts (default: 10)
headers - Dictionary of custom HTTP headers to include in webhook requests
follow_redirect - Whether to follow HTTP redirects (default: True)
reject_unauthorized - Whether to reject unauthorized SSL certificates (default: True)
Get list of webhooks
Get all webhooks in your team:
Filter webhooks
You can filter webhooks by specific criteria:
Get webhook information by ID
Retrieve detailed information about a specific webhook:
Update a webhook
Update an existing webhook's properties:
Note: Only the parameters you specify will be updated. Other parameters will remain unchanged.
Test a webhook
Send a test event to verify your webhook is working correctly:
Test webhook with custom payload
You can also test a webhook with a custom payload:
Remove a webhook
Delete a webhook when it's no longer needed:
Webhook payload structure
When a webhook is triggered, Supervisely sends a POST request to your URL with the following structure:
Labeling Job Completed Event
Labeling Queue Job Completed Event
Labeling Queue Completed Event
Complete example
Here's a complete example that demonstrates webhook management:
Best practices
Use HTTPS endpoints - Always use secure HTTPS URLs for your webhook endpoints
Validate webhook signatures - Implement signature validation on your server to ensure requests are from Supervisely
Handle retries gracefully - Make your endpoint idempotent to handle potential duplicate deliveries
Set appropriate retry settings - Configure retries_count and retries_delay based on your endpoint's reliability
Monitor webhook health - Regularly check webhook delivery status and update if needed
Use custom headers for authentication - Add authentication tokens in headers rather than in URL parameters
Test before production - Use the test() method to verify your webhook endpoint works correctly
Troubleshooting
Webhook not receiving events
Verify the webhook URL is publicly accessible
Check that the action type matches the events you expect
Ensure your server accepts POST requests
Check server logs for incoming requests
SSL/TLS errors
If you're getting SSL errors, you can temporarily disable certificate validation:
Warning: Never use reject_unauthorized=False in production environments.