# Discrepancy in Cost Data Between Billing API and Elastic Cloud Console

**URL:** <https://discuss.elastic.co/t/discrepancy-in-cost-data-between-billing-api-and-elastic-cloud-console/363656>\
**Category:** Elasticsearch\
**Created:** [July 23, 2024, 7:00pm UTC](https://discuss.elastic.co/t/discrepancy-in-cost-data-between-billing-api-and-elastic-cloud-console/363656 "2024-07-23T19:00:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ampdd235](https://avatars.discourse-cdn.com/v4/letter/a/8baadc/32.png) [@ampdd235](https://discuss.elastic.co/u/ampdd235)\
**Post date:** [July 23, 2024, 7:00pm UTC](https://discuss.elastic.co/t/discrepancy-in-cost-data-between-billing-api-and-elastic-cloud-console/363656/1 "2024-07-23T19:00:39Z")

</div>

Hi Elastic Community,

I'm trying to understand how the Billing Endpoint works in Elastic Cloud. Specifically, I'm using the [/costs/\<ORG\_ID\>/items](https://www.elastic.co/guide/en/cloud/current/Billing_Costs_Analysis.html#ec_request_16) endpoint to retrieve cost data, but the totals I'm getting from the API do not match the costs displayed in my Elastic Cloud Console.  
I've ensured I'm querying the API for the same time range as displayed in the console.

I've referred to the documentation here: [Elastic Cloud Billing Costs Analysis](https://www.elastic.co/guide/en/cloud/current/Billing_Costs_Analysis.html#get-costs-items-by-deployment), but I'm still unclear on a few things:

- Why might there be a discrepancy between the totals from the API and the console?
- Are there any hidden costs that are not reflected in the `billing` API?
- Are there other endpoints I need to query to get the complete or correct total cost?
- How should I aggregate the data to match the totals shown in the Elastic Cloud Console?

Here is the response from the following curl request:

`curl -XGET https://api.elastic-cloud.com/api/v1/billing/costs/ORG_ID/items -H "Authorization: ApiKey API_TOKEN`

```auto
"costs": {
        "total": 2.2557, 
        "dimensions": [
            {
                "cost": 2.2269, 
                "type": "capacity"
            }, 
            {
                "cost": 0.0, 
                "type": "data_in"
            }, 
            {
                "cost": 0.0283, 
                "type": "data_internode"
            }, 
            {
                "cost": 0.0005, 
                "type": "data_out"
            }, 
            {
                "cost": 0.0, 
                "type": "storage_api"
            }, 
            {
                "cost": 0.0, 
                "type": "storage_bytes"
            }
        ]
    }, 
  "resources": [...]
 "data_transfer_and_storage": [...]

```

Here's the billing detail for test deployments in our console:

 ![](https://us1.discourse-cdn.com/elastic/original/3X/5/5/550b5520f5045342dab1862c466890b5e38b1926.png)

I've tried adjusting the query parameters to specify a time range, and am still not able to get accurate data.

We'd like to better understand what costs the specified API is returning and if we're missing any endpoints.

Thanks in advance for your help, it's greatly appreciated!

---

<div class="post-metadata">

**Author:** ![ampdd235](https://avatars.discourse-cdn.com/v4/letter/a/8baadc/32.png) [@ampdd235](https://discuss.elastic.co/u/ampdd235)\
**Post date:** [July 29, 2024, 3:00pm UTC](https://discuss.elastic.co/t/discrepancy-in-cost-data-between-billing-api-and-elastic-cloud-console/363656/2 "2024-07-29T15:00:28Z")

</div>

Removed #elastic-cloud

---

<div class="post-metadata">

**Author:** ![ampdd235](https://avatars.discourse-cdn.com/v4/letter/a/8baadc/32.png) [@ampdd235](https://discuss.elastic.co/u/ampdd235)\
**Post date:** [July 29, 2024, 3:04pm UTC](https://discuss.elastic.co/t/discrepancy-in-cost-data-between-billing-api-and-elastic-cloud-console/363656/3 "2024-07-29T15:04:58Z")

</div>

Removed #elastic-cloud

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [July 29, 2024, 5:37pm UTC](https://discuss.elastic.co/t/discrepancy-in-cost-data-between-billing-api-and-elastic-cloud-console/363656/4 "2024-07-29T17:37:31Z")

</div>

Hi @ampdd235 Welcome to the community

2 things are probably contributing to this

- Yes most likely you are not using the same time frames
- The Cloud console is not going to be 100% exactly the same as the Billing API for various internal reasons, but they should be very close...

Example I look at my usage from the Console from 07/01/24 to 07/28/24 those dates are inclusive

 ![Screenshot 2024-07-29 at 10.27.56 AM](https://us1.discourse-cdn.com/elastic/original/3X/2/3/233163efbf4fddd7bc17abd6a16b717c911b4b82.png)

 ![Screenshot 2024-07-29 at 10.28.06 AM](https://us1.discourse-cdn.com/elastic/original/3X/a/8/a89cf97b89b2a8b6fdcc7275003d36d7b2169f25.png)

`$3,146.58`

Then the curl ....

`curl -H "Authorization: ApiKey $EC_API_KEY" -X GET 'https://api.elastic-cloud.com/api/v1/billing/costs/<org_id>?from=2024-07-01T00:00:00Z&to=2024-07-29T00:00:00Z'`

And the return shows...

```auto
{
    "trials": 0.0, 
    "costs": {
        "total": 3147.5603, << Total 
        "dimensions": [
            {
                "cost": 2672.8862, 
                "type": "capacity"
            }, 
...

```

The difference is ~$1 or ~0.03% different which is reasonable / expected...

Try using my approach and perhaps they will align better

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `from` | `string` | N | A datetime for the beginning of the desired range for which to fetch costs. Defaults to start of current month. |
| `to` | `string` | N | A datetime for the end of the desired range for which to fetch costs. Defaults to the current date. |

---

<div class="post-metadata">

**Author:** ![ampdd235](https://avatars.discourse-cdn.com/v4/letter/a/8baadc/32.png) [@ampdd235](https://discuss.elastic.co/u/ampdd235)\
**Post date:** [July 29, 2024, 5:43pm UTC](https://discuss.elastic.co/t/discrepancy-in-cost-data-between-billing-api-and-elastic-cloud-console/363656/5 "2024-07-29T17:43:42Z")

</div>

Ah, this makes sense! Thank you so much for all of your help! We appreciate your response!
