# `mix ash_workflow.gen.invitation`
[🔗](https://github.com/team-alembic/ash_workflow/blob/v0.12.0/lib/mix/tasks/ash_workflow.gen.invitation.ex#L53)

Adds an invitation workflow to a resource

Generates an invitation resource that invites an email address to the
subject. An invitation is accepted, declined or revoked, and expires once
its `expires_at` passes. `resend` moves `expires_at` forward again. The
subject gains `has_many :invitations` and `has_one :latest_invitation`.
When the subject does not exist, it is created with `mix ash.gen.resource`
first.

Nobody may send an invitation until the application defines who may, in
the generated `Checks.CanInvite` module. Nobody may accept or decline
until the application defines how an actor proves they are the invitee,
in the generated `Checks.CanAccept` module.

## Example

```bash
mix ash_workflow.gen.invitation MyApp.Teams.Team --invitee MyApp.Accounts.User --expires-after 7d
```

## Options

* `--invitee` - required. The actor resource. The inviter and the invitee
  who accepts belong to it.
* `--expires-after` - how long an invitation stays open after it is sent
  or resent, given as `10s`, `30m`, `12h`, `2d` or `2w`. Defaults to `7d`.
* `--module` - the invitation resource's module name. Defaults to the
  subject's name with `Invitation` appended.
* `--domain` - the domain for a subject the task creates. Required only
  when the subject does not exist.
* `--transition-log` - also generates a transition log for the invitation
  with `mix ash_workflow.gen.transition_log`. Defaults to `true`.

---

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