> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hypersender.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SMS Phone Heartbeats with Go

> Check that your Android SMS gateway phone is online from Golang: list the heartbeats it sends every 15 minutes, with battery and charging state.

## Overview

The Hypersender SMS app sends a heartbeat every 15 minutes. Each one records the battery level, whether the phone was charging, the app version, and the phone's local time. Use the Go SDK to list them, for example to chart battery level or find when a phone went quiet.

To react to a phone going offline as it happens, use the heartbeat webhooks instead. See the [SMS heartbeats guide](https://docs.hypersender.com/v2/hypersender/overview/sms/sms-heartbeats-guide.md).

## Methods

### List Heartbeats

Get a paginated list of heartbeats for the instance. [(learn more)](https://docs.hypersender.com/v2/api-reference/sms/heartbeats/sms-heartbeats-api.md)

> [tab] Basic Usage
>
> ```go theme={null}
> client := hypersender.NewClient()
>
> res, err := client.SMS.GetHeartbeats(ctx, nil)
> if err != nil {
>     log.Fatal(err)
> }
>
> heartbeats, _ := res["data"].([]any)
> for _, item := range heartbeats {
>     heartbeat, _ := item.(map[string]any)
>     fmt.Println(heartbeat["created_at"], heartbeat["battery_level"], heartbeat["is_charging"])
> }
> ```

> [tab] Basic Usage with Filters
>
> ```go theme={null}
> client := hypersender.NewClient()
>
> res, err := client.SMS.GetHeartbeats(ctx, &hypersender.ListOptions{
>     PerPage: 50,
>     Page:    1,
>     Sort:    "-created_at",
>     Filters: map[string]string{
>         "is_charging": "false",
>         "created_at":  "2025-01-20 00:00:00,2025-01-21 00:00:00",
>         // other filters (check Parameters tab)
>     },
> })
> if err != nil {
>     log.Fatal(err)
> }
>
> meta, _ := res["meta"].(map[string]any)
> fmt.Println(meta["current_page"], meta["last_page"], meta["total"])
> ```

> [tab] Parameters
>
> All fields are optional; pass `nil` for none. Each key in `Filters` is sent as `filter[key]`.
>
> | Parameter | Type | Description |
> | - | - | - |
> | PerPage | int | Items per page (max 50) |
> | Page | int | Page number |
> | Sort | string | `created_at` or `local_timestamp`. Add `-` for descending, for example `-created_at`. |
> | Include | string | Related data to include: `phone`, or `phone.currentAppVersion` |
> | Filters\["app\_version"] | string | Part of the app version, for example `1.50` |
> | Filters\["battery\_level"] | string | Exact battery level in percent, for example `"87"` |
> | Filters\["is\_charging"] | string | `"true"` or `"false"` |
> | Filters\["local\_timestamp"] | string | The phone's local time, as a date or range |
> | Filters\["created\_at"] | string | Date or range. A range is two dates separated by a comma, for example `2025-01-20 00:00:00,2025-01-21 00:00:00`. |
> | Filters\["updated\_at"] | string | Date or range |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.