Webhooks
Real-time event subscriptions. Webhooks enable you to subscribe to system events and receive real-time notifications when assets are created, modified, or verified.
Methods​
| Method (TypeScript) | Method (Python) | Description | HTTP |
|---|---|---|---|
create(webhook) | create(webhook) | Create webhook subscription | POST /webhooks |
get(webhookId) | get(webhook_id) | Retrieve webhook | GET /webhooks/{id} |
list(options?) | list(options=None) | List webhooks | GET /webhooks |
update(webhookId, webhook) | update(webhook_id, webhook) | Update webhook | PATCH /webhooks/{id} |
delete(webhookId) | delete(webhook_id) | Delete webhook | DELETE /webhooks/{id} |
getDeliveries(webhookId, options?) | get_deliveries(webhook_id, options=None) | List webhook deliveries | GET /webhooks/{id}/deliveries |
Example​
- TypeScript
- Python
import { OptropicClient } from 'optropic';
const client = new OptropicClient({ apiKey: 'optr_live_...' });
// Create a webhook for asset creation events
const webhook = await client.webhooks.create({
url: 'https://your-domain.com/webhook',
events: ['asset.created', 'asset.verified'],
active: true,
headers: {
'X-Custom-Header': 'your-value'
}
});
console.log(`Webhook created: ${webhook.id}`);
console.log(`Check deliveries at: /webhooks/${webhook.id}/deliveries`);
from optropic import Optropic
client = Optropic(api_key="optr_live_...")
# Create a webhook for asset creation events
webhook = client.webhooks.create({
'url': 'https://your-domain.com/webhook',
'events': ['asset.created', 'asset.verified'],
'active': True,
'headers': {
'X-Custom-Header': 'your-value'
}
})
print(f"Webhook created: {webhook['id']}")
print(f"Check deliveries at: /webhooks/{webhook['id']}/deliveries")