Auth0Client.Management.Organization (auth0_client v1.0.0)

Copy Markdown View Source

A module representing organizations on Auth0.

Organizations are Auth0's B2B primitive: a tenant hosts many organizations, each with its own members, connections and branding. Roles assigned through assign_member_roles/3 are scoped to that organization, so the same user can be an admin of one and a read-only member of another — which is the part of Auth0 RBAC most often misread.

Auth0 exposes two overlapping connection APIs here. This module implements /connections, whose payload is a superset of the older /enabled_connections; the latter is deliberately not wrapped.

https://auth0.com/docs/api/management/v2/organizations

Summary

Functions

Associates an existing client grant with an organization

Enables a connection for an organization. connection_id is required, and the connection must already exist in the tenant.

Adds a discovery domain to an organization. domain is required.

Adds users to an organization. They must already exist in the tenant.

Gets all organizations.

Assigns roles to a group within this organization

Assigns roles to a member, scoped to this organization

Gets the client grants associated with an organization

Gets a single connection as enabled for this organization

Gets the connections enabled for an organization.

Creates an organization. name is required, and must be lowercase with no spaces.

Creates an invitation.

Deletes an organization

Revokes a pending invitation

Gets a discovery domain by id

Gets a discovery domain by the domain itself

Gets an organization's discovery domains.

Gets a single organization by id

Gets a single organization by name.

Gets the roles a group grants within this organization

Gets the groups assigned to an organization. Uses checkpoint pagination.

Gets an organization's pending invitations

Gets the groups that grant a member a role in this organization, answering "why does this member have this role?".

Gets every role a member holds in this organization, including roles inherited through a group.

Gets the roles a member holds within this organization.

Gets an organization's members.

Removes a client grant from an organization

Disables a connection for this organization. The connection itself is not deleted.

Removes a discovery domain from an organization

Removes roles from a group within this organization

Removes roles from a member of this organization

Removes users from an organization. The users themselves are not deleted.

Gets the members holding a given role in this organization.

Updates an organization

Updates how a connection behaves for this organization

Functions

add_client_grant(id, grant_id)

Associates an existing client grant with an organization

iex> Auth0Client.Management.Organization.add_client_grant("org_abc123", "cgr_1")

add_connection(id, body)

Enables a connection for an organization. connection_id is required, and the connection must already exist in the tenant.

iex> Auth0Client.Management.Organization.add_connection("org_abc123", %{connection_id: "con_1", assign_membership_on_login: true})

add_discovery_domain(id, body)

Adds a discovery domain to an organization. domain is required.

iex> Auth0Client.Management.Organization.add_discovery_domain("org_abc123", %{domain: "acme.com"})

add_members(id, user_ids)

Adds users to an organization. They must already exist in the tenant.

iex> Auth0Client.Management.Organization.add_members("org_abc123", ["auth0|user1"])

all(params \\ %{})

Gets all organizations.

Supports offset pagination (page / per_page / include_totals), checkpoint pagination (from / take), and sort.

iex> Auth0Client.Management.Organization.all()
iex> Auth0Client.Management.Organization.all(take: 50, sort: "name:1")

assign_group_roles(id, group_id, role_ids)

Assigns roles to a group within this organization

iex> Auth0Client.Management.Organization.assign_group_roles("org_abc123", "grp_1", ["rol_1"])

assign_member_roles(id, user_id, role_ids)

Assigns roles to a member, scoped to this organization

iex> Auth0Client.Management.Organization.assign_member_roles("org_abc123", "auth0|user1", ["rol_1"])

client_grants(id, params \\ %{})

Gets the client grants associated with an organization

iex> Auth0Client.Management.Organization.client_grants("org_abc123")
iex> Auth0Client.Management.Organization.client_grants("org_abc123", audience: "https://api.example.com")

connection(id, connection_id)

Gets a single connection as enabled for this organization

iex> Auth0Client.Management.Organization.connection("org_abc123", "con_1")

connections(id, params \\ %{})

Gets the connections enabled for an organization.

Pass is_enabled to filter.

iex> Auth0Client.Management.Organization.connections("org_abc123")

create(body)

Creates an organization. name is required, and must be lowercase with no spaces.

iex> Auth0Client.Management.Organization.create(%{name: "acme-corp", display_name: "Acme Corp"})

create_invitation(id, body)

Creates an invitation.

inviter (with a name), invitee (with an email) and client_id are all required. Unlike most mutations here, this returns the created invitation rather than a bare :ok.

iex> Auth0Client.Management.Organization.create_invitation("org_abc123", %{
...>   inviter: %{name: "Admin"},
...>   invitee: %{email: "new@example.com"},
...>   client_id: "a_client_id"
...> })

delete(id)

Deletes an organization

iex> Auth0Client.Management.Organization.delete("org_abc123")

