Organization Management
Create, manage, and configure organizations with members, invitations, domains, and branding using the TypeScript SDK.
Organization Management
Organizations are the multi-tenancy primitive in Avnology ID. Each organization has members, roles, SSO connections, branding, and policies.
listOrganizations()
List organizations with pagination and filtering.
client.admin.listOrganizations(params?: ListOrganizationsParams): Promise<OrganizationList>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
pageSize | number | no | Orgs per page (default: 25, max: 100) |
pageToken | string | no | Pagination token |
filter | string | no | Filter expression |
Basic usage
const result = await client.admin.listOrganizations({ pageSize: 25 });
for (const org of result.organizations) {
console.log(org.id, org.name, org.slug, org.memberCount);
}createOrganization()
Create a new organization.
client.admin.createOrganization(params: CreateOrganizationParams): Promise<Organization>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
name | string | yes | Display name |
slug | string | no | URL-safe slug (auto-generated from name if omitted) |
domains | string[] | no | Email domains for this org (e.g., ["acme.com"]) |
registrationMode | "open" | "invite_only" | "sso_only" | "disabled" | no | How users can join (default: "invite_only") |
metadata | Record<string, unknown> | no | Custom metadata |
Basic usage
const org = await client.admin.createOrganization({
name: "Acme Corporation",
slug: "acme",
domains: ["acme.com"],
registrationMode: "invite_only",
metadata: { industry: "Technology", plan: "enterprise" },
});
console.log(org.id); // "org_abc123"
console.log(org.slug); // "acme"updateOrganization()
Update organization settings.
client.admin.updateOrganization(params: UpdateOrganizationParams): Promise<Organization>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
organizationId | string | yes | Organization ID |
name | string | no | Updated display name |
registrationMode | string | no | Updated registration mode |
metadata | Record<string, unknown> | no | Updated metadata |
Basic usage
await client.admin.updateOrganization({
organizationId: "org_abc123",
name: "Acme Corp (renamed)",
registrationMode: "sso_only",
});deleteOrganization()
Delete an organization and remove all member associations. User accounts are NOT deleted -- they remain as standalone accounts.
client.admin.deleteOrganization(params: { organizationId: string }): Promise<void>addMember()
Add a user to an organization with a specific role.
client.admin.addOrganizationMember(params: AddMemberParams): Promise<Member>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
organizationId | string | yes | Organization ID |
userId | string | yes | User to add |
role | "owner" | "admin" | "member" | "viewer" | "billing" | yes | Role in the organization |
Basic usage
await client.admin.addOrganizationMember({
organizationId: "org_abc123",
userId: "usr_jane123",
role: "admin",
});listMembers()
List members of an organization.
client.admin.listOrganizationMembers(params: ListMembersParams): Promise<MemberList>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
organizationId | string | yes | Organization ID |
pageSize | number | no | Members per page (default: 25) |
pageToken | string | no | Pagination token |
role | string | no | Filter by role |
Basic usage
const result = await client.admin.listOrganizationMembers({
organizationId: "org_abc123",
pageSize: 50,
});
for (const member of result.members) {
console.log(member.userId, member.email, member.role, member.joinedAt);
}removeMember()
Remove a user from an organization.
client.admin.removeOrganizationMember(params: RemoveMemberParams): Promise<void>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
organizationId | string | yes | Organization ID |
userId | string | yes | User to remove |
createInvitation()
Invite a user to join an organization by email.
client.admin.createInvitation(params: CreateInvitationParams): Promise<Invitation>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
organizationId | string | yes | Organization ID |
email | string | yes | Email address to invite |
role | string | yes | Role the user will have when they accept |
expiresIn | number | no | Invitation TTL in seconds (default: 7 days) |
Basic usage
const invitation = await client.admin.createInvitation({
organizationId: "org_abc123",
email: "[email protected]",
role: "member",
expiresIn: 72 * 3600, // 3 days
});
console.log(invitation.id); // "inv_abc123"
console.log(invitation.status); // "pending"
console.log(invitation.expiresAt); // "2026-04-11T12:00:00Z"verifyDomain()
Initiate domain verification for an organization. Returns a DNS TXT record that must be added to the domain.
client.admin.verifyDomain(params: VerifyDomainParams): Promise<DomainVerification>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
organizationId | string | yes | Organization ID |
domain | string | yes | Domain to verify (e.g., "acme.com") |
Basic usage
const verification = await client.admin.verifyDomain({
organizationId: "org_abc123",
domain: "acme.com",
});
console.log("Add this DNS TXT record:");
console.log(` Host: _avnology-verify.acme.com`);
console.log(` Value: ${verification.txtRecord}`);
console.log(` Status: ${verification.status}`); // "pending"Common errors
| Error class | HTTP status | When |
|---|---|---|
NotFoundError | 404 | Organization not found |
DuplicateError | 409 | Slug already taken |
ForbiddenError | 403 | Insufficient permissions |
ValidationError | 422 | Invalid input |
MemberAlreadyExistsError | 409 | User is already a member |
See also
- Users -- User management
- SSO connections -- Configure SSO per org
- Organization type -- Type definitions