Skip to main content
The Go SDK is currently in beta. The API surface may change between releases.
The phala Go package provides a strongly-typed client for the Phala Cloud API. It handles authentication, automatic retries with exponential backoff, and structured error responses out of the box.

Installation

Requires Go 1.25 or later.

Quick Start

Client Creation

NewClient(opts ...Option) (*Client, error)

Creates a new Phala Cloud API client. The API key is resolved from options first, then falls back to the PHALA_CLOUD_API_KEY environment variable. Returns an error if no API key is available.

Configuration Options

Every option is a function passed to NewClient. They follow Go’s functional options pattern, so you can combine as many as you need.

Environment Variables

The client resolves environment variables automatically. If you pass an explicit option, it takes priority over the corresponding environment variable.

Pointer Helpers

Many request structs use pointer fields for optional values. The SDK provides helper functions to make this ergonomic:
These are especially useful when constructing request structs inline:

CVM ID Resolution

The SDK automatically normalizes CVM identifiers before sending them to the API. You can pass any of the following formats to any method that accepts a cvmID string:
  • UUID (with or without dashes) — dashes are stripped
  • 40-char hex app IDapp_ prefix is added
  • Integer ID, hashed ID, or name — used as-is
This means you never need to worry about converting between ID formats yourself.

Available Methods

Authentication & User

CVM Lifecycle

CVM Configuration

CVM Query

Apps

Workspaces

Nodes, Instance Types, and OS Images

KMS

SSH Keys

Measurement Utilities

See KMS for examples.

Webhook Verification

See Webhooks for full payload format and delivery behavior.