# Webhook Events

Each webhook call is structured as a `WebhookCallDto`, containing a unique, incrementing ID, the tournament ID, and an array of events.

### Webhook Synchronization

Tournament.app supports offline functionality, which can affect webhook event delivery:

- When devices are offline, changes are stored locally.
- Upon reconnection, all accumulated changes are synced to the server.
- These synced changes are then sent as events to your webhook endpoint.
- Each event includes a `createdAt` timestamp, reflecting when the change was made on the user's device.

This approach ensures that no updates are lost, even during periods of disconnection. However, be aware that you may receive multiple events simultaneously when a device comes back online after an extended offline period.

### Webhook Call Structure

Each webhook call will have this structure:

```json
{
  "id": 1234,
  "tournamentId": "tio:T5MMiW8IVuWMp",
  "events": [
    {
      "type": "MatchUpdated",
      "matchId": "tio:uVOK5NQ5ruqqm",
      "createdAt": "2024-08-28T15:12:30.413Z"
    },
    {
      "type": "StandingsUpdated",
      "createdAt": "2024-08-28T15:12:30.413Z"
    },
    {
      "type": "CourtMatchChanged",
      "courtId": "tio:xfelozmkJVomE",
      "createdAt": "2024-08-28T15:12:30.413Z"
    }
  ]
}
```

### Event Types

#### CourtMatchChanged
Triggered when a court gets a new match or a match is removed from a court.
Example:
```json
{
  "type": "CourtMatchChanged",
  "courtId": "tio:XBZxd1GA3Kog9",
  "matchId": "tio:80qYlVngRdUjx",
  "createdAt": "2024-08-27T17:06:23.051Z"
}
```

#### MatchUpdated
Triggered when a match is updated (e.g., score update, player change).
Example:
```json
{
  "type": "MatchUpdated",
  "matchId": "tio:80qYlVngRdUjx",
  "createdAt": "2024-08-27T17:06:23.051Z"
}
```

#### TournamentUpdated
Triggered when tournament state or options are changed.
Example:
```json
{
  "type": "TournamentUpdated",
  "createdAt": "2024-08-27T17:06:23.051Z"
}
```

#### TournamentAdded
Triggered when a new tournament is added.
Example:
```json
{
  "type": "TournamentAdded",
  "createdAt": "2024-08-27T17:06:23.051Z"
}
```

#### EntryListUpdated
Triggered when:
- An entry is added
- An Entry is removed
- An Entry is edited

Example:
```json
{
  "type": "EntryListUpdated",
  "createdAt": "2024-08-27T17:06:23.051Z"
}
```

#### StandingsUpdated
Triggered when the standings of the tournament where updated

Example:
```json
{
  "type": "StandingsUpdated",
  "createdAt": "2024-08-27T17:06:23.051Z"
}
```