# Public Cloud › Compute › Instances › Instance Groups API

> Part of the OVHcloud developer hub. Index of every page and section: https://developers.eu.ovhcloud.com/llms.txt
> The Public Cloud product's sections: https://developers.eu.ovhcloud.com/reference/public-cloud/llms.txt
> Everything in one file: https://developers.eu.ovhcloud.com/llms-full.txt

> 4 operations of the OVHcloud API. Calls carry `authorization: Bearer $OVH_TOKEN`; the EU host is shown, Canada and the United States answer on api.ca.ovhcloud.com and api.us.ovhcloud.com.

Page: https://developers.eu.ovhcloud.com/reference/public-cloud/compute/instances/instance-groups/

OpenAPI v1: https://api.eu.ovhcloud.com/1.0/__schemas/developer-hub-navigation/public-cloud/compute/instances/instance-groups.json?format=openapi3
OpenAPI v2: https://api.eu.ovhcloud.com/v2/__schemas/developer-hub-navigation/public-cloud/compute/instances/instance-groups.json?format=openapi3

## Operations

- `GET /publicCloud/project/{projectId}/compute/instanceGroup/{instanceGroupId}` — Get an instance group
- `GET /publicCloud/project/{projectId}/compute/instanceGroup` — List instance groups
- `POST /publicCloud/project/{projectId}/compute/instanceGroup` — Create an instance group
- `DELETE /publicCloud/project/{projectId}/compute/instanceGroup/{instanceGroupId}` — Delete an instance group

## Get an instance group

`GET /v2/publicCloud/project/{projectId}/compute/instanceGroup/{instanceGroupId}`

Link: https://developers.eu.ovhcloud.com/reference/public-cloud/compute/instances/instance-groups/#getInstanceGroup

**Status:** Stable production version  
**IAM actions:** `publicCloudProject:apiovh:instanceGroup/get`

### Get an instance group

Returns a single instance group (placement group), including its scheduling `policy` and its members.

