Rivergate

Go SDK

A small typed client for the Rivergate API, for services and tools written in Go.

Install

go get github.com/rivergate-dev/rivergate-sdk-go

The package is imported as rivergate.

Create a client

import (
	"context"

	rivergate "github.com/rivergate-dev/rivergate-sdk-go"
)

func run(ctx context.Context, token string) error {
	client, err := rivergate.NewClient("https://rivergate.example.com", token)
	if err != nil {
		return err
	}

	organizations, err := client.ListOrganizations(ctx)
	if err != nil {
		return err
	}
	_ = organizations
	return nil
}

Reading a secret value

value, err := client.GetSecretValue(ctx, orgID, projectID, environmentID, secretID, 0)
if err != nil {
	return err
}
_ = value // Do not log or persist this.

Pass 0 as the version for the current value, or a version number for a specific one. The call is authorized and audited server-side.

Plaintext in process memory

Go strings cannot be reliably erased. Do not log or persist the value, and clear any byte slices you derive from it when practical.

Typed operations

MethodPurpose
ListOrganizationsOrganizations you belong to.
ListProjects, ListEnvironmentsScoped listings.
ListSecretsCursor-paginated secret metadata.
GetSecretOne secret’s metadata.
CreateSecret, UpdateSecretCreate a secret, or append a new version.
ListSecretVersionsVersion history with before and limit.
RollbackSecretMake a historical version current as a new version.
GetSecretValueExplicit value read, current or by version.
DoGeneric call that supports every documented route.

Calling any route

var out map[string]any
err := client.Do(ctx, "GET",
	"/api/v1/organizations/ORG_ID/members", nil, &out)

Handling errors

API failures are returned as *rivergate.APIError, which exposes the HTTP status (StatusCode), a stable error code, a safe message, the request ID and any RetryAfter the server sent. Use the request ID to find the matching server log.

var apiErr *rivergate.APIError
if errors.As(err, &apiErr) {
	log.Printf("rivergate error: status=%d code=%s request_id=%s",
		apiErr.StatusCode, apiErr.Code, apiErr.RequestID)
}

When the server sends Retry-After, it is parsed into APIError.RetryAfter so your retry logic can respect it.

Workload token exchange

For Kubernetes workloads, the module also provides ExchangeWorkloadToken, which trades a projected ServiceAccount JWT for a short-lived Rivergate token. The Operator uses it internally; see Kubernetes Operator.