Webhooks
Code Search can receive push webhooks from your code hosts to trigger immediate re-indexing when code changes. This reduces the delay between a push and the code being searchable from minutes (poll-based) to seconds.
How It Works
Section titled “How It Works”- Developer pushes code to a repository
- Code host sends a webhook to Code Search
- Code Search looks up the repository and queues an index job
- The indexer re-indexes the repository immediately
Only push events trigger re-indexing. Other events (pull requests, issues, etc.) are acknowledged but ignored.
Endpoint
Section titled “Endpoint”POST /api/v1/webhooks/{provider}Supported providers: github, gitlab, gitea, bitbucket.
GitHub
Section titled “GitHub”- Go to your repository or organization settings
- Navigate to Webhooks > Add webhook
- Set the Payload URL to:
https://your-code-search.example.com/api/v1/webhooks/github
- Set Content type to
application/json - Select Just the push event
- Click Add webhook
Organization-wide webhook
Section titled “Organization-wide webhook”For GitHub organizations, you can configure a single webhook that covers all repositories:
- Go to your organization settings
- Navigate to Webhooks > Add webhook
- Use the same URL and settings as above
GitLab
Section titled “GitLab”- Go to your project or group settings
- Navigate to Webhooks
- Set the URL to:
https://your-code-search.example.com/api/v1/webhooks/gitlab
- Check Push events and Tag push events
- Click Add webhook
Group-level webhook
Section titled “Group-level webhook”For GitLab groups (Premium/Ultimate), configure a group webhook to cover all projects:
- Go to your group settings
- Navigate to Webhooks
- Use the same URL and settings as above
- Go to your repository settings
- Navigate to Webhooks > Add Webhook > Gitea
- Set the Target URL to:
https://your-code-search.example.com/api/v1/webhooks/gitea
- Select Push Events under trigger events
- Click Add Webhook
Bitbucket
Section titled “Bitbucket”- Go to your repository settings
- Navigate to Webhooks > Add webhook
- Set the URL to:
https://your-code-search.example.com/api/v1/webhooks/bitbucket
- Select Repository push under triggers
- Click Save
Event Headers
Section titled “Event Headers”Code Search identifies the provider and event type using standard headers:
| Provider | Event Header | Push Event Value |
|---|---|---|
| GitHub | X-GitHub-Event | push |
| GitLab | X-Gitlab-Event | Push Hook or Tag Push Hook |
| Gitea | X-Gitea-Event | push |
| Bitbucket | X-Event-Key | repo:push |
Response Format
Section titled “Response Format”All webhook responses return JSON:
// Successfully queued{ "received": true, "action": "queued", "repo": "org/repo-name"}
// Skipped — job already active{ "received": true, "action": "skipped", "reason": "index job already active"}
// Ignored — not a push event{ "received": true, "action": "ignored", "reason": "not a push event"}
// Ignored — repo not found or excluded{ "received": true, "action": "ignored", "reason": "repository not found"}Idempotency
Section titled “Idempotency”If a repository already has an active index job (e.g., from a previous push or a scheduled sync), the webhook is acknowledged but no duplicate job is created. This prevents job flooding when multiple pushes happen in quick succession.
Combining with Scheduled Sync
Section titled “Combining with Scheduled Sync”Webhooks and scheduled sync work together:
- Webhooks provide instant re-indexing for push events
- Scheduled sync catches changes that don’t trigger webhooks (new repos, force pushes, branch deletions)
You don’t need to choose one or the other. Keep the scheduler enabled and add webhooks for faster updates.
Troubleshooting
Section titled “Troubleshooting”Webhook not triggering re-index
Section titled “Webhook not triggering re-index”- Check the webhook delivery logs in your code host — look for HTTP 200 responses
- Verify the repository name in the webhook payload matches the name in Code Search
- Check that the repository is not excluded
- Look at the API server logs for webhook processing details
Duplicate index jobs
Section titled “Duplicate index jobs”This shouldn’t happen — the webhook handler checks for active jobs before queuing. If you see duplicates, check that you don’t have multiple webhooks configured for the same repository.