Use this API to manage the hooks that GitLab uses to notify external services about events:
- Project webhooks are limited to a single project.
- Group webhooks apply to all projects and subgroups in a group.
- System hooks apply to the entire instance.
You can also test a hook, inspect its event log, resend an event, and manage its custom headers and URL variables.
Managing project webhooks requires administrator access or the Maintainer or Owner role for the project. Managing group webhooks requires administrator access or the Owner role for the group. Managing system hooks requires administrator access.
List all system hooks
GET /api/v4/hooks
Lists all system hooks for the instance.
Parameters
| Name | Type | Description |
|---|---|---|
pageQuery | Integer | Page number of results to retrieve Default: 1Example: 1 |
per_Query | Integer | Number of items to list per page Default: 20Example: 20 |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | Array of APIEntities |
400 | Bad Request | — |
Create a system hook
POST /api/v4/hooks
Creates a system hook. This endpoint has a rate limit of five requests per minute for each authenticated user. On GitLab Self-Managed and GitLab Dedicated, an administrator can change this limit in the application settings.
Request body (application/json)
| Property | Type | Description |
|---|---|---|
branch_ | String | Filter push events by branch.wildcardAllowed values: wildcard,regex,all_ |
custom_ | Array of objects | Custom headers for the hook |
custom_Required | String | Name of the header Example: X- |
custom_Required | String | Value of the header Example: value |
custom_ | String | Custom template for the system hook request payload |
description | String | Description of the hook. |
enable_ | Boolean | If true, |
merge_ | Boolean | If true, |
name | String | Name of the hook. |
push_ | Boolean | If true, |
push_ | String | Filter push events by branch name |
repository_ | Boolean | If true, |
signing_ | String | HMAC signing token used to compute the webhook- header.whsec_ format encoding a 32- |
tag_ | Boolean | If true, |
token | String | Secret token used to validate received payloads. |
urlRequired | String | Webhook URL Example: http: |
url_ | Array of objects | URL variables for interpolation |
url_Required | String | Name of the variable Example: token |
url_Required | String | Value of the variable Example: 123 |
Responses
| Code | Description | Schema |
|---|---|---|
201 | Created | APIEntities |
400 | Validation error | — |
404 | Not found | — |
422 | Unprocessable entity | — |
429 | Too many requests | — |
Retrieve a system hook
GET /api/v4/hooks/{hook_id}
Retrieves a specified system hook.
Parameters
| Name | Type | Description |
|---|---|---|
hook_Path, | Integer | ID of the system hook |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Not found | — |
Create a test run
POST /api/v4/hooks/{hook_id}
Creates a test run for a webhook. Executes the webhook with mock data.
Parameters
| Name | Type | Description |
|---|---|---|
hook_Path, | Integer | ID of the system hook |
Responses
| Code | Description | Schema |
|---|---|---|
201 | Created | — |
400 | Bad Request | — |
404 | Not Found | — |
Update a system hook
PUT /api/v4/hooks/{hook_id}
Updates a specified system hook.
Parameters
| Name | Type | Description |
|---|---|---|
hook_Path, | Integer | ID of the system hook |
Request body (application/json)
| Property | Type | Description |
|---|---|---|
branch_ | String | Filter push events by branch.wildcardAllowed values: wildcard,regex,all_ |
custom_ | Array of objects | Custom headers for the hook |
custom_Required | String | Name of the header Example: X- |
custom_Required | String | Value of the header Example: value |
custom_ | String | Custom template for the system hook request payload |
description | String | Description of the hook. |
enable_ | Boolean | If true, |
merge_ | Boolean | If true, |
name | String | Name of the hook. |
push_ | Boolean | If true, |
push_ | String | Filter push events by branch name |
repository_ | Boolean | If true, |
signing_ | String | HMAC signing token used to compute the webhook- header.whsec_ format encoding a 32- |
tag_ | Boolean | If true, |
token | String | Secret token used to validate received payloads. |
url | String | Webhook URL |
url_ | Array of objects | URL variables for interpolation |
url_Required | String | Name of the variable Example: token |
url_Required | String | Value of the variable Example: 123 |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Validation error | — |
404 | Not found | — |
422 | Unprocessable entity | — |
Delete a system hook
DELETE /api/v4/hooks/{hook_id}
Deletes a specified system hook. Administrators only.
Parameters
| Name | Type | Description |
|---|---|---|
hook_Path, | Integer | ID of the system hook |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Not found | — |
Update a custom header
PUT /api/v4/hooks/{hook_id}/custom_headers/{key}
Updates a custom header for a specified webhook. This feature was introduced in GitLab 17.1.
Parameters
| Name | Type | Description |
|---|---|---|
hook_Path, | Integer | ID of the hook |
keyPath, | String | Name of the custom header |
Request body (application/json)
| Property | Type | Description |
|---|---|---|
valueRequired | String | Value of the custom header |
Responses
| Code | Description | Schema |
|---|---|---|
204 | No Content | — |
400 | Bad Request | — |
404 | Not Found | — |
Delete a custom header
DELETE /api/v4/hooks/{hook_id}/custom_headers/{key}
Deletes a custom header from a specified webhook. This feature was introduced in GitLab 17.1.
Parameters
| Name | Type | Description |
|---|---|---|
hook_Path, | Integer | ID of the hook |
keyPath, | String | Name of the custom header |
Responses
| Code | Description | Schema |
|---|---|---|
204 | No Content | — |
400 | Bad Request | — |
404 | Not Found | — |
Update a URL variable
PUT /api/v4/hooks/{hook_id}/url_variables/{key}
Updates a URL variable for a specified webhook. Setting the value does not replace a literal value in the existing webhook URL with the placeholder. To use the variable, also update the webhook URL to include the {key} placeholder.
Parameters
| Name | Type | Description |
|---|---|---|
hook_Path, | Integer | ID of the hook |
keyPath, | String | Key of the URL variable |
Request body (application/json)
| Property | Type | Description |
|---|---|---|
valueRequired | String | Value of the URL variable |
Responses
| Code | Description | Schema |
|---|---|---|
204 | No Content | — |
400 | Bad Request | — |
404 | Not Found | — |
Delete a URL variable
DELETE /api/v4/hooks/{hook_id}/url_variables/{key}
Deletes a URL variable from a specified webhook.
Parameters
| Name | Type | Description |
|---|---|---|
hook_Path, | Integer | ID of the hook |
keyPath, | String | Key of the URL variable |
Responses
| Code | Description | Schema |
|---|---|---|
204 | No Content | — |
400 | Bad Request | — |
404 | Not Found | — |
List all webhooks for a project
GET /api/v4/projects/{id}/hooks
Lists all webhooks for a specified project.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | ID or URL- |
pageQuery | Integer | Page number of results to retrieve Default: 1Example: 1 |
per_Query | Integer | Number of items to list per page Default: 20Example: 20 |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | Array of APIEntities |
400 | Bad Request | — |
404 | Not Found | — |
Add a webhook to a project
POST /api/v4/projects/{id}/hooks
Adds a webhook to a specified project. This endpoint has a rate limit of five requests per minute for each authenticated user for a given project. On GitLab Self-Managed and GitLab Dedicated, an administrator can change this limit in the application settings. Setting duo_flow_callback_enabled to false is always accepted.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | ID or URL- |
Request body (application/json)
| Property | Type | Description |
|---|---|---|
branch_ | String | Filter push events by branch.wildcardAllowed values: wildcard,regex,all_ |
confidential_ | Boolean | If true, |
confidential_ | Boolean | If true, |
custom_ | Array of objects | Custom headers for the hook |
custom_Required | String | Name of the header Example: X- |
custom_Required | String | Value of the header Example: value |
custom_ | String | Custom template for the webhook request payload |
deployment_ | Boolean | If true, |
description | String | Description of the project webhook. |
duo_ | Boolean | If true,callback_ when it starts.duo_. |
emoji_ | Boolean | If true, |
enable_ | Boolean | If true, |
feature_ | Boolean | If true, |
issues_ | Boolean | If true, |
job_ | Boolean | If true, |
merge_ | Boolean | If true, |
milestone_ | Boolean | If true, |
name | String | Name of the project webhook. |
note_ | Boolean | If true, |
pipeline_ | Boolean | If true, |
push_ | Boolean | If true, |
push_ | String | Filter push events by branch name |
releases_ | Boolean | If true, |
resource_ | Boolean | If true, |
resource_ | Boolean | If true, |
signing_ | String | HMAC signing token used to compute the webhook- header.whsec_ format encoding a 32- |
tag_ | Boolean | If true, |
token | String | Secret token used to validate received payloads. |
urlRequired | String | Webhook URL Example: http: |
url_ | Array of objects | URL variables for interpolation |
url_Required | String | Name of the variable Example: token |
url_Required | String | Value of the variable Example: 123 |
vulnerability_ | Boolean | If true, |
wiki_ | Boolean | If true, |
Responses
| Code | Description | Schema |
|---|---|---|
201 | Created | APIEntities |
400 | Validation error | — |
404 | Not found | — |
422 | Unprocessable entity | — |
429 | Too many requests | — |
Retrieve a project webhook
GET /api/v4/projects/{id}/hooks/{hook_id}
Retrieves a specified webhook for a project.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | ID or URL- |
hook_Path, | Integer | ID of the project webhook |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Not found | — |
Update a project webhook
PUT /api/v4/projects/{id}/hooks/{hook_id}
Updates a specified webhook for a project. Setting duo_flow_callback_enabled to false is always accepted.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | ID or URL- |
hook_Path, | Integer | ID of the project webhook |
Request body (application/json)
| Property | Type | Description |
|---|---|---|
branch_ | String | Filter push events by branch.wildcardAllowed values: wildcard,regex,all_ |
confidential_ | Boolean | If true, |
confidential_ | Boolean | If true, |
custom_ | Array of objects | Custom headers for the hook |
custom_Required | String | Name of the header Example: X- |
custom_Required | String | Value of the header Example: value |
custom_ | String | Custom template for the webhook request payload |
deployment_ | Boolean | If true, |
description | String | Description of the project webhook. |
duo_ | Boolean | If true,callback_ when it starts.duo_. |
emoji_ | Boolean | If true, |
enable_ | Boolean | If true, |
feature_ | Boolean | If true, |
issues_ | Boolean | If true, |
job_ | Boolean | If true, |
merge_ | Boolean | If true, |
milestone_ | Boolean | If true, |
name | String | Name of the project webhook. |
note_ | Boolean | If true, |
pipeline_ | Boolean | If true, |
push_ | Boolean | If true, |
push_ | String | Filter push events by branch name |
releases_ | Boolean | If true, |
resource_ | Boolean | If true, |
resource_ | Boolean | If true, |
signing_ | String | HMAC signing token used to compute the webhook- header.whsec_ format encoding a 32- |
tag_ | Boolean | If true, |
token | String | Secret token used to validate received payloads. |
url | String | Webhook URL |
url_ | Array of objects | URL variables for interpolation |
url_Required | String | Name of the variable Example: token |
url_Required | String | Value of the variable Example: 123 |
vulnerability_ | Boolean | If true, |
wiki_ | Boolean | If true, |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Validation error | — |
404 | Not found | — |
422 | Unprocessable entity | — |
Delete a project webhook
DELETE /api/v4/projects/{id}/hooks/{hook_id}
Deletes a specified webhook for a project. If the webhook was already deleted, returns 404 Not found.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | ID or URL- |
hook_Path, | Integer | ID of the project webhook |
Responses
| Code | Description | Schema |
|---|---|---|
204 | No Content | — |
400 | Bad Request | — |
404 | Not found | — |
Update a custom header
PUT /api/v4/projects/{id}/hooks/{hook_id}/custom_headers/{key}
Updates a custom header for a specified webhook. This feature was introduced in GitLab 17.1.
Parameters
| Name | Type | Description |
|---|---|---|
hook_Path, | Integer | ID of the hook |
keyPath, | String | Name of the custom header |
idPath, | String or integer | ID or URL- |
Request body (application/json)
| Property | Type | Description |
|---|---|---|
valueRequired | String | Value of the custom header |
Responses
| Code | Description | Schema |
|---|---|---|
204 | No Content | — |
400 | Bad Request | — |
404 | Not Found | — |
Delete a custom header
DELETE /api/v4/projects/{id}/hooks/{hook_id}/custom_headers/{key}
Deletes a custom header from a specified webhook. This feature was introduced in GitLab 17.1.
Parameters
| Name | Type | Description |
|---|---|---|
hook_Path, | Integer | ID of the hook |
keyPath, | String | Name of the custom header |
idPath, | String or integer | ID or URL- |
Responses
| Code | Description | Schema |
|---|---|---|
204 | No Content | — |
400 | Bad Request | — |
404 | Not Found | — |
List all events
GET /api/v4/projects/{id}/hooks/{hook_id}/events
Lists all events from the past seven days for a specified webhook. This feature was introduced in GitLab 17.3.
Parameters
| Name | Type | Description |
|---|---|---|
statusQuery | Array of strings | Response status code of the events,200 or 500.successful (200-client_ (400-server_ (500- |
per_Query | Integer | Number of items to list per page Default: 20Maximum: 20Minimum: 1Example: 20 |
pageQuery | Integer | Page number of results to retrieve Default: 1Example: 1 |
idPath, | String or integer | ID or URL- |
hook_Path, | Integer | ID of the hook |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | — |
400 | Bad request | — |
403 | Forbidden | — |
404 | Not found | — |
Resend a webhook event
POST /api/v4/projects/{id}/hooks/{hook_id}/events/{hook_log_id}/resend
Resends a webhook event. This endpoint has a rate limit of five requests per minute for each authenticated user for a given project or group. All webhooks in the same project or group share the limit. On GitLab Self-Managed and GitLab Dedicated, an administrator can change this limit in the application settings. This feature was introduced in GitLab 17.4.
Parameters
| Name | Type | Description |
|---|---|---|
hook_Path, | Integer | ID of the hook |
hook_Path, | Integer | ID of the hook log entry |
idPath, | String or integer | ID or URL- |
Responses
| Code | Description | Schema |
|---|---|---|
201 | Created | — |
400 | Bad Request | — |
404 | Not found | — |
422 | Unprocessable entity | — |
429 | Too many requests | — |
Trigger a test webhook
POST /api/v4/projects/{id}/hooks/{hook_id}/test/{trigger}
Triggers a test webhook. This endpoint has a rate limit of five requests per minute for each authenticated user for a given project or group. On GitLab Self-Managed and GitLab Dedicated, an administrator can change this limit in the application settings. This feature was introduced in GitLab 16.11 for project hooks and GitLab 17.1 for group hooks.
Parameters
| Name | Type | Description |
|---|---|---|
hook_Path, | Integer | ID of the hook |
triggerPath, | String | Type of webhook event to test Allowed values: confidential_,confidential_,deployment_,emoji_,feature_,issues_,job_,merge_,milestone_,note_,pipeline_,push_,releases_,resource_,resource_,tag_,wiki_Minimum length: 1 |
idPath, | String or integer | ID or URL- |
Responses
| Code | Description | Schema |
|---|---|---|
201 | Created | — |
400 | Bad request | — |
403 | Forbidden | — |
404 | Not found | — |
422 | Unprocessable entity | — |
429 | Too many requests | — |
Update a URL variable
PUT /api/v4/projects/{id}/hooks/{hook_id}/url_variables/{key}
Updates a URL variable for a specified webhook. Setting the value does not replace a literal value in the existing webhook URL with the placeholder. To use the variable, also update the webhook URL to include the {key} placeholder.
Parameters
| Name | Type | Description |
|---|---|---|
hook_Path, | Integer | ID of the hook |
keyPath, | String | Key of the URL variable |
idPath, | String or integer | ID or URL- |
Request body (application/json)
| Property | Type | Description |
|---|---|---|
valueRequired | String | Value of the URL variable |
Responses
| Code | Description | Schema |
|---|---|---|
204 | No Content | — |
400 | Bad Request | — |
404 | Not Found | — |
Delete a URL variable
DELETE /api/v4/projects/{id}/hooks/{hook_id}/url_variables/{key}
Deletes a URL variable from a specified webhook.
Parameters
| Name | Type | Description |
|---|---|---|
hook_Path, | Integer | ID of the hook |
keyPath, | String | Key of the URL variable |
idPath, | String or integer | ID or URL- |
Responses
| Code | Description | Schema |
|---|---|---|
204 | No Content | — |
400 | Bad Request | — |
404 | Not Found | — |
Schemas
Objects returned by the operations above and objects nested in their request bodies.
APIEntitiesHook
| Property | Type | Description |
|---|---|---|
alert_ | String | Example:executable |
branch_ | String | Example:wildcard |
created_ | String (date- | Example:2012- |
custom_ | Array of objects | Example:[{"X- |
custom_ | String | Example:{"event": |
description | String | Description of the hook. Example: Hook description |
disabled_ | String (date- | Example:2012- |
enable_ | Boolean | — |
id | Integer (int64) | Example:1 |
merge_ | Boolean | — |
name | String | Name of the hook. Example: Hook name |
organization_ | Integer | Example:1 |
push_ | Boolean | — |
push_ | String | Example:my- |
repository_ | Boolean | — |
signing_ | Boolean | Whether an HMAC signing token is configured. Example: false |
tag_ | Boolean | — |
token_ | Boolean | Whether a secret token is configured. Example: false |
url | String | Example:https: |
url_ | Array of objects | Example:[{"token": |
APIEntitiesProjectHook
| Property | Type | Description |
|---|---|---|
alert_ | String | Example:executable |
branch_ | String | Example:wildcard |
confidential_ | Boolean | — |
confidential_ | Boolean | — |
created_ | String (date- | Example:2012- |
custom_ | Array of objects | Example:[{"X- |
custom_ | String | Example:{"event": |
deployment_ | Boolean | — |
description | String | Description of the hook. Example: Hook description |
disabled_ | String (date- | Example:2012- |
duo_ | Boolean | — |
emoji_ | Boolean | — |
enable_ | Boolean | — |
feature_ | Boolean | — |
id | Integer (int64) | Example:1 |
issues_ | Boolean | — |
job_ | Boolean | — |
merge_ | Boolean | — |
milestone_ | Boolean | — |
name | String | Name of the hook. Example: Hook name |
note_ | Boolean | — |
organization_ | Integer | Example:1 |
pipeline_ | Boolean | — |
project_ | Integer (int64) | Example:1 |
push_ | Boolean | — |
push_ | String | Example:my- |
releases_ | Boolean | — |
repository_ | Boolean | — |
resource_ | Boolean | — |
resource_ | Boolean | — |
signing_ | Boolean | Whether an HMAC signing token is configured. Example: false |
tag_ | Boolean | — |
token_ | Boolean | Whether a secret token is configured. Example: false |
url | String | Example:https: |
url_ | Array of objects | Example:[{"token": |
vulnerability_ | Boolean | — |
wiki_ | Boolean | — |