DarhimLabs API
Custom integration via webhooks
Budowa niestandardowej integracji bez oficjalnego connectora.
Custom integration via webhooks
Budowa niestandardowej integracji bez oficjalnego connectora.
Kiedy tego uzyc
Uzyj tego przepisu, gdy chcesz: Polaczyc DarhimLabs z wewnetrznym systemem przez eventy i REST callbacks.
Endpoint referencyjny: POST /webhooks/endpoints.
Implementacja
Node.js
import { DarhimLabs } from "@darhimlabs/node";
const client = new DarhimLabs(process.env.DARHIMLABS_API_KEY!);
await client.webhookEndpoints.create({ url, events: ['conversation.created', 'message.received'] });
Python
import os
from darhimlabs import DarhimLabs
client = DarhimLabs(api_key=os.environ["DARHIMLABS_API_KEY"])
client.webhook_endpoints.create({'url': url, 'events': ['conversation.created', 'message.received']})
PHP
<?php
$client = new DarhimLabs\Client(["api_key" => $_ENV["DARHIMLABS_API_KEY"]]);
$client->webhookEndpoints->create(['url' => $url, 'events' => ['conversation.created', 'message.received']]);
Ruby
client = DarhimLabs::Client.new(api_key: ENV["DARHIMLABS_API_KEY"])
client.webhook_endpoints.create(url: url, events: ['conversation.created', 'message.received'])
Test it
- Wykonaj request w sandboxie z kluczem
dl_test_.... - Sprawdz
X-Request-IDw odpowiedzi. - Dla webhookow uzyj Webhook Playground, zeby zobaczyc payload live.
Common pitfalls
- Najpierw przetestuj endpoint w /webhooks/playground, dopiero potem podlacz produkcje.
- Loguj
request_idievent_id, zeby support mogl odtworzyc problem. - Dla mutacji dodawaj
Idempotency-Key, szczegolnie jesli request moze byc retryowany.
Production checklist
- Dodaj retry z exponential backoff i jitterem.
- Ogranicz scopes API key do minimalnego zestawu.
- Monitoruj rate limit headers i latency P95.
- Przetestuj bledy
401,409,422i429.