# `HfHub.Webhooks`
[🔗](https://github.com/North-Shore-AI/hf_hub_ex/blob/v0.3.1/lib/hf_hub/webhooks.ex#L1)

Webhooks API for event notifications on HuggingFace Hub.

Webhooks enable automated notifications when events occur on repositories.

## Examples

    # List all webhooks
    {:ok, webhooks} = HfHub.Webhooks.list(token: "hf_xxx")

    # Get a specific webhook
    {:ok, webhook} = HfHub.Webhooks.get("webhook-id", token: "hf_xxx")

    # Create a new webhook
    {:ok, webhook} = HfHub.Webhooks.create("https://example.com/hook",
      watched: [{:model, "bert-base-uncased"}],
      domains: [:repo],
      token: "hf_xxx")

    # Enable/disable a webhook
    {:ok, webhook} = HfHub.Webhooks.enable("webhook-id", token: "hf_xxx")
    {:ok, webhook} = HfHub.Webhooks.disable("webhook-id", token: "hf_xxx")

    # Delete a webhook
    :ok = HfHub.Webhooks.delete("webhook-id", token: "hf_xxx")

# `domain`

```elixir
@type domain() :: :repo | :discussion
```

# `create`

```elixir
@spec create(
  String.t(),
  keyword()
) :: {:ok, HfHub.Webhooks.WebhookInfo.t()} | {:error, term()}
```

Creates a new webhook.

## Arguments

  * `url` - Webhook endpoint URL

## Options

  * `:watched` - List of repos to watch: `[{:model, "user/repo"}, {:dataset, "name"}]`
  * `:domains` - Event domains: `[:repo, :discussion]`
  * `:secret` - Webhook secret for signature verification
  * `:token` - Authentication token (required)

## Examples

    {:ok, webhook} = HfHub.Webhooks.create("https://example.com/hook",
      watched: [{:model, "bert-base-uncased"}],
      domains: [:repo],
      secret: "my-secret",
      token: "hf_xxx")

    {:ok, webhook} = HfHub.Webhooks.create("https://example.com/hook",
      watched: [{:model, "bert-base-uncased"}, {:dataset, "squad"}],
      domains: [:repo, :discussion],
      token: "hf_xxx")

# `delete`

```elixir
@spec delete(
  String.t(),
  keyword()
) :: :ok | {:error, term()}
```

Deletes a webhook.

## Options

  * `:missing_ok` - Don't error if webhook doesn't exist (default: false)
  * `:token` - Authentication token (required)

## Examples

    :ok = HfHub.Webhooks.delete("webhook-id", token: "hf_xxx")
    :ok = HfHub.Webhooks.delete("maybe-exists", missing_ok: true, token: "hf_xxx")

# `disable`

```elixir
@spec disable(
  String.t(),
  keyword()
) :: {:ok, HfHub.Webhooks.WebhookInfo.t()} | {:error, term()}
```

Disables a webhook.

## Options

  * `:token` - Authentication token (required)

## Examples

    {:ok, webhook} = HfHub.Webhooks.disable("webhook-id", token: "hf_xxx")

# `enable`

```elixir
@spec enable(
  String.t(),
  keyword()
) :: {:ok, HfHub.Webhooks.WebhookInfo.t()} | {:error, term()}
```

Enables a webhook.

## Options

  * `:token` - Authentication token (required)

## Examples

    {:ok, webhook} = HfHub.Webhooks.enable("webhook-id", token: "hf_xxx")

# `get`

```elixir
@spec get(
  String.t(),
  keyword()
) :: {:ok, HfHub.Webhooks.WebhookInfo.t()} | {:error, term()}
```

Gets a webhook by ID.

## Options

  * `:token` - Authentication token (required)

## Examples

    {:ok, webhook} = HfHub.Webhooks.get("webhook-id", token: "hf_xxx")

# `list`

```elixir
@spec list(keyword()) :: {:ok, [HfHub.Webhooks.WebhookInfo.t()]} | {:error, term()}
```

Lists all webhooks for the authenticated user.

## Options

  * `:token` - Authentication token (required)

## Examples

    {:ok, webhooks} = HfHub.Webhooks.list(token: "hf_xxx")

# `update`

```elixir
@spec update(
  String.t(),
  keyword()
) :: {:ok, HfHub.Webhooks.WebhookInfo.t()} | {:error, term()}
```

Updates a webhook.

## Options

  * `:url` - New webhook endpoint URL
  * `:watched` - New list of repos to watch
  * `:domains` - New event domains
  * `:secret` - New webhook secret
  * `:token` - Authentication token (required)

## Examples

    {:ok, webhook} = HfHub.Webhooks.update("webhook-id",
      url: "https://new-url.com/hook",
      token: "hf_xxx")

    {:ok, webhook} = HfHub.Webhooks.update("webhook-id",
      watched: [{:model, "gpt2"}],
      token: "hf_xxx")

---

*Consult [api-reference.md](api-reference.md) for complete listing*
