<!-- ZenPays documentation · https://docs.zenpayz.com/docs/reference/objects/api-key -->

# The ApiKey object

Represents an API key for authenticating with the ZenPays API. API keys are used to authenticate requests and can be scoped to specific permissions and environments.

## Fields

<ParamTable
  label="Field"
  rows={[
    { name: "id", type: "string", required: true, desc: "Unique identifier for the API key" },
    { name: "name", type: "string", required: true, desc: "Descriptive name for the API key" },
    { name: "keyPrefix", type: "string", required: true, desc: "Prefix of the key for identification (e.g., 'sk_live_abc...')" },
    { name: "environment", type: "'sandbox' | 'production'", required: true, desc: "Environment the key is valid for" },
    { name: "scopes", type: "string[]", required: true, desc: "Permission scopes granted to this key" },
    { name: "lastUsedAt", type: "string", required: false, desc: "ISO 8601 timestamp when the key was last used" },
    { name: "expiresAt", type: "string", required: false, desc: "ISO 8601 timestamp when the key expires (if applicable)" },
    { name: "createdAt", type: "string", required: true, desc: "ISO 8601 timestamp when the key was created" },
  ]}
/>

## Example

```json
{
  "id": "obj_1a2b3c",
  "name": "string",
  "keyPrefix": "string",
  "environment": "sandbox",
  "scopes": [],
  "lastUsedAt": "2026-01-15T09:30:00Z",
  "expiresAt": "2026-01-15T09:30:00Z",
  "createdAt": "2026-01-15T09:30:00Z"
}
```
