# Selection API

Use the Selection API to manage entity selections across selection pools.
{% admonition type="info" name="Note" %}The maximum selection limit is 5000 entities. This limit is configurable through `CONTENT.SelectionPoolDefinition.MaxSelection`.{% /admonition %}
## Authentication
To use this API, you need:
- The URL of your Content Hub server. You can get this from your Content Hub Administrator. Enter this URL in the <b>{{server}}</b> variable by hovering your mouse over the variable in the <b>Try it</b> pane and then clicking <b>Edit</b>.
- An access token and the client ID. Both are sent with every request. You  can create a token through the [Content Hub interface](https://doc.sitecore.com/ch/en/users/content-hub/create-an-oauth-client.html)  or by [requesting one using the API itself](https://doc.sitecore.com/ch/en/developers/cloud-dev/oauth-tokens.html#grant-flows).

Version: v1.0
License: closed source
Metadata:
  - product: Content Hub

## Servers

```
https://{server}
```

Variables:
- `server`
Default: "your-server"

## Security

### OAuth2.0

Type: oauth2

## Download OpenAPI description

[Selection API](https://api-docs.sitecore.com/_bundle/ch/selection-api/index.yaml)

## Selection

The Selection API lets you list, add, and remove entities from a selection.

### Retrieve a selection by pool and definition

 - [GET /api/selection/{selectionPool}/{definitionName}](https://api-docs.sitecore.com/ch/selection-api/selection/getselection.md): Retrieves selection items for a given selection pool.

{% admonition type="info" name="Note" %}
At least one of the following must be provided. If both are provided, the route parameter takes precedence:
- definitionName (route parameter) - single definition name.
- definitionNames (query parameter) - comma-separated list of definition names; for example, GET /api/selection/AssetSelectionPool?definitionNames=M.Asset,M.Content. 
{% /admonition %}

### Clear a selection for a definition

 - [DELETE /api/selection/{selectionPool}/{definitionName}](https://api-docs.sitecore.com/ch/selection-api/selection/clearselection.md): Removes all the entities for a specific definition from the selection. It does not delete the selection pool itself and does not affect other definitions in the same pool or other sub-pools.

### Create a selection

 - [POST /api/selection](https://api-docs.sitecore.com/ch/selection-api/selection/createselection.md): Creates a selection using one of the following modes:

- Mode 1 Direct Entity IDs - use this mode when you know the specific entity IDs to add.
- Mode 2 Query-Based Selection - use this mode to select entities based on search criteria. The system executes the query and adds matching entities. 

Query types are case-insensitive (for example, BASIC, basic, Basic). You can create queries that include various parameters.

{% admonition type="info" name="Note" %}If values is provided and non-empty, it takes precedence and query is ignored.{% /admonition %}

### Update a selection

 - [PATCH /api/selection](https://api-docs.sitecore.com/ch/selection-api/selection/updateselection.md): Add or remove entities from a selection. {% admonition type="info" name="Note" %} This request can contain multiple commands and is used both to add and to remove entities from a selection using the PATCH object. {% /admonition %}