### Immutable by design
Instance groups are immutable after creation. There is deliberately no `PUT` / update route. Neither the placement `policy` nor the set of members can be changed once the group exists. Membership is fixed at *instance* creation time: an instance joins a group via its `targetSpec.group` field when it is created (see the instance `POST`), and cannot be added to or removed from a group afterward. To change grouping you delete and recreate the affected instances into a different group.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `instanceGroupId` | path | string (uuid) | yes | Instance group ID |
| `projectId` | path | string | yes | Project ID |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | publicCloud.instanceGroup.InstanceGroup | successful operation |
| 404 | object | Error 404 response |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `checksum` | string | read-only | Checksum. Computed hash of the current target specification, used for optimistic concurrency control. Because an instance group has no update route, this value never changes after creation. |
| `createdAt` | string (date-time) | read-only | Creation date. Timestamp at which the instance group was created, in RFC 3339 format. |
| `currentState` | publicCloud.instanceGroup.InstanceGroupCurrentState | read-only | Actual state of the instance group as reported by the backend (OpenStack/Nova server group), including its current members. This is read-only and reflects reality, in contrast to targetSpec which is the desired specification supplied on creation. May be null while the group is still being provisioned and no backend state is known yet. |
| `currentState.location` | publicCloud.common.Location | read-only | Location. Region (and, where applicable, availability zone) where the instance group and its member instances are deployed, as observed on the backend. |
| `currentState.location.availabilityZone` | string |  | Availability zone within the region |
| `currentState.location.region` | string | yes | Region code |
| `currentState.members` | publicCloud.instanceGroup.InstanceGroupMemberRef[] | read-only | Instances currently belonging to this group, each referenced by its identifier (see InstanceGroupMemberRef). Membership is determined at instance-creation time via the instance's targetSpec.group field and cannot be changed afterward. Null or empty when the group has no member instances. |
| `currentState.members[].id` | string (uuid) | read-only | Unique identifier of the instance that belongs to the group. Use it to look up the full instance on the compute instance route. |
| `currentState.name` | string | read-only | Display name of the instance group as reported by the backend. Fixed for the lifetime of the group, since instance groups cannot be updated. |
| `currentState.policy` | publicCloud.instanceGroup.PolicyEnum | read-only | Placement policy currently enforced for the group's members (see PolicyEnum): AFFINITY packs members onto the same hypervisor, ANTI_AFFINITY spreads them across distinct hypervisors. Mirrors the underlying OpenStack/Nova server group policy and is fixed at creation. — one of `AFFINITY`, `ANTI_AFFINITY` |
| `currentTasks` | common.CurrentTask[] | read-only | Current tasks. Asynchronous operations currently running against this instance group, for example the initial provisioning or the deletion. Empty or null when no operation is in progress. |
| `currentTasks[].errors` | common.TaskError[] | read-only | Errors that occurred on the task |
| `currentTasks[].errors[].message` | string | read-only | Error description |
| `currentTasks[].id` | string (uuid) | read-only | Identifier of the current task |
| `currentTasks[].link` | string | read-only | Link to the task details |
| `currentTasks[].status` | common.CurrentTaskStatusEnum | read-only | Current global status of the current task — one of `ERROR`, `PENDING`, `RUNNING`, `SCHEDULED`, `WAITING_USER_INPUT` |
| `currentTasks[].type` | string | read-only | Type of the current task |
| `id` | string (uuid) | read-only | Unique identifier of the instance group, assigned at creation and used to reference it on the GET/DELETE routes |
| `resourceStatus` | common.ResourceStatusEnum | read-only | Lifecycle status of the instance group in the system, for example whether it is being created, ready, or being deleted. Reflects readiness of the resource, not the placement policy itself. — one of `CREATING`, `CREATION_PLANNED`, `DELETING`, `ERROR`, `OUT_OF_SYNC`, `READY`, `SUSPENDED`, `UNKNOWN`, `UPDATING` |
| `targetSpec` | publicCloud.instanceGroup.InstanceGroupTargetSpec | read-only | Target specification. Desired specification of the instance group as supplied on creation (name, location and placement policy). Since an instance group cannot be updated, this specification is fixed for the lifetime of the group. Compare it against currentState to see what the backend actually provisioned. |
| `targetSpec.location` | publicCloud.common.Location | yes | Target location. Region (and optional availability zone) where the instance group, and therefore its member instances, are placed. Immutable after creation. A group cannot be moved to another region/zone, and its members must be created in this same location. |
| `targetSpec.location.availabilityZone` | string |  | Availability zone within the region |
| `targetSpec.location.region` | string | yes | Region code |
| `targetSpec.name` | string | yes | Desired display name of the instance group. Immutable after creation, as instance groups cannot be updated. |
| `targetSpec.policy` | publicCloud.instanceGroup.PolicyEnum | yes | Placement policy applied to the group's member instances (see PolicyEnum): AFFINITY packs members onto the same hypervisor, while ANTI_AFFINITY spreads members across distinct hypervisors. This maps to the underlying OpenStack/Nova server group policy and is immutable after creation. — one of `AFFINITY`, `ANTI_AFFINITY` |

```json
{
  "checksum": "string",
  "createdAt": "2024-01-01T12:00:00Z",
  "currentState": {
    "location": {
      "availabilityZone": "string",
      "region": "string"
    },
    "members": [
      {
        "id": "00000000-0000-0000-0000-000000000000"
      }
    ],
    "name": "string",
    "policy": "AFFINITY"
  },
  "currentTasks": [
    {
      "errors": [
        {
          "message": "string"
        }
      ],
      "id": "00000000-0000-0000-0000-000000000000",
      "link": "string",
      "status": "ERROR",
      "type": "string"
    }
  ],
  "id": "00000000-0000-0000-0000-000000000000",
  "resourceStatus": "CREATING",
  "targetSpec": {
    "location": {
      "availabilityZone": "string",
      "region": "string"
    },
    "name": "string",
    "policy": "AFFINITY"
  }
}
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/compute/instanceGroup/{instanceGroupId}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.get("/v2/publicCloud/project/{projectId}/compute/instanceGroup/{instanceGroupId}")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->get("/v2/publicCloud/project/{projectId}/compute/instanceGroup/{instanceGroupId}");

print_r($result);
?>
```

## List instance groups

`GET /v2/publicCloud/project/{projectId}/compute/instanceGroup`

Link: https://developers.eu.ovhcloud.com/reference/public-cloud/compute/instances/instance-groups/#getInstanceGroups

**Status:** Stable production version  
**IAM actions:** `publicCloudProject:apiovh:instanceGroup/get`

### List instance groups

Lists all instance groups (placement groups) in the project, each with the same shape as the `GET` route (scheduling `policy` and members).

