API Reference
Webhook
Register webhooks for server-pushed notifications.
Webhook
Webhooks let you receive server-pushed notifications when important events occur in a session. Instead of polling the API, register a URL and receive real-time HTTP callbacks for proactive actions, emotional overflow, and stage transitions.
Register Webhook
Register a new webhook endpoint for a session.
Headers
| Header | Type | Required | Description |
|---|---|---|---|
Authorization | string | Yes | Bearer YOUR_API_KEY |
Content-Type | string | Yes | application/json |
Path Parameters
| Parameter | Type | Description |
|---|---|---|
sessionId | string | The session ID to register for |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
url | string | Yes | The HTTPS URL to receive webhook payloads |
secret | string | Yes | Secret key used for HMAC-SHA256 payload signing |
events | string[] | Yes | Array of event types to subscribe to |
Event Types
| Event | Description |
|---|---|
proactive_action | Character initiated a proactive action |
emotional_overflow | Emotion intensity exceeded the character's coping threshold |
stage_transition | Character transitioned to a new soul stage |
Response
| Field | Type | Description |
|---|---|---|
id | string | Unique webhook identifier |
url | string | The registered URL |
events | string[] | Subscribed event types |
created_at | string | ISO 8601 creation timestamp |
Examples
curl
JavaScript
Python
Errors
| Code | Status | Description |
|---|---|---|
UNAUTHORIZED | 401 | Invalid or missing API key |
VALIDATION_ERROR | 400 | Invalid URL, missing events, etc. |
NOT_FOUND | 404 | Session not found |
RATE_LIMIT | 429 | Too many requests |
List Webhooks
List all registered webhooks for a session.
Headers
| Header | Type | Required | Description |
|---|---|---|---|
Authorization | string | Yes | Bearer YOUR_API_KEY |
Path Parameters
| Parameter | Type | Description |
|---|---|---|
sessionId | string | The session ID to query |
Response
Returns an array of webhook objects:
| Field | Type | Description |
|---|---|---|
id | string | Unique webhook identifier |
url | string | The registered URL |
events | string[] | Subscribed event types |
created_at | string | ISO 8601 creation timestamp |
Examples
curl
JavaScript
Python
Errors
| Code | Status | Description |
|---|---|---|
UNAUTHORIZED | 401 | Invalid or missing API key |
NOT_FOUND | 404 | Session not found |
Delete Webhook
Remove a registered webhook.
Headers
| Header | Type | Required | Description |
|---|---|---|---|
Authorization | string | Yes | Bearer YOUR_API_KEY |
Path Parameters
| Parameter | Type | Description |
|---|---|---|
sessionId | string | The session ID |
webhookId | string | The webhook ID to delete |
Response
| Field | Type | Description |
|---|---|---|
deleted | boolean | true if successfully deleted |
id | string | The deleted webhook ID |
Examples
curl
JavaScript
Python
Errors
| Code | Status | Description |
|---|---|---|
UNAUTHORIZED | 401 | Invalid or missing API key |
NOT_FOUND | 404 | Webhook or session not found |
Verifying Webhook Signatures
All webhook payloads are signed with HMAC-SHA256 using the secret you provided during registration. The signature is included in the X-Molroo-Signature header.
To verify a webhook payload:
JavaScript
Python
Webhook Payload Structure
All webhook payloads follow this structure: