> ## Documentation Index
> Fetch the complete documentation index at: https://docs-alpha.pepay.io/llms.txt
> Use this file to discover all available pages before exploring further.

# API Keys

> Create, list, and revoke merchant API keys via the SDK.

## Overview

Use merchant API keys (`x-api-key`) for server-to-server integrations.

## Authentication

Requires a dashboard bearer token (`Authorization: Bearer <jwt>`).

```ts theme={null}
const pepay = new Pepay({ bearerToken: process.env.PEPAY_JWT! });
```

## Request

### List keys

```ts theme={null}
const keys = await pepay.apiKeys.list();
```

### Create a key

```ts theme={null}
const created = await pepay.apiKeys.create({
  name: 'production-server',
  expires_at: null
});
```

### Revoke a key

```ts theme={null}
await pepay.apiKeys.revoke('key_123');
```

## Response

Example list response (keys are masked):

```json theme={null}
[
  {
    "key_id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "Production API Key",
    "expires_at": null,
    "last_used_at": 1766318400,
    "created_at": 1764590400
  }
]
```

## Errors

* `401` missing/invalid dashboard bearer token
* `404` key not found (revoke)
* `403` policy limits (for example: maximum number of active keys)

## Examples

* Rotate keys by creating a new key, deploying it, then revoking the old key.

Next: [Invoices](/sdk/merchants/invoices)
