# Create Webhooks

A webhook receives events for tournaments. Which tournaments depends on who owns the webhook:

- **API token (account):** the webhook fires for every tournament of your account — plus any public tournament you subscribe it to.
- **Public API key:** the webhook fires only for the public tournaments you subscribe it to.

### With an API token, in the Kickertool App
1. Log in to your Tournament.app account
2. Click on your profile picture in the bottom left corner
3. Navigate to "Settings"
4. Select the "API" section
5. Click on "Create Webhook"

### Via API (API token or public API key)
1. `POST /webhooks` with a name, your endpoint URL and an optional `authToken` that we send back as bearer token.
2. Find the tournament: `GET /organizers?search=kixx`, then `GET /organizers/:organizerId/tournaments?state=running`.
3. `PUT /webhooks/:webhookId/tournaments/:tournamentId` to subscribe. Repeat for further tournaments.
4. `DELETE /webhooks/:webhookId/tournaments/:tournamentId` when you are done.

### Subscription rules
- Only tournaments of the key's sport that are shared on a result page can be subscribed (`403 TOURNAMENT_NOT_PUBLIC`).
- Finished or cancelled tournaments cannot be subscribed (`403 TOURNAMENT_FINISHED`); read their final data via `GET`.
- At most 25 subscriptions per webhook (`400 TOO_MANY_SUBSCRIPTIONS`).
- Events stop as soon as the organizer stops sharing the tournament on their result page.
- Subscriptions are removed automatically about a week after the tournament has finished, or when the tournament is deleted. The webhook itself stays.
- After 5 failed deliveries a webhook is disabled; re-enable it with `POST /webhooks/:webhookId/enable`.