> ## Documentation Index
> Fetch the complete documentation index at: https://docs.squadvault.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Flows reference

> Triggers, actions, and variables you can use when building Flows.

Reference for building Flows. For the product walkthrough, see [Flows](/user-guide/flows).

## Triggers

Workflows match on an event type, or run **on a schedule** (stored as a five-field cron + timezone). Optional conditions filter on payload fields (for example `event.type` equals `scrim`).

### Schedule

| Event            | Fires when                      | Common variables                                         |
| ---------------- | ------------------------------- | -------------------------------------------------------- |
| `schedule.fired` | The Flow’s cron schedule is due | `schedule.cron`, `schedule.timezone`, `schedule.firedAt` |

In the builder, choose **On a schedule**, pick a preset (or advanced cron), then activate the Flow.

### Teams and players

| Event                | Fires when                    | Common variables                                                                |
| -------------------- | ----------------------------- | ------------------------------------------------------------------------------- |
| `team.created`       | Team is created               | `team.*` incl. Discord fields (usually empty until linked)                      |
| `team.updated`       | Team fields change            | `team.*` incl. Discord role/channel                                             |
| `team.deleted`       | Team is deleted               | `team.*` incl. Discord role/channel                                             |
| `player.created`     | Player is created             | `player.id`, `player.name`, `player.discordUserId`, `player.nationality`        |
| `player.archived`    | Player is archived            | `player.id`, `player.name`, `player.nationality`                                |
| `player.joined_team` | Player added to a team roster | `player.*` (incl. `nationality`), `team.*` (incl. Discord role/channel), `role` |
| `player.left_team`   | Player removed from a team    | `player.*` (incl. `nationality`), `team.*` (incl. Discord role/channel)         |
| `captain.assigned`   | Roster role becomes captain   | `player.*` (incl. `nationality`), `team.*` (incl. Discord role/channel)         |
| `coach.assigned`     | Roster role becomes coach     | `player.*` (incl. `nationality`), `team.*` (incl. Discord role/channel)         |

### Calendar and availability

| Event                  | Fires when             | Common variables                                 |
| ---------------------- | ---------------------- | ------------------------------------------------ |
| `event.created`        | Calendar event created | `event.*`, optional `team.*` with Discord fields |
| `event.updated`        | Calendar event updated | same                                             |
| `event.deleted`        | Calendar event deleted | `event.id`, `event.title`, optional `team.*`     |
| `availability.updated` | Player RSVP upserted   | `player.id`, `player.name`                       |

### Tasks, documents, tryouts, organization

| Event                   | Fires when                                                            | Common variables                                              |
| ----------------------- | --------------------------------------------------------------------- | ------------------------------------------------------------- |
| `task.created`          | Task created                                                          | `task.id`, `task.title`                                       |
| `task.completed`        | Task status becomes done                                              | `task.id`, `task.title`                                       |
| `document.uploaded`     | Document created                                                      | `document.id`, `document.name`                                |
| `tryout.created`        | Public application submitted                                          | `tryout.*`, `player.name`, `team.*` (Discord when team known) |
| `tryout.accepted`       | Application accepted / converted (including Discord Sync auto-accept) | same                                                          |
| `tryout.declined`       | Application rejected                                                  | same                                                          |
| `tryout.status_changed` | Application status changes (any status)                               | same + `tryout.previousStatus`                                |
| `organization.created`  | Organization created                                                  | `organization.id`, `organization.name`                        |
| `organization.updated`  | Organization updated                                                  | same                                                          |

<Note>
  `tryout.declined` fires when an application is rejected.
  `tryout.status_changed` fires for every status change (including reviewing and shortlisted).
  Filter with a condition on `tryout.result` (the new status) if you only want one outcome.
  Accepted and rejected applications also emit `tryout.accepted` / `tryout.declined`.
</Note>

## Conditions

Each condition has a field, operator, and value. Operators include equality, lists (`in`), and existence checks. Leave conditions empty to run on every matching trigger.

## Actions

Actions run in order (0-based step indexes in templates: `steps.0`, `steps.1`, …).

### Discord

Requires a connected Discord server. See [Discord](/user-guide/discord).

