Niah Docs
Core APIs

Webhooks

Get notified the moment long-running work finishes, instead of polling. Subscribe an HTTPS endpoint to consultation.* and batch.* events.

Events

EventFires when
consultation.completedA consultation finishes successfully
consultation.failedA consultation fails
batch.completedAll items in a batch complete
batch.failedA batch fails entirely
batch.partial_failureA batch completes with some failed items

Register an endpoint

post /v1/webhooks

bash
curl -X POST https://api.niah.si/v1/webhooks \
  -H "Authorization: Bearer $NIAH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/hooks/niah",
    "events": ["consultation.completed", "batch.completed"],
    "description": "Prod pipeline"
  }'
The response includes a secret once. Store it — you'll use it to verify signatures and it can't be retrieved later.

Verify signatures

Every delivery is signed with an HMAC-SHA256 of the raw request body using your webhook secret, sent in the X-Niah-Signature header. Recompute it and compare with a constant-time check before trusting the payload.

python
import hashlib, hmac

def valid(secret: str, raw_body: bytes, header_sig: str) -> bool:
    expected = hmac.new(secret.encode(), raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, header_sig)

Delivery & retries

Respond with a 2xx quickly (do heavy work asynchronously). Niah retries failed deliveries with backoff. Inspect the full delivery history — status codes, errors, and timing — at:

get /v1/webhooks/deliveries

Manage

get/v1/webhooksList configs
put/v1/webhooks/{id}Update (URL, events, enabled)
delete/v1/webhooks/{id}Delete