> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/wazuh/wazuh-dashboard-plugins/llms.txt
> Use this file to discover all available pages before exploring further.

# Check Updates Plugin API

> API reference for the Wazuh Check Updates plugin

The Wazuh Check Updates plugin provides update notification services and version checking functionality for the Wazuh Dashboard.

## Plugin Class

### WazuhCheckUpdatesPlugin

**Location:** `plugins/wazuh-check-updates/public/plugin.ts:12`

```typescript theme={null}
export class WazuhCheckUpdatesPlugin
  implements Plugin<WazuhCheckUpdatesPluginSetup, WazuhCheckUpdatesPluginStart>
```

## Lifecycle Methods

### setup()

Initializes the plugin (no setup tasks required).

**Signature:**

```typescript theme={null}
public setup(core: CoreSetup): WazuhCheckUpdatesPluginSetup
```

**core** `CoreSetup` *required*

OpenSearch Dashboards core setup contract

**Returns:** `WazuhCheckUpdatesPluginSetup` - Empty object

### start()

Activates update checking services.

**Signature:**

```typescript theme={null}
public start(
  core: CoreStart,
  plugins: AppPluginStartDependencies
): WazuhCheckUpdatesPluginStart
```

**core** `CoreStart` *required*

OpenSearch Dashboards core start contract

**plugins** `AppPluginStartDependencies` *required*

Plugin dependencies

**properties**

**wazuhCore** `WazuhCorePluginStart`

Wazuh Core plugin instance

**Returns:** `WazuhCheckUpdatesPluginStart`

**UpdatesNotification** `React.ComponentType`

React component for displaying update notifications

**DismissNotificationCheck** `React.ComponentType`

React component for dismissing update notifications

**getAvailableUpdates** `Function`

Function to retrieve available updates

## Public API

### getAvailableUpdates()

Retrieves information about available Wazuh updates.

**Signature:**

```typescript theme={null}
getAvailableUpdates(
  checkOnly?: boolean,
  forceQuery?: boolean
): Promise<AvailableUpdates>
```

**checkOnly** `boolean` (default: false)

Only check if updates exist without fetching details

**forceQuery** `boolean` (default: false)

Force a fresh query, bypassing cache

**Returns:** `Promise<AvailableUpdates>`

**api\_id** `string`

API host identifier

**current\_version** `string`

Currently installed Wazuh version

**last\_available\_major** `object`

Latest available major version

**properties**

**version** `string`

Version number

**published\_date** `string`

Release date

**tag** `string`

Version tag (e.g., "v4.5.0")

**last\_available\_minor** `object`

Latest available minor version

**last\_available\_patch** `object`

Latest available patch version

**Example:**

```typescript theme={null}
import { getWazuhCheckUpdatesPlugin } from './plugin-services';

const checkUpdates = async () => {
  const updates = await getWazuhCheckUpdatesPlugin().getAvailableUpdates();
  
  if (updates.last_available_patch) {
    console.log(`Patch update available: ${updates.last_available_patch.version}`);
  }
  
  if (updates.last_available_minor) {
    console.log(`Minor update available: ${updates.last_available_minor.version}`);
  }
  
  if (updates.last_available_major) {
    console.log(`Major update available: ${updates.last_available_major.version}`);
  }
};
```

## Components

### UpdatesNotification

Displays update notifications in the UI.

**Usage:**

```typescript theme={null}
import React from 'react';
import { getWazuhCheckUpdatesPlugin } from './plugin-services';

function App() {
  const { UpdatesNotification } = getWazuhCheckUpdatesPlugin();
  
  return (
    <div>
      <UpdatesNotification />
      {/* Other app content */}
    </div>
  );
}
```

**Features:**

* Automatically checks for updates on mount
* Displays notifications for major, minor, and patch updates
* Provides links to release notes
* Respects user dismissal preferences

### DismissNotificationCheck

Allows users to dismiss update notifications.

**Usage:**

```typescript theme={null}
import React from 'react';
import { getWazuhCheckUpdatesPlugin } from './plugin-services';

function UpdateSettings() {
  const { DismissNotificationCheck } = getWazuhCheckUpdatesPlugin();
  
  return (
    <div>
      <h2>Update Notifications</h2>
      <DismissNotificationCheck />
    </div>
  );
}
```

**Props:**

No props required - the component manages its own state.

## Server Plugin

