Guides

Event Types

Organize events into named categories for targeted routing

Event types let you categorize events so endpoints only receive what they care about. Instead of sending every event to every endpoint, you define types like order.created or payment.failed and subscribe endpoints to the types they need.

Naming Conventions

Use dot-separated names that describe the resource and action:

order.created
order.updated
order.canceled
payment.succeeded
payment.failed
user.signup
invoice.finalized

Use lowercase with dots as separators. Keep names consistent: {resource}.{action} in past tense for things that happened.

Creating Event Types

Dashboard

Go to Event Types and click Create Event Type. Enter the name and an optional description.

API

curl -X POST https://api.nahook.com/api/workspaces/ws_YOUR_ID/event-types \
  -H "Authorization: Bearer YOUR_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "order.created",
    "description": "Fired when a new order is placed"
  }'
const response = await fetch(
  "https://api.nahook.com/api/workspaces/ws_YOUR_ID/event-types",
  {
    method: "POST",
    headers: {
      Authorization: "Bearer YOUR_SESSION_TOKEN",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      name: "order.created",
      description: "Fired when a new order is placed",
    }),
  },
);

const eventType = await response.json();
// { id: "evt_abc123", name: "order.created", ... }

Subscribing Endpoints

After creating event types, subscribe endpoints to receive specific events:

curl -X POST https://api.nahook.com/api/workspaces/ws_YOUR_ID/endpoints/ep_YOUR_ID/subscriptions \
  -H "Authorization: Bearer YOUR_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "eventTypeIds": ["evt_abc123", "evt_def456"]
  }'
await fetch(
  "https://api.nahook.com/api/workspaces/ws_YOUR_ID/endpoints/ep_YOUR_ID/subscriptions",
  {
    method: "POST",
    headers: {
      Authorization: "Bearer YOUR_SESSION_TOKEN",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      eventTypeIds: ["evt_abc123", "evt_def456"],
    }),
  },
);

Environment Visibility

Event types are workspace-wide, but you control which event types are visible in each environment. An event type must be published in an environment for fan-out delivery to work there.

For example, you can publish order.created to Production and Staging, but keep order.refunded only in Production until it's ready.

Toggle visibility in the dashboard by selecting an environment and going to Event Types, or use the Management API.

Next Steps

Once you have event types and subscriptions set up, use Fan-Out Routing to send events by type and let Nahook deliver to all subscribed endpoints.