---
name: keypal
description: "Read the keypal docs instead of answering from memory. API key authentication for TypeScript. Issue keys, verify them on every request, scope and revoke them, storing only key hashes in the database you run. Use when a task involves keypal: how it works, how to set it up or configure it, or its API."
---

# keypal

API key authentication for TypeScript. Issue keys, verify them on every request, scope and revoke them, storing only key hashes in the database you run.

This skill points you at the keypal docs, at https://keypal.dev/. When a task involves keypal, read the relevant page before relying on what you remember: the docs are the source of truth, and they change.

## Reading the docs

- Any page as Markdown: add `.md` to its URL (the home page is https://keypal.dev/index.md). Every page link below already points at the Markdown.
- [llms.txt](https://keypal.dev/llms.txt): every page with a one-line summary.
- [llms-full.txt](https://keypal.dev/llms-full.txt): every page in one file, for when you need all of it.
- [JSON API](https://keypal.dev/api/docs/pages.json): the page index, with each page as JSON and Markdown.
- [Changelog](https://keypal.dev/changelog.md): release notes, newest first.

## Pages

- [keypal documentation](https://keypal.dev/docs.md): keypal is API key authentication for TypeScript: issue keys, verify them on every request, scope and revoke them, with memory, Redis or SQL storage.

### Getting started

- [Installation](https://keypal.dev/docs/getting-started/installation.md): Install keypal, then add the database client for the storage adapter you use: ioredis, drizzle-orm, kysely or @prisma/client. The core needs none.
- [Quick start](https://keypal.dev/docs/getting-started/quick-start.md): Go from an empty project to an authenticated request in five steps: create a manager, issue a key, verify it, check its scopes, and revoke it.
- [Configuration](https://keypal.dev/docs/getting-started/configuration.md): Every option createKeys takes, with its default and when to change it, plus the settings you must never change once keys have been issued.

### Concepts

- [API keys](https://keypal.dev/docs/concepts/api-keys.md): What a keypal API key is, what gets stored instead of the secret, what verify checks on every request, and how a key moves from created to revoked.
- [Scopes and permissions](https://keypal.dev/docs/concepts/scopes-and-permissions.md): Limit what each API key may do with scopes, check them on every request, and let a broad scope keep granting the narrower ones you split out of it.
- [Resource scopes](https://keypal.dev/docs/concepts/resource-scopes.md): Grant an API key scopes on specific projects, sites or teams instead of everything, and how keypal combines global, resource and implied scopes.
- [Expiration](https://keypal.dev/docs/concepts/expiration.md): Give API keys an expiry date so they stop working on their own, how keypal treats dates it can't read, and how to check a key's status yourself.
- [Tags](https://keypal.dev/docs/concepts/tags.md): Label API keys with tags so you can find and list groups of keys, such as every key for one environment or integration, then act on each key.
- [Caching](https://keypal.dev/docs/concepts/caching.md): What keypal's key cache stores, why verify still reads every key from storage, and the one setup where turning the cache on saves a round trip.
- [Audit logging](https://keypal.dev/docs/concepts/audit-logging.md): Record who created, revoked, rotated, enabled or disabled each API key, which storage adapters keep the log, and how to query or prune the history.

### Storage

- [Overview](https://keypal.dev/docs/storage/overview.md): Where keypal keeps your API keys: compare the Redis, Drizzle, Kysely, Prisma and memory adapters, what each needs installed, and how to choose.
- [Memory](https://keypal.dev/docs/storage/memory.md): keypal's default in-process store, which keeps keys in memory for tests and local development and loses them when the process exits.
- [Redis](https://keypal.dev/docs/storage/redis.md): Store API keys in Redis with ioredis: the key layout keypal uses, how revoked keys expire, why updates can't undo a revoke, and what isn't supported.
- [Drizzle](https://keypal.dev/docs/storage/drizzle.md): Store API keys in PostgreSQL, MySQL, MariaDB or SQLite through Drizzle ORM: the table schema, column mapping, audit logs and how updates stay safe.
- [Kysely](https://keypal.dev/docs/storage/kysely.md): Store API keys in PostgreSQL, MySQL, MariaDB or SQLite through Kysely: the SQL for each database, column mapping, options and audit log tables.
- [Prisma](https://keypal.dev/docs/storage/prisma.md): Store API keys in PostgreSQL through Prisma: the model to add to your schema, field mapping, the audit log model, and how concurrent updates are handled.
- [Custom storage](https://keypal.dev/docs/storage/custom-storage.md): Verify API keys against a table you already have with a small findByHash lookup, or implement keypal's full Storage interface for any database.

### API reference

- [createKeys()](https://keypal.dev/docs/api-reference/create-keys.md): Create a keypal manager with createKeys: every option it accepts, its default, and the errors it throws for a bad length, alphabet or storage setup.
- [Verification](https://keypal.dev/docs/api-reference/verification.md): Verify an API key from a string or request headers with keypal, read the error code when it fails, and control how often lastUsedAt is written.
- [Key management](https://keypal.dev/docs/api-reference/key-management.md): Create, find, list, revoke, rotate, enable and disable API keys with the keypal manager, including what each method returns and throws.
- [Permissions](https://keypal.dev/docs/api-reference/permissions.md): Check a key's scopes with hasScope, hasAnyScope and hasAllScopes, including per-resource scopes, implied scopes and the checkResource helpers.
- [Audit logs](https://keypal.dev/docs/api-reference/audit-logs.md): Query, count, delete and summarize keypal's audit log entries, with the filters each method takes and the errors it throws when logging is off.
- [Utilities](https://keypal.dev/docs/api-reference/utilities.md): Manager helpers for pulling a key out of request headers, generating and hashing keys, comparing them safely, and clearing a cached key.

### Utilities

- [Standalone functions](https://keypal.dev/docs/utilities/standalone-functions.md): keypal functions you can call without a manager: generate and hash keys, compare them, read keys from headers, check scopes, and get key status.
- [ResourceBuilder](https://keypal.dev/docs/utilities/resource-builder.md): Build a key's resources map with ResourceBuilder's chainable API instead of writing nested objects by hand, then pass it to create or rotate.
- [Error handling](https://keypal.dev/docs/utilities/error-handling.md): Every error code keypal returns from verify or throws from manager methods, what each one means, and how to turn them into HTTP responses.

### Community

- [Contributing](https://keypal.dev/docs/community/contributing.md): Set up the keypal repository, run the unit tests and the Redis and Postgres suites locally, and send a pull request that keeps every key working.
- [AI resources](https://keypal.dev/docs/community/ai.md): Give coding agents keypal's docs: llms.txt and llms-full.txt, a Markdown copy of every page, an agent skill, and a prompt to paste into your editor.
