---
title: "Realtime updates — Depfloy docs"
description: "Subscribe to a project channel over WebSocket with an API token."
url: "https://depfloy.com/docs/api-reference/realtime"
---

# Realtime updates

Depfloy pushes project events over a WebSocket that speaks the Pusher protocol. An API token is enough to connect, authorize a project channel and receive the events the dashboard uses.

AUTH `Authorization: Bearer {API_KEY}` [Create a token →](https://depfloy.com/docs/api-keys)

## 1\. Read the connection values

`GET /api/v1/realtime/config` returns the public connection values. The app secret is never part of the response.

GET /api/v1/realtime/config Request

cURL

```bash
curl https://app.depfloy.com/api/v1/realtime/config \
  -H "Authorization: Bearer {API_KEY}" \
  -H "Accept: application/json"
```

Response

```json
{
  "protocol": "pusher",
  "key": "{APP_KEY}",
  "host": "{WS_HOST}",
  "port": 443,
  "scheme": "https",
  "auth_endpoint": "https://app.depfloy.com/api/v1/broadcasting/auth"
}
```

Read these values at startup instead of hard-coding them.

## 2\. Authorize the project channel

Each project has the private channel `private-project.{id}`. A Pusher client authorizes it by posting `socket_id` and `channel_name` to `auth_endpoint` with your token in the `Authorization` header. The request succeeds when the token’s owner can see the project and the token has `project:read`, and returns `403` otherwise. To act in another organization you belong to, send its id in the `X-Organization` header, as on other API calls. These requests count toward the [API rate limit](https://depfloy.com/docs/api-reference/quickstart#rate-limits).

## 3\. Subscribe

With [pusher-js](https://github.com/pusher/pusher-js) (Node.js or the browser):

```js
import Pusher from 'pusher-js';

const headers = { Authorization: `Bearer ${process.env.DEPFLOY_TOKEN}`, Accept: 'application/json' };
const config = await fetch('https://app.depfloy.com/api/v1/realtime/config', { headers }).then((r) => r.json());

const pusher = new Pusher(config.key, {
  cluster: '',
  wsHost: config.host,
  wsPort: config.port,
  wssPort: config.port,
  forceTLS: config.scheme === 'https',
  enabledTransports: ['ws', 'wss'],
  channelAuthorization: { endpoint: config.auth_endpoint, transport: 'ajax', headers },
});

const channel = pusher.subscribe(`private-project.${projectId}`);

channel.bind('App\\Events\\OperationCompletedEvent', (event) => {
  if (event.operation === 'ssl-setup') {
    console.log(event.data.domain_id, event.status, event.message);
  }
});
```

## SSL setup events

Every change of a domain’s SSL setup is sent as `App\Events\OperationCompletedEvent` with `operation` set to `ssl-setup`:

status string

`queued`, `dns_pending`, `issuing_certificate`, `ready` or `failed`.

message string

Why the setup failed; an empty string for the other statuses.

data object

`project_id` and `domain_id`.

Payload (fields used here)

```json
{
  "channel": "project.14532",
  "operation": "ssl-setup",
  "status": "failed",
  "message": "DNS has not reached the server. Point the domain to the server, then retry SSL setup.",
  "data": { "project_id": 14532, "domain_id": 136526 }
}
```

Events sent while you are disconnected are not replayed. After a reconnect, read the current state with [List domains](https://depfloy.com/docs/api-reference/domains), which returns the same status and reason in `ssl_setup`.

The channel also carries other events the dashboard uses. Only the `ssl-setup` payload above is described here.
