Events

The cPod event system is a real-time stream of platform activity. Every significant state change — an entity being created or updated, a pod transitioning status, a job completing, or a credential being revoked — emits an event. Events are immutable, append-only, and retained for 90 days.

Common event types include:

TypeTrigger
person.created / person.updated / person.deletedPeople domain mutations
pod.created / pod.started / pod.stopped / pod.failedPod lifecycle transitions
job.completed / job.failedWorkflow job completions
credential.created / credential.revokedCredential management
custom.*Custom events emitted by your application

Event Schema

FieldTypeDescription
idstringUUID — unique per event
typestringDot-namespaced event type (e.g. pod.failed)
resourceIdstringID of the affected resource
resourceTypestringResource kind (e.g. pod, person, job)
organizationIdstringOrganization scope
workspaceIdstringWorkspace scope (if applicable)
payloadobjectEvent-specific data (varies by type)
timestampstringISO 8601 UTC — when the event occurred

List Recent Events

import { CpodClient } from '@cpod/sdk'
const sdk = CpodClient.fromEnv()
 
const result = await sdk.events.getHistory({
  organizationId: 'b2c3d4e5-...',
  resourceType: 'pod',
  since: '2026-05-01T00:00:00Z',
  limit: 50,
})
 
for (const event of result.data) {
  console.log(event.timestamp, event.type, event.resourceId)
}

Filter by Event Types

// Fetch only pod failure and job failure events
const result = await sdk.events.getHistory({
  organizationId: 'b2c3d4e5-...',
  types: ['pod.failed', 'job.failed'],
  since: new Date(Date.now() - 86400_000).toISOString(), // last 24 hours
})

Subscribe to Events (In-Process)

The SDK provides a lightweight poll-based subscription API for reacting to events in long-running processes.

const sub = sdk.events.subscribe(
  {
    organizationId: 'b2c3d4e5-...',
    types: ['pod.failed', 'pod.stopped'],
  },
  (event) => {
    console.log('Pod event:', event.type, event.resourceId, event.payload)
  }
)
 
// Dispatch incoming events (e.g. from a webhook payload or SSE frame)
sdk.events.dispatch(incomingEvent)
 
// Stop receiving events
sub.unsubscribe()

Real-Time Subscriptions via Webhooks

For real-time delivery of events to external services (HTTP endpoints, queues, etc.), use webhooks. Webhooks push events to your endpoint as they occur, without polling. Configure webhooks in the cPod dashboard under Settings → Webhooks.

Webhook payloads use the same CpodEvent schema as the REST API. Verify the X-Cpod-Signature header on incoming requests to confirm authenticity.


Emit a Custom Event

Your application can emit custom events into the platform stream. Use a custom.* type prefix.

// Custom events are dispatched via the emulator's POST /v1/events endpoint
// or through your platform's event ingestion API.
await fetch(`${process.env.CPOD_BASE_URL}/v1/events`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.CPOD_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    type: 'custom.report.generated',
    resourceId: 'report-xyz',
    resourceType: 'report',
    payload: { format: 'pdf', rows: 1240 },
  }),
})