Browse the API reference

Create Event Handler

post/extensions/roboledger/{graph_id}/operations/create-event-handler

Part 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-Key header.
  • Bearer token in the Authorization header.

Path parameters

NameTypeDescription
graph_idrequiredstringGraph Id

Header parameters

NameTypeDescription
Idempotency-KeyoptionalstringIdempotency-Key

Request body

Required, application/json.

FieldTypeDescription
namerequiredstring

Human-readable handler name (unique per graph).

descriptionoptionalstring

Free-form description shown in admin UIs.

event_typerequiredstring

Event type to match. Matches the `event_type` field on incoming events from `create-event-block`.

event_categoryoptionalstring

Optional category filter (e.g. 'expense', 'revenue').

match_sourceoptionalstring

Match the event's `source` field (e.g. 'quickbooks', 'plaid'). Useful when the same event_type comes from multiple integrations.

match_agent_typeoptionalstring

Match agent-emitted events by agent_type.

match_resource_typeoptionalstring

Match resource-bound events by resource_type.

match_metadata_expressionoptionalobject

JSONPath-style equality map against event.metadata, e.g. {"category": "payroll"} or {"metadata.category": "payroll"}

transaction_templaterequiredTransactionTemplate

The DSL spec for the GL rows this handler produces. See `TransactionTemplate` for the shape.

TransactionTemplate fields
FieldTypeDescription
transactionsrequiredTransactionTemplateItem[]

At least one debit/credit entry pair

TransactionTemplateItem fields
FieldTypeDescription
entry_templaterequiredTransactionTemplateEntry

One balanced entry (debit + credit pair) — the inner shape of entry_template.

priorityoptionalinteger

Tiebreaker when multiple equally-specific handlers match. Higher = wins.

Default: 0

is_activeoptionalboolean

Inactive handlers are ignored at match time.

Default: true

originoptionalstring

Provenance of the handler. `tenant` = author by graph owner; `hub` = platform-shipped template (immutable for tenants).

One of: hub, tenant

Default: tenant

metadataoptionalobject

Free-form metadata stored alongside the handler.

Example request

curl
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

FieldTypeDescription
operationrequiredstring

Kebab-case operation name

operationIdrequiredstring

op_-prefixed ULID for audit and SSE correlation

statusrequiredstring

Operation lifecycle state

One of: completed, pending, failed

resultoptionalEventHandlerResponse

Command-specific result payload

EventHandlerResponse fields
FieldTypeDescription
idrequiredstring
namerequiredstring
descriptionoptionalstring
event_typerequiredstring
event_categoryoptionalstring
match_sourceoptionalstring
match_agent_typeoptionalstring
match_resource_typeoptionalstring
match_metadata_expressionoptionalobject
transaction_templaterequiredobject
priorityrequiredinteger
is_activerequiredboolean
originrequiredstring
suggested_byoptionalstring
confidenceoptionalnumber
approved_byoptionalstring
approved_atoptionalstring (date-time)
created_atoptionalstring (date-time)
updated_atoptionalstring (date-time)
created_byoptionalstring
atrequiredstring

ISO-8601 UTC timestamp

createdByoptionalstring

User ID that initiated the operation (null for legacy callers)

idempotentReplayoptionalboolean

True when this envelope came from the idempotency cache — the underlying command did not execute again. False on fresh executions.

Default: false

StatusMeaning
400Invalid request
401Authentication required
403Access denied
404Resource not found
409Idempotency-Key conflict — key reused with different body
422Validation error
429Rate limit exceeded
500Internal server error