Configuring Real-Time Event Handlers
In this guide, you will set up Event Handlers in your Guardrails workspace so that GitHub events are processed in real time. This ensures that Guardrails detects changes (such as repositories being created, modified, or deleted) immediately rather than waiting for the next discovery cycle.
The Event Handler framework provides a unified mechanism for responding to cloud events. For GitHub, Event Handlers create webhooks at the organization level that forward events to Guardrails for processing.
Prerequisites
- Turbot/Operator permissions at the Turbot level.
- A GitHub organization connected to your Guardrails workspace.
- The personal access token used to connect the organization must have the Organization Webhooks: Read and write permission. This permission is already included in the required permissions from the connection guide.
Step 1: Verify Webhook Permission
The personal access token used during the Connect an Organization guide includes the Organization Webhooks: Read and write permission. This permission enables Guardrails to create and manage webhooks for capturing real-time events at the organization level.
If you used the recommended permissions from the connection guide, no additional configuration is needed in GitHub. If you're unsure, verify the token's permissions in your GitHub organization's Settings > Personal access tokens > Active tokens.
Step 2: Navigate to the Policies Page
In the Guardrails console, select Guardrails in the left sidebar, then select Policies.

Step 3: Create the Event Handlers Policy
Search for GitHub > Organization > Event Handlers and select New Policy Setting.

Configure the policy setting:
| Field | Value |
|---|---|
| Resource | Select your imported GitHub organization |
| Setting | Enforce: Enabled |
Select Create to save the policy.

Guardrails will now create a webhook in your GitHub organization that forwards events to your workspace.
Step 4: Verify Control Status
Navigate to the Controls page. Search for GitHub > Organization > Event Handlers and verify that the control status is OK.

Select the control to view its details. The message should show Configured, confirming that the webhook was created successfully.

Step 5: Verify the Webhook in GitHub
Navigate to your GitHub organization's Settings > Webhooks to confirm that Guardrails created a webhook.

The webhook should point to your Guardrails workspace endpoint and be configured to receive organization and repository events.
Step 6: Review
- The
GitHub > Organization > Event Handlerscontrol status is OK with the message Configured. - A webhook has been created in your GitHub organization's settings.
- Test the webhook by creating or modifying a repository. The change should appear in Guardrails within seconds.
Next Steps
- Apply policy packs: Explore GitHub Policy Packs for pre-built configurations covering branch protection, secret scanning, and more.
- Review your controls: Navigate to the Dashboard to see how your GitHub organization is evaluated against Guardrails controls.
- Remove an organization: If you need to disconnect a GitHub organization, follow the Remove Organization guide, which includes disabling event handlers as a first step.
Troubleshooting
| Issue | Solution |
|---|---|
| Controls in Error | Controls may enter various states, including errors. Learn more about control states. |
Bad Credentials message | The token may have expired or been revoked. Learn about token expiration. |
forbids access via a personal access token with fine-grained permissions | The token is missing the Organization Webhooks permission. Review required permissions and the fine-grained token permissions reference. |
Resource not accessible by personal access token | The token lacks required organization permissions. Verify the token has Organization Webhooks: Read and write access. |
| Webhook not appearing in GitHub | Ensure the control ran successfully (status OK). If the control shows an error, check the error message for permission issues. |
| Further assistance | Open a support ticket with screenshots and error details, or join the #guardrails channel in the Turbot Community Slack. |