The server-side plugin manages update data and user preferences.

### WazuhCheckUpdatesPlugin (Server)

**Location:** `plugins/wazuh-check-updates/server/plugin.ts:37`

```typescript theme={null}
export class WazuhCheckUpdatesPlugin
  implements Plugin<WazuhCheckUpdatesPluginSetup, WazuhCheckUpdatesPluginStart>
```

### setup() (Server)

**Signature:**

```typescript theme={null}
public async setup(
  core: CoreSetup,
  plugins: PluginSetup
): Promise<WazuhCheckUpdatesPluginSetup>
```

Server setup tasks:

1. **Registers saved object types** - For storing update data and user preferences
2. **Creates router** - Sets up HTTP endpoints
3. **Registers route handler context** - Adds `wazuh_check_updates` context

**Saved Object Types:**

```typescript theme={null}
// Available updates data
core.savedObjects.registerType({
  name: 'wazuh-check-updates-available-updates',
  hidden: false,
  namespaceType: 'agnostic',
  mappings: {
    properties: {
      api_id: { type: 'keyword' },
      current_version: { type: 'keyword' },
      last_available_major: { type: 'object' },
      last_available_minor: { type: 'object' },
      last_available_patch: { type: 'object' },
      last_check_date: { type: 'date' },
    },
  },
});

// User preferences
core.savedObjects.registerType({
  name: 'wazuh-check-updates-user-preferences',
  hidden: false,
  namespaceType: 'single',
  mappings: {
    properties: {
      dismissed_updates: { type: 'object' },
      last_dismissed_date: { type: 'date' },
    },
  },
});
```

### start() (Server)

**Signature:**

```typescript theme={null}
public start(
  core: CoreStart,
  plugins: AppPluginStartDependencies
): WazuhCheckUpdatesPluginStart
```

Server start tasks:

1. **Creates internal saved objects client** - For background operations
2. **Initializes services** - Sets up update checking logic

**Returns:** Empty object

## Server Routes

The plugin exposes REST endpoints for update management.

### GET /api/v1/wazuh-check-updates/updates

Retrieve available updates.

**Query Parameters:**

**api\_id** `string`

API host ID to check updates for

**force** `boolean` (default: false)

Force fresh update check

**Response:**

```typescript theme={null}
{
  data: {
    api_id: "default",
    current_version: "4.7.0",
    last_available_major: null,
    last_available_minor: {
      version: "4.8.0",
      published_date: "2026-02-15",
      tag: "v4.8.0",
      description: "New features and improvements",
      release_url: "https://github.com/wazuh/wazuh/releases/tag/v4.8.0"
    },
    last_available_patch: {
      version: "4.7.1",
      published_date: "2026-03-01",
      tag: "v4.7.1",
      description: "Bug fixes and stability improvements",
      release_url: "https://github.com/wazuh/wazuh/releases/tag/v4.7.1"
    },
    last_check_date: "2026-03-04T10:30:00Z"
  }
}
```

### POST /api/v1/wazuh-check-updates/dismiss

Dismiss update notifications.

**Request Body:**

**version** `string` *required*

Version to dismiss notifications for

**update\_type** `string` *required*

Type of update: "major", "minor", or "patch"

**Example:**

```typescript theme={null}
const response = await fetch('/api/v1/wazuh-check-updates/dismiss', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    version: '4.8.0',
    update_type: 'minor'
  })
});
```

**Response:**

```typescript theme={null}
{
  success: true,
  message: "Update notification dismissed"
}
```

### GET /api/v1/wazuh-check-updates/preferences

Retrieve user notification preferences.

**Response:**

```typescript theme={null}
{
  data: {
    dismissed_updates: {
      "4.8.0": {
        update_type: "minor",
        dismissed_date: "2026-03-04T10:30:00Z"
      }
    },
    last_dismissed_date: "2026-03-04T10:30:00Z"
  }
}
```

### PUT /api/v1/wazuh-check-updates/preferences

Update user notification preferences.

**Request Body:**

**dismissed\_updates** `object` *required*

Map of dismissed update versions

## Request Handler Context

The plugin extends the request handler context.

**Type Definition:**

```typescript theme={null}
declare module 'opensearch_dashboards/server' {
  interface RequestHandlerContext {
    wazuh_check_updates: {
      logger: Logger;
      security: ISecurityFactory;
    };
  }
}
```

