Skip to main content
This guide shows how to add API key verification to your Go applications using the official Unkey Go SDK.

Prerequisites

  • Go 1.21 or higher
  • An Unkey account (free at unkey.com)

1. Install the SDK

2. Set up your Unkey credentials

  1. Create a keyspace in the Unkey Dashboard
  2. Create a root key at Settings → Root Keys
  3. Copy your API ID (looks like api_xxxx)
Set your root key as an environment variable:

3. Create middleware

Here’s how to verify API keys with standard library net/http:

4. Run your server

Test it with a valid API key:

Using with Gin

If you’re using the Gin framework:

Using with Echo

For the Echo framework:

What’s next?

Add rate limiting

Protect your endpoints from abuse

Go SDK Reference

Complete Go SDK documentation

Authorization

Add roles and permissions

Cookbook

More Go recipes and examples
Last modified on June 2, 2026