### Immutable by design
Instance groups cannot be modified after creation. There is deliberately no `PUT` / update route, and membership is fixed at *instance* creation time via the instance's `targetSpec.group` field. See the `GET` route for details.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `X-Pagination-Cursor` | header | string |  | Pagination cursor |
| `X-Pagination-Size` | header | integer |  | Pagination size |
| `projectId` | path | string | yes | Project ID |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | publicCloud.instanceGroup.InstanceGroup[] | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `checksum` | string | read-only | Checksum. Computed hash of the current target specification, used for optimistic concurrency control. Because an instance group has no update route, this value never changes after creation. |
| `createdAt` | string (date-time) | read-only | Creation date. Timestamp at which the instance group was created, in RFC 3339 format. |
| `currentState` | publicCloud.instanceGroup.InstanceGroupCurrentState | read-only | Actual state of the instance group as reported by the backend (OpenStack/Nova server group), including its current members. This is read-only and reflects reality, in contrast to targetSpec which is the desired specification supplied on creation. May be null while the group is still being provisioned and no backend state is known yet. |
| `currentState.location` | publicCloud.common.Location | read-only | Location. Region (and, where applicable, availability zone) where the instance group and its member instances are deployed, as observed on the backend. |
| `currentState.location.availabilityZone` | string |  | Availability zone within the region |
| `currentState.location.region` | string | yes | Region code |
| `currentState.members` | publicCloud.instanceGroup.InstanceGroupMemberRef[] | read-only | Instances currently belonging to this group, each referenced by its identifier (see InstanceGroupMemberRef). Membership is determined at instance-creation time via the instance's targetSpec.group field and cannot be changed afterward. Null or empty when the group has no member instances. |
| `currentState.members[].id` | string (uuid) | read-only | Unique identifier of the instance that belongs to the group. Use it to look up the full instance on the compute instance route. |
| `currentState.name` | string | read-only | Display name of the instance group as reported by the backend. Fixed for the lifetime of the group, since instance groups cannot be updated. |
| `currentState.policy` | publicCloud.instanceGroup.PolicyEnum | read-only | Placement policy currently enforced for the group's members (see PolicyEnum): AFFINITY packs members onto the same hypervisor, ANTI_AFFINITY spreads them across distinct hypervisors. Mirrors the underlying OpenStack/Nova server group policy and is fixed at creation. — one of `AFFINITY`, `ANTI_AFFINITY` |
| `currentTasks` | common.CurrentTask[] | read-only | Current tasks. Asynchronous operations currently running against this instance group, for example the initial provisioning or the deletion. Empty or null when no operation is in progress. |
| `currentTasks[].errors` | common.TaskError[] | read-only | Errors that occurred on the task |
| `currentTasks[].errors[].message` | string | read-only | Error description |
| `currentTasks[].id` | string (uuid) | read-only | Identifier of the current task |
| `currentTasks[].link` | string | read-only | Link to the task details |
| `currentTasks[].status` | common.CurrentTaskStatusEnum | read-only | Current global status of the current task — one of `ERROR`, `PENDING`, `RUNNING`, `SCHEDULED`, `WAITING_USER_INPUT` |
| `currentTasks[].type` | string | read-only | Type of the current task |
| `id` | string (uuid) | read-only | Unique identifier of the instance group, assigned at creation and used to reference it on the GET/DELETE routes |
| `resourceStatus` | common.ResourceStatusEnum | read-only | Lifecycle status of the instance group in the system, for example whether it is being created, ready, or being deleted. Reflects readiness of the resource, not the placement policy itself. — one of `CREATING`, `CREATION_PLANNED`, `DELETING`, `ERROR`, `OUT_OF_SYNC`, `READY`, `SUSPENDED`, `UNKNOWN`, `UPDATING` |
| `targetSpec` | publicCloud.instanceGroup.InstanceGroupTargetSpec | read-only | Target specification. Desired specification of the instance group as supplied on creation (name, location and placement policy). Since an instance group cannot be updated, this specification is fixed for the lifetime of the group. Compare it against currentState to see what the backend actually provisioned. |
| `targetSpec.location` | publicCloud.common.Location | yes | Target location. Region (and optional availability zone) where the instance group, and therefore its member instances, are placed. Immutable after creation. A group cannot be moved to another region/zone, and its members must be created in this same location. |
| `targetSpec.location.availabilityZone` | string |  | Availability zone within the region |
| `targetSpec.location.region` | string | yes | Region code |
| `targetSpec.name` | string | yes | Desired display name of the instance group. Immutable after creation, as instance groups cannot be updated. |
| `targetSpec.policy` | publicCloud.instanceGroup.PolicyEnum | yes | Placement policy applied to the group's member instances (see PolicyEnum): AFFINITY packs members onto the same hypervisor, while ANTI_AFFINITY spreads members across distinct hypervisors. This maps to the underlying OpenStack/Nova server group policy and is immutable after creation. — one of `AFFINITY`, `ANTI_AFFINITY` |

