> For the complete documentation index, see [llms.txt](https://docs.skeddly.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.skeddly.com/resources/managed-services/createmanagedservicesselector-method.md).

# CreateManagedServicesSelector Method

## Description

Creates a Managed Services Selector in a plan.

## HTTP Request

`POST https://api.skeddly.com/api/ManagedServices/Plans/<planId>/Selectors`

## URL Parameters

### planId

ID of the Managed Services Plan to that will contain the selector.

Type: `string`

Required: Yes

## Body

The body is a JSON structure with the following properties.

### credentialIds

Identifiers of the credentials used by the selector when matching resources.

Type: Array of `string`

Required: Yes

### groupIdComparisons

Group identifier comparisons used by the selector when matching resources. Only valid if `resourceType` is `azure-virtual-machine`.

Type: Array of [ManagedServicesGroupIdComparison](/data-types/managedservicesgroupidcomparison-object.md) objects

Required: No

### name

Name of the Managed Services Selector.

Type: `string`

Required: Yes

### regionNames

Regions/locations used by the selector when matching resources.

Type: Array of `string`

Required: No

### resourceIdComparisons

Resource identifier comparisons used by the selector when matching resources.

Type: Array of [ManagedServicesResourceIdComparison](/data-types/managedservicesresourceidcomparison-object.md) objects

Required: No

### resourceTagComparisons

Resource tag comparisons used by the selector when matching resources.

Type: Array of [ManagedServicesResourceTagComparison](/data-types/managedservicesresourcetagcomparison-object.md) objects

Required: No

### resourceIds

Resource identifiers used by the selector when matching resources.

Type: Array of `string`

Required: No

### resourceType

Type of resources that will be selected by the selector.

Type: `string`

Valid Values:

* `amazon-ec2-instance`
* `amazon-ebs-volume`
* `amazon-rds-instance`
* `amazon-rds-cluster`
* `amazon-documentdb-cluster`
* `amazon-lightsail-instance`
* `amazon-fsx-filesystem`
* `amazon-appstream-fleet`
* `amazon-redshift-cluster`
* `azure-virtual-machine`
* `google-vm-instance`
* `google-cloudsql-instance`

Required: Yes

### selectorCode

Unique code for the Managed Services Selector.

Type: `string`

Required: No

Default Value: Automatically generated `string`

## Returns

A [ManagedServicesSelector](/data-types/managedservicesselector-object.md) object.

## Sample Request

{% tabs %}
{% tab title="HTTP" %}

```http
POST /api/ManagedServices/Plans/plan-00000001/Selectors HTTP/1.1
Host: api.skeddly.com
Authorization: AccessKey <api key>
Content-Type: application/json

{
    "name": "Development EC2 Instances",
    
    "credentialIds": [
        "cred-00000001",
        "cred-00000002"
    ],
    
    "resourceType": "amazon-ec2-instance",
    
    "resourceTagComparisons": [
        {
            "tagName": "start-schedule",
            "compareType": "equals",
            "tagValue": "daily-0800"
        }
    ]
}
```

{% endtab %}

{% tab title="Bash" %}

```bash
curl -X POST "https://api.skeddly.com/api/ManagedServices/Plans/plan-00000001/Selectors" \
  -H "Authorization: AccessKey <api key>" \
  -d name="Development EC2 Instances" \
  -d credentialIds[0]=cred-00000001 \
  -d credentialIds[1]=cred-00000002 \
  -d resourceType=amazon-ec2-instances \
  -d resourceTagComparisons[0].tagName=start-schedule \
  -d resourceTagComparisons[0].compareType=equals \
  -d resourceTagComparisons[0].tagValue=daily-0800
```

{% endtab %}
{% endtabs %}

## Sample Response

```javascript
{
    "planId": "plan-00000001",
    "selectorId": "selector-00000001",
    "name": "Development EC2 Instances",
    
    "state": "active",
    "syncState": "ready",
    
    "createdDate": "2023-02-13T00:00:00Z",
    "lastModifiedDate": "2023-02-14T00:00:00Z",
    "lastModifiedBy": "u-00000001",
    
    "selectorCode": "0000000000000000",
    
    "credentialIds": [
        "cred-00000001",
        "cred-00000002"
    ],
    
    "resourceType": "amazon-ec2-instance",
    
    "resourceTagComparisons": [
        {
            "tagName": "start-schedule",
            "compareType": "equals",
            "tagValue": "daily-0800"
        }
    ]
}
```
