API Key Authentication

Secure Your Dart Frog API with API Keys

The Zuplo API Gateway protects your backend API from unauthorized access, abuse, and overload. Add API key authentication to your Dart Frog API in minutes.

Secure Access

Authenticate every request before it reaches your backend.

Control Costs

Set rate limits and quotas to prevent runaway usage.

Ensure Reliability

Shield your backend from overload with traffic management.

How it works

The Zuplo API Gateway sits between your clients and your Dart Frog backend, providing a secure layer of protection and control.

Customer VPC
Backend
Client
Zuplo API Gateway
Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.

Step-by-step tutorial

It takes only a few minutes to put Zuplo in front of your Dart Frog backend, adding API key authentication, and configuring your origin to trust requests from Zuplo using JWT verification.

1

Create a Route in Zuplo

First, create a new route in your Zuplo project that will proxy requests to your Dart Frog backend. This route will be the entry point for your API consumers.

Creating a route in Zuplo
Learn how to create routes

📄 OpenAPI native. Import your existing OpenAPI spec to instantly create routes and power your API documentation.

2

Add API Key Authentication Policy

Add the API Key Authentication policy to your route. This policy validates incoming API keys and ensures only authorized consumers can access your API.

Adding API Key Authentication policy in Zuplo
API Key Authentication docs

🔐 Leaked key? No problem. As a GitHub Secret Scanning partner, Zuplo can automatically revoke exposed keys before they can be exploited.

3

Enable the JWT Service Plugin

Enable the JWT Service Plugin in your Zuplo project. This plugin generates JWTs that your origin API can validate, creating a secure trust relationship between Zuplo and your backend.

TypeScriptmodules/zuplo.runtime.ts
export function runtimeInit(runtime: RuntimeExtensions) {
  // Register the JWT Service Plugin
  runtime.addPlugin(new JwtServicePlugin());
}
JWT Service Plugin docs
4

Secure Your Dart Frog API with JWT Authentication

Configure your Dart Frog backend to validate the JWTs issued by Zuplo. This ensures that only requests coming through your Zuplo gateway are accepted.

JavascriptDart
import 'dart:convert';
import 'package:dart_frog/dart_frog.dart';
import 'package:jose/jose.dart';
import 'package:http/http.dart' as http;

const String issuer = 'https://my-api-a32f34.zuplo.api/__zuplo/issuer';
const String jwksUrl = '$issuer/.well-known/jwks.json';

Future<Jwks> fetchJwks() async {
  final response = await http.get(Uri.parse(jwksUrl));
  if (response.statusCode != 200) {
    throw Exception('Failed to load JWKS');
  }
  return Jwks.fromJson(jsonDecode(response.body));
}

Handler validateJwt(Handler handler) {
  return (context) async {
    final authorization = context.request.headers['Authorization'];
    if (authorization == null || !authorization.startsWith('Bearer ')) {
      return Response(statusCode: 401, body: 'No token provided');
    }

    final token = authorization.substring(7);
    try {
      final jwks = await fetchJwks();
      final jwt = JsonWebToken.unverified(token);

      final keyStore = JsonWebKeyStore()
        ..addKeySetUrl(Uri.parse(jwksUrl));

      final isValid = await jwt.verify(keyStore, issuer: issuer, algorithms: ['RS256']);

      if (!isValid) {
        return Response(statusCode: 401, body: 'Invalid token');
      }

      context = context.provide<JsonWebToken>(() => jwt);
      return handler(context);
    } catch (e) {
      return Response(statusCode: 401, body: 'Invalid token');
    }
  };
}

final Handler protectedRoute = (context) async {
  final jwt = context.read<JsonWebToken>();
  final claims = jwt.claims;

  return Response.json(body: {
    'message': 'Access granted',
    'user': claims.toJson(),
  });
};

void main() {
  final app = Router()
    ..use(validateJwt)
    ..get('/protected', protectedRoute);

  serve(app);
}
5

Call Your API Through Zuplo

Now you can call your API through Zuplo using an API key. The request will be authenticated at the gateway, and a JWT will be forwarded to your Dart Frog backend.

Terminalbash
curl -X GET \
  'https://your-api.zuplo.dev/your-route' \
  -H 'Authorization: Bearer YOUR_API_KEY'

Ready to secure your API?

Get started with Zuplo for free and add API key authentication to your Dart Frog API in minutes.

Start for FreeRead the Docs

Scale your APIs with
confidence.

Start for free or book a demo with our team.
Book a demoStart for Free
SOC 2 TYPE 2High Performer Spring 2025Momentum Leader Spring 2025Best Estimated ROI Spring 2025Easiest To Use Spring 2025Fastest Implementation Spring 2025

Get Updates From Zuplo

Zuplo logo
© 2026 zuplo. All rights reserved.
Products & Features
API ManagementAI GatewayMCP ServersMCP GatewayDeveloper PortalRate LimitingOpenAPI NativeGitOpsProgrammableAPI Key ManagementMulti-cloudAPI GovernanceMonetizationSelf-Serve DevX
Developers
DocumentationBlogLearning CenterCommunityChangelogIntegrations
Product
PricingSupportSign InCustomer Stories
Company
About UsMedia KitCareersStatusTrust & Compliance
Privacy PolicySecurity PoliciesTerms of ServiceTrust & Compliance
Docs
Pricing
Sign Up
Login
ContactBook a demoFAQ
Zuplo logo
DocsPricingSign Up
Login