Skip to main content
The official Unkey Go SDK provides full access to Unkey’s API for managing keys, verifying requests, and rate limiting in Go applications.

Installation

Requirements: Go 1.21 or higher

Initialization

Create a client with your root key:
Never expose your root key in client-side code or commit it to version control.

Verify API Keys

Validate a user’s API key:

Verification Response

The response contains:

HTTP Middleware

Protect your HTTP endpoints with authentication:

Standard Library (net/http)

Gin Framework

Echo Framework


Create API Keys

Issue new keys for your users:
The full API key is only returned once at creation. Unkey stores only a cryptographic hash.

Create Key with Auto-Refill

Create Key with Rate Limits


Update Keys

Modify an existing key:

Delete Keys

Permanently revoke a key:

Rate Limiting

Use the rate limit API directly:

Cost-Based Rate Limiting


Error Handling

Handle errors with type assertions:

Advanced Usage

Context with Timeout

Custom HTTP Client

Concurrent Verification


Complete Example: API Server


GitHub Repository

Go SDK on GitHub

Complete auto-generated API reference and source code

Next Steps

Go Quickstart

Step-by-step integration guide

Rate Limiting

Protect endpoints from abuse

Authorization

Add roles and permissions

API Reference

REST API documentation