# Webhooks

Webhooks enable EGYM to push real-time notifications to your application. We use HTTPS to send these notifications to a
URL you specify. You can create multiple webhooks for a single gym.

## Use cases

You can use webhook event notifications to alert your app to certain events.

### Use Case 1 - Customer Gym Checkin/Gym Checkout Event

The customer Gym Checkin/Gym Checkout events notifies your application once a customer has physically checked-in or checked-out to/from a gym.

### Use Case 2 - Customer Equipment Checkin Event.

The customer Equipment Checkin event notifies your application once a customer has logged in to equipment in a gym.

### Use Case 3 - Customer membership delete event.

The customer membership delete event notifies your application once member data gets deleted from EGYM.

# Serve webhook endpoint

Serve this endpoint so that it can be accessed by us without additional configuration and/or VPNs.
Only HTTPS endpoints with valid SSL certificates are allowed.
Timeout for requests to your endpoint is 5 seconds, after that requests will be treated as unsuccessful.

# Event call endpoint definition

Method: `POST`

Headers: `x-api-key:{your_secret}, Content-Type:application/json`

Payload: `{ "accountId": "[UUID]", "timestamp": 1667921312188, "type" : "GYM_CHECKIN" }`

`accountId` - account id of the user, UUID

`timestamp` - UTC timestamp of the event

`type` - event type

## Event types

| Event type | Description |
|  --- | --- |
| GYM_CHECKIN | Occurs whenever a customer has physically checked in at a gym |
| GYM_CHECKOUT | Occurs whenever a customer has physically checked out from a gym |
| EQUIPMENT_CHECKIN | Occurs whenever a customer has physically logged in to equipment in a gym |
| MEMBERSHIP_DELETE | Occurs once member data gets deleted from EGYM |
| GENIUS_ONBOARDING_COMPLETED | Occurs when a member completes EGYM Genius onboarding |
| TEST | Test event for webhook endpoint verification |


More events coming soon
Additional webhook event types will be added in future releases to support more integration use cases.

# How to enable webhooks

## Configuration via API (current)

API configuration will be replaced
The webhook management API endpoints are currently used for configuration but will be replaced with a UI-based configuration interface in the future. We recommend using the API for now, and we will provide migration guidance when the UI becomes available.

To configure webhooks programmatically:

1. [Authenticate](/mms-api-v2/authentication) with your API credentials
2. Use the [Webhook API endpoints](/mms-api-v2/apis/mms-v2/webhooks) to:
  - Create webhook subscriptions
  - Update webhook URLs and secrets
  - List configured webhooks
  - Delete webhook subscriptions


## Configuration via UI (future)

A user-friendly interface for webhook configuration will be available in the future, eliminating the need for API-based setup.