Create a hook
POST
/admin/hooks
const url = 'https://gitea.example.com/api/v1/admin/hooks';const options = { method: 'POST', headers: {Authorization: 'Basic <credentials>', 'Content-Type': 'application/json'}, body: '{"active":false,"authorization_header":"example","branch_filter":"example","config":{"additionalProperty":"example"},"events":["example"],"type":"dingtalk"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://gitea.example.com/api/v1/admin/hooks \ --header 'Authorization: Basic <credentials>' \ --header 'Content-Type: application/json' \ --data '{ "active": false, "authorization_header": "example", "branch_filter": "example", "config": { "additionalProperty": "example" }, "events": [ "example" ], "type": "dingtalk" }'Authorizations
Section titled “Authorizations”Request Body
Section titled “Request Body”Media typeapplication/json
CreateHookOption options when create a hook
object
active
boolean
authorization_header
string
branch_filter
string
config
required
CreateHookOptionConfig has all config options in it required are “content_type” and “url” Required
object
key
additional properties
string
events
Array<string>
type
required
string
Responses
Section titled “Responses”Hook
Media typeapplication/json
Hook a hook is a web hook when one repository changed
object
active
boolean
authorization_header
string
branch_filter
string
config
object
key
additional properties
string
created_at
string format: date-time
events
Array<string>
id
integer format: int64
type
string
updated_at
string format: date-time
Examplegenerated
{ "active": true, "authorization_header": "example", "branch_filter": "example", "config": { "additionalProperty": "example" }, "created_at": "2026-04-15T12:00:00Z", "events": [ "example" ], "id": 1, "type": "example", "updated_at": "2026-04-15T12:00:00Z"}