# com.atiproto.repo.subscription.count

> Published by [atiproto.com](https://lexicon.garden/identity/did:plc:4x5dcv6u4wlkjcssto7f22nu)

✓ This is the authoritative definition for this NSID.

## Links

- [View on Lexicon Garden](https://lexicon.garden/lexicon/did:plc:4x5dcv6u4wlkjcssto7f22nu/com.atiproto.repo.subscription.count)
- [Documentation](https://lexicon.garden/lexicon/did:plc:4x5dcv6u4wlkjcssto7f22nu/com.atiproto.repo.subscription.count/docs)
- [Examples](https://lexicon.garden/lexicon/did:plc:4x5dcv6u4wlkjcssto7f22nu/com.atiproto.repo.subscription.count/examples)

## Definitions

### `com.atiproto.repo.subscription.count`

**Type**: `query`

Count active subscriptions. If subject is provided, counts subscriptions received by that DID. If omitted, counts subscriptions the authenticated user has active (as the subscriber). Optionally filtered by a start/end datetime window (matching billingStartDate). When the authenticated user is the subject/owner of the target, the response also includes the sum of amounts.

#### Parameters

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `endDate` | `string` (datetime) | No | Only count subscriptions whose billingStartDate is at or before this timestamp |
| `subject` | `string` (did) | No | DID of the user being subscribed to. If omitted, the query counts subscriptions the authenticated user has active as the subscriber. |
| `startDate` | `string` (datetime) | No | Only count subscriptions whose billingStartDate is at or after this timestamp |

#### Output

**Encoding**: `application/json`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `count` | `integer` | Yes | Number of active subscriptions matching the filter |
| `amount` | `integer` | No | Sum of all subscription amounts in cents. Only returned when the authenticated user is the subject/owner of the target (or when counting their own active subscriptions). |
| `currency` | `string` | No | Currency of the summed amount. Only returned when the authenticated user is the subject/owner of the target (or when counting their own active subscriptions). |

## Raw Schema

```json
{
  "id": "com.atiproto.repo.subscription.count",
  "defs": {
    "main": {
      "type": "query",
      "output": {
        "schema": {
          "type": "object",
          "required": [
            "count"
          ],
          "properties": {
            "count": {
              "type": "integer",
              "description": "Number of active subscriptions matching the filter"
            },
            "amount": {
              "type": "integer",
              "description": "Sum of all subscription amounts in cents. Only returned when the authenticated user is the subject/owner of the target (or when counting their own active subscriptions)."
            },
            "currency": {
              "type": "string",
              "maxLength": 3,
              "description": "Currency of the summed amount. Only returned when the authenticated user is the subject/owner of the target (or when counting their own active subscriptions)."
            }
          }
        },
        "encoding": "application/json"
      },
      "parameters": {
        "type": "params",
        "properties": {
          "endDate": {
            "type": "string",
            "format": "datetime",
            "description": "Only count subscriptions whose billingStartDate is at or before this timestamp"
          },
          "subject": {
            "type": "string",
            "format": "did",
            "description": "DID of the user being subscribed to. If omitted, the query counts subscriptions the authenticated user has active as the subscriber."
          },
          "startDate": {
            "type": "string",
            "format": "datetime",
            "description": "Only count subscriptions whose billingStartDate is at or after this timestamp"
          }
        }
      },
      "description": "Count active subscriptions. If subject is provided, counts subscriptions received by that DID. If omitted, counts subscriptions the authenticated user has active (as the subscriber). Optionally filtered by a start/end datetime window (matching billingStartDate). When the authenticated user is the subject/owner of the target, the response also includes the sum of amounts."
    }
  },
  "$type": "com.atproto.lexicon.schema",
  "lexicon": 1
}
```
