A lightweight Python client for managing webhooks via the Credo AI API. Supports creating, reading, updating, and deleting webhooks with minimal setup.
- 1. Installation
- 2. Configuration
- 3. Usage
- 4. Testing CRUD Operations
- 5. API Overview
- 6. Developer Tips
- Python 3.10+
- Poetry
git clone <repository-url>
cd webhooks
poetry install
poetry env info --path
source $(poetry env info --path)/bin/activate # macOS/Linux
# or
$(poetry env info --path)\Scripts\activate.bat # Windows
-
Copy the environment template:
cp env.template .env
-
Edit the
.envfile:API_KEY=your_credo_ai_api_key TENANT=your_tenant_name WEBHOOK_URL=https://your-webhook-endpoint.com/webhook SERVER=https://api.credo.ai
from src.app.credo_client_lite import CredoClientLite
client = CredoClientLite.load_config()
if client.authenticate():
print("Authenticated")
else:
print("Authentication failed")To test your setup and list all webhooks:
poetry run python src/app/credo_client_lite.pyRun the test script to exercise the full webhook lifecycle:
poetry run python src/tests/test_webhook_crud.pyThis test will:
- Create a webhook
- Retrieve and print its configuration
- Update its description and URL
- Delete it from the system
| Method | Description |
|---|---|
load_config() |
Load settings from .env |
authenticate() |
Exchange API key for bearer token |
get_webhooks() |
Fetch all webhooks |
get_webhook(webhook_id) |
Fetch a single webhook by ID |
create_webhook(payload) |
Create a new webhook |
update_webhook(id, payload) |
Modify an existing webhook |
delete_webhook(webhook_id) |
Delete a webhook |
payload = {
"data": {
"type": "webhook",
"attributes": {
"description": "My test webhook",
"url": client.webhook_url,
"event_types": ["use_case_review_status_updated"],
"event_type_prefix": "CredoAI",
"event_type_suffix": "v1",
"environment": "production",
"authentication_method": "none"
}
}
}
response = client.create_webhook(payload)
webhook_id = response["data"]["id"]Logs are written to webhooks.log and printed to console:
import logging
logging.basicConfig(level=logging.INFO)client = CredoClientLite(
api_key="your_api_key",
tenant="your_tenant",
webhook_url="https://your-endpoint.com/webhook",
server="https://api.credo.ai"
)use_case_governance_status_updated🛑 DEPRECATEDuse_case_review_status_updateduse_case_custom_field_updateduse_case_review_commentuse_case_review_status_updateduse_case_review_task_status_updated
For an exhaustive list, see webhooks-general-guide.md.