| Action                                        | Notes                                                                                                                                                                                                                             |
| --------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `discord.create_role`                         | Optional color, guild permissions via permission editor ([PermissionFlagsBits](https://discord.js.org/docs/packages/discord.js/14.27.0/PermissionFlagsBits:Variable)), link to team. Outputs `roleId`, `roleName`.                |
| `discord.edit_role`                           | Update name, color, and/or permissions by role ID                                                                                                                                                                                 |
| `discord.delete_role`                         | By role ID                                                                                                                                                                                                                        |
| `discord.create_category`                     | Returns `categoryId`. Optional `privateForRoleId` (deny @everyone, allow role).                                                                                                                                                   |
| `discord.create_text_channel`                 | Optional parent; `privateForRoleId`; can link as team channel                                                                                                                                                                     |
| `discord.create_voice_channel`                | Optional parent; `privateForRoleId`                                                                                                                                                                                               |
| `discord.set_channel_permissions`             | Works on **categories and channels**. `makePrivate` for a role, or custom `allow` / `deny` (`team`, `view`, `none`, or bitfield). Use `{{steps.N.categoryId}}` / `{{steps.N.channelId}}` and `{{steps.N.roleId}}`.                |
| `discord.assign_role` / `discord.remove_role` | Needs Discord user ID + role ID                                                                                                                                                                                                   |
| `discord.assign_team_role`                    | Assigns a role to every roster player with a Discord link. `teamId` defaults to the trigger team; omit `roleId` to use the team's linked Discord role. Outputs `assignedCount`, `skippedCount`, `failedCount`, `discordMentions`. |
| `discord.send_message`                        | Channel ID or org log channel. Plain `content` and/or a single `embed` (`title`, `description`, `color` as hex like `#a162ff`, `footer`, `fields`). Content is optional when an embed is set.                                     |

### SquadVault

| Action                         | Notes                                                      |
| ------------------------------ | ---------------------------------------------------------- |
| `squadvault.send_notification` | In-app notification (workflow, title, body, optional user) |
| `squadvault.get_team`          | Loads team + Discord links into step outputs               |
| `squadvault.get_team_players`  | Roster + `discordMentions` string for pings                |
| `squadvault.get_player`        | Single player lookup                                       |
| `squadvault.get_member`        | Org member / user lookup                                   |

### Communication

| Action                  | Notes                                                                                                                   |
| ----------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| `communication.webhook` | One-off signed POST to a URL (optional secret). For always-on org events, use [Webhooks](/user-guide/webhooks) instead. |

## Lookup outputs

### Get team (`squadvault.get_team`)

Config: `teamId` (defaults from `{{team.id}}` when present).

Outputs include: `id`, `name`, `description`, `game`, `image`, `discordRoleId`, `discordRoleMention`, `teamChannelId`.

### Get team players (`squadvault.get_team_players`)

Config: `teamId`, optional `includeArchived`.

| Output            | Description                                           |
| ----------------- | ----------------------------------------------------- |
| `count`           | Number of players returned                            |
| `names`           | Comma-separated display names                         |
| `discordUserIds`  | Comma-separated Discord IDs                           |
| `discordMentions` | Space-separated `<@id>` mentions for Discord messages |
| `players`         | Full array (code / advanced use)                      |

### Get player / Get member

* **Get player** — `discordMention`, `discordUserId`, `userId`, `nationality`, …
* **Get member** — `userId`, `name`, `email`, `role`, … (empty user ID may fall back to the event actor)

## Code mode shape

```json theme={null}
{
  "triggerEventType": "team.created",
  "conditions": [],
  "actions": [
    {
      "provider": "discord",
      "actionType": "discord.create_role",
      "config": {
        "name": "{{team.name}}",
        "permissions": "none",
        "linkToTeam": true
      }
    },
    {
      "provider": "discord",
      "actionType": "discord.create_category",
      "config": {
        "name": "{{team.name}}",
        "privateForRoleId": "{{steps.0.roleId}}"
      }
    },
    {
      "provider": "discord",
      "actionType": "discord.create_text_channel",
      "config": {
        "name": "{{team.name|slug}}-general",
        "parentId": "{{steps.1.categoryId}}",
        "privateForRoleId": "{{steps.0.roleId}}"
      }
    }
  ]
}
```

## Related

* [Flows](/user-guide/flows) — builder, templates, activity
* [Discord](/user-guide/discord) — bot connection and sync
* [Teams and players](/user-guide/teams-and-players) — roster changes that fire join/leave events
