# `Chronicle.WebHooks.DefinitionBuilder`
[🔗](https://github.com/Cratis/Chronicle.Elixir/blob/main/lib/chronicle/web_hooks/definition_builder.ex#L4)

Immutable builder for webhook definitions.

When no event types are configured explicitly, the builder uses all registered
event types passed to `new/1`.

# `t`

```elixir
@type t() :: %Chronicle.WebHooks.DefinitionBuilder{
  active?: boolean(),
  authorization: Chronicle.WebHooks.Target.authorization(),
  event_sequence_id: String.t(),
  event_types: [module()],
  headers: %{optional(String.t()) =&gt; String.t()},
  registered_event_types: [module()],
  replayable?: boolean()
}
```

# `build`

```elixir
@spec build(t(), String.t(), String.t()) :: Chronicle.WebHooks.Definition.t()
```

Builds a webhook definition.

# `new`

```elixir
@spec new([module()]) :: t()
```

Creates a new definition builder.

# `not_active`

```elixir
@spec not_active(t()) :: t()
```

Marks the webhook as inactive.

# `not_replayable`

```elixir
@spec not_replayable(t()) :: t()
```

Marks the webhook as not replayable.

# `on_event_sequence`

```elixir
@spec on_event_sequence(t(), String.t()) :: t()
```

Sets the event sequence id for the webhook.

# `with_basic_auth`

```elixir
@spec with_basic_auth(t(), String.t(), String.t()) :: t()
```

Uses HTTP basic authentication.

# `with_bearer_token`

```elixir
@spec with_bearer_token(t(), String.t()) :: t()
```

Uses HTTP bearer-token authentication.

# `with_event_type`

```elixir
@spec with_event_type(t(), module()) :: t()
```

Adds an event type to the webhook definition.

# `with_header`

```elixir
@spec with_header(t(), String.t(), String.t()) :: t()
```

Adds or replaces a target header.

# `with_oauth`

```elixir
@spec with_oauth(t(), String.t(), String.t(), String.t(), String.t() | nil) :: t()
```

Uses OAuth client credentials authentication. The optional `scope` is requested from the
authority; when omitted no scope is sent.

---

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