# Elastic Addresses

> Source: https://developers.cloud66.com/v3/endpoints/elastic-addresses/

## List Elastic Addresses

URL: https://developers.cloud66.com/v3/endpoints/elastic-addresses/#list
Endpoint: GET /elastic_addresses
OAuth scope: public

Returns all elastic addresses (failover groups) that belong to the authenticated user's account.

Elastic addresses provide high availability by allowing traffic to be switched between primary and secondary stacks during failures or maintenance operations. They are also known as failover groups.

**Related models:** ElasticAddress, Stack

**Key Features:**
- **High Availability**: Automatic traffic switching during failures
- **Maintenance Windows**: Manual switching for zero-downtime updates
- **Multi-Cloud Support**: Works across different cloud providers
- **Real-time Monitoring**: Status tracking for primary and secondary stacks

<ResponseCodes 
  codes={[200, 401, 403]}
  overrides={{
    200: "Success - Returns list of elastic addresses",
    403: "Forbidden - OAuth token lacks required `public` scope"
  }}
/>

### Response

```json
{
  "response": [
    {
      "id": 123,
      "uid": "abc123def456",
      "address": "203.0.113.10",
      "primary_stack": "my-primary-stack",
      "secondary_stack": "my-backup-stack",
      "current_stack": "primary",
      "status": "active",
      "cloud": "AWS",
      "region": "us-east-1",
      "created_at": "2023-01-15T10:30:00Z",
      "updated_at": "2023-01-15T10:30:00Z"
    },
    {
      "id": 124,
      "uid": "def456ghi789",
      "address": "203.0.113.20", 
      "primary_stack": "app-prod-cluster",
      "secondary_stack": "app-backup-cluster",
      "current_stack": "secondary",
      "status": "active",
      "cloud": "DigitalOcean",
      "region": "nyc3",
      "created_at": "2023-01-10T14:20:00Z",
      "updated_at": "2023-01-12T09:15:00Z"
    }
  ]
}
```

---

## Create Elastic Address

URL: https://developers.cloud66.com/v3/endpoints/elastic-addresses/#create
Endpoint: POST /elastic_addresses
OAuth scope: admin

Creates a new elastic address (failover group) that provides high availability by allowing traffic to be switched between primary and secondary stacks.

Both stacks must support failover groups and you must have appropriate permissions on both stacks. The stacks cannot be the same and must have DNS configurations.

<Callout type="info" title="Stack Requirements">
Stacks must not be cluster or prepress type and must have head DNS present to be used in failover groups.
</Callout>

**Related models:** ElasticAddress, Stack

**Validation Rules:**
- Primary and secondary stacks must be different
- You must have failover group edit permissions on both stacks
- Stacks must support failover group functionality
- Stacks cannot be cluster or prepress type

<ResponseCodes 
  codes={[200, 400, 401, 403, 422]}
  overrides={{
    200: "Success - Failover group created successfully",
    400: "Bad Request - Invalid stack configuration or validation errors",
    403: "Forbidden - OAuth token lacks required `admin` scope or insufficient permissions on stacks",
    422: "Unprocessable Entity - Cannot create failover group at this time"
  }}
/>

### Parameters

- `primary_stack_uid` (string, optional) — UID of the primary stack for the failover group
- `secondary_stack_uid` (string, optional) — UID of the secondary/backup stack for the failover group
- `current_stack` (string, optional) — Which stack is currently active ("primary" or "secondary")

### Request body

```json
{
  "primary_stack_uid": "stack-123-abc",
  "secondary_stack_uid": "stack-456-def",
  "current_stack": "primary"
}
```

### Response

```json
{
  "response": {
    "ok": true,
    "message": "Failover Group created"
  }
}
```

---

## Update Elastic Address

URL: https://developers.cloud66.com/v3/endpoints/elastic-addresses/#update
Endpoint: PUT /elastic_addresses/:uid
OAuth scope: admin

Modifies the specified elastic address (failover group) with new stack assignments or current stack settings.

Validates changes against business rules and permissions before applying updates. You must have appropriate permissions on both existing and new stacks.

<Callout type="info" title="DNS Updates">
Updating an elastic address will trigger DNS updates to reflect the new configuration and ensure proper traffic routing.
</Callout>

**Related models:** ElasticAddress, Stack

**Update Rules:**
- Primary and secondary stacks must be different
- You must have failover group edit permissions on all involved stacks
- New stacks must support failover group functionality
- DNS updates are automatically triggered after successful update

<ResponseCodes 
  codes={[200, 400, 401, 403, 422]}
  overrides={{
    200: "Success - Failover group updated successfully",
    400: "Bad Request - Invalid failover group UID or stack configuration",
    403: "Forbidden - OAuth token lacks required `admin` scope or insufficient permissions on stacks",
    422: "Unprocessable Entity - Issue updating the failover group"
  }}
/>

### Parameters

- `uid` (string, optional) — Elastic address UID
- `primary_stack_uid` (string, optional) — UID of the primary stack for the failover group
- `secondary_stack_uid` (string, optional) — UID of the secondary/backup stack for the failover group
- `current_stack` (string, optional) — Which stack is currently active ("primary" or "secondary")

### Request body

```json
{
  "primary_stack_uid": "stack-789-ghi",
  "secondary_stack_uid": "stack-456-def",
  "current_stack": "secondary"
}
```

### Response

```json
{
  "response": {
    "ok": true,
    "message": "Failover Group updated"
  }
}
```

---

## Delete Elastic Address

URL: https://developers.cloud66.com/v3/endpoints/elastic-addresses/#delete
Endpoint: DELETE /elastic_addresses/:uid
OAuth scope: admin

Permanently removes the specified elastic address (failover group) from the system.

<Callout type="warning" title="Attachment Restriction">
Cannot delete a failover group that is currently attached to a stack. You must first detach it from all stacks before deletion.
</Callout>

**Related models:** ElasticAddress, Stack

The deletion process will:
1. Verify the failover group is not attached to any stack
2. Remove the elastic address configuration
3. Log the deletion event for audit purposes

<ResponseCodes 
  codes={[200, 400, 401, 403]}
  overrides={{
    200: "Success - Failover group deleted successfully",
    400: "Bad Request - Invalid failover group UID or failover group is attached to a stack",
    403: "Forbidden - OAuth token lacks required `admin` scope"
  }}
/>

### Parameters

- `uid` (string, optional) — Elastic address UID

### Response

```json
{
  "response": {
    "ok": true,
    "message": "Failover Group deleted"
  }
}
```
