Skip to main content

Event Definitions vs Events

  • Event Definition: The schema/template that defines what an event should look like
  • Event: The actual message published at runtime with real data

Event Schemas

Event schemas define the structure and types of data in your event payloads. When an event definition exists, EnSync validates the payload before publishing:
  • Validation: Events that don’t match the schema will be rejected
  • Documentation: Clear contracts between publishers and subscribers

Creating Event Definitions

Event definitions are created in the EnSync Dashboard. You can also create them programmatically via the API (see API Reference). Example event definition:
Once created, you can publish events that match this definition:

Schema Types

Common types used in schemas:

Schema Validation

EnSync validates first-level fields only. Deeply nested structures are not validated.

Best Practices

  • First-level validation only: Use "object" type for nested structures
  • Use consistent types: Don’t mix strings and numbers for the same field
  • Document nested structures separately: Provide documentation for object contents
  • Version your schemas: Use event name versioning when making breaking changes
If no event definition exists for an event name, EnSync accepts any valid JSON payload. Once a definition exists, payloads must match the schema or publishing will fail.