Use the Nuon API from Go
The Nuon Go SDK provides typed access to the Nuon control-plane API. Use it to work with organizations, apps, installs, components, workflows, action workflows, runbooks, and other Nuon resources from a Go program.Package to use:github.com/nuonco/nuon/sdks/nuon-goThe former standalone package atgithub.com/nuonco/nuon-gois deprecated. New integrations should use the SDK in the main Nuon repository.
Requirements
- Go 1.24.4 or later
- A Nuon API token
- The ID of the Nuon organization the request should access
The SDK does not read environment variables itself. Your program must read them and pass their values to the client constructor.
Match the SDK to the deployed control plane
Version selection is part of correctness for BYOC integrations. The SDK’s methods, request types, response types, enum values, and validation are generated from a particular snapshot of the Nuon control-plane OpenAPI document. A BYOC control plane may run a different Nuon release from Nuon Cloud, especially during a rollout. Do not assume that the latest SDK is compatible with every deployed control plane. Nuon does not currently publish a broad SDK/API compatibility matrix, and the SDK does not perform a runtime compatibility handshake. Before selecting or upgrading the SDK:-
Query the control plane the integration will actually call:
A response includes the deployed
version, sourcegit_ref, andrecommended_cli_version. For example, Nuon Cloud athttps://api.nuon.coreturned the following on August 10, 2026:This example is a point-in-time response, not a version recommendation. Query the target control plane before selecting or upgrading its SDK. - Pin the SDK version or source revision verified for that control-plane release. Do not infer compatibility from version-number similarity: control-plane and SDK module versions are separate release streams.
- Test the exact SDK and control-plane pairing in a non-production environment. Exercise every endpoint and model shape the integration uses, including pagination and writes.
- Record the verified pairing in the integration’s release metadata or dependency-update notes.
latest:
go.mod:
go.mod and go.sum. Avoid an unreviewed go get ...@latest in automated dependency updates.
Plan control-plane and client upgrades together
Treat a control-plane upgrade and an SDK upgrade as one compatibility change, even when they are deployed separately:- Inventory the SDK methods and generated model fields the integration uses.
- Validate the existing client against the candidate control plane.
- Validate the candidate SDK against the candidate control plane.
- If the candidate control plane remains compatible with the existing client, upgrade the control plane first, then the client. This avoids deploying a client that calls endpoints an older control plane does not have.
- If either side contains a breaking API change, coordinate the rollout and get an explicit supported upgrade path from Nuon rather than relying on deployment order alone.
- Keep rollback artifacts for both the client and control plane until production verification is complete.
recommended_cli_version applies to the Nuon CLI; it is useful release context but is not an SDK compatibility declaration. Likewise, API responses include X-Nuon-API-Version, but the Go SDK does not currently read or enforce that header. These values are useful for diagnostics and deployment checks, not proof of compatibility.
Install the SDK
Create a client
Create one client and reuse it.WithURL is required. In most integrations, validate the token and organization ID before constructing the client so configuration errors fail early.
nuon.New requires WithURL; it does not automatically select Nuon Cloud or discover a BYOC control plane. For software that must never fall back from BYOC to Nuon Cloud, require NUON_API_URL instead of applying the default:
Switch organizations
Organization-scoped methods use the client’s current organization ID. If an application intentionally operates across organizations, update it before the next request:Call the API
The SDK exposes anuon.Client interface with resource-oriented methods. Most methods accept a context.Context, identifiers, and an optional generated request or query model.
Get one resource
Create or update a resource
Request and response types live in themodels package:
Work with nested data
Some resources support recursive responses. For example, requesting an app configuration withrecurse enabled includes its related configuration data:
Paginate every list operation
Paginated methods return three values:nil as the query uses the server default, which is currently 10 results. If the integration needs the complete collection, continue until hasMore is false.
GetApps, GetAllInstalls, GetAppInstalls, GetAppComponents, GetWorkflows, and GetInstallDeploys.
The maximum page size is 100. Do not increment the offset by the number of returned records; increment it by the requested page size, as shown above.
Handle errors
Always preserve the SDK error with%w when adding operation-specific context:
nuon.IsBadRequest(err)— HTTP 400nuon.IsUnauthorized(err)— HTTP 401nuon.IsForbidden(err)— HTTP 403nuon.IsNotFound(err)— HTTP 404nuon.IsServerError(err)— HTTP 5xxnuon.ToAPIError(err)— extracts a readable API error messagenuon.ToUserError(err)— extracts an API response explicitly marked as a user error
ToAPIError and ToUserError walk wrapped error chains.
Common API areas
The public client covers these major resource groups:
See the current
Client interface for the complete method list and signatures.
Structure integrations for testing
nuon.Client intentionally exposes the whole SDK, which is often more than one package needs. Define a small local interface containing only the methods your code calls. Production code can receive the real SDK client, and tests can provide a focused fake.
Recommended integration practices
- Use the in-tree SDK path, not the deprecated standalone module.
- Identify the deployed control-plane
versionandgit_ref, then pin a verified SDK version for that environment. - Require the correct
NUON_API_URLfor BYOC integrations; do not silently send their traffic to Nuon Cloud. - Validate
NUON_API_TOKENandNUON_ORG_IDin your configuration layer. - Reuse a client rather than constructing one for every request.
- Give network operations a caller-controlled context and timeout.
- Paginate list calls explicitly when completeness matters.
- Wrap errors with
%w, but run the SDK’s HTTP status helpers before wrapping. - Program against the handwritten
nuon.Clientfacade, not generatedclient/operationstransport types. - Treat generated
modelsas versioned API contracts and test them when either the SDK or control plane changes. - Commit the pinned dependency in
go.modandgo.sum; avoid unattended@latestupgrades. - Never expose API tokens in logs, command output, or error messages.
Working examples
Two Nuon extensions demonstrate current SDK usage:nuon-ext-terraformshows client construction, install and app-config lookups, generated model inspection, and complete pagination.nuon-ext-cf-stackshows client construction and retrieving an install and its stack before operating on AWS resources.