Overview
Webhooks allow you to build or set up integrations that subscribe to specific events in your Gitea repositories. When an event is triggered, Gitea sends an HTTP POST payload to the webhook’s configured URL. Webhooks can be configured to trigger for specific events or all repository events.Webhook Types
Gitea supports multiple webhook formats for integration with various platforms:- Gitea - Native Gitea webhook format
- Gogs - Gogs-compatible webhook format
- Slack - Slack notifications
- Discord - Discord channel notifications
- DingTalk - DingTalk group notifications
- Telegram - Telegram bot messages
- Microsoft Teams - Teams channel notifications
- Feishu - Feishu/Lark notifications
- Matrix - Matrix room notifications
- WeCom - WeChat Work notifications
- Packagist - Packagist package updates
Event Types
Webhooks can be configured to trigger on the following events:| Event | Description |
|---|---|
create | Branch or tag created |
delete | Branch or tag deleted |
fork | Repository forked |
push | Git push to repository |
issues | Issue opened, closed, reopened, edited, or deleted |
issue_assign | Issue assigned or unassigned |
issue_label | Issue labels updated |
issue_milestone | Issue milestone changed |
issue_comment | Comment created, edited, or deleted on issue |
pull_request | Pull request opened, closed, reopened, edited, or synchronized |
pull_request_assign | Pull request assigned or unassigned |
pull_request_label | Pull request labels updated |
pull_request_milestone | Pull request milestone changed |
pull_request_comment | Comment on pull request |
pull_request_review_approved | Pull request approved |
pull_request_review_rejected | Pull request rejected |
pull_request_review_comment | Review comment on pull request |
pull_request_sync | Pull request synchronized |
pull_request_review_request | Review requested on pull request |
repository | Repository created or deleted |
release | Release published, updated, or deleted |
package | Package created or deleted |
wiki | Wiki page created, edited, or deleted |
status | Commit status updated |
workflow_run | GitHub Actions workflow run event |
workflow_job | GitHub Actions workflow job event |
modules/webhook/type.go:10-43
Creating a Webhook
application/json or application/x-www-form-urlencodedWebhook Configuration
HTTP Method
By default, webhooks use POST requests. You can configure a custom HTTP method if needed:models/webhook/webhook.go:129
Content Types
Webhooks support two content types:- JSON (
application/json) - Recommended format, payload sent as JSON - Form (
application/x-www-form-urlencoded) - Payload sent as form data
Authorization Headers
You can configure custom authorization headers for webhooks:models/webhook/webhook.go:209-229
Webhook Payloads
All webhook payloads follow a consistent structure with event-specific data.Push Event
modules/structs/hook.go:298-325
Issue Event
modules/structs/hook.go:384-405
Pull Request Event
modules/structs/hook.go:427-452
Create Event
modules/structs/hook.go:155-172
Webhook Security
Secret Token Validation
When you set a secret token for your webhook, Gitea signs the payload with HMAC-SHA256 and includes the signature in the request headers:Request Headers
Webhook requests include identifying headers:Branch Filtering
You can configure webhooks to trigger only for specific branches using glob patterns:models/webhook/webhook.go:25
Webhook Delivery Status
Webhooks have three possible delivery statuses:- None - Not yet delivered
- Succeed - Successfully delivered (2xx response)
- Fail - Delivery failed (non-2xx response or network error)
modules/webhook/type.go:133-141
Viewing Delivery History
Each webhook maintains a delivery history showing:- Request payload
- Response status code
- Response body
- Delivery timestamp
- Delivery duration
System Webhooks
Administrators can create system-level webhooks that trigger for events across all repositories:- Navigate to Site Administration
- Click System Webhooks
- Configure webhook with the same options as repository webhooks
- Organization-wide event monitoring
- Security auditing
- Automated backups
- External analytics
models/webhook/webhook.go:127
Troubleshooting
Webhook Not Triggering
- Verify the webhook is Active
- Check that the event type is enabled in webhook settings
- Verify branch filter matches the pushed branch
- Check webhook delivery history for errors
Timeout Errors
- Webhook endpoints must respond within the configured timeout
- Use asynchronous processing for long-running tasks
- Return 2xx response immediately, process in background
Authentication Failures
- Verify secret token matches on both sides
- Check authorization header format
- Ensure HTTPS is used for secure token transmission
Best Practices
- Use HTTPS: Always use HTTPS endpoints for webhooks to protect secrets and payload data
- Validate signatures: Always verify the webhook signature before processing payloads
- Respond quickly: Return HTTP 2xx response immediately, process asynchronously
- Handle retries: Implement idempotency to handle duplicate deliveries
- Log deliveries: Maintain logs of webhook deliveries for debugging
- Use specific events: Subscribe only to needed events to reduce noise
- Secure secrets: Store webhook secrets securely, rotate regularly
API Reference
Manage webhooks programmatically using the Gitea API:modules/structs/hook.go:48-83