> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stackshift.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Events API

> Read the catalog and recent events, stream them live, and manage destinations, rules and deliveries under /api/v1/events.

> [!TIP]
>
> **Live.** This area is documented as current, user-reliable behavior.

## Goal

Automate Events from your own code.

## Prerequisites

* An API token. Add team\_id to work on a team’s events.

## Workflow

**Step 1**

GET /api/v1/events/catalog to list event types.

**Step 2**

POST /api/v1/events/subscriptions to add a webhook destination and receive its secret once.

**Step 3**

POST /api/v1/events/rules to send matching events to a target.

**Step 4**

GET /api/v1/events/deliveries?dead\_letter=true to find what gave up, then POST /api/v1/events/deliveries/\{id}/replay.

## Endpoints

* GET /catalog, GET / (recent events: type, product, project\_id, since, cursor, limit), GET /\{eventId}, GET /stats?days=7.
* GET /stream: a server-sent event stream of event: platform.event messages. Resume with Last-Event-ID. Each connection ends after 10 minutes; reconnect. Up to 5 open streams per user.
* GET, POST /subscriptions; GET, PATCH, DELETE /subscriptions/\{id}; POST /subscriptions/\{id}/rotate-secret; POST /subscriptions/\{id}/test.
* GET, POST /rules; POST /rules/preview; GET, PATCH, DELETE /rules/\{id}; POST /rules/\{id}/test.
* GET /deliveries (status, dead\_letter, subscription\_id, rule\_id, event\_id, cursor, limit); GET /deliveries/\{id} with its attempts; POST /deliveries/\{id}/replay.

## Create a rule

* target\_type is webhook, function, queue, job\_event, agent, notification or automation.
* target\_config: webhook \{ subscription\_id }; function \{ project\_id, function }; queue \{ queue, job }; job\_event \{ name, correlation\_path }; agent \{ agent\_id } or \{ stackie: true, prompt }; notification \{ channels, title }; automation \{ automation\_id }.

```json POST /api/v1/events/rules theme={null}
{
  "name": "Failed deploys to on-call",
  "event_types": ["deploy.failed"],
  "filters": { "project_ids": ["p_789"] },
  "target_type": "webhook",
  "target_config": { "subscription_id": "sub_123" }
}
```

## SDKs and agents

The JavaScript, Python and Go SDKs wrap these endpoints in an events client. Agents and Stackie use the actions events.catalog.inspect, events.recent.inspect, events.subscription.create, events.subscription.delete, events.rule.create, events.rule.update, events.rule.delete and events.delivery.replay. In n8n, the StackShift Trigger node subscribes a webhook and lists the catalog.

## Expected result

> [!TIP]
>
> Your code manages the same rules and destinations shown in the dashboard.

## Related guides

> [card] [Rules and filters](https://docs.stackshift.cloud/events/rules-and-filters.md)
>
> A rule matches events by type pattern, project, subject and data conditions, then sends each match to one target.

> [card] [Verify webhook signatures](https://docs.stackshift.cloud/events/verify-webhooks.md)
>
> Every webhook is signed with HMAC-SHA256 of the timestamp and raw body. Verify it with the SDK for JavaScript, Python, Go, Ruby or PHP.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.