# How to pass date in Elastic co billing API

**URL:** <https://discuss.elastic.co/t/how-to-pass-date-in-elastic-co-billing-api/281376>\
**Category:** Elasticsearch\
**Created:** [August 13, 2021, 3:03pm UTC](https://discuss.elastic.co/t/how-to-pass-date-in-elastic-co-billing-api/281376 "2021-08-13T15:03:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Divyank\_Mahalle](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/divyank_mahalle/32/91240_2.png) [@Divyank\_Mahalle](https://discuss.elastic.co/u/Divyank_Mahalle)\
**Post date:** [August 13, 2021, 3:03pm UTC](https://discuss.elastic.co/t/how-to-pass-date-in-elastic-co-billing-api/281376/1 "2021-08-13T15:03:44Z")

</div>

Hi,  
I have generate API key and I am getting data for current month by default using the curl command.  
I am checking for some format how to add dates in api to retrieve data for last 3 months.  
I checked documentation but didn't found any example using dates.

```auto
curl -XGET https://api.elastic-cloud.com/api/v1/billing/costs/<organization_id> \
-H "Authorization: ApiKey <yourapikey>"

```

> Query parameters

| 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. Note: there is currently a three-month maximum date range. |
| `to` | `string` | N | A datetime for the end of the desired range for which to fetch costs. Defaults to end of current month. Note: there is currently a three-month maximum date range. |

[https://www.elastic.co/guide/en/cloud/current/Billing\_Costs\_Analysis.html#Billing\_Costs\_Analysis](https://www.elastic.co/guide/en/cloud/current/Billing_Costs_Analysis.html#Billing_Costs_Analysis)

---

<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:** [August 13, 2021, 3:23pm UTC](https://discuss.elastic.co/t/how-to-pass-date-in-elastic-co-billing-api/281376/2 "2021-08-13T15:23:00Z")

</div>

`curl -XGET "https://api.elastic-cloud.com/api/v1/billing/costs/4212746406/deployments?from=2021-07-01&to=2021-08-01" -H "Authorization: ApiKey $EC_API_KEY"`

Not the Times are UTC  
Note the quotes around the URL etc syntax is key.

Here specify detailed Date with Time

`curl -XGET "https://api.elastic-cloud.com/api/v1/billing/costs/4212746406/deployments?from=2021-07-01T00:00:00.000Z&to=2021-08-01T00:00:00.000Z" -H "Authorization: ApiKey $EC_API_KEY"`

This is a valid Date

`2021-08-01`

This is a valid Date-Time

`2021-08-01T00:00:00.000Z`

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 10, 2021, 3:23pm UTC](https://discuss.elastic.co/t/how-to-pass-date-in-elastic-co-billing-api/281376/3 "2021-09-10T15:23:11Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