```json
[
  {
    "checksum": "string",
    "createdAt": "2024-01-01T12:00:00Z",
    "currentState": {
      "location": {
        "availabilityZone": "string",
        "region": "string"
      },
      "members": [
        {
          "id": "00000000-0000-0000-0000-000000000000"
        }
      ],
      "name": "string",
      "policy": "AFFINITY"
    },
    "currentTasks": [
      {
        "errors": [
          {
            "message": "string"
          }
        ],
        "id": "00000000-0000-0000-0000-000000000000",
        "link": "string",
        "status": "ERROR",
        "type": "string"
      }
    ],
    "id": "00000000-0000-0000-0000-000000000000",
    "resourceStatus": "CREATING",
    "targetSpec": {
      "location": {
        "availabilityZone": "string",
        "region": "string"
      },
      "name": "string",
      "policy": "AFFINITY"
    }
  }
]
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/compute/instanceGroup" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.get("/v2/publicCloud/project/{projectId}/compute/instanceGroup")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->get("/v2/publicCloud/project/{projectId}/compute/instanceGroup");

print_r($result);
?>
```

## Create an instance group

`POST /v2/publicCloud/project/{projectId}/compute/instanceGroup`

Link: https://developers.eu.ovhcloud.com/reference/public-cloud/compute/instances/instance-groups/#createInstanceGroup

**Status:** Stable production version  
**IAM actions:** `publicCloudProject:apiovh:instanceGroup/create`

### Create an instance group

Creates a new instance group (placement group). Creation is asynchronous: the group starts in `CREATING` and becomes `READY` once the backend has provisioned it.

### Placement policy
`targetSpec.policy` chooses how members are scheduled relative to each other:
* `AFFINITY` — members are placed on the same hypervisor.
* `ANTI_AFFINITY` — members are placed on different hypervisors (for high availability).

### Immutable, membership set at instance creation
The group is immutable once created. There is deliberately no `PUT` / update route, so the `policy` can never be changed. The group is created empty: instances are not added here. An instance joins the group only at its own creation time, via its `targetSpec.group` field (see the instance `POST`), and membership cannot change afterward (OpenStack/Nova server groups are immutable).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `projectId` | path | string | yes | Project ID |

### Request body (required)

Type: `publicCloud.instanceGroup.InstanceGroupCreation`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `targetSpec` | publicCloud.instanceGroup.InstanceGroupTargetSpec | yes | Target specification. Desired specification of the instance group to create: its name, location and placement policy (see PolicyEnum). All of these values are fixed for the lifetime of the group, as instance groups cannot be updated once created. |
| `targetSpec.location` | publicCloud.common.Location | yes | Target location. Region (and optional availability zone) where the instance group, and therefore its member instances, are placed. Immutable after creation. A group cannot be moved to another region/zone, and its members must be created in this same location. |
| `targetSpec.location.availabilityZone` | string |  | Availability zone within the region |
| `targetSpec.location.region` | string | yes | Region code |
| `targetSpec.name` | string | yes | Desired display name of the instance group. Immutable after creation, as instance groups cannot be updated. |
| `targetSpec.policy` | publicCloud.instanceGroup.PolicyEnum | yes | Placement policy applied to the group's member instances (see PolicyEnum): AFFINITY packs members onto the same hypervisor, while ANTI_AFFINITY spreads members across distinct hypervisors. This maps to the underlying OpenStack/Nova server group policy and is immutable after creation. — one of `AFFINITY`, `ANTI_AFFINITY` |

