Skip to content

Manage Accounts with Go

Accounts model who pays for usage. In project-scoped integrations, pass the project explicitly so account IDs, wallets, routes, limits, and ledgers stay inside the same project boundary.

account, err := client.Manager.CreateAccountForProject(ctx, "proj_gateway", types.CreateAccountRequest{
Name: "Acme",
PrimarySubjectType: "org",
PrimarySubjectID: "org_001",
})
if err != nil {
return err
}
fmt.Println(account.ID)

PrimarySubjectType and PrimarySubjectID are optional, but they must be provided together. When present, Meterry creates the primary subject route for the account as part of account creation.

You can also set ProjectID directly on the request and call CreateAccount:

account, err := client.Manager.CreateAccount(ctx, types.CreateAccountRequest{
ProjectID: "proj_gateway",
Name: "Acme",
})
accounts, err := client.Manager.ListAccountsForProject(ctx, "proj_gateway")
if err != nil {
return err
}
for _, account := range accounts {
fmt.Println(account.ID, account.Name, account.Status)
}

For tenant-level compatibility, ListAccounts(ctx) still exists. New project-aware integrations should prefer ListAccountsForProject.

Method Description
CreateAccount Creates an account. Uses req.ProjectID when set.
CreateAccountForProject Creates an account under /projects/:project_id/accounts.
ListAccounts Lists accounts without an explicit project path.
ListAccountsForProject Lists accounts under /projects/:project_id/accounts.