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

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.

Guardrails Policies page in the left navigation

Step 3: Create the Event Handlers Policy

Search for GitHub > Organization > Event Handlers and select New Policy Setting.

Policies page with search for GitHub Organization Event Handlers and New Policy Setting button

Configure the policy setting:

FieldValue
ResourceSelect your imported GitHub organization
SettingEnforce: Enabled

Select Create to save the policy.

New policy setting dialog showing Resource selection and Enforce Enabled setting

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.

Controls page showing GitHub Organization Event Handlers control in OK state

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

Event Handlers control detail showing Configured status

Step 5: Verify the Webhook in GitHub

Navigate to your GitHub organization's Settings > Webhooks to confirm that Guardrails created a webhook.

GitHub organization webhooks page showing the Guardrails webhook

The webhook should point to your Guardrails workspace endpoint and be configured to receive organization and repository events.

Step 6: Review

Next Steps

Troubleshooting

IssueSolution
Controls in ErrorControls may enter various states, including errors. Learn more about control states.
Bad Credentials messageThe token may have expired or been revoked. Learn about token expiration.
forbids access via a personal access token with fine-grained permissionsThe token is missing the Organization Webhooks permission. Review required permissions and the fine-grained token permissions reference.
Resource not accessible by personal access tokenThe token lacks required organization permissions. Verify the token has Organization Webhooks: Read and write access.
Webhook not appearing in GitHubEnsure the control ran successfully (status OK). If the control shows an error, check the error message for permission issues.
Further assistanceOpen a support ticket with screenshots and error details, or join the #guardrails channel in the Turbot Community Slack.