# Stack Alerts

> Source: https://developers.cloud66.com/v3/endpoints/stack-alerts/

## Get Stack Alert

URL: https://developers.cloud66.com/v3/endpoints/stack-alerts/#show
Endpoint: GET /stacks/:stack_id/alerts/:alert_name
OAuth scope: public

Returns comprehensive details about the specified stack alert configuration.

Retrieves the alert settings including notification channels, thresholds, and current status for the specified alert type on the stack.

**Related models:** Stack, Alert

**Common Alert Names:**
- **deployment_success**: Deployment completed successfully
- **deployment_failure**: Deployment failed
- **server_down**: Server became unavailable
- **server_up**: Server became available
- **scaling_complete**: Auto-scaling operation completed
- **backup_complete**: Backup operation completed

<ResponseCodes 
  codes={[200, 400, 401, 403, 404]}
  overrides={{
    200: "Success - Returns alert configuration details",
    400: "Bad Request - Invalid alert name",
    403: "Forbidden - OAuth token lacks required `public` scope",
    404: "Not Found - Stack not found"
  }}
/>

### Parameters

- `stack_id` (string, optional) — Stack UID
- `alert_name` (string, optional) — Alert name (e.g., "deployment_success", "server_down")

### Response

```json
{
  "response": {
    "name": "deployment_success",
    "description": "Notifies when a deployment completes successfully",
    "channels": [
      {
        "type": "email",
        "enabled": true,
        "recipients": ["admin@example.com"]
      },
      {
        "type": "slack",
        "enabled": true,
        "webhook_url": "https://hooks.slack.com/services/YOUR/SLACK/WEBHOOK"
      }
    ],
    "active": true,
    "settings": {
      "frequency": "immediate",
      "threshold": 1
    }
  }
}
```

---

## List Stack Alerts

URL: https://developers.cloud66.com/v3/endpoints/stack-alerts/#list
Endpoint: GET /stacks/:stack_id/alerts
OAuth scope: public

Returns a collection of alert configurations for the specified stack.

Stack alerts provide notification capabilities for various stack events including deployments, server status changes, and system health monitoring. Each alert can be configured with multiple notification channels.

**Related models:** Stack, Alert

**Available Alert Types:**
- **deployment_success**: Deployment completed successfully
- **deployment_failure**: Deployment failed
- **server_down**: Server became unavailable
- **server_up**: Server became available
- **scaling_complete**: Auto-scaling operation completed
- **backup_complete**: Backup operation completed

<ResponseCodes 
  codes={[200, 401, 403, 404]}
  overrides={{
    200: "Success - Returns list of stack alert configurations",
    403: "Forbidden - OAuth token lacks required `public` scope",
    404: "Not Found - Stack not found"
  }}
/>

### Parameters

- `stack_id` (string, optional) — Stack UID

### Response

```json
{
  "response": [
    {
      "name": "deployment_success",
      "description": "Notifies when a deployment completes successfully",
      "channels": [
        {
          "type": "email",
          "enabled": true,
          "recipients": ["admin@example.com"]
        },
        {
          "type": "slack", 
          "enabled": true,
          "webhook_url": "https://hooks.slack.com/services/YOUR/SLACK/WEBHOOK"
        }
      ],
      "active": true
    },
    {
      "name": "server_down",
      "description": "Notifies when a server goes down",
      "channels": [
        {
          "type": "email",
          "enabled": true,
          "recipients": ["ops@example.com", "admin@example.com"]
        }
      ],
      "active": true
    }
  ]
}
```

---

## Update Stack Alerts

URL: https://developers.cloud66.com/v3/endpoints/stack-alerts/#update
Endpoint: PUT /stacks/:stack_id/alerts
OAuth scope: admin

Updates multiple stack alert configurations in a single operation.

Modifies notification settings for specified alerts on the stack. Validates changes against business rules and permissions before applying updates.

**Related models:** Stack, Alert

**Configurable Alert Types:**
- **deployment_success**: Deployment completed successfully
- **deployment_failure**: Deployment failed
- **server_down**: Server became unavailable
- **server_up**: Server became available
- **scaling_complete**: Auto-scaling operation completed
- **backup_complete**: Backup operation completed

**Channel Configuration:**
- **email**: Recipients list with email addresses
- **slack**: Webhook URL for Slack integration
- **webhook**: Custom webhook endpoints
- **sms**: SMS notification settings

<Callout type="info" title="Bulk Updates">
This endpoint allows updating multiple alert configurations simultaneously. Only specified alerts in the request will be modified - other existing alerts remain unchanged.
</Callout>

<ResponseCodes 
  codes={[200, 400, 401, 403, 422]}
  overrides={{
    200: "Success - Alerts updated successfully",
    400: "Bad Request - Invalid alert configuration or parameters",
    403: "Forbidden - OAuth token lacks required `admin` scope",
    422: "Unprocessable Entity - Validation errors in alert settings"
  }}
/>

### Parameters

- `stack_id` (string, optional) — Stack UID
- `alerts` (string, optional) — Alert configurations to update, keyed by alert name

### Request body

```json
{
  "alerts": {
    "deployment_success": {
      "channels": [
        {
          "type": "email",
          "enabled": true,
          "recipients": ["admin@example.com", "dev-team@example.com"]
        },
        {
          "type": "slack",
          "enabled": true,
          "webhook_url": "https://hooks.slack.com/services/YOUR/SLACK/WEBHOOK"
        }
      ],
      "active": true,
      "settings": {
        "frequency": "immediate",
        "threshold": 1
      }
    },
    "server_down": {
      "channels": [
        {
          "type": "email",
          "enabled": true,
          "recipients": ["ops@example.com"]
        }
      ],
      "active": true,
      "settings": {
        "frequency": "immediate",
        "threshold": 1
      }
    }
  }
}
```

### Response

```json
{
  "response": {
    "ok": true,
    "message": "Alerts updated successfully"
  }
}
```
