Create Event Handler
/extensions/roboledger/{graph_id}/operations/create-event-handlerPart of Extensions: RoboLedger.
Define a rule that fires GL transactions when a matching event block is created with apply_handlers=True. Match criteria (event_type, event_category, match_source, match_agent_type, etc.) act as AND-joined filters — null fields match anything. The highest-priority matching handler wins. AI-suggested handlers (suggested_by='ai') require approval before they are eligible for matching.
Idempotency: supply an Idempotency-Key header to make safe retries; replays within 24 hours return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
Authentication
Authenticate in any one of these ways — not all of them:
- API key in the
X-API-Keyheader. - Bearer token in the
Authorizationheader.
Path parameters
| Name | Type | Description |
|---|---|---|
graph_idrequired | string | Graph Id |
Header parameters
| Name | Type | Description |
|---|---|---|
Idempotency-Keyoptional | string | Idempotency-Key |
Request body
Required, application/json.
| Field | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
namerequired | string | Human-readable handler name (unique per graph). | ||||||||||||
descriptionoptional | string | Free-form description shown in admin UIs. | ||||||||||||
event_typerequired | string | Event type to match. Matches the `event_type` field on incoming events from `create-event-block`. | ||||||||||||
event_categoryoptional | string | Optional category filter (e.g. 'expense', 'revenue'). | ||||||||||||
match_sourceoptional | string | Match the event's `source` field (e.g. 'quickbooks', 'plaid'). Useful when the same event_type comes from multiple integrations. | ||||||||||||
match_agent_typeoptional | string | Match agent-emitted events by agent_type. | ||||||||||||
match_resource_typeoptional | string | Match resource-bound events by resource_type. | ||||||||||||
match_metadata_expressionoptional | object | JSONPath-style equality map against event.metadata, e.g. {"category": "payroll"} or {"metadata.category": "payroll"} | ||||||||||||
transaction_templaterequired | TransactionTemplate | The DSL spec for the GL rows this handler produces. See `TransactionTemplate` for the shape. TransactionTemplate fields
| ||||||||||||
priorityoptional | integer | Tiebreaker when multiple equally-specific handlers match. Higher = wins. Default: | ||||||||||||
is_activeoptional | boolean | Inactive handlers are ignored at match time. Default: | ||||||||||||
originoptional | string | Provenance of the handler. `tenant` = author by graph owner; `hub` = platform-shipped template (immutable for tenants). One of: Default: | ||||||||||||
metadataoptional | object | Free-form metadata stored alongside the handler. |
Example request
curl -X POST "https://api.robosystems.ai/extensions/roboledger/{graph_id}/operations/create-event-handler" \
-H "X-API-Key: $ROBOSYSTEMS_API_KEY" \
-H "Idempotency-Key: <Idempotency-Key>" \
-H "Content-Type: application/json" \
-d '{
"event_type": "vendor_bill_received",
"match_source": "quickbooks",
"name": "QB Vendor Bill — Default Expense Posting",
"priority": 0,
"transaction_template": {
"transactions": [
{
"entry_template": {
"credit": {
"amount": "{{ event.amount }}",
"element_id": "elem_coa_accounts_payable"
},
"debit": {
"amount": "{{ event.amount }}",
"element_id": "elem_coa_office_supplies"
}
}
}
]
}
}'Responses
200 Successful Response
| Field | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
operationrequired | string | Kebab-case operation name | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
operationIdrequired | string | op_-prefixed ULID for audit and SSE correlation | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
statusrequired | string | Operation lifecycle state One of: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
resultoptional | EventHandlerResponse | Command-specific result payload EventHandlerResponse fields
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
atrequired | string | ISO-8601 UTC timestamp | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
createdByoptional | string | User ID that initiated the operation (null for legacy callers) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
idempotentReplayoptional | boolean | True when this envelope came from the idempotency cache — the underlying command did not execute again. False on fresh executions. Default: |
| Status | Meaning |
|---|---|
| 400 | Invalid request |
| 401 | Authentication required |
| 403 | Access denied |
| 404 | Resource not found |
| 409 | Idempotency-Key conflict — key reused with different body |
| 422 | Validation error |
| 429 | Rate limit exceeded |
| 500 | Internal server error |