go-auditGo Audit
Features

API Call Logging

Capture every outgoing or third-party API request with header and body redaction, smart truncation, and automatic correlation to the surrounding business transaction.

Why log API calls?

Compliance

Prove what data left your service and when. Build evidence for SOC2, ISO 27001, and PCI audits.

Debugging

Replay third-party calls verbatim. See exactly which payload caused that flaky integration to fail.

Cost & vendor analysis

Track per-vendor latency and request volume. Spot expensive endpoints before the bill arrives.

Record an API call

Wrap your HTTP client and forward each request to the auditor. The recorder captures method, URL, status, durations, and bodies — redacting and truncating as configured.

http_client.go
err := auditor.API().Record(ctx, audit.APICall{
    Method:       "POST",
    URL:          "https://api.stripe.com/v1/charges",
    StatusCode:   200,
    RequestBody:  bodyBytes,
    ResponseBody: respBytes,
    DurationMS:   142,
})

Header & body redaction

Configure a list of header names and JSON paths to redact before persistence. Sensitive values are replaced with a fixed marker so audit logs stay safe to share with auditors and engineers alike.

before.json
{
  "authorization": "Bearer sk_live_abc123...",
  "user": {
    "email": "alice@example.com",
    "ssn":   "123-45-6789"
  }
}
after.json
{
  "authorization": "[REDACTED]",
  "user": {
    "email": "alice@example.com",
    "ssn":   "[REDACTED]"
  }
}

Size truncation

Bodies above your configured limit are truncated and tagged so you can audit large payloads without bloating storage. Tune the cap to match your retention budget.

config.go
audit.Config{
    MaxBodyBytes: 64 * 1024,
}
Truncated payloads are marked with a __truncated: true flag so you can detect them downstream.

Cross-concern correlation

Every audit event written inside a transaction shares the same txn_id. Replay the full sequence — DB writes, API calls, more DB writes — when reconstructing what a single business operation actually did.

DB WRITEAPI CALLDB WRITE
txn_id: 7f3a8c92-bd11-44e2-9a3e-0c2fb1d7e441

On this page