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

> ## Agent Instructions
> Use Stable documentation by default. Honor an explicit Beta request or a URL under /docs/beta/. If the requested version conflicts with the installed CLI package or API origin, clarify the target before writing integration code.
> Pages under /docs/beta/ document Beta; other product pages document Stable. Keep the CLI package, commands, API origin, and credentials within the selected version. State the documentation version in your answer.
> For MCP search, always pass version: Stable or version: Beta. Unfiltered search mixes both versions. For filesystem reads, keep Beta queries under /beta/ and exclude /beta/ from Stable queries; discover paths before reading them.
> The public docs base is https://photon.codes/docs. Convert MCP page paths to public URLs under that base, preserving /beta/ when present. Read https://photon.codes/docs/skill.md for version selection and https://photon.codes/docs/llms.txt for the version indexes.

# Count Messages

> Count Messages: countMessages in the TypeScript, Python, Rust and Go clients.

`GET /v1/projects/{id}/messages/count`

Counts matching Messages before pagination. Delivery updates do not add Messages; results are eventually consistent.

**TypeScript**

```typescript TypeScript theme={null}
photon.projects.countMessages(input: CountMessagesInput, options?: RequestOptions): Promise<CountMessagesOutput>
```

**Python**

```python Python theme={null}
photon.projects.count_messages(input: CountMessagesInput) -> models.CountMessagesResponse
```

**Rust**

```rust Rust theme={null}
client.count_messages(id: String, params: Option<CountMessagesParams>).await -> Result<ResponseValue<types::CountMessagesResponse>, Error<CountMessagesError>>
```

**Go**

```go Go theme={null}
client.Projects.CountMessages(ctx context.Context, params *CountMessagesParams, opts ...RequestOption) (*CountMessagesResponse, error)
```

```typescript TypeScript theme={null}
import { Photon } from "@photon-ai/api";

const photon = new Photon({
  headers: { Authorization: `Bearer ${process.env.PHOTON_API_TOKEN}` },
});
const result = await photon.projects.countMessages({
  path: {
    id: "id",
  },
});
```

```python Python theme={null}
import os

from photon_api import Photon
from photon_api.rpc_generated import CountMessagesInput

photon = Photon(headers={"Authorization": f"Bearer {os.environ['PHOTON_API_TOKEN']}"})
result = photon.projects.count_messages(
    CountMessagesInput.model_validate({
        "path": {
            "id": "id",
        },
    })
)
```

```rust Rust theme={null}
use photon_ai_api::{Credential, PhotonClientBuilder, SecretString};

let token = std::env::var("PHOTON_API_TOKEN")?;
let client = PhotonClientBuilder::new()
    .credential("accountServiceKey", Credential::Bearer(SecretString::from(token)))
    .build()?;
let result = client
    .count_messages("id".to_owned(), None)
    .await
    .map_err(|error| format!("{error:?}"))?
    .into_inner();
```

```go Go theme={null}
import (
	"context"
	"os"

	photonapi "github.com/photon-hq/api/packages/go"
)

ctx := context.Background()
client := photonapi.NewClient(photonapi.WithAPIKey(os.Getenv("PHOTON_API_TOKEN")))
result, err := client.Projects.CountMessages(ctx, &photonapi.CountMessagesParams{
	ID: "id",
})
if err != nil {
	return err
}
_ = result
```

```json 200 theme={null}
{
  "count": 0,
  "groups": [
    {
      "count": 0,
      "status": "received"
    }
  ]
}
```

## Parameters

**id** `string` *required*

**createdBefore** `string (date-time)`

Exclusive upper bound on createdAt, RFC 3339. Cannot combine with updatedAt bounds.

**createdSince** `string (date-time)`

Inclusive lower bound on createdAt, RFC 3339. Cannot combine with updatedAt bounds.

**direction** `MessageDirection`

Message origin: received or dispatched, including later delivery outcomes

**excludeContentTypes** `string`

Comma-separated content types to exclude from resource-scoped Message lists and counts. Requires resourceId. A group is excluded when group is selected or all of its parts are excluded; retained Messages are unchanged. Supported values: attachment, group, message.delete, message.read, poll, poll.update, poll.vote, reaction, space.participants.update, space.typing.update, text, text.update, voice.

**perspectiveUserId** `string`

Selects this User's sent or received Messages. Requires spaceId; cannot combine with resourceId.

**platform** `Platform`

Restricts the page to one platform

**resourceId** `string`

Resource associated with the Message when sent or received. Can combine with spaceId, but not perspectiveUserId.

**spaceId** `string`

Requires resourceId or perspectiveUserId. User perspectives use created\_at order and exclude time bounds and platform filters.

**updatedBefore** `string (date-time)`

Exclusive upper bound on updatedAt, RFC 3339. Cannot combine with createdAt bounds.

**updatedSince** `string (date-time)`

Inclusive lower bound on updatedAt, RFC 3339. Cannot combine with createdAt bounds.

**interval** `"day"`

Calendar-day counts by Message.createdAt

**timeZone** `string`

IANA zone for calendar-day buckets; defaults to UTC; requires interval

## Returns

**`200`** Matching Message count, optional direction groups and daily buckets CountMessagesResponse

**One of: MessageCount**

**count** `integer` *required*

**groups** `array of MessageStatusCount` *required*

**One of: DailyMessageCount**

**buckets** `array of MessageCountBucket` *required*

**count** `integer` *required*

**groups** `array of MessageStatusCount` *required*

**interval** `"day"` *required*

**timeZone** `string` *required*


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