# member_balance (timeseries)

| Required permit | Rate limit tokens cost | Available intervals |
| --- | --- | --- |
| Reporting:Api:Report:MemberBalance | 3 | 5m, 1h, 1d, 1w, 1mo |

This report allows you to get information about members balance in loyalty club (community).

When a member is added to loyalty club then `in` type serie is incremented.
When a member is removed from loyalty club then `out` type serie is decremented.

## Fields

### community_id

| Type | Filterable |
| --- | --- |
| Integer | <Icon icon="material-outline-done"/> (via `X-Customer` header) |

ID of member's community

### type

| Type | Filterable |
| --- | --- |
| Enum | <Icon icon="material-outline-done"/> |

Serie type.

This field is enum, possible values are:
* `in` - members that opt in to loyalty club
* `out` - members that opt out from loyalty club

### optin_channel

| Type | Filterable |
| --- | --- |
| String | <Icon icon="material-outline-done"/> |

See [members report](/doc-344016#Un0optin_channel).

### optin_subchannel

| Type | Filterable |
| --- | --- |
| String | <Icon icon="material-outline-done"/> |

See [members report](/doc-344016#Un0optin_subchannel).

### optin_platform

| Type | Filterable |
| --- | --- |
| Enum | <Icon icon="material-outline-done"/> |

See [members report](/doc-344016#Un0optin_platform).

### gender

| Type | Filterable | Readonly |
| --- | --- | --- |
| String | <Icon icon="material-outline-done"/> | <Icon icon="material-outline-highlight_off"/> |

See [members report](/doc-344016#Un0gender).

### age

| Type | Filterable |
| --- | --- |
| Enum | <Icon icon="material-outline-done"/> |

See [members report](/doc-344016#Un0age).

### consents

| Type | Filterable |
| --- | --- |
| Object(key: name of consent, value: boolean status of consent) | <Icon icon="material-outline-done"/> |

See [members report](/doc-344016#Un0consents).

## Query without aggregations

Query returns series with member balances.

```json
{
    "interval": "1d",
    "range_timezone": "America/Denver",
    "time_buckets": [
        "2024-04-08T00:00:00.000-06:00",
        "2024-04-09T00:00:00.000-06:00",
        "2024-04-11T00:00:00.000-06:00",
        "2024-04-22T00:00:00.000-06:00",
        "2024-04-23T00:00:00.000-06:00",
        "2024-04-24T00:00:00.000-06:00",
        "2024-04-25T00:00:00.000-06:00"
    ],
    "series": [
        {
            "label": {
                "type": "out"
            },
            "values": [
                2,
                2,
                1,
                1,
                null,
                1,
                5
            ]
        },
        {
            "label": {
                "type": "in"
            },
            "values": [
                null,
                4,
                300,
                2,
                1,
                null,
                11
            ]
        }
    ],
    "data_points": 11,
    "result_type": "timeseries"
}
```

## Aggregations

### total

Fetch members balance in context of all communities.

### optin_platform

Fetch members balance grouped by optin_platform.

#### Labels

| Key | Type | Description |
| --- | --- | --- |
| optin_platform | Enum | See in `Fields` |

#### Example query response

```json
{
    "interval": "1d",
    "range_timezone": "America/Denver",
    "time_buckets": [
        "2024-04-08T00:00:00.000-06:00",
        "2024-04-09T00:00:00.000-06:00",
        "2024-04-11T00:00:00.000-06:00",
        "2024-04-22T00:00:00.000-06:00",
        "2024-04-23T00:00:00.000-06:00",
        "2024-04-24T00:00:00.000-06:00",
        "2024-04-25T00:00:00.000-06:00"
    ],
    "series": [
        {
            "label": {
                "type": "out",
                "optin_platform": "other"
            },
            "values": [
                2,
                2,
                1,
                1,
                null,
                1,
                5
            ]
        },
        {
            "label": {
                "type": "in",
                "optin_platform": "other"
            },
            "values": [
                null,
                4,
                300,
                2,
                1,
                null,
                11
            ]
        }
    ],
    "data_points": 11,
    "result_type": "timeseries"
}
```

### total_optin_platform

Fetch optin_platform aggregation in context of all communities.