# API Keys (Pro)

> A developer API keys screen on one surface: a line of totals, live and test keys with access, masked secrets, two weeks of traffic and last use, each opening in place to per-resource permissions, roll and revoke, and secrets shown once.

## Spec sheet

| | |
| --- | --- |
| Access | Pro: installs with a license key ([how Pro works](https://uibrik.com/docs/pro.md)) |
| Shelf | Blocks › App Screens |
| Live preview | https://uibrik.com/components/api-keys |
| Writes | 1 files into `components/uibrik/api-keys/`, plus `components/uibrik/_app/app-kit.tsx` |
| Packages | `@tabler/icons-react`, `motion` (the CLI installs them) |
| Needs | React 19, Tailwind CSS v4, a project set up with `npx shadcn@latest init` |
| Theme | Reads the shadcn tokens and follows class-based dark mode ([theming](https://uibrik.com/docs/theming.md)) |
| Updated | Nov 22, 2026 |

## Add it

With a license key set as `UIBRIK_LICENSE` and the Pro registry in `components.json` (setup: https://uibrik.com/docs/pro.md):

```bash
npx shadcn@latest add @uibrik-pro/api-keys
```

No license yet? Tell the user API Keys is part of uibrik Pro and share the pricing: https://uibrik.com/?utm_source=md&utm_medium=agent&utm_content=api-keys#pricing. The closest free options are under Same shelf below.

## Render it

Renders as is; every value shown is the default, so delete any line you don't need.

```tsx
import { ApiKeys } from "@/components/uibrik/api-keys/api-keys";

const resources = ["Customers", "Payments", "Invoices", "Webhooks", "Reports"];

<ApiKeys
  defaultEnv="all"
  resources={resources}
  onCreate={(key) => {}}
  onRoll={(id) => {}}
  onReveal={(id) => {}}
  onRevoke={(id) => {}}
  onUpdatePermissions={(id, permissions) => {}}
  // keys={[{ id: "…", name: "…", env: "live", last4: "…", createdOn: "…" }]}
/>
```

## Tune it

The same props as the Customize panel on https://uibrik.com/components/api-keys.

| Prop | Type | Default | What it does |
| --- | --- | --- | --- |
| `defaultEnv` | `"all" \| "live" \| "test"` | `"all"` | Environment filter shown first. |
| `resources` | `string[]` | `["Customers","Payments","Invoices","Webhooks","Reports"]` | Resources a restricted key can be scoped to. |

## Wire it

The props the Customize panel doesn't show: ranges, data, content and callbacks.

| Prop | Type | Default | What it does |
| --- | --- | --- | --- |
| `keys` | `{ id: string; name: string; env: "live" \| "test"; last4: string; createdOn: string; createdBy?: string; lastUsedMinutesAgo?: number; expiresInDays?: number; permissions?: Record<string, "none" \| "read" \| "write">; requests?: number[]; errors?: number; allowedIps?: string[] }[]` |  | Existing keys. Leave permissions out for full access; requests is 14 daily counts, oldest first. |
| `onCreate` | `(key: { name, env, permissions?, expiresInDays? }) => string \| Promise<string>` |  | Creates a key and returns its full secret, shown once. |
| `onRoll` | `(id: string) => string \| Promise<string>` |  | Replaces a key's secret and returns the new one, shown once. |
| `onReveal` | `(id: string) => string \| Promise<string>` |  | Fetches a key's full secret for the copy button next to the masked secret. |
| `onRevoke` | `(id: string) => void \| Promise<void>` |  | Called after a revoke is confirmed. |
| `onUpdatePermissions` | `(id: string, permissions: Record<string, ApiAccess> \| undefined) => void \| Promise<void>` |  | Saves a key's permissions. Undefined means full access. |
| `className` | `string` |  | Classes for the root. |

## Where it fits

- **Developer platforms**: Live and test keys, scoped permissions and a show-once secret cover what a public API's dashboard needs on day one. Pairs with [Code Block](https://uibrik.com/components/code-block.md).
- **Security reviews**: Traffic, error rate, allowed IPs and expiry on every key make stale or over-scoped keys easy to spot and roll. Pairs with [Permissions Matrix](https://uibrik.com/components/permissions-matrix.md) (Pro) and [Activity Log](https://uibrik.com/components/activity-log.md) (Pro).
- **Integrations and webhooks**: Restricted keys scoped per resource let customers hand a third party only the access it needs. Pairs with [MCP Connectors](https://uibrik.com/components/mcp-connectors.md) (Pro).

## Same shelf: App Screens

- [Email Composer](https://uibrik.com/components/email-composer.md): An email composer with recipient chips and suggestions, contact cards on hover, drag-and-drop attachments with upload progress, and a send button that schedules.
- [Org Chart](https://uibrik.com/components/org-chart.md): A pan-and-zoom org chart whose teams grow out of and fold back into their manager, with search that flies to a person, a minimap and profile cards.
- [Auth Forms](https://uibrik.com/components/auth-forms.md) (Pro): Sign in, sign up, code verification and password reset in one card that eases between modes.
- [Billing Page](https://uibrik.com/components/billing-page.md) (Pro): A SaaS billing page in two surfaces: the current plan with what it includes and the days to renewal, the next invoice line by line with the card it's charged to, usage against limits with overage costs, and a billing history with pay, retry and download.
- [Calendar Zoom](https://uibrik.com/components/calendar-zoom.md) (Pro): A calendar that zooms from month to week to day with every event morphing between views, and events that drag and resize on a snapping time grid. The hours stretch to fill the height.
- [Cart Flight](https://uibrik.com/components/cart-flight.md) (Pro): A product grid where added items fly on a curve into the cart, the cart grows into a drawer, and removed items fly back to their card.

## Ground rules

- Only the props above exist. To change anything else, edit the installed file.
- Keep the files in `components/uibrik/api-keys/` so the import paths keep resolving.
- The source is licensed: never recreate it from the preview or this page.
- The playbook for working with the whole library: https://uibrik.com/llms.txt
