Events

How to configure life events

This is technical documentation. For the functional overview of events, see Events

An event is a life event your country registers in OpenCRVS (for example birth or death). You configure each event in your country config repository under src/events/, then expose all event configs to the core via a single API handler.

The core fetches the event configurations from the country config server via a predefined HTTP endpoint. This means you can, for example, implement custom logic for defining your configs — as long as the endpoint exists and returns a valid array of event configurations.

File layout

In a typical country config (see opencrvs-countryconfig):

Path
Purpose

src/events/<event>/index.ts

Event definition (defineConfig)

src/events/<event>/forms/

Declaration, review, print, and correction forms

src/events/index.ts

Aggregates all events into eventConfigs

src/api/events/handler.ts

Returns eventConfigs to the OpenCRVS client

Define an event

Wrap each event in the defineConfig() helper.

Example:

// src/events/birth/index.ts
import { ActionType, defineConfig, field } from '@opencrvs/toolkit/events'
import { birthDeclarationForm } from './forms/declaration'

export const birthEvent = defineConfig({
  id: 'birth',
  label: {
    defaultMessage: 'Birth',
    description: 'This is what this event is referred as in the system',
    id: 'event.birth.label'
  },
  declaration: birthDeclarationForm,
  dateOfEvent: field('child.dob'),
  // title, summary, actions, flags, ...
})

Register events with the API

Export every event from src/events/index.ts, then return that array from your events handler:

EventConfig schema

Last updated