SDKs
Go
github.com/pentify/pentify-go — typed client generated from the Pentify OpenAPI 3.1 spec via oapi-codegen. Go 1.21+.
Install
go get github.com/pentify/pentify-goClient construction
import "github.com/pentify/pentify-go"
p := pentify.New(os.Getenv("PENTIFY_API_KEY"))
// or with options:
p := pentify.New(os.Getenv("PENTIFY_API_KEY"),
pentify.WithBaseURL("https://api.pentify.io/v1"),
pentify.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}),
pentify.WithMaxRetries(5),
)Namespaced API
| Field | Surface |
|---|---|
p.Scans | List, Create, Retrieve, Cancel |
p.Targets | List, Create, Retrieve, Verify, Delete |
p.Reports | Retrieve, PDFURL, ListFindings |
p.Usage | Retrieve |
p.Webhooks | List, Create, Retrieve, Delete, Verify |
Context propagation
Every method takes a context.Context as its first parameter. Always pass the request-scoped context — the SDK respects cancellation and deadlines.
scan, err := p.Scans.Create(ctx, &pentify.CreateScan{
Target: "example.com",
ScanType: "quick",
})Pagination
iter := p.Scans.List(ctx, &pentify.ListScansParams{Limit: 100})
for iter.Next() {
s := iter.Current()
fmt.Println(s.ID, s.Status)
}
if err := iter.Err(); err != nil {
log.Fatal(err)
}Errors
scan, err := p.Scans.Create(ctx, &pentify.CreateScan{...})
if err != nil {
var apiErr *pentify.APIError
if errors.As(err, &apiErr) {
switch apiErr.Code {
case pentify.CodeInsufficientTokens:
// apiErr.Details has Required, Balance, TopUpURL
case pentify.CodeRateLimited:
// apiErr.RetryAfter
}
}
}See Errors.
Retry behavior
429, 502, 503, 504 retried with exponential backoff. Honors Retry-After. Set WithMaxRetries(0) to disable.
Webhook verification
import pentifywebhook "github.com/pentify/pentify-go/webhook"
event, err := pentifywebhook.Verify(
r.Header.Get("pentify-signature"),
rawBody,
os.Getenv("PENTIFY_WEBHOOK_SECRET"),
5*time.Minute,
)
if err != nil { /* reject */ }
if event.Type == "scan.completed" {
// event.Data fully typed
}See Webhooks.