Labels
Labels are key-value pairs attached to events. Hook0 uses them to route events to the right subscriptions. You can use labels for multi-tenancy, environment separation, or any filtering logic you need.
Key points
- Every event must include at least one label
- Subscriptions filter events by matching label values
- Labels are how you implement multi-tenant routing
- Matching is case-sensitive and exact
Minimum Requirement
How labels work
Matching rules
- A subscription receives an event only if all its label filters match the event's labels
- If an event lacks a label that the subscription filters on, the event is not delivered
- Subscriptions can have fewer labels than events (partial matching)
- Label values are case-sensitive and must match exactly
Common patterns
| Pattern | Example label | Purpose |
|---|---|---|
| Multi-tenancy | tenant_id: "acme_corp" | Isolate events per customer |
| Environment | environment: "production" | Separate prod/staging/dev |
| Priority | priority: "critical" | Route urgent events differently |
| Geographic | region: "eu-west-1" | Route by location |
| Source | source: "mobile_app" | Identify event origin |
Naming conventions
- Use
snake_casefor keys:tenant_id,event_source - Be descriptive:
payment_providernotpp - Avoid sensitive data: never use
password,ssn,credit_card - Use consistent naming across all events
What's next?
- Events - Attach labels to events
- Subscriptions - Filter events with labels
- Event Types - Categorize your events
- Applications - Manage labels per application