Valta Docs
API Keys SDK
ApiKey type
| Field | Type | Description |
|---|---|---|
id | string | Key ID, used to revoke. |
name | string | Human-readable label you assigned at creation. |
keyPrefix | string | First few characters of the key (e.g. sk_valta_abc...). |
tier | string | The tier this key operates under. |
lastUsed | string | null | ISO 8601 timestamp of the last authenticated request, or null if never used. |
createdAt | string | ISO 8601 timestamp. |
The full key value is never included in list or get responses. It is returned only at creation.
valta.keys.list()
Returns all API keys on your account. Never includes the full key value.
Returns ApiKey[]
ts
import { ValtaClient } from 'valta-sdk'
const valta = new ValtaClient({ apiKey: process.env.VALTA_API_KEY })
const keys = await valta.keys.list()
for (const key of keys) {
console.log(key.id, key.name, key.keyPrefix, key.lastUsed)
}
valta.keys.create(params)
Creates a new named API key. The full key is returned once only in fullKey. It cannot be retrieved again.
Parameters
| Field | Type | Required | Description |
|---|---|---|---|
name | string | yes | Label for this key (e.g. production, ci-pipeline). |
Returns CreateKeyResponse
| Field | Type | Description |
|---|---|---|
id | string | Key ID for future revocation. |
name | string | The name you provided. |
keyPrefix | string | Displayable prefix. |
fullKey | string | The complete API key. Shown once — store immediately. |
createdAt | string | ISO 8601 timestamp. |
ts
const result = await valta.keys.create({ name: 'production' })
// Store result.fullKey immediately — it cannot be retrieved again
console.log(result.fullKey) // sk_valta_...
console.log(result.id) // key_...
Store the
fullKeyimmediately. Once this response is gone, the full key cannot be retrieved again. If you lose it, revoke the key and create a new one.
valta.keys.revoke(keyId)
Permanently revokes a key. Any request using the revoked key will receive 401 UNAUTHORISED immediately. This action cannot be undone.
Returns { success: true }
ts
await valta.keys.revoke('key_...')
// { success: true }
// All subsequent requests with that key return 401