# `StandardWebhooks`
[🔗](https://github.com/standard-webhooks/standard-webhooks/tree/main/libraries/elixir/blob/main/lib/standard_webhooks.ex#L1)

Documentation for `Standard Webhooks`

# `endpoint_verification_response`

```elixir
@spec endpoint_verification_response(challenge :: String.t(), secret :: binary()) ::
  String.t()
```

Calculate the response to an endpoint verification challenge given a challenge and secret

Takes the value of the `webhook-challenge` header and returns the value for the
`webhook-challenge-response` header.

# `sign`

```elixir
@spec sign(
  id :: String.t(),
  timestamp :: integer(),
  payload :: binary() | String.t(),
  secret :: binary()
) :: String.t()
```

Sign a Standard Webhook given an id, timestamp, payload and secret

The payload can be bytes (a binary) or a string (a UTF-8 binary). It's signed byte for byte,
so it must be the exact body that will be sent.

# `validate_timestamp`

# `verify`

```elixir
@spec verify(binary() | String.t(), Plug.Conn.t(), binary()) :: boolean()
```

Verify a Standard Webhook given a payload, Plug.Conn and secret

The payload must be the raw request body, exactly as received, either as bytes (a binary) or
as a string (a UTF-8 binary). It's verified byte for byte, so don't pass a re-encoded version
of the parsed body: even a minor difference in the serialization (e.g. whitespace or key
order) will cause verification to fail.

# `verify_endpoint_verification_response`

```elixir
@spec verify_endpoint_verification_response(
  challenge :: String.t(),
  header :: String.t(),
  secret :: binary()
) :: boolean()
```

Verify the response to an endpoint verification challenge given a challenge, response and secret

Takes the challenge that was sent and the value of the `webhook-challenge-response` header.

---

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