---
title: "Update Event Handler"
method: POST
path: "/extensions/roboledger/{graph_id}/operations/update-event-handler"
tags: ["RoboLedger: Ledger & Events"]
---

# Update Event Handler

`POST /extensions/roboledger/{graph_id}/operations/update-event-handler`

## Request

- Base URL: `https://api.robosystems.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://api.robosystems.ai/extensions/roboledger/{graph_id}/operations/update-event-handler`
- Auth: one of:
  - API key in header `X-API-Key`
  - HTTP bearer

Patch an event handler's match criteria, template, priority, or active state. Pass approve=true to approve an AI-suggested handler; approve=false to revoke approval. Only supplied fields are updated.

**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.

## Path parameters

- `graph_id` string, required

## Headers

- `Idempotency-Key` string, nullable

## Request body

- UpdateEventHandlerRequest: Update an existing event handler. All fields except `event_handler_id` are optional — pass only what changes. `transaction_template` is **fully replaced** when supplied (no partial template patches). `metadata_patch` does deep-merge into the existing metadata. `approve=true` sets `approved_by` and `approved_at`; `approve=false` clears them.
  - `event_handler_id` string, required: The handler to update.
  - `name` string, nullable: New name. Omit to leave unchanged.
  - `description` string, nullable: New description.
  - `event_category` string, nullable
  - `match_source` string, nullable
  - `match_agent_type` string, nullable
  - `match_resource_type` string, nullable
  - `match_metadata_expression` object, nullable
  - `transaction_template` TransactionTemplate: The handler's output spec — one or more balanced entries to post. Wire shape:: { "transactions": [{ "entry_template": { "debit": {"element_id": "elem_...", "amount": "{{ event.amount }}"}, "credit": {"element_id": "elem_...", "amount": "{{ event.amount }}"} } }] }
    - `transactions` TransactionTemplateItem[], required: At least one debit/credit entry pair
      - `entry_template` TransactionTemplateEntry, required: One balanced entry (debit + credit pair) — the inner shape of entry_template.
        - `debit` TransactionTemplateLeg, required: One side of a journal entry leg (debit or credit).
          - `element_id` string, required: Element ULID (elem_ prefixed) identifying the account to post to
          - `amount` string, required: Amount expression. Supports: '{{ event.amount }}' — raw event amount (cents); '{{ event.amount }} / 2' — half of event amount; '{{ event.metadata.fee_cents }}' — field from event metadata
        - `credit` TransactionTemplateLeg, required: One side of a journal entry leg (debit or credit).
          - `element_id` string, required: Element ULID (elem_ prefixed) identifying the account to post to
          - `amount` string, required: Amount expression. Supports: '{{ event.amount }}' — raw event amount (cents); '{{ event.amount }} / 2' — half of event amount; '{{ event.metadata.fee_cents }}' — field from event metadata
  - `priority` integer, nullable
  - `is_active` boolean, nullable: Toggle activation. False removes the handler from match-time consideration without deleting it.
  - `approve` boolean, nullable: Approval shortcut: True stamps approved_by/approved_at to the current user; False clears both.
  - `metadata_patch` object: Deep-merged into the existing handler.metadata. Pass `{}` to leave metadata unchanged.

## Response `200`

Successful Response

- OperationEnvelopeEventHandlerResponse
  - `operation` string, required: Kebab-case operation name
  - `operationId` string, required: op_-prefixed ULID for audit and SSE correlation
  - `status` 'completed' | 'pending' | 'failed', required: Operation lifecycle state
  - `result` EventHandlerResponse
    - `id` string, required
    - `name` string, required
    - `description` string, nullable
    - `event_type` string, required
    - `event_category` string, nullable
    - `match_source` string, nullable
    - `match_agent_type` string, nullable
    - `match_resource_type` string, nullable
    - `match_metadata_expression` object, nullable
    - `transaction_template` object, required
    - `priority` integer, required
    - `is_active` boolean, required
    - `origin` string, required
    - `suggested_by` string, nullable
    - `confidence` number, nullable
    - `approved_by` string, nullable
    - `approved_at` string, date-time, nullable
    - `created_at` string, date-time, nullable
    - `updated_at` string, date-time, nullable
    - `created_by` string, nullable
  - `at` string, required: ISO-8601 UTC timestamp
  - `createdBy` string, nullable: User ID that initiated the operation
  - `idempotentReplay` boolean: True when this envelope came from the idempotency cache — the underlying command did not execute again. False on fresh executions.

## Other responses

- `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

---

[API](https://skmtc.dev/robosystems/apis/robosystems-api.md) · [All operations](https://skmtc.dev/robosystems/apis/robosystems-api/llms.txt) · [OpenAPI document](https://skmtc.dev/robosystems/apis/robosystems-api/revisions/e661e2d5ca6a?raw)