```json
{
  "targetSpec": {
    "location": {
      "availabilityZone": "string",
      "region": "string"
    },
    "name": "string",
    "policy": "AFFINITY"
  }
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | publicCloud.instanceGroup.InstanceGroup | successful operation |
| 409 | object | Error 409 response |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `checksum` | string | read-only | Checksum. Computed hash of the current target specification, used for optimistic concurrency control. Because an instance group has no update route, this value never changes after creation. |
| `createdAt` | string (date-time) | read-only | Creation date. Timestamp at which the instance group was created, in RFC 3339 format. |
| `currentState` | publicCloud.instanceGroup.InstanceGroupCurrentState | read-only | Actual state of the instance group as reported by the backend (OpenStack/Nova server group), including its current members. This is read-only and reflects reality, in contrast to targetSpec which is the desired specification supplied on creation. May be null while the group is still being provisioned and no backend state is known yet. |
| `currentState.location` | publicCloud.common.Location | read-only | Location. Region (and, where applicable, availability zone) where the instance group and its member instances are deployed, as observed on the backend. |
| `currentState.location.availabilityZone` | string |  | Availability zone within the region |
| `currentState.location.region` | string | yes | Region code |
| `currentState.members` | publicCloud.instanceGroup.InstanceGroupMemberRef[] | read-only | Instances currently belonging to this group, each referenced by its identifier (see InstanceGroupMemberRef). Membership is determined at instance-creation time via the instance's targetSpec.group field and cannot be changed afterward. Null or empty when the group has no member instances. |
| `currentState.members[].id` | string (uuid) | read-only | Unique identifier of the instance that belongs to the group. Use it to look up the full instance on the compute instance route. |
| `currentState.name` | string | read-only | Display name of the instance group as reported by the backend. Fixed for the lifetime of the group, since instance groups cannot be updated. |
| `currentState.policy` | publicCloud.instanceGroup.PolicyEnum | read-only | Placement policy currently enforced for the group's members (see PolicyEnum): AFFINITY packs members onto the same hypervisor, ANTI_AFFINITY spreads them across distinct hypervisors. Mirrors the underlying OpenStack/Nova server group policy and is fixed at creation. — one of `AFFINITY`, `ANTI_AFFINITY` |
| `currentTasks` | common.CurrentTask[] | read-only | Current tasks. Asynchronous operations currently running against this instance group, for example the initial provisioning or the deletion. Empty or null when no operation is in progress. |
| `currentTasks[].errors` | common.TaskError[] | read-only | Errors that occurred on the task |
| `currentTasks[].errors[].message` | string | read-only | Error description |
| `currentTasks[].id` | string (uuid) | read-only | Identifier of the current task |
| `currentTasks[].link` | string | read-only | Link to the task details |
| `currentTasks[].status` | common.CurrentTaskStatusEnum | read-only | Current global status of the current task — one of `ERROR`, `PENDING`, `RUNNING`, `SCHEDULED`, `WAITING_USER_INPUT` |
| `currentTasks[].type` | string | read-only | Type of the current task |
| `id` | string (uuid) | read-only | Unique identifier of the instance group, assigned at creation and used to reference it on the GET/DELETE routes |
| `resourceStatus` | common.ResourceStatusEnum | read-only | Lifecycle status of the instance group in the system, for example whether it is being created, ready, or being deleted. Reflects readiness of the resource, not the placement policy itself. — one of `CREATING`, `CREATION_PLANNED`, `DELETING`, `ERROR`, `OUT_OF_SYNC`, `READY`, `SUSPENDED`, `UNKNOWN`, `UPDATING` |
| `targetSpec` | publicCloud.instanceGroup.InstanceGroupTargetSpec | read-only | Target specification. Desired specification of the instance group as supplied on creation (name, location and placement policy). Since an instance group cannot be updated, this specification is fixed for the lifetime of the group. Compare it against currentState to see what the backend actually provisioned. |
| `targetSpec.location` | publicCloud.common.Location | yes | Target location. Region (and optional availability zone) where the instance group, and therefore its member instances, are placed. Immutable after creation. A group cannot be moved to another region/zone, and its members must be created in this same location. |
| `targetSpec.location.availabilityZone` | string |  | Availability zone within the region |
| `targetSpec.location.region` | string | yes | Region code |
| `targetSpec.name` | string | yes | Desired display name of the instance group. Immutable after creation, as instance groups cannot be updated. |
| `targetSpec.policy` | publicCloud.instanceGroup.PolicyEnum | yes | Placement policy applied to the group's member instances (see PolicyEnum): AFFINITY packs members onto the same hypervisor, while ANTI_AFFINITY spreads members across distinct hypervisors. This maps to the underlying OpenStack/Nova server group policy and is immutable after creation. — one of `AFFINITY`, `ANTI_AFFINITY` |

```json
{
  "checksum": "string",
  "createdAt": "2024-01-01T12:00:00Z",
  "currentState": {
    "location": {
      "availabilityZone": "string",
      "region": "string"
    },
    "members": [
      {
        "id": "00000000-0000-0000-0000-000000000000"
      }
    ],
    "name": "string",
    "policy": "AFFINITY"
  },
  "currentTasks": [
    {
      "errors": [
        {
          "message": "string"
        }
      ],
      "id": "00000000-0000-0000-0000-000000000000",
      "link": "string",
      "status": "ERROR",
      "type": "string"
    }
  ],
  "id": "00000000-0000-0000-0000-000000000000",
  "resourceStatus": "CREATING",
  "targetSpec": {
    "location": {
      "availabilityZone": "string",
      "region": "string"
    },
    "name": "string",
    "policy": "AFFINITY"
  }
}
```

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/compute/instanceGroup" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN" \
  -H "content-type: application/json" \
  -d '{ }'
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

# Request body type: publicCloud.instanceGroup.InstanceGroupCreation
result = client.post("/v2/publicCloud/project/{projectId}/compute/instanceGroup",
	targetSpec = None, # Target specification. Desired specification of the instance group to create: its name, location and placement policy (see PolicyEnum). All of these values are fixed for the lifetime of the group, as instance groups cannot be updated once created. (type: publicCloud.instanceGroup.InstanceGroupTargetSpec)
)

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

// Request body type: publicCloud.instanceGroup.InstanceGroupCreation
$result = $ovh->post("/v2/publicCloud/project/{projectId}/compute/instanceGroup", array(
	targetSpec => null, // Target specification. Desired specification of the instance group to create: its name, location and placement policy (see PolicyEnum). All of these values are fixed for the lifetime of the group, as instance groups cannot be updated once created. (type: publicCloud.instanceGroup.InstanceGroupTargetSpec)
));

print_r($result);
?>
```

