# Device payload count

**URL:** <https://forums.losant.com/t/device-payload-count/4248>\
**Category:** Help\
**Tags:** device-state\
**Created:** [December 2, 2021, 3:59pm UTC](https://forums.losant.com/t/device-payload-count/4248 "2021-12-02T15:59:46Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [December 2, 2021, 3:59pm UTC](https://forums.losant.com/t/device-payload-count/4248/1 "2021-12-02T15:59:47Z")

</div>

I know I can see current month payload count per Application, but is there a similar value I could see payload per device when selecting one of the applications? Or is something like this available via the API?

---

<div class="post-metadata">

**Author:** ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)\
**Post date:** [December 2, 2021, 4:03pm UTC](https://forums.losant.com/t/device-payload-count/4248/2 "2021-12-02T16:03:19Z")

</div>

We do allow for returning a given device’s payload counts for a time period through the API -

> **[Device Actions](https://docs.losant.com/rest-api/device/#payload-counts)**
>
> A detailed look at the various REST actions supported by the Device resource of the Losant API. Learn more.

However, this is not exposed in the Losant user interface. You’ll need to make an API request to get the data.

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [December 2, 2021, 4:52pm UTC](https://forums.losant.com/t/device-payload-count/4248/3 "2021-12-02T16:52:01Z")

</div>

Thanks ! that’s great.  
I used the API Workflow node and just added in the required email in the JSON template and received an email with the downloadable report right away! Is that the default functionality? That’s great!

When looking at the numbers in the report and comparing to what’s shown on the “Application Info/Usage” page, it doesn’t add up with what I see on the report. Is that maybe just a timing issue of when it’s generated or is there any good explanation of how it adds up?

---

<div class="post-metadata">

**Author:** ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)\
**Post date:** [December 2, 2021, 4:56pm UTC](https://forums.losant.com/t/device-payload-count/4248/4 "2021-12-02T16:56:15Z")

</div>

Can you please provide …

- The device report, along with the device ID (including time range)
- The application report, along with the application ID (including time range)
- What you are expecting the device report to reflect

These statistics are aggregated approximately every 15 minutes, so if there is a minor discrepancy, that may be the cause.

Note that what is included in the device payload count is …

- Connections to the MQTT broker
- Disconnections from the MQTT broker
- State reports
- Commands sent to the device
- Messages the device published to custom MQTT topics
- Messages the device received on custom MQTT topics it subscribed to

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [December 2, 2021, 4:56pm UTC](https://forums.losant.com/t/device-payload-count/4248/5 "2021-12-02T16:56:39Z")

</div>

The report showed this as below but Application info showed 688. Which combination of numbers do I add up?

 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/f/fd2b90032c7c8fd3092ff6e4e1385a7b5cc27ff2.png)

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [December 2, 2021, 4:57pm UTC](https://forums.losant.com/t/device-payload-count/4248/6 "2021-12-02T16:57:29Z")

</div>

Wait, I think I know. The default time range is a month, but Application info reset on 12/1. Sounds right?

---

<div class="post-metadata">

**Author:** ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)\
**Post date:** [December 2, 2021, 5:01pm UTC](https://forums.losant.com/t/device-payload-count/4248/7 "2021-12-02T17:01:36Z")

</div>

When using the API directly, both [device.payloadCounts](https://docs.losant.com/rest-api/device/#payload-counts) and [application.payloadCounts](https://docs.losant.com/rest-api/application/#payload-counts) defaults to:

- start: (now minus 30 days)
- end: (now)

In the Losant user interface, under the “Usage” tab, we set the time range to:

- start: (beginning of the current month)
- end: (end of the current month)

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [December 2, 2021, 5:35pm UTC](https://forums.losant.com/t/device-payload-count/4248/8 "2021-12-02T17:35:57Z")

</div>

ok, tried changing start and end time like this,  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/8/827c798ff7c1387c444f03af7dfdcc29f794b194.png)  
but debug message says this:  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/b/b7ebf7b0bcde2948e5dbc090e23502e9e1c3a759.png)

---

<div class="post-metadata">

**Author:** ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)\
**Post date:** [December 2, 2021, 6:38pm UTC](https://forums.losant.com/t/device-payload-count/4248/9 "2021-12-02T18:38:46Z")

</div>

This is in reference to the `payloadCounts` endpoints? Because …

- Those are both GET requests, thus they do not take a body
- Neither of those takes an `email` property
- `start` and `end` should be passed as query parameters - as in [https://api.losant.com/applications/APPLICATION\_ID/payloadCounts?start=-129600000&end=0](https://api.losant.com/applications/APPLICATION_ID/payloadCounts?start=-129600000&end=0)

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [December 2, 2021, 6:42pm UTC](https://forums.losant.com/t/device-payload-count/4248/10 "2021-12-02T18:42:34Z")

</div>

Yes, so I can not do this within a Losant API workflow node?

---

<div class="post-metadata">

**Author:** ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)\
**Post date:** [December 2, 2021, 7:39pm UTC](https://forums.losant.com/t/device-payload-count/4248/11 "2021-12-02T19:39:14Z")

</div>

Wait, are you using the [devices.payloadCounts](https://docs.losant.com/rest-api/devices/#payload-counts) endpoint (for returning payload counts for multiple devices)? To this point I’ve been assuming you’ve been using [device.payloadCounts](https://docs.losant.com/rest-api/device/#payload-counts) (for a single device) as that’s what I recommended originally.

Anyways, in that case, the schema for the request can be found [here](https://docs.losant.com/rest-api/schemas#devices-payload-count-export-post-schema), and per that schema, `start` and `end` should be at the top level of the request body – not inside a `query` object as you have it here. So it should be …

```json
{
  "email": "landersson@iotdiag.com",
  "start": -129600000,
  "end": 0
}

```

And you may know this already, but just to make sure … unlike the single-device endpoint, the multi-device endpoint kicks off an asynchronous task to calculate the payload counts and then returns that value to the email or callbackUrl you provide in the request. It _does not_ return the payload counts in the response body for the API request.
