getCvmInfo
GET /cvms/{cvmId}
Returns full CVM details including configuration, status, and metadata.
Parameters:
Returns:
CvmInfo — version-aware response with CVM details.
Example:
logs object with complete presigned URLs for the serial, stdout, and stderr channels, plus the pieces needed to build container log URLs. If the requester cannot access the CVM, the request fails with HTTP 404. The logs fields are null when signed log URLs are not available for that CVM yet, for example when it has no VM. You do not need to use these URLs yourself: the log helpers below read them for you.
Read CVM logs
Available in@phala/cloud 0.6.0 and later. The behavior described here is complete in 0.6.4, so use 0.6.4 or later.
fetchCvmLogs and followCvmLogs read logs from a CVM. They are standalone functions exported from @phala/cloud, not methods on the client, so pass the client as the first argument.
CvmLogSource:
CvmLogsOptions:
since, until, timestamps, and format: "ndjson" apply to container logs only. Passing them with a node source throws a LogAccessError with code ERR-17-001 before any request is sent.
Return types:
CvmLogEntry is { channel: "stdout" | "stderr" | "console" | "stdin"; message: string }. console appears for containers started with a TTY. message is exactly what the container wrote, usually ending in a newline. An empty message stays an empty string.
Container names
The SDK resolves the container name once at the start of a follow, with one composition call. It tries these steps in order:- An exact match on a container name.
- A unique match on the start of a container ID, unless
matchContainerIdPrefixisfalse. - If you gave no name, the first container in the composition.
LogAccessError with code ERR-17-001 and the message Ambiguous container prefix '<name>': web, worker, which lists the candidates. If nothing matches, it throws a LogAccessError with code ERR-17-007. If the composition has no containers and returns an error string, for example because the CVM is stopped, the SDK throws a LogAccessError with that message.
A name you pass must be 1 to 128 characters, start with a letter or digit, and then use only letters, digits, _, ., and -. It must not contain ... Other names, such as /app, are rejected with ERR-17-001 before any request is sent. The SDK does not strip a leading / from a name you pass.
Cancellation
Pass anAbortSignal in options.signal. Aborting it during a follow ends the follow without throwing, and so does leaving the for await loop or calling return() on the generator. Waits between reconnects are interrupted at once. The signal also applies to a one-shot fetchCvmLogs, including its lookups. A signal that is already aborted before a follow starts makes the iteration throw an AbortError without sending any request. A fetch that is aborted rejects with an AbortError.
Behavior:
- Every connection uses a fresh signed URL, with one CVM info lookup per connection.
- Follow reconnects after a stream ends or fails. Failures back off from 250 ms, doubling up to 5 s, and follow gives up after 5 consecutive failures. Starts of two connections are at least 1 s apart.
- HTTP errors are handled by status.
5xxand429are failures.401withERR-17-003fetches a new URL and retries, up to 3 times in a row. The count resets after a connection that delivered records or ended cleanly.401withERR-17-002fetches a new URL and counts as a failure. Any other4xxstops follow. - A gateway error line inside a
200stream, or a network error, counts as a failure. A connection that delivered at least one record resets the failure count before its own failure is counted. - Container follow always requests timestamps internally. It sends the caller’s
tailuntil the first connection is accepted. Every later request sendstail=allplussince, and skips lines it already delivered at the boundary second, so a reconnect does not repeat output. Before any timestamped record arrives, it uses yoursinceif you set one, otherwise the second the first connection was accepted. Timestamps are removed from the output unless you settimestamps: true. - Container follow: if a stream ends cleanly with no new output within 10 s, it backs off and counts the end. After 5 such ends in a row, follow stops with
log stream keeps ending without new output; the container may have stopped. A clean end after records, or after an idle connection of 10 s or more, reconnects at once and resets the count. - Node follow never stops on a clean end. After the first connection it requests
tail=0. - If you set
until, follow finishes normally, without an error, when the stream reaches that time. - A missing container is not retried.
- Node follow and fetch drop
[vmm heartbeat]and[teepod heartbeat]lines. - A text-format record that looks like
{"error": ...}is treated as a guest error only at the very start of the body. Use NDJSON (the default for entries) for reliable detection. - The helpers request CVM info with API version
2026-01-21internally, so they work with clients configured for older versions.
LogAccessError, which extends ResourceError. Match on code rather than the message.
LogAccessError also carries errorCode, structuredDetails, links, and requestId from the API error envelope.
LogAccessError with code ERR-17-006 (“Container logs are disabled”) before sending any log request. Follow checks this before its first log request and again on every reconnect, because each connection looks up the CVM info. Node channels are not affected. A missing container throws a LogAccessError with code ERR-17-007 (see Container names).
If the agent inside the CVM cannot read a container’s logs, for example because the container uses a Docker logging driver that does not support reading, the helper throws LogAccessError with code ERR-17-009 and the agent’s message. This applies to text and NDJSON, in fetch and in follow. Follow stops on it. A server-returned HTTP 502 with ERR-17-009 is different: follow reconnects. See Fetch Logs over HTTP for the full error code list.
Lower-level exports: @phala/cloud also exports fetchCvmChannelLogs, streamCvmChannelLogs, fetchContainerLogs, fetchContainerLogsEntries, streamContainerLogs, streamContainerLogsEntries, getCvmLogEndpoint, and resolveLogTimeWindow. Prefer fetchCvmLogs and followCvmLogs unless you need one of these for a specific case.
Without the helper
If you are not using the JS SDK, or need full control, you can read the URLs fromgetCvmInfo and make the HTTP requests yourself. Use API version 2026-01-21 or later so the response includes logs. You then handle URL expiry, reconnects, and heartbeat lines in your own code. See Fetch Logs over HTTP for the URL format, query parameters, and reconnect rules.
getCvmList
GET /cvms/paginated
Returns a paginated list of CVMs.
Parameters:
Returns: Paginated list of CVM objects.
Example:
getCvmState
GET /cvms/{cvmId}/state
Returns the current state of a CVM (non-streaming, immediate response).
Parameters:
Returns:
CvmState
Example:
getCvmStats
GET /cvms/{cvmId}/stats
Returns system information and resource usage for a CVM.
Parameters:
Returns:
CvmSystemInfo
Example:
getCvmNetwork
GET /cvms/{cvmId}/network
Returns network information including public URLs and internal IP.
Parameters:
Returns:
CvmNetwork
Example:
getCvmContainersStats
GET /cvms/{cvmId}/composition
Returns container-level information including running state and log endpoints.
Parameters:
Returns:
CvmContainersStats
Example:
getCvmAttestation
GET /cvms/{cvmId}/attestation
Returns TEE attestation details including certificates and TCB info.
Parameters:
Returns:
CvmAttestation
Example:
getCvmDockerCompose
GET /cvms/{cvmId}/docker-compose
Returns the raw docker-compose configuration as a string.
Parameters:
Returns:
string — raw docker-compose YAML content.
Example:
getCvmComposeFile
GET /cvms/{cvmId}/compose_file
Returns the full compose file object with utility methods for hashing.
Parameters:
Returns:
LooseAppCompose — compose file object with getHash() and toString() methods.
Example:
getCvmPreLaunchScript
GET /cvms/{cvmId}/pre-launch-script
Returns the pre-launch script content.
Parameters:
Returns:
string — pre-launch script content.
getCvmStatusBatch
GET /cvms/status/batch
Returns the status of multiple CVMs in a single request.
Parameters:
Returns:
GetCvmStatusBatchResponse
Example:
getCvmUserConfig
GET /cvms/{cvmId}/user-config
Returns the user-level configuration for a CVM.
Parameters:
Returns:
CvmUserConfig — user configuration details.
checkCvmIsAllowed
POST /cvms/{cvmId}/is-allowed
Checks whether a CVM’s current deployment is allowed by its on-chain dstack App contract. This queries the blockchain to verify that the compose hash and device ID are registered. Useful for diagnosing on-chain KMS permission issues.
Parameters:
Returns:
IsAllowedResult
Example:

