vanta-sdk-go is an unofficial idiomatic Go client for the Vanta API, aligned with the public Vanta developer docs and the Postman collection in this repository.
- Import path:
github.com/richardoc/vanta-sdk-go/v1 - Minimum Go version:
1.26(fromgo.mod) - Auth: OAuth client credentials (built-in) or static bearer token
- Surface: generated services and endpoint methods from the collection
- Pagination: explicit
pageCursor/pageSizeparams + generic pager helper
go get github.com/richardoc/vanta-sdk-go/v1package main
import (
"context"
"fmt"
vanta "github.com/richardoc/vanta-sdk-go/v1"
)
func main() {
ctx := context.Background()
ts, err := vanta.NewOAuthClientCredentialsTokenSource(vanta.OAuthClientCredentialsConfig{
ClientID: "YOUR_CLIENT_ID",
ClientSecret: "YOUR_CLIENT_SECRET",
Scope: "controls.self:read controls.self:write",
// AuthURL defaults to https://api.vanta.com/oauth/token
})
if err != nil {
panic(err)
}
client, err := vanta.NewClient(vanta.WithTokenSource(ts))
if err != nil {
panic(err)
}
pageSize := 10
resp, err := client.Services.Controls.ListControls(ctx, &vanta.ControlsListControlsParams{
PageSize: &pageSize,
})
if err != nil {
panic(err)
}
fmt.Printf("%+v\n", resp)
}Generated methods return per-operation typed response structs inferred from response examples and expose typed request body structs for JSON endpoints.
Typed JSON decoding emits a warning once per unknown response field path via vanta.UnknownFieldWarningf. Set vanta.UnknownFieldWarningf = nil if you need to suppress those warnings.
- Built-in OAuth client credentials flow via
NewOAuthClientCredentialsTokenSource. - Static token mode via
WithTokenSource(vanta.StaticTokenSource("...")).
Most list endpoints expose:
pageSizepageCursor
The SDK also includes generic cursor helpers (ResultsPage[T], Pager[T]) for custom typed wrappers.
Non-2xx responses are returned as *vanta.APIError with:
StatusCodeStatus- raw
Body - parsed JSON body when available (
ParsedBody)
- Retries are intentionally not enabled in-library.
- Multipart endpoints are supported via generated
FormDatafields. - Base API URL defaults to
https://api.vanta.com/v1. - OAuth token URL defaults to
https://api.vanta.com/oauth/token.