# `Lightning.Workflows.Trigger`
[🔗](https://github.com/OpenFn/lightning/blob/main/lib/lightning/workflows/trigger.ex#L1)

Ecto model for Triggers.

Triggers represent the criteria in which a Job might be invoked.

## Types

### Webhook (default)

A webhook trigger allows a Job to invoked (via `Lightning.Invocation`) when it's
endpoint is called.

# `t`

```elixir
@type t() :: %Lightning.Workflows.Trigger{
  __meta__: Ecto.Schema.Metadata.t(),
  comment: term(),
  cron_cursor_job: term(),
  cron_cursor_job_id: term(),
  cron_expression: term(),
  custom_path: term(),
  delete: term(),
  edges: term(),
  enabled: term(),
  has_auth_method: term(),
  id: Ecto.UUID.t() | nil,
  inserted_at: term(),
  legacy_bare_path: term(),
  project_id: term(),
  type: term(),
  updated_at: term(),
  webhook_auth_methods: term(),
  webhook_reply: term(),
  webhook_response_config: term(),
  workflow: term(),
  workflow_id: term()
}
```

# `trigger_type`

```elixir
@type trigger_type() :: :webhook | :cron
```

# `cast_changeset`

# `custom_path_shape_error?`

```elixir
@spec custom_path_shape_error?(Ecto.Changeset.t()) :: boolean()
```

Whether a rejected changeset failed only on the shape of its custom path.

A duplicate or a missing project also report against `:custom_path`, and
neither may be answered by inserting without the path, since the path would
be written back afterwards.

# `new`

# `synchronous?`

```elixir
@spec synchronous?(t()) :: boolean()
```

Returns true if the trigger uses a synchronous webhook reply mode
(i.e., the HTTP connection is held open waiting for a response).

This set must stay in step with the reply modes that actually publish a
`{:webhook_response, ...}` message — see
`LightningWeb.RunChannel.maybe_send_after_completion_response/2`, which
broadcasts for `:after_completion` only. A mode that is synchronous here but
has no publisher there parks the request process until the webhook response
timeout for a message nobody sends, so `:custom` (accepted by the schema but
not implemented, and not offered by the trigger editor) is deliberately
excluded.

# `valid_custom_path?`

```elixir
@spec valid_custom_path?(term()) :: boolean()
```

Whether a string is usable as a webhook's custom path.

Asked by anything that copies a path written before these rules existed.

# `validate`

---

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