# Subscription Count

Subscription count reports how many active connections are subscribed to a channel.

Vask supports subscription count in three places:

- Live `pusher_internal:subscription_count` WebSocket events.
- `info=subscription_count` on HTTP API responses.
- `subscription_count` webhooks.

Presence channels use `user_count` for distinct members and do not emit subscription-count events.

## Live client events

When enabled for the app, Vask sends subscription-count events to subscribers of public, private, cache, and encrypted cache channels.

```json
{
    "event": "pusher_internal:subscription_count",
    "channel": "public-feed",
    "data": "{\"subscription_count\":12}"
}
```

SDKs may expose this as a channel event.

```js
channel.bind('pusher:subscription_count', (event) => {
    console.log(event.subscription_count);
});
```

## HTTP API info

Request `subscription_count` for a single channel:

```text
GET https://api.vask.dev/apps/{app_key}/channels/public-feed?info=subscription_count
```

```json
{
    "occupied": true,
    "subscription_count": 12
}
```

Request count information while triggering an event:

```json
{
    "name": "feed.updated",
    "channel": "public-feed",
    "data": "{}",
    "info": "subscription_count"
}
```

## Webhooks

Enable `subscription_count` on the app webhook endpoint to receive count changes server-side.

```json
{
    "time_ms": 1736937600000,
    "events": [
        {
            "name": "subscription_count",
            "channel": "public-feed",
            "subscription_count": 12
        }
    ]
}
```

Subscription-count webhooks can be frequent on busy channels. Enable them only when your backend needs every count change.

## Related docs

- [Events](/docs/events)
- [HTTP API reference](/docs/http-api)
- [Webhooks](/docs/webhooks)
