# Date breakdown

To perform a date breakdown query on the order resource send a `POST` request to the `/orders/date_breakdown` endpoint specifying in the payload the [query keys](#query-keys) and [filter](/metrics-api-reference/resources/orders/filters.md) parameters like in the generic example below:

```json
{
  "date_breakdown": {
    "by": "...",
    "field": "...",
    "operator": "...",
    "interval": "...",
    "breakdown": {
      "by": "...",
      "field": "...",
      "operator": "...",
      "condition": { ... },
      "sort": "...",
      "limit": ...,
      "breakdown": {
        "by": "...",
        "field": "...",
        "operator": "...",
        "condition": { ... },
        "sort": "...",
        "limit": ...
      }
    }
  },
  "filter": { ... }
}
```

{% hint style="info" %}
Please find more information on how date breakdown queries work [here](/metrics/getting-started/queries/date-breakdown.md).
{% endhint %}

### Query keys

These are the keys you need to set when performing a date breakdown query:

<table><thead><tr><th>Key</th><th>Type</th><th data-type="checkbox">Required</th><th>Description</th><th>Values</th></tr></thead><tbody><tr><td><strong><code>by</code></strong></td><td>String</td><td>true</td><td>The date field you want the results of the query aggragated by.</td><td>See the <a href="#by-values">related table</a> to check the full list of valid values for this key.</td></tr><tr><td><strong><code>field</code></strong></td><td>String</td><td>true</td><td>The field you want the metrics or statistics computed on.</td><td>See the <a href="#operators-and-field-values">related table</a> to check the full list of valid values for this key.</td></tr><tr><td><strong><code>operator</code></strong></td><td>String</td><td>true</td><td>The computing operator.</td><td>See the <a href="#operators-and-field-values">related table</a> to check the full list of valid operators based on the value you assigned to the <code>field</code> key.</td></tr><tr><td><strong><code>interval</code></strong></td><td>String</td><td>false</td><td>The time interval over which the metrics / stats are computed. The results will be aggregated by date accordingly.</td><td>One of <code>hour</code>, <code>day</code>, <code>week</code>, <code>month</code>, or <code>year</code> (default is <code>month</code>).</td></tr><tr><td><strong><code>breakdown</code></strong></td><td>Object</td><td>false</td><td>The optional breakdown (eventually nested).</td><td>See the <a href="/pages/FDxerOlRUkZ831rBgsOe">related section</a> for any information about the breakdown query.</td></tr></tbody></table>

### `by` values

These are the valid values you can specify for the `by` key of the date breakdown query:

| Value                              | Description                                                                                                                                                                                                          |
| ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`order.approved_at`**            | The date and time at which the order was approved (complete date plus hours, minutes and seconds — according to the [ISO 8601](https://www.w3.org/TR/NOTE-datetime) standard).                                       |
| **`order.archived_at`**            | The date and time at which the order was archived (complete date plus hours, minutes and seconds — according to the [ISO 8601](https://www.w3.org/TR/NOTE-datetime) standard).                                       |
| **`order.cancelled_at`**           | The date and time at which the order was cancelled (complete date plus hours, minutes and seconds — according to the [ISO 8601](https://www.w3.org/TR/NOTE-datetime) standard).                                      |
| **`order.created_at`**             | The date and time at which the order was created (complete date plus hours, minutes and seconds — according to the [ISO 8601](https://www.w3.org/TR/NOTE-datetime) standard).                                        |
| **`order.fulfillment_updated_at`** | The date and time at which the order's fulfillment status was last updated (complete date plus hours, minutes and seconds — according to the [ISO 8601](https://www.w3.org/TR/NOTE-datetime) standard).              |
| **`order.payment_updated_at`**     | The date and time at which the order's payment status was last updated (complete date plus hours, minutes and seconds — according to the [ISO 8601](https://www.w3.org/TR/NOTE-datetime) standard).                  |
| **`order.placed_at`**              | The date and time at which the order was placed (complete date plus hours, minutes and seconds — according to the [ISO 8601](https://www.w3.org/TR/NOTE-datetime) standard).                                         |
| **`order.updated_at`**             | The date and time at which the order was last updated (complete date plus hours, minutes and seconds — according to the [ISO 8601](https://www.w3.org/TR/NOTE-datetime) standard).                                   |
| **`order.current_date`**           | The date and time of the order's latest status change, regardless of the order's status (complete date plus hours, minutes and seconds — according to the [ISO 8601](https://www.w3.org/TR/NOTE-datetime) standard). |
| **`shipments.cancelled_at`**       | The date and time at which the shipment status was cancelled (complete date plus hours, minutes and seconds — according to the [ISO 8601](https://www.w3.org/TR/NOTE-datetime) standard).                            |
| **`shipments.delivered_at`**       | The date and time at which the shipment was delivered (complete date plus hours, minutes and seconds — according to the [ISO 8601](https://www.w3.org/TR/NOTE-datetime) standard).                                   |
| **`shipments.on_hold_at`**         | The date and time at which the shipment status was put on hold (complete date plus hours, minutes and seconds — according to the [ISO 8601](https://www.w3.org/TR/NOTE-datetime) standard).                          |
| **`shipments.picking_at`**         | The date and time at which the shipment was picked (complete date plus hours, minutes and seconds — according to the [ISO 8601](https://www.w3.org/TR/NOTE-datetime) standard).                                      |
| **`shipments.packing_at`**         | The date and time at which the shipment was packed (complete date plus hours, minutes and seconds — according to the [ISO 8601](https://www.w3.org/TR/NOTE-datetime) standard).                                      |
| **`shipments.ready_to_ship_at`**   | The date and time at which the shipment was ready to ship (complete date plus hours, minutes and seconds — according to the [ISO 8601](https://www.w3.org/TR/NOTE-datetime) standard).                               |
| **`shipments.shipped_at`**         | The date and time at which the shipment was shipped (complete date plus hours, minutes and seconds — according to the [ISO 8601](https://www.w3.org/TR/NOTE-datetime) standard).                                     |
| **`shipments.created_at`**         | The date and time at which the shipment was created (complete date plus hours, minutes and seconds — according to the [ISO 8601](https://www.w3.org/TR/NOTE-datetime) standard).                                     |
| **`shipments.updated_at`**         | The date and time at which the shipment was updated (complete date plus hours, minutes and seconds — according to the [ISO 8601](https://www.w3.org/TR/NOTE-datetime) standard).                                     |
| **`resource_errors.created_at`**   | The date and time at which the resource error was created (complete date plus hours, minutes and seconds — according to the [ISO 8601](https://www.w3.org/TR/NOTE-datetime) standard).                               |
| **`resource_errors.updated_at`**   | The date and time at which the resource error was updated (complete date plus hours, minutes and seconds — according to the [ISO 8601](https://www.w3.org/TR/NOTE-datetime) standard).                               |

### Operators and `field` values

These are the valid values you can specify for the `field` key of the date breakdown query and the related valid operators, based on that key:

| Value                                              | Operators                                                                                                                     |
| -------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| **`customer.id`**                                  | <p><code>cardinality</code></p><p><code>value\_count</code></p>                                                               |
| **`customer.email`**                               | <p><code>cardinality</code></p><p><code>value\_count</code></p>                                                               |
| **`customer.group_name`**                          | <p><code>cardinality</code></p><p><code>value\_count</code></p>                                                               |
| **`customer.reference`**                           | <p><code>cardinality</code></p><p><code>value\_count</code></p>                                                               |
| **`customer.reference_origin`**                    | <p><code>cardinality</code></p><p><code>value\_count</code></p>                                                               |
| **`line_items.code`**                              | <p><code>cardinality</code></p><p><code>value\_count</code></p>                                                               |
| **`line_items.discount`**                          | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`line_items.id`**                                | <p><code>cardinality</code></p><p><code>value\_count</code></p>                                                               |
| **`line_items.item_id`**                           | <p><code>cardinality</code></p><p><code>value\_count</code></p>                                                               |
| **`line_items.options_amount`**                    | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`line_items.quantity`**                          | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`line_items.tax_amount`**                        | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`line_items.tax_rate`**                          | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`line_items.total_amount`**                      | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`line_items.unit_amount`**                       | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`line_items.options.id`**                        | <p><code>cardinality</code></p><p><code>value\_count</code></p>                                                               |
| **`line_items.options.quantity`**                  | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`line_items.options.total_amount`**              | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`line_items.options.unit_amount`**               | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`market.id`**                                    | `cardinality`                                                                                                                 |
| **`market.number`**                                | <p><code>cardinality</code></p><p><code>value\_count</code></p>                                                               |
| **`order.adjustment_amount`**                      | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`order.adjustment_tax_amount`**                  | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`order.adjustment_taxable_amount`**              | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`order.discount_amount`**                        | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`order.duty_amount`**                            | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`order.gift_card_code`**                         | `value_count`                                                                                                                 |
| **`order.gift_card_amount`**                       | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`order.id`**                                     | <p><code>cardinality</code></p><p><code>value\_count</code></p>                                                               |
| **`order.line_item_options_count`**                | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`order.number`**                                 | `value_count`                                                                                                                 |
| **`order.payment_method_amount`**                  | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`order.payment_method_tax_amount`**              | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`order.payment_method_taxable_amount`**          | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`order.reference`**                              | <p><code>cardinality</code></p><p><code>value\_count</code></p>                                                               |
| **`order.reference_origin`**                       | <p><code>cardinality</code></p><p><code>value\_count</code></p>                                                               |
| **`order.shipments_count`**                        | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`order.shipping_amount`**                        | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`order.shipping_taxable_amount`**                | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`order.skus_count`**                             | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`order.subtotal_amount`**                        | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`order.subtotal_tax_amount`**                    | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`order.subtotal_taxable_amount`**                | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`order.total_amount`**                           | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`order.total_amount_with_taxes`**                | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`order.total_tax_amount`**                       | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`order.total_taxable_amount`**                   | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`order.seconds_in_draft`**                       | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>stats</code></p><p><code>percentiles</code></p> |
| **`order.seconds_in_approved`**                    | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>stats</code></p><p><code>percentiles</code></p> |
| **`order.seconds_in_placed`**                      | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>stats</code></p><p><code>percentiles</code></p> |
| **`order.refunds_total_amount_with_taxes`**        | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`order.total_amount_with_taxes_net_of_refunds`** | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`refunds.id`**                                   | `value_count`                                                                                                                 |
| **`refunds.amount`**                               | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>sum</code></p><p><code>stats</code></p>         |
| **`refunds.number`**                               | `value_count`                                                                                                                 |
| **`shipments.id`**                                 | <p><code>cardinality</code></p><p><code>value\_count</code></p>                                                               |
| **`shipments.number`**                             | <p><code>cardinality</code></p><p><code>value\_count</code></p>                                                               |
| **`shipments.items_count`**                        | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>stats</code></p><p><code>percentiles</code></p> |
| **`shipments.cost_amount`**                        | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>stats</code></p><p><code>percentiles</code></p> |
| **`shipments.reference`**                          | <p><code>cardinality</code></p><p><code>value\_count</code></p>                                                               |
| **`shipments.reference_origin`**                   | <p><code>cardinality</code></p><p><code>value\_count</code></p>                                                               |
| **`shipments.seconds_in_picking`**                 | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>stats</code></p><p><code>percentiles</code></p> |
| **`shipments.seconds_in_ready_to_ship`**           | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>stats</code></p><p><code>percentiles</code></p> |
| **`shipments.seconds_in_shipped`**                 | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>stats</code></p><p><code>percentiles</code></p> |
| **`shipments.fulfillment_time`**                   | <p><code>avg</code></p><p><code>max</code></p><p><code>min</code></p><p><code>stats</code></p><p><code>percentiles</code></p> |
| **`shipments.stock_location.id`**                  | <p><code>cardinality</code></p><p><code>value\_count</code></p>                                                               |
| **`shipments.stock_location.reference`**           | <p><code>cardinality</code></p><p><code>value\_count</code></p>                                                               |
| **`shipments.stock_location.reference_origin`**    | <p><code>cardinality</code></p><p><code>value\_count</code></p>                                                               |
| **`shipments.shipping_method.id`**                 | <p><code>cardinality</code></p><p><code>value\_count</code></p>                                                               |
| **`shipments.shipping_method.reference`**          | <p><code>cardinality</code></p><p><code>value\_count</code></p>                                                               |
| **`shipments.shipping_method.reference_origin`**   | <p><code>cardinality</code></p><p><code>value\_count</code></p>                                                               |
| **`shipments.shipping_category.id`**               | <p><code>cardinality</code></p><p><code>value\_count</code></p>                                                               |
| **`shipments.shipping_category.reference`**        | <p><code>cardinality</code></p><p><code>value\_count</code></p>                                                               |
| **`shipments.shipping_category.reference_origin`** | <p><code>cardinality</code></p><p><code>value\_count</code></p>                                                               |
| **`resource_errors.code`**                         | <p><code>cardinality</code></p><p><code>value\_count</code></p>                                                               |
| **`resource_errors.id`**                           | <p><code>cardinality</code></p><p><code>value\_count</code></p>                                                               |
| **`resource_errors.message`**                      | <p><code>cardinality</code></p><p><code>value\_count</code></p>                                                               |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.commercelayer.io/metrics-api-reference/resources/orders/date-breakdown.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
