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-gogo get github.com/Aristiun/aribot-go@v1.0.0Go 1.22 or later. The module uses the Go standard library only.
import aribot "github.com/Aristiun/aribot-go"What you can do with it
- Security gates: ask the server for the allow, warn or block decision on a code change, get per-file feedback and fix steps.
- Agent decision API: an AI agent asks whether it may call a tool before it acts, and gets the company's policy decision.
- Code review: register a repository or upload code, verify every threat in the diagram against the code, read the traceability matrix.
- Pipeline security: projects, scans, findings, SBOMs and gate results for CI/CD.
- Threat modeling: upload a diagram, list its components and threats, run the AI analysis, export a report.
- Compliance and remediation: scan a diagram against a standard, read framework reports, generate and track remediation plans.
- Connector API: the operations the hosted Aribot connector offers, for your own tools.
Sign in
Create an API key in Aribot under Company Admin > Developer & API. The client looks for a credential in this order:
aribot.WithAPIKey(...)passed toaribot.New.- The
ARIBOT_API_KEYenvironment variable (use this in CI). - The
ARIBOT_TOKENenvironment variable (a JWT access token).
export ARIBOT_API_KEY=... # from Company Admin > Developer & APIclient, 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
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.
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
// 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:
| Sentinel | When |
|---|---|
aribot.ErrValidation | 400 or 422 |
aribot.ErrAuthentication | 401: the credential is missing, expired or revoked |
aribot.ErrLicenseRequired | 402: the company has no licence for this feature; Payload has the details |
aribot.ErrPermissionDenied | 403: the user or key may not do this |
aribot.ErrNotFound | 404 |
aribot.ErrConflict | 409 |
aribot.ErrRateLimited | 429 after the retries; RetryAfter holds the server's wait |
aribot.ErrServer | 5xx |
aribot.ErrRedirectRefused | the server answered with a redirect |
aribot.ErrConfig | bad 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.
_, 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
- HTTPS only. Plain http works for
localhost,127.0.0.1and::1, for local development. A base URL with credentials, a path, a query or a fragment is refused. - TLS certificates are always verified. Add a private CA with
ARIBOT_CA_BUNDLE(a PEM file); it is added to the system roots. - Redirects are never followed, so the credential cannot travel to another host. A redirect returns
ErrRedirectRefused. - API keys go in the
X-API-Keyheader; JWT access tokens and agent keys inAuthorization: Bearer. - The credential never appears in error messages, and printing a
Clientor anOptionwith anyfmtverb shows only the credential's kind and source. - Only GET and HEAD requests are retried, on 429, 502, 503, 504 and network errors: at most 3 attempts, waiting as long as
Retry-Afterasks, up to 30 seconds. Writes are sent once. Passaribot.WithIdempotencyKey(...)to make a write retryable; it is sent asIdempotency-Key. Use it with endpoints that honour that header, such asConnector.CreateScan. - Ids are escaped as single path segments, so an id cannot change which endpoint is called.
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.