# Connections

Connections link your organization to external platforms. Most providers receive real-time webhook
events from your games. The LINE connection is different — it publishes streams inside LINE via LIFF
or MINI App.

## Connection Types

| Type | What it does | Providers |
| :--- | :----------- | :-------- |
| **Event webhooks** | Push play and prize events to your stack | Webhook, Custom, Zapier, Braze, HubSpot, Mailchimp, Salesforce, Segment |
| **Publishing** | Open streams inside a messaging app | [LINE (LIFF / MINI App)](/connections/line) |

---

## Supported Providers

| Provider       | Description                          |
| :------------- | :----------------------------------- |
| **Webhook**    | Any HTTP endpoint with optional auth |
| **Custom**     | Custom API URL with optional API key |
| **Zapier**     | Zapier webhook (HTTPS required)      |
| **Braze**      | Braze messaging platform — see [Braze Connection](/connections/braze) |
| **HubSpot**    | HubSpot CRM                          |
| **Mailchimp**  | Mailchimp email marketing            |
| **Salesforce** | Salesforce CRM                       |
| **Segment**    | Segment analytics                    |
| **LINE**       | Publish streams in LINE via LIFF / MINI App — see [LINE Connection](/connections/line) |

---

## How Event Webhooks Work

1. **Create a connection** at the organization level with your provider credentials
2. **Link the connection** to one or more streams (campaigns)
3. **Choose trigger events** that determine when the webhook fires
4. When a trigger event occurs, DailyPlay sends a POST request to your endpoint with event data

:::tip
For LINE setup and permanent links, see [LINE Connection](/connections/line). LINE is not linked to
stream trigger events.
:::

---

## Trigger Events

Each stream connection can be configured to fire on one or more of these events:

| Event              | Fires when…                        |
| :----------------- | :--------------------------------- |
| `stream_access`    | A player opens the stream page     |
| `play_start`       | A player starts a game             |
| `play_complete`    | A player finishes a game           |
| `prize_redemption` | A player claims a prize or voucher |

---

## Setting Up a Webhook Connection

### 1. Create the Connection

1. Go to **Connections** from the main navigation
2. Click **Add Connection**
3. Choose your provider (e.g. **Webhook**)
4. Enter the required credentials:
   - **Webhook / Custom** — Endpoint URL and optional authorization header or API key
   - **Zapier** — Webhook URL (must be HTTPS)
   - **Other providers** — API key and any provider-specific fields
5. Save the connection

### 2. Link to a Stream

1. Open the stream you want to connect
2. Go to the **Connections** tab
3. Select an available connection from your organization
4. Choose which **trigger events** should fire the webhook
5. Save

---

## Payload Format

When a trigger event occurs, DailyPlay sends an HTTP POST request to your configured endpoint. The
payload is JSON and includes context about the event, the game, and the player.

### Example: `play_complete` Event

```json
{
  "event_type": "play_complete",
  "game_id": "163",
  "stream_id": 453,
  "stream_slug": "my-campaign-slug",
  "stream_name": "My Campaign Stream",
  "player_uuid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "session_id": "s9k8j7h6-g5f4-d3c2-b1a0-123456789abc",
  "score": 85,
  "play_duration_seconds": 32,
  "url_params": {
    "user_id": "usr_123",
    "email": "player@example.com",
    "source": "email_campaign"
  },
  "timestamp": "2026-04-09T14:30:00.000Z"
}
```

### Payload Fields

| Field                   | Type   | Description                                                         |
| :---------------------- | :----- | :------------------------------------------------------------------ |
| `event_type`            | string | The trigger event name (e.g. `play_complete`)                       |
| `game_id`               | string | The ID of the game that was played                                  |
| `stream_id`             | number | The ID of the stream (campaign) the game belongs to                 |
| `stream_name`           | string | The display name of the stream                                      |
| `player_uuid`           | string | Unique identifier for the player                                    |
| `session_id`            | string | Unique identifier for the play session                              |
| `score`                 | number | The player's score (for `play_complete`)                            |
| `play_duration_seconds` | number | How long the player took to complete the game, in seconds           |
| `url_params`            | object | Any URL query parameters passed when the player accessed the stream |
| `timestamp`             | string | ISO 8601 timestamp of when the event occurred                       |

:::tip
The `url_params` field captures any query parameters from the stream URL. This is useful for
passing through tracking IDs, user identifiers, or campaign tags from your existing systems — for
example
`https://app.dailyplay.ai/stream/<org-slug>/my-stream?user_id=usr_123&source=email_campaign`.
:::

---

## Managing Connections

- **Edit** — Update credentials or rename a connection from the Connections page
- **Enable / Disable** — Toggle a connection on or off without deleting it
- **Remove from stream** — Unlink a connection from a specific stream while keeping the connection
  available for other streams
- **Delete** — Permanently remove a connection from your organization

:::note
Only organization **owners** and **admins** can create, edit, or delete connections.
:::