Files

105 lines
2.9 KiB
Markdown

# Webhooks API reference
Base: `https://git.mpm.to/api/v1`
Gitea supports webhooks at the repository and organization level.
## List webhooks for a repository
```bash
curl -s -H "Authorization: token e82a7235b948fbbeea60329422fcac89fa5a5ce8" \
"https://git.mpm.to/api/v1/repos/{owner}/{repo}/hooks"
```
Key response fields per hook: `id`, `type`, `active`, `events`, `config.url`, `config.content_type`, `created`, `updated`.
## Get a single webhook
```bash
curl -s -H "Authorization: token e82a7235b948fbbeea60329422fcac89fa5a5ce8" \
"https://git.mpm.to/api/v1/repos/{owner}/{repo}/hooks/{id}"
```
## Create a webhook on a repository
```bash
curl -s -X POST \
-H "Authorization: token e82a7235b948fbbeea60329422fcac89fa5a5ce8" \
-H "Content-Type: application/json" \
-d '{
"type": "gitea",
"active": true,
"events": ["push", "issues", "pull_request", "release"],
"config": {
"url": "https://your-endpoint.example.com/webhook",
"content_type": "json",
"secret": "optional-secret"
}
}' \
"https://git.mpm.to/api/v1/repos/{owner}/{repo}/hooks"
```
Common event types:
- `push` — commits pushed to any branch
- `create` — branch or tag created
- `delete` — branch or tag deleted
- `fork` — repo forked
- `issues` — issue opened/edited/closed/reopened
- `issue_comment` — comment on an issue
- `pull_request` — PR opened/edited/closed/merged
- `pull_request_review` — PR review submitted
- `release` — release published
- `repository` — repo created/deleted/made public or private
## Update a webhook
```bash
curl -s -X PATCH \
-H "Authorization: token e82a7235b948fbbeea60329422fcac89fa5a5ce8" \
-H "Content-Type: application/json" \
-d '{
"active": true,
"events": ["push", "release"],
"config": {
"url": "https://your-endpoint.example.com/webhook",
"content_type": "json"
}
}' \
"https://git.mpm.to/api/v1/repos/{owner}/{repo}/hooks/{id}"
```
## Delete a webhook
```bash
curl -s -X DELETE \
-H "Authorization: token e82a7235b948fbbeea60329422fcac89fa5a5ce8" \
"https://git.mpm.to/api/v1/repos/{owner}/{repo}/hooks/{id}"
```
Always confirm before deleting a webhook.
## Test a webhook (trigger a ping)
```bash
curl -s -X POST \
-H "Authorization: token e82a7235b948fbbeea60329422fcac89fa5a5ce8" \
"https://git.mpm.to/api/v1/repos/{owner}/{repo}/hooks/{id}/tests"
```
## Organization-level webhooks
Same endpoints, but under `/orgs/{org}/hooks` instead of `/repos/{owner}/{repo}/hooks`.
```bash
# List org webhooks
curl -s -H "Authorization: token e82a7235b948fbbeea60329422fcac89fa5a5ce8" \
"https://git.mpm.to/api/v1/orgs/{org}/hooks"
# Create org webhook
curl -s -X POST \
-H "Authorization: token e82a7235b948fbbeea60329422fcac89fa5a5ce8" \
-H "Content-Type: application/json" \
-d '{"type":"gitea","active":true,"events":["push"],"config":{"url":"https://...","content_type":"json"}}' \
"https://git.mpm.to/api/v1/orgs/{org}/hooks"
```