```yaml
product: AlterLab
title: Keys API Reference
category: api
comparison_context: "AlterLab is an alternative to Firecrawl, ScrapingBee, and Bright Data."
source_url: https://alterlab.io/docs/api/generated/keys
```

# Keys API Reference

Auto-generated API reference for keys endpoints, built from the OpenAPI spec.

## GET /api/v1/api-keys

List API keys
List active API keys for the current organization. Returns key metadata (name, prefix, scopes, last used) but never the full key value. Supports pagination.

Authentication: `Authorization: Bearer <session token>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `limit` | query | `integer` | no | Maximum number of keys to return (1-100) |
| `offset` | query | `integer` | no | Number of keys to skip |
| `created_via` | query | `string` | no | Only keys created this way (dashboard, agent_signup, agent_trial, mcp_oauth, cli, platform, internal). |
| `X-Organization-Id` | header | `string` | no |  |

## POST /api/v1/api-keys

Create an API key
Create a new API key for the current organization. The full key value is returned ONLY in this response — store it securely. Subsequent requests only return the key prefix.

Authentication: `Authorization: Bearer <session token>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `X-Organization-Id` | header | `string` | no |  |
| `name` | body | `string` | yes | Name for the API key |
| `default_max_age` | body | `integer` | no |  |
| `scopes` | body | `string[]` | no |  |

## POST /api/v1/api-keys/legacy-notice-shown

Mark Legacy Notice Shown
Mark the legacy keys deprecation notice as shown for this user.

Authentication: `Authorization: Bearer <session token>`

## GET /api/v1/api-keys/legacy-status

Get Legacy Keys Status
Legacy-key notice status. Kept for dashboard compatibility: no key stores a recoverable copy any more, so there are never legacy keys to report.

Authentication: `Authorization: Bearer <session token>`

## POST /api/v1/api-keys/service-account

Create a service account API key
Create a service account (M2M) API key scoped to the current organisation. Unlike user keys, service account keys have no associated user and can be restricted to specific IP ranges via an allowlist. Restricted to org owners and admins. The full key value is returned ONLY in this response — store it securely.

Authentication: `Authorization: Bearer <session token>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `X-Organization-Id` | header | `string` | no |  |
| `name` | body | `string` | yes | Descriptive name for the key |
| `ip_allowlist` | body | `string[]` | no |  |
| `replaces_key_id` | body | `string` | no |  |
| `scopes` | body | `string[]` | no |  |

## DELETE /api/v1/api-keys/{key_id}

Revoke an API key
Soft-delete (revoke) an API key. The key is immediately invalidated and can no longer be used for authentication.

Authentication: `Authorization: Bearer <session token>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `key_id` | path | `string` | yes | API key id |
| `X-Organization-Id` | header | `string` | no |  |

## PATCH /api/v1/api-keys/{key_id}

Rename an API key
Rename an API key. Owner/Admin can rename any key; members can only rename their own.

Authentication: `Authorization: Bearer <session token>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `key_id` | path | `string` | yes | API key id |
| `X-Organization-Id` | header | `string` | no |  |
| `name` | body | `string` | no |  |
| `default_max_age` | body | `integer` | no |  |

## POST /api/v1/api-keys/{key_id}/activate-demo

Run a one-time, non-billed demo scrape for this key
Executes exactly one scrape against a fixed demo URL on behalf of the authenticated user, without debiting credits, then marks the key as activated (last_used_at) and fires the first_scrape activation event. Allowed once per key and rate limited per user.

Authentication: `Authorization: Bearer <session token>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `key_id` | path | `string` | yes | API key id |
| `X-Organization-Id` | header | `string` | no |  |

## DELETE /api/v1/api-keys/{key_id}/limits

Delete Key Limits
Remove spend limits from an API key.

Authentication: `X-API-Key: <your key>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `key_id` | path | `string` | yes | API key UUID |
| `X-Organization-Id` | header | `string` | no |  |

## GET /api/v1/api-keys/{key_id}/limits

Get Key Limits
Get spend limit configuration and status for a specific API key.

Authentication: `X-API-Key: <your key>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `key_id` | path | `string` | yes | API key UUID |
| `X-Organization-Id` | header | `string` | no |  |

## PUT /api/v1/api-keys/{key_id}/limits

Set Key Limits
Set or update spend limits for an API key. At least one of budget_limit_microcents or request_limit must be set.

Authentication: `X-API-Key: <your key>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `key_id` | path | `string` | yes | API key UUID |
| `X-Organization-Id` | header | `string` | no |  |
| `budget_limit_microcents` | body | `integer` | no |  |
| `request_limit` | body | `integer` | no |  |
| `reset_period` | body | `"daily" \| "weekly" \| "monthly"` | no | How often the counters reset. |
| `enabled` | body | `boolean` | no | Whether this limit is active. |
| `approval_above_usd` | body | `number` | no |  |

## POST /api/v1/api-keys/{key_id}/regenerate

Regenerate an API key
Regenerate an API key value while preserving name, limits, and metadata. The new key works immediately; the old key keeps working until `previous_key_valid_until` (API_KEY_ROTATION_GRACE_SECONDS, default 24h). The new full key value is returned ONLY in this response.

Authentication: `Authorization: Bearer <session token>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `key_id` | path | `string` | yes | API key id |
| `X-Organization-Id` | header | `string` | no |  |

## GET /api/v1/api-keys/{key_id}/usage

Get Key Usage
Get usage summary for a specific API key.

Authentication: `Authorization: Bearer <session token>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `key_id` | path | `string` | yes | API key UUID |
| `days` | query | `integer` | no | Days of usage to query |
| `X-Organization-Id` | header | `string` | no |  |

## GET /api/v1/api-keys/{key_id}/usage/by-tier

Get Key Usage By Tier
Get usage breakdown by scraping tier for a specific API key.

Authentication: `Authorization: Bearer <session token>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `key_id` | path | `string` | yes | API key UUID |
| `days` | query | `integer` | no | Days of usage to query |
| `X-Organization-Id` | header | `string` | no |  |

## GET /api/v1/api-keys/{key_id}/usage/errors

Get Key Usage Errors
Get error type aggregation for a specific API key.

Authentication: `Authorization: Bearer <session token>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `key_id` | path | `string` | yes | API key UUID |
| `days` | query | `integer` | no | Days of usage to query |
| `X-Organization-Id` | header | `string` | no |  |

## GET /api/v1/api-keys/{key_id}/usage/requests

Get Key Usage Requests
Get paginated request log for a specific API key. Supports filtering by status (success/failed), tier, and domain. Results are ordered by created_at DESC.

Authentication: `Authorization: Bearer <session token>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `key_id` | path | `string` | yes | API key UUID |
| `days` | query | `integer` | no | Days of usage to query |
| `page` | query | `integer` | no | Page number (1-based) |
| `page_size` | query | `integer` | no | Rows per page |
| `status` | query | `"success" \| "failed"` | no | Filter by request outcome |
| `tier` | query | `string` | no | Filter by tier_used value |
| `domain` | query | `string` | no | Substring match on extracted domain |
| `X-Organization-Id` | header | `string` | no |  |

## GET /api/v1/api-keys/{key_id}/usage/timeseries

Get Key Usage Timeseries
Get daily spend and request counts for a specific API key.

Authentication: `Authorization: Bearer <session token>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `key_id` | path | `string` | yes | API key UUID |
| `days` | query | `integer` | no | Days of usage to query |
| `X-Organization-Id` | header | `string` | no |  |
