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:Schema Types
Common types used in schemas:| Type | Description | Example |
|---|---|---|
string | Text data | "order-123" |
number | Integer values | 42 |
float | Decimal values | 99.99 |
boolean | True/false | true |
array | List of items | [1, 2, 3] |
object | Nested structure | {"address": {...}} |
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.