ComposioWebhookDeliveryError
composio.errors.ComposioWebhookDeliveryError
Stack trace
composio.errors.ComposioWebhookDeliveryError: Failed to deliver webhook to https://example.com/webhook: 401 Unauthorized
File "/app/composio/triggers.py", line 87, in deliver_webhook
response = requests.post(url, json=payload, headers=headers)
File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 117, in post
return request('post', url, data=data, json=json, **kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 530, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 439, in send
raise ComposioWebhookDeliveryError(f"Failed to deliver webhook to {url}: {resp.status_code} {resp.reason}") Why it happens
Composio triggers send webhooks to external URLs. This error occurs when the webhook POST request fails due to invalid authentication, unreachable endpoint, incorrect payload format, or network timeouts. The Composio client raises this exception to signal delivery failure.
Detection
Monitor webhook delivery status codes and catch ComposioWebhookDeliveryError exceptions to log failed webhook URLs and response details before retrying or alerting.
Causes & fixes
Webhook URL requires authentication but no or invalid credentials were provided
Add correct authentication headers or tokens to the webhook request headers in your Composio trigger configuration.
Webhook endpoint URL is unreachable due to network issues or incorrect URL
Verify the webhook URL is correct and accessible from your environment; fix DNS or firewall issues blocking outbound requests.
Payload format does not match the webhook receiver's expected schema
Adjust the payload structure in your Composio trigger to match the receiver's API specification exactly.
Webhook delivery timed out due to slow or unresponsive endpoint
Increase the HTTP request timeout setting or optimize the webhook receiver to respond faster.
Code: broken vs fixed
import os
import requests
url = 'https://example.com/webhook'
payload = {'event': 'triggered'}
headers = {}
# This line triggers ComposioWebhookDeliveryError if auth is missing or URL unreachable
response = requests.post(url, json=payload, headers=headers)
response.raise_for_status() import os
import requests
url = os.environ.get('WEBHOOK_URL')
payload = {'event': 'triggered'}
headers = {'Authorization': f"Bearer {os.environ.get('WEBHOOK_TOKEN')}"} # Added auth header
# Fixed: added auth headers and used env vars for URL and token
response = requests.post(url, json=payload, headers=headers, timeout=10)
response.raise_for_status()
print('Webhook delivered successfully') Workaround
Wrap webhook delivery calls in try/except ComposioWebhookDeliveryError, log the error details, and implement a retry mechanism with exponential backoff to handle transient failures.
Prevention
Use environment variables for webhook URLs and credentials, validate webhook endpoints before deployment, and implement monitoring with alerting on webhook delivery failures to catch issues early.