---
title: "POST /indices/buckets"
method: POST
path: "/indices/buckets"
---

# POST /indices/buckets

`POST /indices/buckets`

Aggregates on indexed data with search queries pertaining to particular fields.

Requires permission to access the [GetBucketsAggregation](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions) action.

## Request body

- object
  - `indexName` string — The name of the index to search.
  - `queryString` string, required — The search query string.
  - `aggregationField` string, required — The aggregation field.
  - `queryVersion` string — The version of the query.
  - `bucketsAggregationType` object, required — The type of bucketed aggregation performed.
    - `termsAggregation` object — Performs an aggregation that will return a list of buckets. The list of buckets is a ranked list of the number of occurrences of an aggregation field value.
      - `maxBuckets` integer — The number of buckets to return in the response. Default to 10.

## Response `200`

Success

- GetBucketsAggregationResponse
  - `totalCount` integer — The total number of things that fit the query string criteria.
  - `buckets` Bucket[] — <p>The main part of the response with a list of buckets. Each bucket contains a <code>keyValue</code> and a <code>count</code>.</p> <p> <code>keyValue</code>: The aggregation field value counted for the particular bucket.</p> <p> <code>count</code>: The number of documents that have that value.</p>
    - `keyValue` string — The value counted for the particular bucket.
    - `count` integer — The number of documents that have the value counted for the particular bucket.

## Other responses

- `480` — InvalidRequestException
- `481` — ThrottlingException
- `482` — UnauthorizedException
- `483` — ServiceUnavailableException
- `484` — InternalFailureException
- `485` — ResourceNotFoundException
- `486` — InvalidQueryException
- `487` — InvalidAggregationException
- `488` — IndexNotReadyException

---

[API](https://skmtc.net/aws/apis/iot.md) · [All operations](https://skmtc.net/aws/apis/iot/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/aws/iot/revisions/deef5c4b09f0/schema)
