How to validate a VAT number using C# in .NET Framework

Let’s take a look at how to quickly and easily look up and validate VAT numbers within .NET Framework. It’s a lot easier than you might think. Let’s get started.

First, install Cloudmersive’s Validate API using the Package Manager console:

Install-Package Cloudmersive.APIClient.NET.Validate -Version 1.2.7

Then call VatVatLookup and input your VAT code.

using System;
using System.Diagnostics;
using Cloudmersive.APIClient.NET.Validate.Api;
using Cloudmersive.APIClient.NET.Validate.Client;
using Cloudmersive.APIClient.NET.Validate.Model;
namespace Example
public class VatVatLookupExample
public void main()
// Configure API key authorization: Apikey
Configuration.Default.AddApiKey("Apikey", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Configuration.Default.AddApiKeyPrefix("Apikey", "Bearer");
var apiInstance = new VatApi();
var input = new VatLookupRequest(); // VatLookupRequest | Input VAT code
// Lookup a VAT code
VatLookupResponse result = apiInstance.VatVatLookup(input);
catch (Exception e)
Debug.Print("Exception when calling VatApi.VatVatLookup: " + e.Message );

That’s it! Your return will include whether the number is valid, as well as the business name, address, and country code.

Image for post

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store