delete_invitation(id, invitation_id)

Revokes a pending invitation

iex> Auth0Client.Management.Organization.delete_invitation("org_abc123", "inv_1")

discovery_domain(id, discovery_domain_id)

Gets a discovery domain by id

iex> Auth0Client.Management.Organization.discovery_domain("org_abc123", "dom_1")

discovery_domain_by_name(id, domain)

Gets a discovery domain by the domain itself

iex> Auth0Client.Management.Organization.discovery_domain_by_name("org_abc123", "acme.com")

discovery_domains(id, params \\ %{})

Gets an organization's discovery domains.

Discovery domains route a user to an organization by their email domain — Home Realm Discovery. Uses checkpoint pagination.

iex> Auth0Client.Management.Organization.discovery_domains("org_abc123")

get(id)

Gets a single organization by id

iex> Auth0Client.Management.Organization.get("org_abc123")

get_by_name(name)

Gets a single organization by name.

The name is the lowercase, space-free identifier, not display_name.

iex> Auth0Client.Management.Organization.get_by_name("acme-corp")

group_roles(id, group_id, params \\ %{})

Gets the roles a group grants within this organization

iex> Auth0Client.Management.Organization.group_roles("org_abc123", "grp_1")

groups(id, params \\ %{})

Gets the groups assigned to an organization. Uses checkpoint pagination.

iex> Auth0Client.Management.Organization.groups("org_abc123")

invitation(id, invitation_id, params \\ %{})

Gets a single invitation

iex> Auth0Client.Management.Organization.invitation("org_abc123", "inv_1")

invitations(id, params \\ %{})

Gets an organization's pending invitations

iex> Auth0Client.Management.Organization.invitations("org_abc123")

member_effective_role_source_groups(id, user_id, params \\ %{})

Gets the groups that grant a member a role in this organization, answering "why does this member have this role?".

Pass role_id to narrow it to one role.

iex> Auth0Client.Management.Organization.member_effective_role_source_groups("org_abc123", "auth0|user1", role_id: "rol_1")

member_effective_roles(id, user_id, params \\ %{})

Gets every role a member holds in this organization, including roles inherited through a group.

member_roles/3 reports only direct assignments. Uses checkpoint pagination.

iex> Auth0Client.Management.Organization.member_effective_roles("org_abc123", "auth0|user1")

member_roles(id, user_id, params \\ %{})

Gets the roles a member holds within this organization.

Not to be confused with role_members/3, which goes the other way — the members holding a given role.

iex> Auth0Client.Management.Organization.member_roles("org_abc123", "auth0|user1")

members(id, params \\ %{})

Gets an organization's members.

Supports offset and checkpoint pagination, plus fields / include_fields.

iex> Auth0Client.Management.Organization.members("org_abc123")
iex> Auth0Client.Management.Organization.members("org_abc123", take: 50)

remove_client_grant(id, grant_id)

Removes a client grant from an organization

iex> Auth0Client.Management.Organization.remove_client_grant("org_abc123", "cgr_1")

remove_connection(id, connection_id)

Disables a connection for this organization. The connection itself is not deleted.

iex> Auth0Client.Management.Organization.remove_connection("org_abc123", "con_1")

remove_discovery_domain(id, discovery_domain_id)

Removes a discovery domain from an organization

iex> Auth0Client.Management.Organization.remove_discovery_domain("org_abc123", "dom_1")

remove_group_roles(id, group_id, role_ids)

Removes roles from a group within this organization

iex> Auth0Client.Management.Organization.remove_group_roles("org_abc123", "grp_1", ["rol_1"])

remove_member_roles(id, user_id, role_ids)

Removes roles from a member of this organization

iex> Auth0Client.Management.Organization.remove_member_roles("org_abc123", "auth0|user1", ["rol_1"])

remove_members(id, user_ids)

Removes users from an organization. The users themselves are not deleted.

iex> Auth0Client.Management.Organization.remove_members("org_abc123", ["auth0|user1"])

role_members(id, role_id, params \\ %{})

Gets the members holding a given role in this organization.

The inverse of member_roles/3. Uses checkpoint pagination.

iex> Auth0Client.Management.Organization.role_members("org_abc123", "rol_1")

update(id, body)

Updates an organization

iex> Auth0Client.Management.Organization.update("org_abc123", %{display_name: "Acme Corporation"})

update_connection(id, connection_id, body)

Updates how a connection behaves for this organization

iex> Auth0Client.Management.Organization.update_connection("org_abc123", "con_1", %{show_as_button: false})

update_discovery_domain(id, discovery_domain_id, body)

Updates a discovery domain

iex> Auth0Client.Management.Organization.update_discovery_domain("org_abc123", "dom_1", %{use_for_organization_discovery: true})