OrganizationsManager

OrganizationsManager

The organizations class provides a simple abstraction for performing CRUD operations on Auth0 OrganizationsManager.

Constructor

new OrganizationsManager(options)

Source:
Parameters:
Name Type Description
options object

The client options.

Name Type Attributes Description
baseUrl string

The URL of the API.

headers object <optional>

Headers to be included in all requests.

retry object <optional>

Retry Policy Config

Members

organizations :external:RestClient

Provides an abstraction layer for performing CRUD operations on https://auth0.com/docs/api/v2.

Source:
Type:

Methods

addEnabledConnection(params, data, cbopt) → {Promise|undefined}

Add an enabled connection for an organization

Source:
Parameters:
Name Type Attributes Description
params object

Organization parameters

Name Type Description
id string

ID of the Organization.

data object

enable connection data

Name Type Description
connection_id string

connection ID to enable

assign_membership_on_login boolean

flag to allow assign membership on login

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params =  { id :'ORGANIZATION_ID'};
var data = { "connection_id" : "CONNECTION_ID", assign_membership_on_login: false };

management.organizations.addEnabledConnection(params, data, function (err) {
  if (err) {
    // Handle error.
  }
});

addMemberRoles(params, data, cbopt) → {Promise|undefined}

Add a Role to a Member in an organization

Source:
Parameters:
Name Type Attributes Description
params object

Organization parameters

Name Type Description
id string

ID of the Organization.

user_id string

ID of the user.

data object

Add member roles data.

Name Type Description
roles Array

Array of role IDs.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params =  {id : 'ORGANIZATION_ID', user_id: 'user_id'};
var data = { roles: ["ROLE_ID_1", "ROLE_ID_2"]}

management.organizations.addMemberRoles(params, data, function (err) {
  if (err) {
    // Handle error.
  }
});

addMembers(params, data, cbopt) → {Promise|undefined}

Add members in an organization

Source:
Parameters:
Name Type Attributes Description
params object

Organization parameters

Name Type Description
id string

ID of the Organization.

data object

add members data

Name Type Description
members Array

Array of user IDs

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params =  { id :'ORGANIZATION_ID'};
var data = { members: [ 'USER_ID1', 'USER_ID2' ] }
management.organizations.addMembers(params, data, function (err) {
  if (err) {
    // Handle error.
  }
});

create(data, cbopt) → {Promise|undefined}

Create a new organization.

Source:
Parameters:
Name Type Attributes Description
data object

Organization data object.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
management.organizations.create(data, function (err) {
  if (err) {
    // Handle error.
  }

  // Organization created.
});

createInvitation(params, data, cbopt) → {Promise|undefined}

Create an invitation in an organization

Source:
Parameters:
Name Type Attributes Description
params object

Organization parameters

Name Type Description
id string

ID of the Organization.

data Array

Invitation data

Name Type Attributes Description
inviter object

The person who is sending the invite.

Name Type Description
name string

Name of the person who is sending the invite

invitee object

Invitee to whom invitation is intended for

Name Type Description
email object

Email of the invitee to whom invitation is intended for

client_id string

Auth0 client used to resolve the default application login URI. This endpoint must expect &invitation=... and &organization=... parameters (added by API2) to continue the flow with /authorize. If client_id does not have configured login URI, use the tenant level default login route if configured, otherwise return 400

connection_id string <optional>

Force user to authenticate against a specific identity provider.

app_metadata object <optional>

Application metadata to be assigned to the user after accept the invitation.

user_metadata object <optional>

User metadata to be assigned to the user after accept the invitation.

roles Array <optional>

List of roles to be assigned to the user

ttl_sec number <optional>

Number of seconds for which the invitation is valid before expiration. If unspecified or set to 0, this value defaults to 604800 seconds (7 days). Upper limit on ttl_sec is 30 days.

send_invitation_email boolean <optional>

Whether the user will receive an invitation email (true) or no email (false). Default is true.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params =  { id :'ORGANIZATION_ID'};
var data = {
  client_id: CLIENT_ID,
  invitee: { email: 'invitee@example.com' },
  inviter: { name: 'John Doe' }
};

management.organizations.createInvitation(params, data, function (err) {
  if (err) {
    // Handle error.
  }
});

delete(params, cbopt) → {Promise|undefined}

Delete an existing organization.

Source:
Parameters:
Name Type Attributes Description
params object

Organization parameters.

