# `Vaartix.Webhook`
[🔗](https://github.com/vaartix-mail/vaartix-elixir/blob/v0.1.0/lib/vaartix/webhook.ex#L1)

Check that a webhook request really came from Vaartix (Standard Webhooks spec).

    # Phoenix: read the raw body first (see the README), then:
    case Vaartix.Webhook.verify(raw_body, conn.req_headers, System.fetch_env!("VAARTIX_WEBHOOK_SECRET")) do
      {:ok, %{"type" => "email.bounced", "data" => %{"details" => details}}} ->
        details["diagnosticCode"]   # the receiving server's reply
      {:ok, _event} -> :ok
      {:error, reason} -> reason
    end

# `events`

Every webhook event type.

# `verify`

```elixir
@spec verify(binary(), list() | map(), String.t(), keyword()) ::
  {:ok, map()} | {:error, String.t()}
```

Verify a request and return `{:ok, payload}` or `{:error, reason}`. `headers` is a list of
`{name, value}` tuples (like `conn.req_headers`) or a map; names are matched case-insensitively.
Options: `:tolerance` in seconds (default 300), `:now` (Unix seconds).

---

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