Skip to content

Update a repository webhook

PATCH /api/v5/repos/{owner}/{repo}/hooks/{id}

This endpoint updates a webhook in the specified repository. You can change its remote notification URL, encryption type, and request password, and configure the triggers for each event type, such as code push, tag push, issue creation or closure, comments, and merge requests.

Supported access tokens

  • AtomGit user access token (AtomGit user access tokens)

Anonymous access

This endpoint does not allow anonymous access.

Request parameters

Parameter Location Type Required Description
owner path string Yes Address path of the namespace that owns the repository (the address path of an enterprise, organization, or individual)
repo path string Yes Repository path (path)
id path integer Yes Webhook ID
access_token query string Yes User authorization code

Request Body:

The request body contains the update information for the webhook and is submitted in JSON format:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "url": {
      "description": "Remote HTTP URL",
      "type": "string"
    },
    "encryption_type": {
      "description": "Encryption type: 0 password, 1 signing secret",
      "type": "integer",
      "enum": [0, 1]
    },
    "password": {
      "description": "This password is included when requesting the URL to prevent malicious requests to the URL",
      "type": "string"
    },
    "push_events": {
      "description": "Push code to the repository",
      "type": "boolean"
    },
    "tag_push_events": {
      "description": "Push a tag to the repository",
      "type": "boolean"
    },
    "issues_events": {
      "description": "Create/close an issue",
      "type": "boolean"
    },
    "note_events": {
      "description": "Comment on an issue, code, and so on",
      "type": "boolean"
    },
    "merge_requests_events": {
      "description": "Merge request and after merge",
      "type": "boolean"
    }
  },
  "required": ["url"]
}

Response parameters

Field Type Always returned Nullable Description
id integer Yes No Webhook ID
url string Yes Yes Remote HTTP URL
password string Yes Yes Password included when requesting the URL, which prevents malicious requests to the URL
result string Yes Yes Push result information, may be null
project_id integer Yes Yes Project ID
result_code integer Yes Yes Result code
push_events boolean Yes Yes Whether to push code to the repository
tag_push_events boolean Yes Yes Whether to push tags to the repository
issues_events boolean Yes Yes Whether to create/close issues
note_events boolean Yes Yes Whether to comment on issues/code and so on
merge_requests_events boolean Yes Yes Whether to trigger on merge requests and after merge
created_at string Yes Yes Creation time
active boolean Yes Yes Whether enabled

Error response

400 Invalid parameters

{
  "error": "invalid_request",
  "message": "The url parameter cannot be empty",
  "field": "url"
}

401 Unauthenticated

{
  "error": "unauthorized",
  "message": "Missing or invalid access token"
}

HTTP status codes

Status code Description
200 Success (OK)
401 Requires authentication
403 Forbidden
404 Resource not found (Not found)
429 Too many requests, rate limit triggered (Rate limited)
500 Internal server error

Request example

Parameter description

Replace <owner> with the address path of the namespace that owns the repository (the address path of an enterprise, organization, or individual); replace <repo> with the repository path (path); replace <id> with the ID of the webhook to update; replace <token> with your AtomGit user access token.

cURL

curl -X PATCH 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/hooks/<id>?access_token=<token>' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
    "url": "https://api.atomgit.com/webhooks/notify",
    "encryption_type": 0,
    "password": "123456",
    "push_events": true,
    "tag_push_events": false,
    "issues_events": false,
    "note_events": false,
    "merge_requests_events": false
  }'

JavaScript

// Native fetch (Node.js 18+ / browser)
const response = await fetch("https://api.atomgit.com/api/v5/repos/<owner>/<repo>/hooks/<id>?access_token=<token>", {
  method: "PATCH",
  headers: {
    "Accept": "application/json",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    url: "https://api.atomgit.com/webhooks/notify",
    push_events: true,
    tag_push_events: false,
    issues_events: false,
    note_events: false,
    merge_requests_events: false,
  }),
});

if (!response.ok) {
  throw new Error(`Request failed: ${response.status}`);
}

const data = await response.json();
console.log(data);

Python

import requests

resp = requests.patch(
    "https://api.atomgit.com/api/v5/repos/<owner>/<repo>/hooks/<id>",
    params={"access_token": "<token>"},
    headers={
        "Accept": "application/json",
        "Content-Type": "application/json",
    },
    json={
        "url": "https://api.atomgit.com/webhooks/notify",
        "push_events": True,
        "tag_push_events": False,
        "issues_events": False,
        "note_events": False,
        "merge_requests_events": False,
    },
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

Response example

Status code: 200

{
  "id": 282463,
  "url": "https://api.atomgit.com/webhooks/notify",
  "password": "123445",
  "result": null,
  "project_id": 282463,
  "result_code": 0,
  "push_events": false,
  "tag_push_events": false,
  "issues_events": true,
  "note_events": false,
  "merge_requests_events": true,
  "created_at": "2024-09-26T16:13:27+08:00",
  "active": true
}

Error codes

Error code Description
401 Unauthenticated or invalid credentials (missing or invalid access token)
400 Invalid parameters or the request cannot be parsed
404 Request path does not exist
405 Request method not supported
429 Too many requests, rate limit triggered
500 Internal system error

Markdown source: View on AtomGit·Content from the open-source project gitcode-dev/atomgit-api-doc