AribotDevelopers Sign in

Aribot Go SDK

The Go client for Aribot by Ayurak: security gates for code changes, the agent decision API for AI agents, code review against the threat model, pipeline security, threat modeling, compliance and remediation, from your own Go services, tools and CI jobs.

go get github.com/Aristiun/aribot-go
bash
go get github.com/Aristiun/aribot-go@v1.0.0

Go 1.22 or later. The module uses the Go standard library only.

go
import aribot "github.com/Aristiun/aribot-go"

What you can do with it

Sign in

Create an API key in Aribot under Company Admin > Developer & API. The client looks for a credential in this order:

  1. aribot.WithAPIKey(...) passed to aribot.New.
  2. The ARIBOT_API_KEY environment variable (use this in CI).
  3. The ARIBOT_TOKEN environment variable (a JWT access token).
bash
export ARIBOT_API_KEY=...        # from Company Admin > Developer & API
go
client, err := aribot.New()      // finds the credential as above
if err != nil {
	log.Fatal(err)
}
fmt.Println(client)              // kind and source only; the value is never shown

me, err := client.Me(ctx)

Other settings: aribot.WithBaseURL sets the server (default https://aribot.ayurak.com, host only), aribot.WithTimeout sets the time limit for one attempt, and ARIBOT_CA_BUNDLE adds a private CA certificate. Every call takes a context.Context.

Example: a gate decision for a pull request

go
decision, err := client.Gates.Decide(ctx, aribot.GateDecideRequest{
	GateConfigID: 12,
	Gate:         "pull_request",
	HeadSHA:      "3f2c1e9a",
	Files: []aribot.ChangedFile{
		{Path: "api/payments.go", ChangedLines: [][2]int{{40, 72}}},
	},
})
if err != nil {
	log.Fatal(err) // no decision: treat the change as blocked
}
fmt.Println(decision.Outcome, decision.Reasons)
if !decision.Passed() {
	os.Exit(1)
}

Only file paths and changed line ranges leave your machine. File contents are never sent. Passed is true for allow and warn; any other outcome counts as blocked.

Example: the agent decision API

An agent asks before each tool call. This call uses the agent's own key (agk_..., created for the agent in Aribot), passed with aribot.WithAgentKey or set in ARIBOT_AGENT_KEY. The company API key is never sent on this call.

go
client, err := aribot.New(aribot.WithAgentKey(os.Getenv("ARIBOT_AGENT_KEY")))
if err != nil {
	log.Fatal(err)
}

mayCall := func(ctx context.Context, tool, resource string, args any) bool {
	answer, err := client.Gateway.Decide(ctx, aribot.AgentDecideRequest{
		Tool:     tool,
		Resource: resource,
		Args:     args,
	})
	if err != nil {
		return false // fail closed: no decision means no action
	}
	return answer.Allowed
}

if mayCall(ctx, "crm.read_contact", "contact:4711", map[string]any{"fields": []string{"email"}}) {
	// call the tool
}

The server hashes Args; keep them small. Resource is at most 300 characters. A decision request is sent once and never retried.

More examples

go
// Code review against the threat model
scan, _ := client.CodeReview.CreateScan(ctx, aribot.CreateCodeScanRequest{RepositoryID: "...", DiagramID: "42"})
id := fmt.Sprint(scan["id"])
_, _ = client.CodeReview.StartScan(ctx, id)
matrix, _ := client.CodeReview.Traceability(ctx, id, "", "")

// Pipeline scan of a pull request
run, _ := client.Pipeline.Scan(ctx, "7", aribot.PipelineScanRequest{PullRequestID: "128"})
gates, _ := client.Pipeline.GetGateResults(ctx, fmt.Sprint(run["id"]))

// Threat model from a diagram file
f, _ := os.Open("architecture.png")
defer f.Close()
result, _ := client.ThreatModeling.AnalyzeDiagram(ctx, aribot.UploadFile{Name: "architecture.png", Content: f}, aribot.AnalyzeDiagramOptions{})
threats, _ := client.ThreatModeling.GetThreats(ctx, fmt.Sprint(result["id"])) // once analysis finishes

// A platform scan through the connector API, safe to retry with an idempotency key
job, _ := client.Connector.CreateScan(ctx, aribot.ConnectorScanRequest{AccountID: 3},
	aribot.WithIdempotencyKey("nightly-3-2026-11-23"))

Results: the gate and agent decisions are structs. Calls that return one JSON object return map[string]any. List calls return json.RawMessage, because the server sends either a plain list or a paginated object ({"results": [...]}); decode it into your own types. File downloads return []byte.

Errors

A response with status 400 or higher is an *aribot.APIError with StatusCode, Code (the server's error code, when sent), Message and Payload (the JSON body). Check the kind with errors.Is:

SentinelWhen
aribot.ErrValidation400 or 422
aribot.ErrAuthentication401: the credential is missing, expired or revoked
aribot.ErrLicenseRequired402: the company has no licence for this feature; Payload has the details
aribot.ErrPermissionDenied403: the user or key may not do this
aribot.ErrNotFound404
aribot.ErrConflict409
aribot.ErrRateLimited429 after the retries; RetryAfter holds the server's wait
aribot.ErrServer5xx
aribot.ErrRedirectRefusedthe server answered with a redirect
aribot.ErrConfigbad base URL, no credential, or an invalid argument

A failure with no response (connection, timeout, TLS, cancelled context) is an *aribot.NetworkError, which unwraps to the cause.

go
_, err := client.CodeReview.StartScan(ctx, scanID)
var apiErr *aribot.APIError
switch {
case errors.Is(err, aribot.ErrLicenseRequired):
	fmt.Println("ask your company admin to enable this feature")
case errors.Is(err, aribot.ErrRateLimited) && errors.As(err, &apiErr):
	fmt.Println("try again in", apiErr.RetryAfter)
case err != nil:
	log.Fatal(err)
}

Security notes

Upgrading from the earlier Go client

Version 1.0.0 is the first release of this module (github.com/Aristiun/aribot-go). The earlier client under github.com/ayurak/aribot-go was never published. Its calls whose endpoints no longer exist are dropped, and the others use their current routes. See CHANGELOG.md for every dropped and remapped call.

Documentation

Full reference: https://aribot.ayurak.com/developers/sdk/go/

Licence: proprietary, see LICENSE.md. Use of the Aribot service is subject to your agreement with Ayurak.