Valta Docs

Authentication

There are two ways to authenticate with the Valta SDK.

Method 1: API key (recommended)

Pass your API key to the constructor. This is the standard approach for server-side applications.

ts
import { ValtaClient } from 'valta-sdk'

const valta = new ValtaClient({
  apiKey: process.env.VALTA_API_KEY,
})

API keys are set once at initialization and sent on every request. Store the key in an environment variable — never hardcode it or commit it to git.

Method 2: Email and password (CLI / scripts)

For CLI tools or scripts where an API key is not pre-configured, authenticate with email and password. The token is automatically set on the client after a successful login.

ts
const valta = new ValtaClient()

const { token, user } = await valta.auth.login('you@company.com', 'password')

// The client is now authenticated — token is set automatically
console.log(user.email)
console.log(user.plan) // 'free' | 'builder' | 'startup'

Who am I

Returns the authenticated user's profile and current credit balance.

ts
const me = await valta.auth.whoami()

console.log(me.id)               // usr_...
console.log(me.email)            // you@company.com
console.log(me.name)             // Your Name
console.log(me.plan)             // 'free' | 'builder' | 'startup'
console.log(me.creditsRemaining) // e.g. 342

Rotating API keys

Rotates your current API key. The old key is revoked immediately — update any services using it before calling this.

ts
const { token } = await valta.auth.refreshToken()
// Old key is now invalid. New token is set on the client automatically.

Logging out

Revokes the current key server-side. Any subsequent requests using it will receive a 401.

ts
await valta.auth.logout()

Where to get API keys

  1. Open dashboard.valta.co/api-keys
  2. Click Create Key and give it a name
  3. Copy the full key — it is shown once only. Store it immediately.

After creation, the dashboard shows only the key prefix (e.g. sk_valta_abc...). The full value cannot be retrieved again.

API keys are scoped to your user account. Do not share keys between projects. Revoke unused keys from the dashboard or via valta.keys.revoke(keyId).

Next steps