Account.Reference
Better Stack account reference data: the roles a team member can have and the teams your token can reach.
Plain Effects over the SDK: use them in a stack program at plan time (the
providers bring the credentials) or in any Effect program given
BetterStack.fromApiToken(...) and an HttpClient. Finders fail with the
typed ReferenceNotFound.
Errors stay typed (ReferenceNotFound and the SDK’s tags) so plain Effect
code can branch on them. A stack program may only fail with
ConfigError, so inside Alchemy.Stack(...) end a plan-time read with
Effect.orDie: a miss then stops the plan, as a lookup that finds
nothing does.
const responder = yield* BetterStack.Account.findRole("Responder");yield* BetterStack.Account.TeamMember("alice", { email: "alice@example.com", roleId: responder.id });findRole
Section titled “findRole”const findRole = (nameOrKind: string, options?: OrganizationOptions)One role by name (case-insensitive, "Responder") or by built-in kind
("responder", "team_lead", …; a name match wins). Fails with
ReferenceNotFound when the organization has no such role.
Examples
Section titled “Examples”Example
const lead = yield* BetterStack.Account.findRole("team_lead");See also
findTeam
Section titled “findTeam”const findTeam = (name: string, options?: OrganizationOptions)One team by its exact name (names are unique in an organization, ignoring
case). Fails with ReferenceNotFound when the token reaches none.
Examples
Section titled “Examples”Example
const staging = yield* BetterStack.Account.findTeam("Staging");See also
const roles = ( options?: OrganizationOptions, ): Effect.Effect<Array<Account.Role>, Account.ListRoleError, BetterStackOpContext>Every role in the organization: the built-in ones (role says which:
admin, billing_admin, team_lead, responder, member) and the
custom ones. A role’s id is what Account.TeamMember’s roleId takes.
Examples
Section titled “Examples”Example
const roles = yield* BetterStack.Account.roles();See also
const teams = ( options?: TeamListOptions, ): Effect.Effect<Array<Account.Team>, Account.ListTeamError, BetterStackOpContext>Every team the token can reach (a team-scoped token sees its own team).
A team’s id (t123) is what every team-scoped resource’s teamId
takes. To manage a team, use Account.Team; to reference one, use
Account.Team.lookup({ id }).
Examples
Section titled “Examples”Example
const staging = (yield* BetterStack.Account.teams({ search: "staging" }))[0];See also