Name Type Description
id string

Organization ID.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
management.organizations.delete({ id: ORGANIZATION_ID }, function (err) {
  if (err) {
    // Handle error.
  }

  // Organization deleted.
});

deleteInvitation(params, cbopt) → {Promise|undefined}

Delete an invitation from an organization

Source:
Parameters:
Name Type Attributes Description
params object

Organization parameters

Name Type Description
id string

ID of the Organization.

invitation_id string

Invitation ID

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params =  { id :'ORGANIZATION_ID', invitation_id: 'INVITATION_ID };

management.organizations.deleteInvitation(params, function (err) {
  if (err) {
    // Handle error.
  }
});

getAll(paramsopt, cbopt) → {Promise|undefined}

Get all organizations.

Source:
Parameters:
Name Type Attributes Description
params object <optional>

Organizations parameters.

Name Type Attributes Description
per_page number <optional>

Number of results per page.

page number <optional>

Page number, zero indexed.

from string <optional>

For checkpoint pagination, the Id from which to start selection from.

take number <optional>

For checkpoint pagination, the number of entries to retrieve. Default 50.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example

This method takes an optional object as first argument that may be used to specify pagination settings. If pagination options are not present, the first page of a limited number of results will be returned.

// Pagination settings.
var params = {
  per_page: 10,
  page: 0
};

management.organizations.getAll(params, function (err, organizations) {
  console.log(organizations.length);
});

getByID(params, cbopt) → {Promise|undefined}

Get an Auth0 organization.

Source:
Parameters:
Name Type Attributes Description
params object

Organization parameters.

Name Type Description
id string

Organization ID.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
management.organizations.getByID({ id: ORGANIZATION_ID }, function (err, role) {
  if (err) {
    // Handle error.
  }

  console.log(organization);
});

getByName(params, cbopt) → {Promise|undefined}

Get an Auth0 organization.

Source:
Parameters:
Name Type Attributes Description
params object

Organization parameters.

Name Type Description
name string

Organization name.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
management.organizations.getByName({ name: ORGANIZATION_NAME}, function (err, role) {
  if (err) {
    // Handle error.
  }

  console.log(organization);
});

getEnabledConnection(params, callbackopt) → {Promise|undefined}

Get Enabled Connection in a Organization

Source:
Parameters:
Name Type Attributes Description
params object

Organization parameters.

Name Type Description
id string

Organization ID.

connection_id string

Connection ID.

callback function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example

This methods takes the organization ID and connection ID and returns the enabled connection

var params = {id : 'ORGANIZATION_ID', connection_id: 'CONNECTION_ID'}

management.organizations.getEnabledConnections( {id : 'ORGANIZATION_ID', connection_id: 'CONNECTION_ID'}, function (err, enabled_connection) {
  console.log(enabled_connection);
});

getEnabledConnections(params, cbopt) → {Promise|undefined}

Get Enabled Connections in a Organization

Source:
Parameters:
Name Type Attributes Description
params object

Organization parameters.

Name Type Description
id string

Organization ID.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example

This method takes an organization ID and returns the enabled connections in an Organization

var params = {id : 'ORGANIZATION_ID'}

management.organizations.getEnabledConnections( {id : 'ORGANIZATION_ID'}, function (err, enabled_connections) {
  console.log(enabled_connections);
});

getInvitation(callback, params, cbopt) → {Promise|undefined}

Get an Invitation in a Organization

Source:
Parameters:
Name Type Attributes Description
callback
params object

Organization parameters

Name Type Description
id string

Organization ID

invitation_id string

Invitation ID

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Examples
var params = {id : 'ORGANIZATION_ID', invitation_id: 'INVITATION_ID'}

This methods takes the organization ID and user ID and returns the invitation

management.organizations.getInvitation({id : 'ORGANIZATION_ID', invitation_id: 'INVITATION_ID'}, function (err, invite) {
  console.log(invite);
});

getInvitations(callback, params, cbopt) → {Promise|undefined}

Get Invites in a Organization

Source:
Parameters:
Name Type Attributes Description
callback

});

params object

Organization parameters

Name Type Attributes Description
id string

Organization ID

per_page number <optional>

Number of results per page.

page number <optional>

Page number, zero indexed.

from string <optional>

For checkpoint pagination, the Id from which to start selection from.

take number <optional>

For checkpoint pagination, the number of entries to retrieve. Default 50.

fields string <optional>

