# social.coves.aggregator.createApiKey

> Published by [coves.social](https://lexicon.garden/identity/did:web:coves.social)

✓ This is the authoritative definition for this NSID.

## Links

- [View on Lexicon Garden](https://lexicon.garden/lexicon/did:web:coves.social/social.coves.aggregator.createApiKey)
- [Documentation](https://lexicon.garden/lexicon/did:web:coves.social/social.coves.aggregator.createApiKey/docs)
- [Examples](https://lexicon.garden/lexicon/did:web:coves.social/social.coves.aggregator.createApiKey/examples)

## Definitions

### `social.coves.aggregator.createApiKey`

**Type**: `procedure`

Create an API key for the authenticated aggregator. Requires OAuth authentication. The API key is returned ONCE and cannot be retrieved again. Store it securely.

#### Input

**Encoding**: `application/json`

| Property | Type | Required | Description |
|----------|------|----------|-------------|

#### Output

**Encoding**: `application/json`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `did` | `string` (did) | Yes | DID of the aggregator that owns this key |
| `key` | `string` | Yes | The plain-text API key. This is shown ONCE and cannot be retrieved again. Format: ckapi_<64-hex-chars> (32 bytes hex-encoded) |
| `createdAt` | `string` (datetime) | Yes | ISO8601 timestamp when the key was created |
| `keyPrefix` | `string` | Yes | First 12 characters of the key (e.g., 'ckapi_ab12cd') for identification in logs and UI |

#### Errors

- **AuthenticationRequired**: OAuth authentication is required to create an API key
- **OAuthSessionRequired**: OAuth session is required (not service JWT) to create an API key
- **AggregatorRequired**: Only registered aggregators can create API keys
- **KeyGenerationFailed**: Failed to generate the API key

## Raw Schema

```json
{
  "id": "social.coves.aggregator.createApiKey",
  "defs": {
    "main": {
      "type": "procedure",
      "input": {
        "schema": {
          "type": "object",
          "properties": {},
          "description": "No input required. The key is generated server-side for the authenticated aggregator."
        },
        "encoding": "application/json"
      },
      "errors": [
        {
          "name": "AuthenticationRequired",
          "description": "OAuth authentication is required to create an API key"
        },
        {
          "name": "OAuthSessionRequired",
          "description": "OAuth session is required (not service JWT) to create an API key"
        },
        {
          "name": "AggregatorRequired",
          "description": "Only registered aggregators can create API keys"
        },
        {
          "name": "KeyGenerationFailed",
          "description": "Failed to generate the API key"
        }
      ],
      "output": {
        "schema": {
          "type": "object",
          "required": [
            "key",
            "keyPrefix",
            "did",
            "createdAt"
          ],
          "properties": {
            "did": {
              "type": "string",
              "format": "did",
              "description": "DID of the aggregator that owns this key"
            },
            "key": {
              "type": "string",
              "maxLength": 256,
              "description": "The plain-text API key. This is shown ONCE and cannot be retrieved again. Format: ckapi_<64-hex-chars> (32 bytes hex-encoded)"
            },
            "createdAt": {
              "type": "string",
              "format": "datetime",
              "description": "ISO8601 timestamp when the key was created"
            },
            "keyPrefix": {
              "type": "string",
              "maxLength": 64,
              "description": "First 12 characters of the key (e.g., 'ckapi_ab12cd') for identification in logs and UI"
            }
          }
        },
        "encoding": "application/json"
      },
      "description": "Create an API key for the authenticated aggregator. Requires OAuth authentication. The API key is returned ONCE and cannot be retrieved again. Store it securely."
    }
  },
  "$type": "com.atproto.lexicon.schema",
  "lexicon": 1
}
```
