Manage webhooks on the HuggingFace Hub.
Webhooks allow you to receive real-time notifications when repos are updated, pull requests are opened, comments are posted, etc.
See: https://huggingface.co/docs/hub/webhooks
Example
# Create a webhook watching a user's models
{:ok, wh} = HuggingfaceClient.create_webhook(
url: "https://my-server.example.com/webhook",
watched: [%{type: "user", name: "my-user"}],
domains: ["repo", "discussion"],
secret: "my-secret",
access_token: "hf_..."
)
IO.puts("Webhook ID: #{wh["id"]}")
# List all webhooks
{:ok, webhooks} = HuggingfaceClient.list_webhooks(access_token: "hf_...")
Summary
Functions
Creates a new webhook.
Deletes a webhook.
Gets information about a specific webhook.
Lists all webhooks belonging to the authenticated user.
Updates an existing webhook.
Functions
@spec create(keyword()) :: {:ok, map()} | {:error, Exception.t()}
Creates a new webhook.
Options
:url— HTTPS URL that will receive the webhook events (required):watched— list of items to watch. Each is a map with:type(user, org, model, dataset, space) and:name. Example:[%{type: "user", name: "my-user"}]:domains— list of event domains to watch:"repo"and/or"discussion"(default: both):secret— optional secret to verify payloads:access_token
Example
{:ok, webhook} = HuggingfaceClient.create_webhook(
url: "https://my-server.com/hook",
watched: [%{type: "model", name: "bert-base-uncased"}],
domains: ["repo"],
access_token: "hf_..."
)
@spec delete( String.t(), keyword() ) :: :ok | {:error, Exception.t()}
Deletes a webhook.
Example
:ok = HuggingfaceClient.delete_webhook("wh-id", access_token: "hf_...")
@spec get( String.t(), keyword() ) :: {:ok, map()} | {:error, Exception.t()}
Gets information about a specific webhook.
Example
{:ok, wh} = HuggingfaceClient.get_webhook("my-webhook-id", access_token: "hf_...")
@spec list(keyword()) :: {:ok, [map()]} | {:error, Exception.t()}
Lists all webhooks belonging to the authenticated user.
Example
{:ok, webhooks} = HuggingfaceClient.list_webhooks(access_token: "hf_...")
Enum.each(webhooks, fn w -> IO.puts(w["url"]) end)
@spec update( String.t(), keyword() ) :: {:ok, map()} | {:error, Exception.t()}
Updates an existing webhook.
Options
Same as create/1. Only provided fields are updated.
Example
{:ok, updated} = HuggingfaceClient.update_webhook("wh-id",
url: "https://new-url.example.com/hook",
access_token: "hf_..."
)