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:- Sends the
X-Phala-Versionheader with every request - Validates responses against the version-specific Zod schema
- 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 from2025-10-28 to 2026-01-21:
-
Update client creation (or omit
versionto use the default): -
Update user response access:
-
Update CVM info access:
Related
- SDK Overview — getting started with the SDK
- Schema Reference — full schema definitions per version