## Delete an instance group

`DELETE /v2/publicCloud/project/{projectId}/compute/instanceGroup/{instanceGroupId}`

Link: https://developers.eu.ovhcloud.com/reference/public-cloud/compute/instances/instance-groups/#deleteInstanceGroup

**Status:** Stable production version  
**IAM actions:** `publicCloudProject:apiovh:instanceGroup/delete`

### Delete an instance group

Deletes an instance group (placement group). Deletion is asynchronous: the resource transitions to `DELETING` and the backend then removes it.

A group is normally removed once it is empty (has no member instances). Because membership is fixed at *instance* creation time and cannot be edited on an existing group, freeing a group means deleting or recreating its member instances first. Deleting the group tears down only the placement grouping. It does not delete the instances themselves. A delete already in progress is reported as `ResourceAlreadyBeingDeleted`.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `instanceGroupId` | path | string (uuid) | yes | Instance group ID |
| `projectId` | path | string | yes | Project ID |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | publicCloud.instanceGroup.InstanceGroup | successful operation |
| 404 | object | Error 404 response |
| 409 | object | Error 409 response |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `checksum` | string | read-only | Checksum. Computed hash of the current target specification, used for optimistic concurrency control. Because an instance group has no update route, this value never changes after creation. |
| `createdAt` | string (date-time) | read-only | Creation date. Timestamp at which the instance group was created, in RFC 3339 format. |
| `currentState` | publicCloud.instanceGroup.InstanceGroupCurrentState | read-only | Actual state of the instance group as reported by the backend (OpenStack/Nova server group), including its current members. This is read-only and reflects reality, in contrast to targetSpec which is the desired specification supplied on creation. May be null while the group is still being provisioned and no backend state is known yet. |
| `currentState.location` | publicCloud.common.Location | read-only | Location. Region (and, where applicable, availability zone) where the instance group and its member instances are deployed, as observed on the backend. |
| `currentState.location.availabilityZone` | string |  | Availability zone within the region |
| `currentState.location.region` | string | yes | Region code |
| `currentState.members` | publicCloud.instanceGroup.InstanceGroupMemberRef[] | read-only | Instances currently belonging to this group, each referenced by its identifier (see InstanceGroupMemberRef). Membership is determined at instance-creation time via the instance's targetSpec.group field and cannot be changed afterward. Null or empty when the group has no member instances. |
| `currentState.members[].id` | string (uuid) | read-only | Unique identifier of the instance that belongs to the group. Use it to look up the full instance on the compute instance route. |
| `currentState.name` | string | read-only | Display name of the instance group as reported by the backend. Fixed for the lifetime of the group, since instance groups cannot be updated. |
| `currentState.policy` | publicCloud.instanceGroup.PolicyEnum | read-only | Placement policy currently enforced for the group's members (see PolicyEnum): AFFINITY packs members onto the same hypervisor, ANTI_AFFINITY spreads them across distinct hypervisors. Mirrors the underlying OpenStack/Nova server group policy and is fixed at creation. — one of `AFFINITY`, `ANTI_AFFINITY` |
| `currentTasks` | common.CurrentTask[] | read-only | Current tasks. Asynchronous operations currently running against this instance group, for example the initial provisioning or the deletion. Empty or null when no operation is in progress. |
| `currentTasks[].errors` | common.TaskError[] | read-only | Errors that occurred on the task |
| `currentTasks[].errors[].message` | string | read-only | Error description |
| `currentTasks[].id` | string (uuid) | read-only | Identifier of the current task |
| `currentTasks[].link` | string | read-only | Link to the task details |
| `currentTasks[].status` | common.CurrentTaskStatusEnum | read-only | Current global status of the current task — one of `ERROR`, `PENDING`, `RUNNING`, `SCHEDULED`, `WAITING_USER_INPUT` |
| `currentTasks[].type` | string | read-only | Type of the current task |
| `id` | string (uuid) | read-only | Unique identifier of the instance group, assigned at creation and used to reference it on the GET/DELETE routes |
| `resourceStatus` | common.ResourceStatusEnum | read-only | Lifecycle status of the instance group in the system, for example whether it is being created, ready, or being deleted. Reflects readiness of the resource, not the placement policy itself. — one of `CREATING`, `CREATION_PLANNED`, `DELETING`, `ERROR`, `OUT_OF_SYNC`, `READY`, `SUSPENDED`, `UNKNOWN`, `UPDATING` |
| `targetSpec` | publicCloud.instanceGroup.InstanceGroupTargetSpec | read-only | Target specification. Desired specification of the instance group as supplied on creation (name, location and placement policy). Since an instance group cannot be updated, this specification is fixed for the lifetime of the group. Compare it against currentState to see what the backend actually provisioned. |
| `targetSpec.location` | publicCloud.common.Location | yes | Target location. Region (and optional availability zone) where the instance group, and therefore its member instances, are placed. Immutable after creation. A group cannot be moved to another region/zone, and its members must be created in this same location. |
| `targetSpec.location.availabilityZone` | string |  | Availability zone within the region |
| `targetSpec.location.region` | string | yes | Region code |
| `targetSpec.name` | string | yes | Desired display name of the instance group. Immutable after creation, as instance groups cannot be updated. |
| `targetSpec.policy` | publicCloud.instanceGroup.PolicyEnum | yes | Placement policy applied to the group's member instances (see PolicyEnum): AFFINITY packs members onto the same hypervisor, while ANTI_AFFINITY spreads members across distinct hypervisors. This maps to the underlying OpenStack/Nova server group policy and is immutable after creation. — one of `AFFINITY`, `ANTI_AFFINITY` |

```json
{
  "checksum": "string",
  "createdAt": "2024-01-01T12:00:00Z",
  "currentState": {
    "location": {
      "availabilityZone": "string",
      "region": "string"
    },
    "members": [
      {
        "id": "00000000-0000-0000-0000-000000000000"
      }
    ],
    "name": "string",
    "policy": "AFFINITY"
  },
  "currentTasks": [
    {
      "errors": [
        {
          "message": "string"
        }
      ],
      "id": "00000000-0000-0000-0000-000000000000",
      "link": "string",
      "status": "ERROR",
      "type": "string"
    }
  ],
  "id": "00000000-0000-0000-0000-000000000000",
  "resourceStatus": "CREATING",
  "targetSpec": {
    "location": {
      "availabilityZone": "string",
      "region": "string"
    },
    "name": "string",
    "policy": "AFFINITY"
  }
}
```

### Example

```bash
curl -X DELETE \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/compute/instanceGroup/{instanceGroupId}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.delete("/v2/publicCloud/project/{projectId}/compute/instanceGroup/{instanceGroupId}")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->delete("/v2/publicCloud/project/{projectId}/compute/instanceGroup/{instanceGroupId}");

print_r($result);
?>
```
