-
Notifications
You must be signed in to change notification settings - Fork 374
📝 Document webhooks #554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
📝 Document webhooks #554
Changes from 8 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
c0124e7
📝 Document webhooks
coyotte508 40ca212
fixup! 📝 Document webhooks
coyotte508 b9dca40
Update docs/hub/webhooks.md
coyotte508 0d7a9f2
Update docs/hub/webhooks.md
coyotte508 868df3e
Update docs/hub/webhooks.md
coyotte508 ccd7b17
Update docs/hub/webhooks.md
coyotte508 66930b8
Update docs/hub/webhooks.md
coyotte508 aedb144
Update docs/hub/webhooks.md
coyotte508 f0da9c7
Update docs/hub/webhooks.md
coyotte508 98e68d7
Update docs/hub/webhooks.md
coyotte508 3913170
Update docs/hub/webhooks.md
coyotte508 b756d57
Update docs/hub/webhooks.md
coyotte508 22897e7
Update docs/hub/webhooks.md
coyotte508 9cbb7eb
📝 Add screenshots + full payload + change domain to scope
coyotte508 9d3daaa
💬 Sample to "here is an example..."
coyotte508 01574e5
✏️
coyotte508 99e742c
✏️ Proof reading
coyotte508 7f284f8
📝 Improve secrets doc + document daily triggers
coyotte508 af52533
fixup! 📝 Improve secrets doc + document daily triggers
coyotte508 efb995d
💬 Update payloads
coyotte508 75ab75a
Update docs/hub/webhooks.md
coyotte508 7c400b5
Update docs/hub/webhooks.md
coyotte508 23f96c4
Apply suggestions from code review
coyotte508 f2ce396
Apply suggestions from code review
coyotte508 e824dc7
Add link to webhooks-explorers
coyotte508 a4107d9
Typo
coyotte508 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| # Webhooks | ||
|
|
||
| Webhooks allow you to react when new changes happen on specific repos or repos belonging to specific users / organizations (not just your repos, but any repo!). | ||
|
|
||
| You can configure the webhooks in your [settings](https://huggingface.co/settings/webhooks). | ||
|
|
||
| You can watch repo changes or community events. If you watch all repos belonging to a user or an organization, you can also receive events for repo creation. | ||
coyotte508 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Webhook payloads | ||
coyotte508 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| After registering a webhook, you will be notified of events via an `HTTP POST` call on the specified URL. The payload is encoded in JSON. | ||
coyotte508 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
coyotte508 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| To determine the nature of the event, you can look at the `event` and `domain` fields in the payload. | ||
coyotte508 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| You can check the last payloads sent in the activity tab of the webhook page, as well as replay webhooks. | ||
|
|
||
| ### Event & Domain | ||
|
|
||
| The top-level properties `event` and `domain` are always specified and used to determine the nature of the event. | ||
|
|
||
| `event` can take one of the following values: | ||
coyotte508 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - `"create"` | ||
coyotte508 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - `"delete"` | ||
| - `"update"` | ||
| - `"move"` | ||
|
|
||
| `domain` specifies the domain of the event. It can be one of the following values: | ||
coyotte508 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| - `["repo"]` - Global events on repos: create, delete, move | ||
| - `["repo", "content"]` - Events on the content of the repo, like new commits or tags. Triggers on new pull requests as well due to the newly created reference / commit. | ||
| - `["repo", "config"]` - Events on the config: update space secrets, update settings, update DOIs, disabled or not, ... | ||
| - `["community", "discussion"]` - Creating a discussion or pull request, updating the title or status | ||
| - `["community", "discussion", "comment"]` - Creating, updating, hiding a comment | ||
coyotte508 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ⚠️ **You should consider that any event on a more granular domain is an `"update"` on the encompassing domains.** ⚠️ | ||
coyotte508 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| For example, any event on the domain `["community", "discussion", "..."]` is also an `"update"` of the domain `["community", "discussion"]`. | ||
|
|
||
| This is important in case more granularity is added to the domains by Hugging Face. For example if the domain `["repo", "config", "doi"]` is added, it would be accompanied by an `"add"` event when DOIs are created. | ||
|
|
||
| If you follow the rule above, your application will treat any event on `["repo", "config", "doi"]` as an `"update"` on `["repo", "config"]`, and will not break if Hugging Face adds more granularity to its domains. | ||
coyotte508 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Repo | ||
|
|
||
| In the current version of webhooks, the top level property `repo` is always specified, as events can always be associated to a repo. Sample payload: | ||
coyotte508 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ```json | ||
| "repo": { | ||
| "type": "model", | ||
| "name": "some-user/some-repo", | ||
| "gitalyUid": "583c43bd0009f32d976f788446d5010ed6ea4af0c6d0235358378cb56d312f2b", | ||
| "id": "6366c000a2abcdf2fd69a080", | ||
| "private": false, | ||
| "url": { | ||
| "web": "http://huggingface.co/some-user/some-repo", | ||
| "api": "http://huggingface.co/api/models/some-user/some-repo" | ||
| }, | ||
| "headSha": "c379e821c9c95d613899e8c4343e4bfee2b0c600", | ||
| "tags": [ | ||
| "license:other", | ||
| "has_space" | ||
| ], | ||
| "author": { | ||
| "id": "61d2000c3c2083e1c08af22d" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| `headSha` is only sent when the domain starts with `"repo"`, it's not sent on community events. | ||
coyotte508 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Discussion | ||
coyotte508 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| The top level property `discussion` is specified on community events. Its `isPullRequest` property is a boolean indicating if the discussion is also a pull request. Sample payload: | ||
coyotte508 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ```json | ||
| "discussion": { | ||
| "id": "639885d811ae2bad2b7ba461", | ||
| "title": "Hello!", | ||
| "url": { | ||
| "web": "https://huggingface.co/some-user/some-repo/discussions/3", | ||
| "api": "https://huggingface.co/api/models/some-user/some-repo/discussions/3" | ||
| }, | ||
| "status": "open", | ||
| "author": { | ||
| "id": "61d2000c3c2083e1c08af22d" | ||
| }, | ||
| "isPullRequest": true, | ||
| "changes": { | ||
| "base": "refs/heads/main" | ||
| } | ||
| "num": 3 | ||
| } | ||
| ``` | ||
|
|
||
| ### Comment | ||
|
|
||
| The top level property `comment` is specified when a comment is created, including on discussion creation, or updated. Sample payload: | ||
coyotte508 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ```json | ||
| "comment": { | ||
| "id": "6398872887bfcfb93a306f18", | ||
| "author": { | ||
| "id": "61d2000c3c2083e1c08af22d" | ||
| }, | ||
| "content": "This adds an env key", | ||
| "hidden": false, | ||
| "url": { | ||
| "web": "http://huggingface.co/some-user/some-repo/discussions/4#6398872887bfcfb93a306f18" | ||
coyotte508 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Webhook secret | ||
|
|
||
| You can associate a secret to your webhook in two ways: | ||
|
|
||
| - Updating the url of the webhook to add your secret as a query parameter. | ||
coyotte508 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - Setting the secret on the webhook. It will be sent as a `X-Webhook-Secret` HTTP header on every request. | ||
coyotte508 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.