Skip to Content
SDKsCommon Tasks

Common Tasks

All Chirpier SDKs expose helpers around the same resource model. These examples show the most common operations beyond logging.

Resolve an event definition

After logging, use listEvents to find the event definition and get the event_id needed for analytics, policies, and sharing.

const events = await client.listEvents(); const event = events.find( (e) => e.agent === "openclaw.main" && e.event === "task.duration_ms", );

Query analytics comparisons

Use analytics windows to compare the current period against a previous one.

const analytics = await client.getEventAnalytics(eventID, { view: "window", period: "1h", previous: "previous_1d", }); // analytics.data.value_pct_change shows % change vs same hour yesterday

Create a policy

Policies define alert conditions. Choose the aggregate based on the event shape.

const policy = await client.createPolicy({ event_id: eventID, title: "High error rate", channel: "ops", period: "hour", aggregate: "sum", condition: "gt", threshold: 50, severity: "warning", enabled: true, });

Set up a destination and test it

Create a destination, send a test notification, and inspect the delivery.

const destination = await client.createDestination({ channel: "slack", url: "https://hooks.slack.com/services/T000/B000/secret", scope: "all", policy_ids: [], enabled: true, }); const test = await client.testDestination(destination.destination_id); const deliveries = await client.getAlertDeliveries(test.alert_id, { kind: "test" });

Triage an alert

Read an alert, inspect deliveries, and move it through the lifecycle.

const alerts = await client.listAlerts("triggered"); for (const alert of alerts) { const deliveries = await client.getAlertDeliveries(alert.alert_id, { kind: "alert" }); // inspect deliveries... await client.acknowledgeAlert(alert.alert_id); // later: await client.resolveAlert(alert.alert_id); }

When to use SDK helpers

Use the SDK helpers when you want one authenticated client for both:

  • Logging event data
  • Managing Chirpier resources

Use raw HTTP when you need language-agnostic integrations, shell automation, or direct infrastructure-level control.

For endpoint-by-endpoint behavior, see API Reference.

Last updated on