# `Wardrik.Hook`

Delivers a service's request to an agent's webhook trigger.

    :ok = Wardrik.Hook.deliver(scope,
      agent: "agt_1",
      trigger: "issues",
      body: body,
      headers: headers
    )

# `deliver`

```elixir
@spec deliver(Wardrik.Scope.t(), keyword()) ::
  term() | :ok | {:error, Wardrik.Error.t()}
```

Deliver a webhook request to a trigger.

    Wardrik.Hook.deliver(scope, agent: "agt_1", trigger: "daily", body: body, headers: headers)

Runs the agent once for a request sent to its webhook trigger, after checking the request against the trigger's secret. A request that fails the check returns not_found, the same as a missing trigger. unavailable means the agent can't run now and the service should retry later.

`POST /v1/hooks/{agent}/{trigger}`

# `deliver_with_secret`

```elixir
@spec deliver_with_secret(Wardrik.Scope.t(), keyword()) ::
  term() | :ok | {:error, Wardrik.Error.t()}
```

Deliver a webhook request with the secret in the path.

    Wardrik.Hook.deliver_with_secret(scope, agent: "agt_1", trigger: "daily", secret: "s3cret", body: body, headers: headers)

Works like hook.deliver, for services that only accept a URL. The secret is the last path segment of the URL. Keep this URL as private as an API token.

`POST /v1/hooks/{agent}/{trigger}/{secret}`

---

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