unkey

Expert information on Unkey, an open-source API key management platform. Suitable for helping developers create, validate, and manage API keys, and for guidance on features such as built-in rate limiting, usage tracking, temporary keys, key rotation, and key-based access controls to provide an API authentication layer for developer platforms, SaaS APIs, and internal services.

Last repository push
GitHub Stars
219
Forks
38
Issues / PRs
1

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "unkey" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-aba9b17e42679a0968aa7b0257879e5ef584ac0484d1f690abd2bb075408341c. Verify the upstream source and version against https://github.com/TerminalSkills/skills before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

github.com

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Expert information on Unkey, an open-source API key management platform. Suitable for helping developers create, validate, and manage API keys, and for guidance on features such as built-in rate limiting, usage tracking, temporary keys, key rotation, and key-based access controls to provide an API authentication layer for developer platforms, SaaS APIs, and internal services.

0 Downloads

Introduction source: third_party · TerminalSkills · 1.0.0 Reference

SkillPi interpretation

Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: unkey
description: >-
  You are an expert in Unkey, the open-source API key management platform.
  You help developers create, validate, and manage API keys with built-in rate
  limiting, usage tracking, temporary keys, key rotation, and per-key
  permissions — providing the complete API authentication layer for developer
  platforms, SaaS APIs, and internal services without building custom key
  infrastructure.
license: Apache-2.0
compatibility: ''
metadata:
  author: terminal-skills
  version: 1.0.0
  category: Backend Development
  tags:
    - api-keys
    - authentication
    - rate-limiting
    - usage
    - developer-platform

Unkey — API Key Management

You are an expert in Unkey, the open-source API key management platform. You help developers create, validate, and manage API keys with built-in rate limiting, usage tracking, temporary keys, key rotation, and per-key permissions — providing the complete API authentication layer for developer platforms, SaaS APIs, and internal services without building custom key infrastructure.

Core Capabilities

Key Management

import { Unkey } from "@unkey/api";

const unkey = new Unkey({ rootKey: process.env.UNKEY_ROOT_KEY! });

// Create API key for a customer
const { result } = await unkey.keys.create({
  apiId: process.env.UNKEY_API_ID!,
  prefix: "sk_live",                       // Key prefix for identification
  name: "Acme Corp Production Key",
  ownerId: "customer-42",                  // Link to your user
  meta: {                                  // Custom metadata
    plan: "pro",
    team: "engineering",
  },
  roles: ["api.read", "api.write"],        // RBAC permissions
  ratelimit: {
    type: "fast",
    limit: 100,                            // 100 requests
    duration: 60000,                       // Per minute
  },
  remaining: 10000,                        // Total usage limit (optional)
  expires: Date.now() + 30 * 24 * 60 * 60 * 1000,  // 30 days (optional)
});

console.log(result.key);                   // sk_live_abc123... (show once!)
console.log(result.keyId);                 // key_xxx (for management)

Key Verification (in your API)

import { verifyKey } from "@unkey/api";

// Middleware — verify API key on every request
async function authMiddleware(req: Request) {
  const key = req.headers.get("Authorization")?.replace("Bearer ", "");
  if (!key) return new Response("Missing API key", { status: 401 });

  const { result, error } = await verifyKey({
    key,
    apiId: process.env.UNKEY_API_ID!,
  });

  if (error || !result.valid) {
    return new Response(JSON.stringify({
      error: "Invalid API key",
      code: result?.code,                  // "NOT_FOUND" | "RATE_LIMITED" | "USAGE_EXCEEDED" | "EXPIRED"
    }), { status: result?.code === "RATE_LIMITED" ? 429 : 403 });
  }

  // Key is valid — access metadata
  const { ownerId, meta, roles, remaining, ratelimit } = result;
  console.log(`Customer: ${ownerId}, Plan: ${meta.plan}, Remaining: ${remaining}`);

  // Check permissions
  if (!roles.includes("api.write") && req.method !== "GET") {
    return new Response("Insufficient permissions", { status: 403 });
  }

  // Rate limit info in response headers
  return {
    ownerId,
    meta,
    headers: {
      "X-RateLimit-Limit": String(ratelimit?.limit),
      "X-RateLimit-Remaining": String(ratelimit?.remaining),
      "X-RateLimit-Reset": String(ratelimit?.reset),
    },
  };
}

Key Lifecycle

// Update key (change limits, roles)
await unkey.keys.update({
  keyId: "key_xxx",
  ratelimit: { type: "fast", limit: 500, duration: 60000 },  // Upgrade limit
  roles: ["api.read", "api.write", "api.admin"],
  meta: { plan: "enterprise" },
});

// Revoke key
await unkey.keys.delete({ keyId: "key_xxx" });

// List keys for a customer
const { result: keys } = await unkey.apis.listKeys({
  apiId: process.env.UNKEY_API_ID!,
  ownerId: "customer-42",
});

// Usage analytics
const { result: verifications } = await unkey.keys.getVerifications({
  keyId: "key_xxx",
  start: Date.now() - 7 * 24 * 60 * 60 * 1000,  // Last 7 days
  end: Date.now(),
  granularity: "day",
});

Installation

npm install @unkey/api

Best Practices

  1. Prefix keys — Use sk_live_, sk_test_ prefixes; identifies key type at a glance
  2. Rate limiting built-in — Set per-key rate limits at creation; Unkey enforces at verify time
  3. Usage limits — Set remaining for prepaid/quota models; key auto-invalidates when exhausted
  4. RBAC roles — Assign roles to keys; check in your middleware; scope access per endpoint
  5. Key rotation — Create new key, update client, revoke old; zero-downtime rotation
  6. Metadata — Store plan, team, environment in meta; use for analytics and feature flags
  7. Expiring keys — Set expires for trial keys, temporary access; auto-expire without cron
  8. Self-hostable — Run Unkey on your own infrastructure for data sovereignty; open-source

Current listing version

1.0.0

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value92/100

Highlights

  • 提供完整的 API 密钥管理解决方案,涵盖创建、验证、权限控制、速率限制等核心功能
  • 面向开发者平台、SaaS API 和内部服务,解决高频刚需问题
  • 包含端到端代码示例和最佳实践指导
Trigger Precision95/100

Highlights

  • description 明确描述 Unkey 专家角色及核心能力
  • 触发词精准覆盖 API 密钥管理的多种场景
  • 边界清晰,无歧义
Structure and Standards95/100

Highlights

  • 结构清晰,分区明确(Core Capabilities、Installation、Best Practices)
  • 包含完整 TypeScript 代码示例
  • frontmatter 完整,单文件长度符合规范
Execution Reliability90/100

Highlights

  • 工具来源明确(@unkey/api)
  • 参数使用正确,包含完善的错误处理机制
  • 覆盖主要异常场景(无效密钥、速率限制、权限不足)
Evidence Verifiability (mean of the first four)93/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.