Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

doc: improved doc for event subscription

=b22e9fa53bed
diff --git a/docs/documentation/platform/event-subscriptions.mdx b/docs/documentation/platform/event-subscriptions.mdx
index ca6ceebd12..c2006f21df 100644
--- a/docs/documentation/platform/event-subscriptions.mdx
+++ b/docs/documentation/platform/event-subscriptions.mdx
@@ -5,114 +5,124 @@ description: "Subscribe to events in Infisical for real-time updates"
---
<Info>
- **Note:** Event Subscriptions is a paid feature. - **Infisical Cloud users:** Event Subscriptions is available under
- the **Enterprise Tier**. - **Self-Hosted Infisical:** Please contact [[email protected]](mailto:[email protected])
- to purchase an enterprise license.
+ Event Subscriptions is a paid feature.
+ - **Infisical Cloud:** Available under the **Enterprise Tier**.
+ - **Self-Hosted:** Contact [[email protected]](mailto:[email protected]) to purchase an enterprise license.
</Info>
-Event Subscriptions in Infisical allow you to receive real-time notifications when specific actions occur within your account or organization. These notifications include changes to secrets, users, teams, and many more **coming soon**.
+Event Subscriptions allow you to receive real-time notifications when specific actions occur within your Infisical projects. You can subscribe to changes such as secret modifications, with support for additional resource types coming soon.
## How It Works
-- Server receives message over pubsub connection indicating changes have occurred
-- Server processes the change notification
-- Updated data is synchronized across all connected Infisical instances
-- Client applications receive real-time updates through [Server-Sent Events (SSE)](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events)
-- All servers maintain consistent state without manual intervention
+Event Subscriptions use [Server-Sent Events (SSE)](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events) to deliver real-time updates to your applications:
-This ensures your infrastructure stays up-to-date automatically, without requiring restarts or manual synchronization.
+1. Your application opens an SSE connection to the Infisical Events API.
+2. When a subscribed event occurs (e.g., a secret is updated), Infisical pushes a notification through the connection.
+3. Your application receives the event instantly and can take appropriate action.
<Note>
Event Subscriptions are designed for real-time communication and do not include persistence or replay
- capabilities—events are delivered once and are not stored for future retrieval.
+ capabilities—events are delivered once and are not stored for future retrieval. Ensure your application
+ maintains an active connection to receive events.
</Note>
-## Supported Resources
+## Supported Events
-You can currently subscribe to notifications for the following resources and event types:
+You can subscribe to the following event types:
-- **Secrets**
- - `secret:created`: Triggered when a secret is created
- - `secret:updated`: Triggered when a secret is updated
- - `secret:deleted`: Triggered when a secret is deleted
+### Secrets
+
+| Event | Description |
+|-------|-------------|
+| `secret:created` | Triggered when a new secret is created |
+| `secret:updated` | Triggered when an existing secret is modified |
+| `secret:deleted` | Triggered when a secret is removed |
+| `secret:import-mutation` | Triggered when a secret changes via an import |
-## Permissions Setup
-To receive events on a supported resource, the identity must have `Subscribe` action permission on that resource.
+## Permissions Setup
-Follow these steps to set up the necessary permissions:
+To receive events, the machine identity must have the **Secret Events** permission with the appropriate actions enabled.
<Steps>
- <Step title="Select a project and copy the Project ID">
- ![Select Project](/images/platform/events/select-project.png)
+ <Step title="Copy your Project ID">
+ ![Select Project](/images/platform/events/select-project.png)
-On your project page, open **Project Settings** from the sidebar.
+ Navigate to **Project Settings** from the sidebar. In the Project name section, click **Copy Project ID**, or extract it from the URL:
-In the Project name section, click **Copy Project ID** to copy your Project ID, or extract it from the URL:
-`https://app.infisical.com/project/<your_project_id>/settings`
+ ```
+ https://app.infisical.com/project/<your_project_id>/settings
+ ```
+ </Step>
- </Step>
+ <Step title="Open Project Roles">
+ ![Project Detail](/images/platform/events/project-detail.png)
+ ![Project Access](/images/platform/events/project-access.png)
-<Step title="Navigate to Access Management and open Project Roles">
- ![Project Detail](/images/platform/events/project-detail.png) ![Project
- Access](/images/platform/events/project-access.png) Navigate to **Access Management**, then select **Project Roles**.
-</Step>
+ Go to **Access Management** and select **Project Roles**.
+ </Step>
-<Step title="Select an existing role or create a new one">
- ![Project Role](/images/platform/events/project-role.png) You can either edit an existing role or create a new role
- for event subscriptions.
-</Step>
+ <Step title="Create or edit a role">
+ ![Project Role](/images/platform/events/project-role.png)
-<Step title="Assign policies to the role">
- ![Role Detail](/images/platform/events/role-detail.png) Select the specific resources that the role should have access
- to. ![Add policy](/images/platform/events/add-policy.png)
-</Step>
+ Create a new role for event subscriptions, or edit an existing one.
+ </Step>
- <Step title="Enable the Subscribe action in permissions">
- ![Policy setting](/images/platform/events/policy-setting.png)
+ <Step title="Add a policy to the role">
+ ![Role Detail](/images/platform/events/role-detail.png)
- Ensure the **Subscribe** action is selected for the relevant resources and events.
+ Select the resources the role should have access to.
- ## Conditions
+ ![Add policy](/images/platform/events/add-policy.png)
+ </Step>
- By default, the role will have access to all events for the selected resources in this project.
+ <Step title="Enable event actions">
+ ![Policy setting](/images/platform/events/policy-setting.png)
- <AccordionGroup>
- <Accordion title="Full Access">
- ![Policy setting](/images/platform/events/access-full.png)
- </Accordion>
- <Accordion title="Path Prefix">
- ![Policy setting](/images/platform/events/access-path.png)
- </Accordion>
- <Accordion title="Environment">
- ![Policy setting](/images/platform/events/access-dev.png)
- </Accordion>
- </AccordionGroup>
- </Step>
+ Enable the actions corresponding to the events you want to receive (e.g., read, create, update, delete).
+ </Step>
</Steps>
+### Filtering Events with Conditions
+
+You can scope events to specific secret paths, environments, or other conditions.
+
+![Policy condition](/images/platform/events/policy-condition.png)
+
+This allows you to receive only the events relevant to your use case, reducing noise and improving efficiency.
+
## Getting Started
-Currently, events are only available via [API](/api-reference/endpoints/events) but will soon be available in our SDKs, Kubernetes Operator, and more.
+Event Subscriptions are currently available via the [Events API](/api-reference/endpoints/events). Support for SDKs, Kubernetes Operator, and other integrations is coming soon.
+
+### Prerequisites
-### API Usage
+You need an authentication token from a machine identity. Follow the [machine identities documentation](/documentation/platform/identities/machine-identities#authentication-methods) to set up authentication.
-You need an auth token to use this API. To get an authentication token, follow the authentication guide for one of our supported auth methods from the [machine identities documentation](/documentation/platform/identities/machine-identities#authentication-methods).
+### Subscribing to Events
-#### Creating a Subscription
+To subscribe to events, make a request to the events endpoint with your project ID and optional filters.
![Postman Subscription](/images/platform/events/postman-subscribe.png)
-**Request Parameters:**
+#### Request Parameters
+
+| Parameter | Type | Description |
+|-----------|------|-------------|
+| `projectId` | string | The ID of the project to subscribe to |
+| `register` | array | List of event filters |
+| `register[].conditions` | object | Optional conditions to filter events |
+| `register[].conditions.environmentSlug` | string | Filter by environment (e.g., `dev`, `staging`, `prod`) |
+| `register[].conditions.secretPath` | string | Filter by secret path (e.g., `/api/keys`) |
+
+#### Response
-- `projectId`: Project whose events you want to subscribe to
-- `register`: List of event filters
- - `conditions`: Conditions to filter events on
- - `environmentSlug`: Project environment
- - `secretPath`: Path of the secrets
+The endpoint responds with `Content-Type: text/event-stream` to initiate an SSE connection.
![Postman Subscription Response](/images/platform/events/postman-sse-response.png)
-The subscribe endpoint responds with a `text/event-stream` content type to initiate SSE streaming.
+Events are delivered as JSON payloads containing the event type and relevant metadata.
-For more specific details, please refer to our [API Reference](/api-reference/endpoints/events).
+<Tip>
+ For complete API specifications and additional examples, see the [API Reference](/api-reference/endpoints/events).
+</Tip>
diff --git a/docs/images/platform/events/add-policy.png b/docs/images/platform/events/add-policy.png
index 00e6b76f03..bc1392b765 100644
Binary files a/docs/images/platform/events/add-policy.png and b/docs/images/platform/events/add-policy.png differ
diff --git a/docs/images/platform/events/policy-condition.png b/docs/images/platform/events/policy-condition.png
new file mode 100644
index 0000000000..28898639af
Binary files /dev/null and b/docs/images/platform/events/policy-condition.png differ
diff --git a/docs/images/platform/events/policy-setting.png b/docs/images/platform/events/policy-setting.png
index cadab9b823..5aa24f9d54 100644
Binary files a/docs/images/platform/events/policy-setting.png and b/docs/images/platform/events/policy-setting.png differ