---
title: "POST /store/count"
method: POST
path: "/store/count"
---

# POST /store/count

`POST /store/count`

Count the number of documents in a collection that match a specified query. This endpoint is useful for pagination, analytics, and understanding the size of your dataset.

## Headers

- `X-DITTO-TXN-ID` integer

## Request body

- CountRequest — Request parameters for counting documents in a collection. Use this to get the total number of documents matching specific criteria.
  - `args` unknown
  - `collection` string, required — The name of the collection to count documents in
  - `query` string, required — A query expression that filters which documents to count. Use parameterized values with :param syntax for better security and performance

## Response `200`

The count operation completed successfully. Returns the total number of matching documents and the transaction ID of the operation.

- CountResponse — Response from a count operation, providing both the count and transaction ID for consistency tracking.
  - `count` integer, required — The total number of documents that matched the query criteria
  - `txnId` integer, required — The transaction ID at which this count was performed, useful for consistency checks

## Other responses

- `400` — The request was malformed. This typically indicates an invalid query syntax, unknown collection, or invalid parameters. Check the error message for specific details.
- `401` — Authentication failed. Ensure you're providing a valid API key or JWT token in the Authorization header.
- `500` — An unexpected error occurred on the server. This could indicate a temporary service disruption or internal error. Retry the request after a brief delay.

---

[API](https://skmtc.dev/ditto/apis/ditto-http-rpc-api.md) · [All operations](https://skmtc.dev/ditto/apis/ditto-http-rpc-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/ditto/ditto-http-rpc-api/revisions/0f6d8b15f32d/schema)
