# What does /api/v1/users-doc-count represent?

**URL:** <https://forum.communityhealthtoolkit.org/t/what-does-api-v1-users-doc-count-represent/2893>\
**Category:** Technical Support\
**Tags:** api, replication\
**Created:** [July 10, 2023, 6:17pm UTC](https://forum.communityhealthtoolkit.org/t/what-does-api-v1-users-doc-count-represent/2893 "2023-07-10T18:17:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![michael](https://communityhealthtoolkit.b-cdn.net/user_avatar/forum.communityhealthtoolkit.org/michael/32/319_2.png) [@michael](https://forum.communityhealthtoolkit.org/u/michael)\
**Post date:** [July 10, 2023, 6:17pm UTC](https://forum.communityhealthtoolkit.org/t/what-does-api-v1-users-doc-count-represent/2893/1 "2023-07-10T18:17:54Z")

</div>

The [documentation](https://docs.communityhealthtoolkit.org/apps/reference/api/#get-apiv1users-doc-count) for this endpoint says that it returns the “quantity of documents replicated by the given user”.

The sample JSON looks like this:

```auto
{
    "limit": 10000,
    "users": {
        "_id": "replication-count-mary",
        "_rev": "5-cd3252e852ae075da216c3c3fe461291",
        "user": "mary",
        "date": 1595328973273,
        "count": 58
    }
}

```

I have a few questions about this:

1. I often use the words “replication” and “sync” interchangeably, is there actually a difference?
2. Does the `date` property represent the **most recent** date that this user replicated or is it the date that the API call was made?
3. Does the `58` in the example above represent **total doc count** for the user (as the name `users-doc-count` suggests) or just **changes**?
4. _If it represents just changes_, is it the sum total of local (device) and remote (server) changes?
5. _If it represents total doc count_, is there a reason we describe it as “documents replicated” (my assumption is that we do not replicate 100% of a user’s documents every time they sync)?
6. I’m assuming this is stored as a document in a database (as opposed to being calculated on the fly), if so, which database is it in?

cc: @binod

---

<div class="post-metadata">

**Author:** ![diana](https://communityhealthtoolkit.b-cdn.net/user_avatar/forum.communityhealthtoolkit.org/diana/32/2049_2.png) [@diana](https://forum.communityhealthtoolkit.org/u/diana)\
**Post date:** [July 10, 2023, 7:30pm UTC](https://forum.communityhealthtoolkit.org/t/what-does-api-v1-users-doc-count-represent/2893/2 "2023-07-10T19:30:37Z")

</div>

Hi @michael

Thanks for the question!

1. Replication and sync are the same thing.  
However, I’ve seen the term `replication` used when referring to initial-replication, and the term sync when referring to the replication that happens after first login.
2. The `date` is when the entry was created. It is not necessarily the most recent replication date. (there are some criteria for updating this doc).
3. 58 is the total doc count
4. I think that `documents replicated` can be ambiguous. This number represents a “payload” that the server needs to support for this user to get the necessary changes.
5. These docs are stored in `medic-logs` database.

---

<div class="post-metadata">

**Author:** ![michael](https://communityhealthtoolkit.b-cdn.net/user_avatar/forum.communityhealthtoolkit.org/michael/32/319_2.png) [@michael](https://forum.communityhealthtoolkit.org/u/michael)\
**Post date:** [July 10, 2023, 8:06pm UTC](https://forum.communityhealthtoolkit.org/t/what-does-api-v1-users-doc-count-represent/2893/3 "2023-07-10T20:06:49Z")

</div>

Thanks! Another follow-up question…

> [@diana](#):
>
> 58 is the total doc count

I assume this represents the number “on the device”… so if a user has 10,000 total docs, and 2,500 have already been purged (_so only 7,500 are on the device_), the `count` will be 7,500. Is that correct?

---

<div class="post-metadata">

**Author:** ![diana](https://communityhealthtoolkit.b-cdn.net/user_avatar/forum.communityhealthtoolkit.org/diana/32/2049_2.png) [@diana](https://forum.communityhealthtoolkit.org/u/diana)\
**Post date:** [July 10, 2023, 9:46pm UTC](https://forum.communityhealthtoolkit.org/t/what-does-api-v1-users-doc-count-represent/2893/4 "2023-07-10T21:46:17Z")

</div>

This is correct. purged docs are not part of this number.