**Usage:**

```typescript theme={null}
router.get(
  { path: '/my-endpoint', validate: false },
  async (context, request, response) => {
    // Access logger
    context.wazuh_check_updates.logger.info('Checking updates');
    
    // Access security
    const user = await context.wazuh_check_updates.security.getCurrentUser(request);
    
    return response.ok();
  }
);
```

## Integration Example

Complete example of integrating update checks:

```typescript theme={null}
import React, { useEffect, useState } from 'react';
import { EuiCallOut, EuiButton, EuiSpacer } from '@elastic/eui';
import { getWazuhCheckUpdatesPlugin } from './plugin-services';

function UpdateChecker() {
  const [updates, setUpdates] = useState(null);
  const [loading, setLoading] = useState(true);
  const { getAvailableUpdates, DismissNotificationCheck } = getWazuhCheckUpdatesPlugin();
  
  useEffect(() => {
    const checkUpdates = async () => {
      try {
        const availableUpdates = await getAvailableUpdates();
        setUpdates(availableUpdates);
      } catch (error) {
        console.error('Failed to check updates:', error);
      } finally {
        setLoading(false);
      }
    };
    
    checkUpdates();
  }, []);
  
  if (loading) {
    return <div>Checking for updates...</div>;
  }
  
  const hasUpdates = updates?.last_available_patch || 
                     updates?.last_available_minor || 
                     updates?.last_available_major;
  
  if (!hasUpdates) {
    return (
      <EuiCallOut
        title="You're up to date!"
        color="success"
        iconType="check"
      >
        <p>Wazuh {updates?.current_version} is the latest version.</p>
      </EuiCallOut>
    );
  }
  
  return (
    <div>
      {updates.last_available_patch && (
        <EuiCallOut
          title="Patch update available"
          color="primary"
          iconType="iInCircle"
        >
          <p>
            Version {updates.last_available_patch.version} is available.
            This update includes bug fixes and stability improvements.
          </p>
          <EuiButton
            href={updates.last_available_patch.release_url}
            target="_blank"
          >
            View release notes
          </EuiButton>
        </EuiCallOut>
      )}
      
      <EuiSpacer />
      
      {updates.last_available_minor && (
        <EuiCallOut
          title="Minor update available"
          color="warning"
          iconType="alert"
        >
          <p>
            Version {updates.last_available_minor.version} is available.
            This update includes new features and improvements.
          </p>
          <EuiButton
            href={updates.last_available_minor.release_url}
            target="_blank"
          >
            View release notes
          </EuiButton>
        </EuiCallOut>
      )}
      
      <EuiSpacer />
      
      <DismissNotificationCheck />
    </div>
  );
}

export default UpdateChecker;
```

## Best Practices

> **Check Updates on Application Start**
>
> Check for updates when the application starts, but don't block the UI:
>
> ```typescript theme={null}
> useEffect(() => {
>   // Non-blocking update check
>   getAvailableUpdates(true).catch(console.error);
> }, []);
> ```

> **Respect User Preferences**
>
> Always check if the user has dismissed a notification before showing it:
>
> ```typescript theme={null}
> const preferences = await fetch('/api/v1/wazuh-check-updates/preferences')
>   .then(r => r.json());
>
> const isDismissed = preferences.data.dismissed_updates[version];
> ```

> **Cache Update Data**
>
> Avoid checking for updates too frequently. Use the cached data:
>
> ```typescript theme={null}
> // Use cached data (default)
> const updates = await getAvailableUpdates();
>
> // Force refresh only when necessary
> const freshUpdates = await getAvailableUpdates(false, true);
> ```

> **Handle Errors Gracefully**
>
> Update checks may fail due to network issues. Handle errors without breaking the UI:
>
> ```typescript theme={null}
> try {
>   const updates = await getAvailableUpdates();
> } catch (error) {
>   // Log but don't show error to user
>   console.error('Update check failed:', error);
>   // Continue with application functionality
> }
> ```

## Related Resources

> **[Main Plugin](/api/main-plugin)**
>
> Main dashboard plugin API

> **[Wazuh Core](/api/wazuh-core)**
>
> Core services and configuration

> **[Update Guide](/guides/upgrade)**
>
> How to upgrade Wazuh

> **[Release Notes](https://documentation.wazuh.com/current/release-notes/)**
>
> Wazuh release notes


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.