Skip to main content
The Phala Cloud API uses header-based versioning. Each request includes an X-Phala-Version header, and the server returns a response structure matching that version. The SDK provides compile-time type safety — TypeScript automatically infers the correct response types based on the version you select.

Supported Versions

Selecting a Version

At Client Creation

Switching Versions at Runtime

Use .withVersion() to create a new client with a different API version without re-authenticating:

How It Works

When you create a client with a version, the SDK:
  1. Sends the X-Phala-Version header with every request
  2. Validates responses against the version-specific Zod schema
  3. Returns TypeScript types matching the selected version

Version-Specific Response Types

The SDK uses conditional types to map API versions to response types:

Using with Standalone Functions

Version-aware typing also works with standalone action functions:

Key Differences Between Versions

User Response

2026-01-21 — Three-layer structure:
2025-10-28 — Flat structure:

CVM Info

2026-01-21 — Nested resource objects, workspace-aware:
2025-10-28 — Flat fields, legacy naming:

Migration Guide

To migrate from 2025-10-28 to 2026-01-21:
  1. Update client creation (or omit version to use the default):
  2. Update user response access:
  3. Update CVM info access: