# Method: indexing.datasources.items.poll

- [HTTP request](https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/indexing.datasources.items/poll#body.HTTP_TEMPLATE)
- [Path parameters](https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/indexing.datasources.items/poll#body.PATH_PARAMETERS)
- [Request body](https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/indexing.datasources.items/poll#body.request_body)
  - [JSON representation](https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/indexing.datasources.items/poll#body.request_body.SCHEMA_REPRESENTATION)
- [Response body](https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/indexing.datasources.items/poll#body.response_body)
  - [JSON representation](https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/indexing.datasources.items/poll#body.PollItemsResponse.SCHEMA_REPRESENTATION)
- [Authorization scopes](https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/indexing.datasources.items/poll#body.aspect)
- [Try it!](https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/indexing.datasources.items/poll#try-it)

Polls for unreserved items from the indexing queue and marks a set as reserved, starting with items that have the oldest timestamp from the highest priority `https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/ItemStatus.Code`. The priority order is as follows:

`https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/ItemStatus.Code#ENUM_VALUES.ERROR`

`https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/ItemStatus.Code#ENUM_VALUES.MODIFIED`

`https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/ItemStatus.Code#ENUM_VALUES.NEW_ITEM`

`https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/ItemStatus.Code#ENUM_VALUES.ACCEPTED`

Reserving items ensures that polling from other threads cannot create overlapping sets.

After handling the reserved items, the client should put items back into the unreserved state, either by calling `https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/indexing.datasources.items/index_#google.apps.search.v1.ItemsService.IndexItem` or by calling `https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/indexing.datasources.items/push#google.apps.search.v1.ItemsService.PushItem` with the type `https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/indexing.datasources.items/push#PushItem.Type.ENUM_VALUES.REQUEUE`

Items automatically become available (unreserved) after 4 hours even if no update or push method is called.

This API requires an admin or service account to execute. The service account used is the one whitelisted in the corresponding data source.

### HTTP request

`POST https://cloudsearch.googleapis.com/v1/indexing/{name=datasources/*}/items:poll`

The URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.

### Path parameters

| Parameters ||
|---|---|
| `name` | `string` The name of the data Source to poll items. Format: datasources/{sourceId} |

### Request body

The request body contains data with the following structure:

| JSON representation |
|---|
| ``` { "connectorName": string, "statusCodes": [ enum (`https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/ItemStatus.Code`) ], "limit": integer, "queue": string, "debugOptions": { object (`https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/DebugOptions`) } } ``` |

| Fields ||
|---|---|
| `connectorName` | `string` The name of connector making this call. Format: datasources/{sourceId}/connectors/{id} |
| `statusCodes[]` | ``enum (`https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/ItemStatus.Code`)`` Limit the items polled to the ones with these statuses. |
| `limit` | `integer` Maximum number of items to return. The maximum value is 100 and the default value is 20. |
| `queue` | `string` Queue name to fetch items from. If unspecified, items.poll will fetch from 'default' queue. The maximum length is 100 characters. |
| `debugOptions` | ``object (`https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/DebugOptions`)`` Common debug options. |

### Response body

If successful, the response body contains data with the following structure:

| JSON representation |
|---|
| ``` { "items": [ { object (`https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/indexing.datasources.items#Item`) } ] } ``` |

| Fields ||
|---|---|
| `items[]` | ``object (`https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/indexing.datasources.items#Item`)`` Set of items from the queue available for connector to process. These items have the following subset of fields populated: `https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/indexing.datasources.items#Item.FIELDS.version` `https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/indexing.datasources.items#ItemMetadata.FIELDS.hash` `https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/indexing.datasources.items#ItemStructuredData.FIELDS.hash` `https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/indexing.datasources.items#ItemContent.FIELDS.hash` `https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/indexing.datasources.items#Item.FIELDS.payload` `https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/indexing.datasources.items#Item.FIELDS.status` `https://developers.google.com/workspace/cloud-search/docs/reference/rest/v1/indexing.datasources.items#Item.FIELDS.queue` |

### Authorization scopes

Requires one of the following OAuth scopes:

- `https://www.googleapis.com/auth/cloud_search.indexing`
- `https://www.googleapis.com/auth/cloud_search`

For more information, see the [Authorization guide](https://developers.google.com/workspace/guides/configure-oauth-consent).