Dashboard

Go SDK

github.com/suman0359/sentriq/sdks/go is a server-only SDK — it holds a secret key and must never run in browser-facing (WASM) code. For browser-side tracking, see the Browser SDK. Not yet tagged as a released Go module — install via go get against a commit, or a local replace directive (see below).

Install

go get github.com/suman0359/sentriq/sdks/go

Initialize

import (
    "os"

    sentriq "github.com/suman0359/sentriq/sdks/go"
)

client, err := sentriq.NewClient(
    os.Getenv("SENTRIQ_SECRET_KEY"),
    // Optional. Defaults to the hosted Sentriq API.
    sentriq.WithAPIURL(os.Getenv("SENTRIQ_API_URL")),
    // Optional. Defaults to 10 seconds. Ignored if WithHTTPClient is set.
    sentriq.WithTimeout(10 * time.Second),
    // Optional. Automatic retries for idempotent GET requests only. Default 2.
    sentriq.WithMaxRetries(2),
)

Resources

client.Events.Retrieve(ctx, eventID)
client.Events.List(ctx, environmentID, sentriq.ListEventsParams{})
client.Events.SubmitOutcome(ctx, eventID, sentriq.SubmitOutcomeRequest{Label: sentriq.OutcomeLabelLegitimate})
client.Events.ListOutcomes(ctx, eventID, page)

client.Devices.Retrieve(ctx, deviceID)
client.Devices.List(ctx, environmentID, page)
client.Devices.ListEvents(ctx, deviceID, page)
client.Devices.ListAccounts(ctx, deviceID, page)
client.Devices.ListSignals(ctx, deviceID)
client.Devices.ListResolutions(ctx, deviceID, page)
client.Devices.Trust(ctx, environmentID, externalAccountID, deviceID)
client.Devices.RevokeTrust(ctx, environmentID, externalAccountID, deviceID)

client.Accounts.ListDevices(ctx, environmentID, externalAccountID, page)

client.Risk.List(ctx, environmentID, sentriq.ListRiskAssessmentsParams{})

client.Network.List(ctx, environmentID, page)

client.Webhooks.VerifySignature(rawBody, timestamp, signature, secret)
No Policies, webhook management, or event ingestion here
Same boundary as every server SDK — there is no client.Policies, no client.Webhooks.Create()/List()/Update()/Delete(), and no event ingestion method: POST /v1/events only accepts a public key, which this server SDK never holds. Trust methods are always Account+Device-scoped — there is no device-global Trust(ctx, deviceID) form. See the Node.js SDK docs for the full explanation.

Context and cancellation

Every method's first parameter is context.Context, propagated into the underlying request — your own deadline or cancellation is honored, including mid-retry-backoff.

Errors

var apiErr *sentriq.Error
if errors.As(err, &apiErr) {
    apiErr.StatusCode, apiErr.Code, apiErr.RequestID, apiErr.Fields, apiErr.RetryAfterSeconds
}

if errors.Is(err, sentriq.ErrNotFound) {
    // idiomatic category check
}

One structured *sentriq.Error type plus errors.Is/errors.As — Go's own idiom, not a deep class hierarchy. Sentinels: ErrConfiguration, ErrNetwork, ErrTimeout, ErrAuthentication, ErrPermission, ErrNotFound, ErrValidation, ErrRateLimit.

Retries

A GET request retries automatically (bounded exponential backoff plus jitter) on a network error, timeout, 429, or 5xx, honoring Retry-After (seconds or an HTTP-date). Mutations (POST/DELETE) are never automatically retried — this API has no generic idempotency-key mechanism today, so blindly retrying a mutation could double-apply it.

Security notes

fmt.Sprintf("%v"/"%+v"/"%#v", client) never contains the secret key — Client implements String()/GoString(). Go's default reflection-based formatter would otherwise print every struct field, exported or not.

Version compatibility

Go 1.22+ (tested on 1.22.2; CI additionally covers 1.22/1.23/1.24). Zero third-party dependencies.