# APIKey.rolled

URL: /business/events/APIKey.rolled · Id: `event:APIKey.rolled`

> Emitted each time an API Key is rolled.

[APIKey.roll](/business/nouns/api-key/roll) emits `APIKey.rolled` when it completes on an [API Key](/business/nouns/api-key).

| Property | Value |
| --- | --- |
| Emitted by | [APIKey.roll](/business/nouns/api-key/roll) |
| Noun | [API Key](/business/nouns/api-key) |
| Wakes | None. |

### Payload
Each delivery is an [Event](/business/nouns/event) record. `data` holds what [APIKey.roll](/business/nouns/api-key/roll) returns.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | `string` | Yes | `APIKey.rolled`. |
| `at` | `datetime` | Yes | When it happened. |
| `seq` | `integer` | No | Its position in the namespace, one more than the Event before; any seq is a cursor into the history. |
| `data` | `json` | Yes | The Thing as the Action left it. |
| `data.apiKey` | [API Key](/business/nouns/api-key) | Yes | The replacement API Key. |
| `data.apiKey.name` | `string` | Yes | What the Customer calls it, so a list of keys reads by purpose. |
| `data.apiKey.environment` | `string` | Yes | One of `test` or `live`: a `test` key reaches test records and moves no money. |
| `data.apiKey.verbs` | list of [Verb](/business/nouns/verb) | No | The Verbs it may call. Unset: every Verb the Customer’s Entitlements grant. |
| `data.apiKey.prefix` | `string` | No | The first characters of the secret, shown in place of it everywhere after issue. |
| `data.apiKey.lastUsedAt` | `datetime` | No | When it last signed a call. |
| `data.apiKey.expiresAt` | `datetime` | No | When it stops working on its own. Unset: it works until rolled or revoked. |
| `data.apiKey.revokedAt` | `datetime` | No | When it was revoked. A revoked key fails its next call. |
| `data.secret` | `string` | Yes | The replacement’s full secret, returned once. |

### Example
```json
{
  "$id": "https://api.sb/petpantry.shop/events/event_1",
  "$type": "Event",
  "name": "APIKey.rolled",
  "at": "2026-10-22T12:00:00Z",
  "data": {
    "apiKey": {
      "$id": "https://api.sb/petpantry.shop/api-keys/api_key_1",
      "$type": "APIKey",
      "name": "Nightly sync",
      "environment": "test",
      "verbs": [
        "verb_1"
      ],
      "prefix": "sk_live_4f2a",
      "lastUsedAt": "2026-10-22T12:00:00Z",
      "expiresAt": "2026-10-22T12:00:00Z",
      "revokedAt": "2026-10-22T12:00:00Z"
    },
    "secret": "sk_live_9c1e…"
  },
  "seq": 1
}
```