Skip to main content

Events API

Ariftly uses an event-sourced architecture. Every state change in the platform is recorded as an immutable event. The Events API lets you stream and query the event log.

Event types

Event TypeEmitted When
task.createdA task is dispatched
task.progressAn agent emits a progress update
task.completeAn agent completes a task
task.failedAn agent reports failure
artifact.emittedAn agent emits an artifact
approval.requestedAn agent requests human approval
approval.resolvedA human approves or denies
session.messageA message is added to a session
session.closedA session ends
tool_call.executedThe tool proxy executes a tool call

Stream events (SSE)

GET /events/stream

Returns a Server-Sent Events stream of all events in real time.

Query parameters:

ParameterDescription
task_idOnly stream events for a specific task
agentOnly stream events from a specific agent
typesComma-separated list of event types to include

Example:

curl -N https://api.ariftly.io/v1/events/stream \
-H "Authorization: Bearer $ARIFTLY_API_KEY" \
-H "Accept: text/event-stream" \
--data-urlencode "task_id=task_01j9x8k..."

SSE stream format:

event: task.progress
data: {"task_id":"task_01j9x8k...","message":"Analyzing document","progress":0.3}

event: artifact.emitted
data: {"task_id":"task_01j9x8k...","artifact_id":"art_01j9x8m...","type":"ai_readiness.questionnaire_response"}

event: task.complete
data: {"task_id":"task_01j9x8k...","artifact_count":1}

List events

GET /events

Query historical events.

Query parameters:

ParameterTypeDescription
task_idstringFilter by task
agentstringFilter by agent
typestringFilter by event type
afterISO 8601Events after this timestamp
beforeISO 8601Events before this timestamp
limitintegerMax results. Default: 50, max: 500

Webhooks

Subscribe to events via webhook instead of polling:

POST /webhooks
{
"url": "https://your-server.com/ariftly-webhook",
"events": ["task.complete", "approval.requested"],
"secret": "your-signing-secret"
}

Webhook payloads are signed with HMAC-SHA256. Verify the X-Ariftly-Signature header:

import crypto from 'crypto';

function verifyWebhook(payload: string, signature: string, secret: string) {
const expected = crypto
.createHmac('sha256', secret)
.update(payload)
.digest('hex');
return `sha256=${expected}` === signature;
}