Comma-separated list of fields to include or exclude (based on value provided for include_fields) in the result. Leave empty to retrieve all fields.

include_fields boolean <optional>

Whether specified fields are to be included (true) or excluded (false). Defaults to true.

sort string <optional>

Field to sort by. Use field:order where order is 1 for ascending and -1 for descending Defaults to created_at:-1.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Examples
var params = {id : 'ORGANIZATION_ID'}

This method takes an organization ID and returns the invites in an Organization

management.organizations.getInvitations( {id : 'ORGANIZATION_ID'}, function (err, invites) {
  console.log(invites);

getMemberRoles(callback, params, cbopt) → {Promise|undefined}

Get Roles from a Member in a Organization

Source:
Parameters:
Name Type Attributes Description
callback
params object

Organization parameters

Name Type Description
id string

ID of the Organization.

user_id string

ID of the user.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Examples
var params = {id : 'ORGANIZATION_ID', user_id: 'user_id'}

This methods takes the organization ID and user ID and returns the roles

management.organizations.getMemberRoles( {id : 'ORGANIZATION_ID', user_id: 'user_id'}, function (err, roles) {
  console.log(roles);
});

getMembers(params, cbopt) → {Promise|undefined}

Get Members in a Organization

Source:
Parameters:
Name Type Attributes Description
params object

Organization parameters

Name Type Attributes Description
id string

Organization ID

from string <optional>

For checkpoint pagination, the Id from which to start selection from.

take number <optional>

For checkpoint pagination, the number of entries to retrieve. Default 50.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example

This method takes an organization ID and returns the members in an Organization

 var params = {id : 'ORGANIZATION_ID'}

management.organizations.getMembers( {id : 'ORGANIZATION_ID'}, function (err, members) {
  console.log(members);
});

removeEnabledConnection(params, cbopt) → {Promise|undefined}

Remove an enabled connection from an organization

Source:
Parameters:
Name Type Attributes Description
params object

Organization parameters

Name Type Description
id string

ID of the Organization.

connection_id string

ID of the Connection.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params =  { id :'ORGANIZATION_ID', connection_id: 'CONNECTION_ID' };

management.organizations.removeEnabledConnection(params, function (err) {
  if (err) {
    // Handle error.
  }
});

removeMemberRoles(params, data, cbopt) → {Promise|undefined}

Remove Roles from a Member of an organization

Source:
Parameters:
Name Type Attributes Description
params object

Organization parameters

Name Type Description
id string

ID of the Organization.

user_id string

Id of the User

data object

Remove member roles data.

Name Type Description
roles Array

Array of role IDs.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params =  { id :'ORGANIZATION_ID', user_id: 'USER_ID };
var data = { roles: ["ROLE_ID_1", "ROLE_ID_2"]}

management.organizations.removeMemberRoles(params, data, function (err) {
  if (err) {
    // Handle error.
  }
});

removeMembers(params, data, cbopt) → {Promise|undefined}

Remove members from an organization

Source:
Parameters:
Name Type Attributes Description
params object

Organization parameters

Name Type Description
id string

ID of the Organization.

data object

add members data

Name Type Description
members Array

Array of user IDs

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params =  { id :'ORGANIZATION_ID' };
var data = { members: [ 'USER_ID1', 'USER_ID2' ] }

management.organizations.removeMembers(params, data, function (err) {
  if (err) {
    // Handle error.
  }
});

update(params, data, cbopt) → {Promise|undefined}

Update an existing organization.

Source:
Parameters:
Name Type Attributes Description
params object

Organization parameters.

Name Type Description
id string

Organization ID.

data object

Updated organization data.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var data = { display_name: 'New name' };
var params = { id: ORGANIZATION_ID };

management.organizations.update(params, data, function (err, organization) {
  if (err) {
    // Handle error.
  }

  console.log(organization.name);  // 'New name'
});

updateEnabledConnection(params, data, cbopt) → {Promise|undefined}

Update an enabled connection from an organization

Source:
Parameters:
Name Type Attributes Description
params object

Organization parameters

Name Type Description
id string

ID of the Organization.

connection_id string

ID of the Connection.

data object

Updated connection.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params =  { id :'ORGANIZATION_ID', connection_id: 'CONNECTION_ID' };
var data = { assign_membership_on_login: true };

management.organizations.updateEnabledConnection(params, data, function (err) {
  if (err) {
    // Handle error.
  }
});