API - Hello world! - Authentication

Hello World: Getting Started with MetaDefender MFT API in PowerShell

Welcome to the first step in integrating with the OPSWAT MetaDefender Manage File Transfer (MFT) API. This simple "Hello World!" example demonstrates how to authenticate with the API and retrieve the current version of your MFT instance using PowerShell.

Whether you're evaluating the API or preparing for deeper integration, this example provides a quick and practical starting point. You'll learn how to:

This is a great way to verify connectivity and ensure your credentials are working correctly before diving into more advanced operations like file scanning, policy enforcement, or audit logging.

Let’s get started!

Set Up Your API Endpoint and Credentials

Before making any requests, you’ll need to configure your script with the correct API endpoint. Replace the placeholder URL with the actual address of your MetaDefender MFT instance.

In our example we used: http://localhost:8010/vault_rest

Update the username and password with your own credentials.

The next PowerShell snippet demonstrates how to obtain an authentication token from /authenticate endpoint. This token is required for all subsequent API requests and ensures secure access to the MFT services.

Powershell
Copy

Using the Authentication Token

Once you've successfully authenticated, you'll receive an auth token. This token must be included in the Authorization header of all subsequent API requests, using the following format:

Authorization = "Bearer $token"

To retrieve the current version of MetaDefender MFT, send a GET request to the /version endpoint.

Each server response includes two components:

  • HTTP status code – indicating the result of the request (e.g., 200 for success). More on Wikipedia
  • Response body – returned in JSON format, containing the requested data. More on API Documentation

You can refer to the API documentation for a complete list of response codes and expected content for each endpoint.

Powershell
Copy

Whole Script

Powershell
Copy
Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard