Wocha Docs

Go SDK

Go Management SDK for the Wocha Customer API.

wocha-go is the Go SDK for the Wocha authentication and authorisation platform Management API. Standard library only — no external HTTP dependencies.

Installation

go get github.com/wocha-dev/wocha/sdks/go

Requires Go 1.21+.

Configuration

import "github.com/wocha-dev/wocha/sdks/go"
 
client, err := wocha.NewClient(
    wocha.WithTenant("acme"),
    wocha.WithAPIKey(os.Getenv("WOCHA_API_KEY")),
)

For self-hosted deployments:

client, err := wocha.NewClient(
    wocha.WithBaseURL("https://your-domain.com/v1"),
    wocha.WithAPIKey("wocha_mgmt_..."),
)

Environment variables WOCHA_API_KEY and WOCHA_TENANT are used as fallbacks.

Quick start

users, err := client.Users.List(ctx, &wocha.UserListParams{PageSize: 25})
if err != nil {
    log.Fatal(err)
}
for _, u := range users.Data {
    fmt.Println(u.Email)
}

Key services

ServiceExample
Usersclient.Users.Get(ctx, "usr_abc")
Organisationsclient.Organisations.Create(ctx, params)
Permissionsclient.Permissions.Check(ctx, params)
Sessionsclient.Sessions.RevokeAll(ctx, "usr_abc")
Webhookswocha/webhook package for signature verification
Applicationsclient.Applications.RotateSecret(ctx, id)

Permission check

resp, err := client.Permissions.Check(ctx, &wocha.PermissionCheckParams{
    UserID:       "user_123",
    Permission:   "read",
    ResourceType: "document",
    ResourceID:   "doc_456",
})
if resp.Allowed {
    // grant access
}

Webhook verification

import "github.com/wocha-dev/wocha/sdks/go/webhook"
 
event, err := webhook.ConstructEvent(payload, signatureHeader, secret)

Learn more

On this page